Re: [potential issue, question] whiteout shows up in merged directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 4, 2023 at 10:47 AM Jingbo Xu <jefflexu@xxxxxxxxxxxxxxxxx> wrote:
>
> 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.
>

The case of whiteouts creates by overlayfs itself was reported
by zhangyi and handled by this patchs set:

https://lore.kernel.org/linux-unionfs/1509486350-21362-1-git-send-email-amir73il@xxxxxxxxx/

so you could say that the problem is due to the way that you
created those layers.

There is a simple workaround for you though:

mkdir -p /mnt/lower1/dir /mnt/lower2/dir

Making 'dir' a merge dir avoids the problem.
Not sure if that helps.

The alternative way is:
setfattr -n "trusted.overlay.origin" /mnt/lower1/dir

Thanks,
Amir.




[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux