Skip to contentSkip to conversation

Overlayfs: Deleting files from the lower dir

DISCUSSION [email protected] 2 participants 2 messages Sep 25, 2023 – Sep 26, 2023

lore
Share & tools
lore
#0 lore raw

Hi,

We are using an overlayfs to make our configuration persistent. The lower dir is /etc and the upper dir is located on the persistent /data partition. This is the mount command we use to create the overlay:

mount -n -t overlay \
-o workdir=$WORK_DIR \
-o lowerdir=/etc \
-o upperdir=/data \
-o index=off,xino=off,redirect_dir=off,metacopy=off \
/data /etc

Problem is that when we do remove a file from
the lower dir ("rm /etc/file1.txt" for example) and afterwards list the directory content with the ls command we do get following output:

$ls /etc
file1.txt file2.txt file3.txt

$rm /etc/file1.txt

$ls /etc
ls: ./file1.txt: No such file or directory
file2.txt file3.txt

Like expected, the file is not listed anymore but we do get an error message ("No such file or directory"). When we list the directory using the tree command we do not get an error but the file (possibly the character device to white out the deleted file?) still gets listed in the output contrary to what we would expect.

We are using linux kernel version 5.10.9.

Any hint on why this does happen or how to solve this would be very appreciated.

Kind regards,
Alexis

#1 lore raw
Quoted 12 lines · On Mon, Sep 25, 2023 at 5:56 PM <[email protected]> wrote:

Hi,

We are using an overlayfs to make our configuration persistent. The lower dir is /etc and the upper dir is located on the persistent /data partition. This is the mount command we use to create the overlay:

mount -n -t overlay \

(quoted diff) +0 -4
-o workdir=$WORK_DIR \
-o lowerdir=/etc \
-o upperdir=/data \
-o index=off,xino=off,redirect_dir=off,metacopy=off \
Quoted 2 lines

/data /etc

What is the lower (readonly) and upper filesystem type? Any reason that you explicitly disable redirect_dir? I am asking because this is not a common configuration and not one that I test regularly.

Quoted 15 lines

Problem is that when we do remove a file from
the lower dir ("rm /etc/file1.txt" for example) and afterwards list the directory content with the
ls command we do get following output:

$ls /etc
file1.txt file2.txt file3.txt

$rm /etc/file1.txt

$ls /etc
ls: ./file1.txt: No such file or directory
file2.txt file3.txt

Quoted 7 lines

Like expected, the file is not listed anymore but we do get an error message ("No such file or directory"). When we list the directory using the tree command we do not get an error but the file (possibly the character device to white out the deleted file?) still gets listed in the
output contrary to what we would expect.

It is very much unexpected.

Quoted 2 lines

We are using linux kernel version 5.10.9.

Is this a regression with this kernel version?
Or is this the behavior you always observed?
Do you see any overlayfs related messages in kmsg while observing this?

Quoted 3 lines

Any hint on why this does happen or how to solve this would be very appreciated.

On quick look you could try to upgrade to kernel >= 5.10.37 with this fix
* 0f8528c78fc8 - ovl: invalidate readdir cache on changes to dir with origin

This is a fix to a bug where lower dir was removed, which is not your case, but maybe there is something that I am overlooking.

Thanks,
Amir.