Feature #8456

Test whiteouts support with overlayfs

Added by intrigeri 2014-12-18 13:45:05 . Updated 2019-12-07 11:27:56 .

Status:
Resolved
Priority:
Elevated
Assignee:
Category:
Target version:
Start date:
2014-12-18
Due date:
% Done:

100%

Feature Branch:
Type of work:
Test
Blueprint:

Starter:
Affected tool:
Deliverable for:

Description

See notes 3 and 4 on parent ticket.


Subtasks


History

#1 Updated by intrigeri 2014-12-21 21:01:39

For non-directories deletion, overlayfs uses a char device on the upper filesystem.

Documentation/filesystems/overlayfs.txt reads:

> When a whiteout is found in the upper level of a merged directory, any matching name in the lower level is ignored, and the whiteout itself is also hidden.

… which may explain why anonym wrote “However, when testing overlayfs I couldn’t for the life of me find the location of this whiteout character devices after deleting files”. If it’s so well hidden, then it may break tails-create-iuk.

#2 Updated by intrigeri 2014-12-21 21:28:03

  • Assignee changed from intrigeri to anonym
  • QA Check set to Info Needed

Here’s what I did (and sorry for the mixed Japanese/English locales):

cd /tmp
mkdir lower lowerdir tmpfs merged
touch lower/file
mkdir lower/dir
mksquashfs lower lower.squashfs
mount -t tmpfs tmpfs tmpfs
mkdir tmpfs/{upperdir,workdir}
mount -o loop -t squashfs lower.squashfs lowerdir
mount -t overlay overlay -olowerdir=lowerdir,upperdir=tmpfs/upperdir,workdir=tmpfs/workdir merged
ls -lA merged/
total 0
drwxr-xr-x 2 root root 3 12月 21 22:13 dir
-rw-r--r-- 1 root root 0 12月 21 22:13 file
rm merged/file
ls -lA merged/
total 0
drwxr-xr-x 2 root root 3 12月 21 22:13 dir
ls -lA tmpfs/upperdir/
total 0
c--------- 1 root root 0, 0 12月 21 22:22 file

=> indeed a char device has appeared in the upperdir.

Then, to simulate what tails-create-iuk would do, I do:

mksquashfs tmpfs/upperdir upper.squashfs

And to simulate what would happen when live-boot uses upper.squashfs that would come from an IUK:

mkdir uppermnt
mount upper.squashfs uppermnt
ls -lA uppermnt
total 0
c--------- 1 root root 0, 0 12月 21 22:22 file

=> indeed, we get the char device back.

anonym, does it look OK to you? I’m curious what you did differently.

Now going to test the same when deleting directories.

#3 Updated by intrigeri 2014-12-21 21:39:26

Testing directory deletion:

cd /tmp
mkdir lower lowerdir tmpfs merged
touch lower/file
mkdir lower/dir
mksquashfs lower lower.squashfs
mount -t tmpfs tmpfs tmpfs
mkdir tmpfs/{upperdir,workdir}
mount -o loop -t squashfs lower.squashfs lowerdir
mount -t overlay overlay -olowerdir=lowerdir,upperdir=tmpfs/upperdir,workdir=tmpfs/workdir merged
ls -lA merged/
total 0
drwxr-xr-x 2 root root 3 12月 21 22:13 dir
-rw-r--r-- 1 root root 0 12月 21 22:13 file
rmdir merged/dir
ls -lA merged/
total 0
-rw-r--r-- 1 root root 0 12月 21 22:30 file
ls -lA tmpfs/upperdir/
total 0
c--------- 1 root root 0, 0 12月 21 22:30 dir
mksquashfs tmpfs/upperdir upper.squashfs
mkdir uppermnt
mount upper.squashfs uppermnt
ls -lA uppermnt
total 0
c--------- 1 root root 0, 0 12月 21 22:30 dir

I’m surprised to see a char device again. With getfattr (from the attr package), I see there’s no xattr set on uppermnt/dir nor tmpfs/upperdir/dir. Go figure. Anyway, seems like it’ll be good enough for our needs.

I’d still like to see anonym review my tests and confirm :)

#4 Updated by anonym 2015-01-06 14:14:13

intrigeri wrote:
> I’d still like to see anonym review my tests and confirm :)

Your tests makes sense, and I can confirm your results, so all looks good. In fact, when I looked back into the lower dirs remaining from my own tests, I can see the expected char devices (from removed files/dirs) so I obviously was just confused.

#5 Updated by intrigeri 2015-01-06 15:37:34

  • Status changed from Confirmed to Resolved
  • Assignee deleted (anonym)
  • % Done changed from 0 to 100
  • QA Check deleted (Info Needed)

#6 Updated by intrigeri 2019-12-07 11:27:56

FWIW, in my tests I’ve never seen xattrs used to indicate file deletion: I’ve only seen character device nodes, both for directories and non-directories.

To display the xattrs set on a file, one can run getfattr -d --match=- $FILE. Note that by default, getfattr will only display user xattrs, which is not what we want in this context.