Linux Overlay Filesystem development
 help / color / mirror / Atom feed
* [potential issue, question] whiteout shows up in merged directory
@ 2023-09-04  7:47 Jingbo Xu
  2023-09-04  8:57 ` Amir Goldstein
  0 siblings, 1 reply; 9+ messages in thread
From: Jingbo Xu @ 2023-09-04  7:47 UTC (permalink / raw)
  To: Miklos Szeredi, Amir Goldstein, overlayfs; +Cc: Xiang Gao

Hi, all,

I found an issue may be related to overlayfs on the latest master branch
[1] when I'm developing tarfs mode for erofs-utils [2], which converts
and merges tar layers into one merged erofs image with overlayfs-like model.

The issue is that, the whiteout from lowerdir may still shows up in the
merged directory.  Though this issue is initially found with erofs, it
can also be reproduced with ext4.  Following is a simple reproducer with
ext4.

```
mkdir -p /mnt/lower1/dir /mnt/lower2
mknod /mnt/lower1/file1 c 0 0
mknod /mnt/lower1/dir/file2 c 0 0
mount -t overlay none -olowerdir=/mnt/lower1:/mnt/lower2 /mnt2

# ls  -l /mnt2/
total 4
drwxr-xr-x 2 root root 4096 Sep  4 14:40 dir

# ls  -l /mnt2/dir
ls: cannot access /mnt2/dir/file2: No such file or directory
total 0
c????????? ? ? ? ?            ? file2
```

It seems that this issue is relevant to whether the parent directory of
the whiteout is a merged directory or not.  In the above example, file1
is hidden from the merged directory as expected (with its parent
directory '/' a merged directory), while file2 shows up unexpectedly
(with its parent directory '/dir' from lowerdir).


I also noticed that this issue doesn't exist if the whiteout is created
by overlayfs itself rather than handcrafted with mknod like:

```
mkdir -p /mnt/lower/dir /mnt/upper /mnt/work
touch /mnt/lower/file1
touch /mnt/lower/dir/file2
mount -t overlay none
-olowerdir=/mnt/lower,upperdir=/mnt/upper,workdir=/mnt/work /mnt1
rm /mnt1/file1
rm /mnt1/dir/file2
umount /mnt1
mount -t overlay -olowerdir=/mnt/upper:/mnt/lower none /mnt2

# ls -l /mnt2/
total 8
drwxr-xr-x 1 root root 4096 Sep  4 15:45 dir

# ls -l /mnt2/dir/
total 0
```

I'm not sure if it's a known issue or not, or due to my mishandling.
Appreciate if you could shed a light on this.


[1] git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
[2]
https://lore.kernel.org/all/20230901094706.27539-1-jefflexu@linux.alibaba.com/

-- 
Thanks,
Jingbo

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-09-04 15:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-04  7:47 [potential issue, question] whiteout shows up in merged directory Jingbo Xu
2023-09-04  8:57 ` Amir Goldstein
2023-09-04 12:49   ` Jingbo Xu
2023-09-04 13:27     ` Gao Xiang
2023-09-04 14:07       ` Amir Goldstein
2023-09-04 14:38         ` Gao Xiang
2023-09-04 15:03           ` Amir Goldstein
2023-09-04 15:12             ` Gao Xiang
2023-09-04 15:01         ` Jingbo Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox