From: Jingbo Xu <jefflexu@linux.alibaba.com>
To: Miklos Szeredi <miklos@szeredi.hu>,
Amir Goldstein <amir73il@gmail.com>,
overlayfs <linux-unionfs@vger.kernel.org>
Cc: Xiang Gao <xiang@kernel.org>
Subject: [potential issue, question] whiteout shows up in merged directory
Date: Mon, 4 Sep 2023 15:47:32 +0800 [thread overview]
Message-ID: <a05e13c7-2fc2-77d8-05b5-759a73d7f5e2@linux.alibaba.com> (raw)
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
next reply other threads:[~2023-09-04 7:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-04 7:47 Jingbo Xu [this message]
2023-09-04 8:57 ` [potential issue, question] whiteout shows up in merged directory 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a05e13c7-2fc2-77d8-05b5-759a73d7f5e2@linux.alibaba.com \
--to=jefflexu@linux.alibaba.com \
--cc=amir73il@gmail.com \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=xiang@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox