containers / fuse-overlayfs

FUSE implementation for overlayfs
GNU General Public License v2.0
535 stars 85 forks source link

Request: online file modification in layers #190

Closed jobcespedes closed 4 years ago

jobcespedes commented 4 years ago

I am testing fuse-overalyfs as an unionfs. I'm coming from unionfs-fusẹ. There are some file modifications (online, while mounted) that work in unionfs-fusẹ but not in fuse-overlayfs. I don't have the knowledge to determine if it is because of a bug, a different functionality or me? I'll be thankful if you help determine what it is. Let me present 3 cases. First, these are the steps to reproduce:

Directory layout for cases:

# parent directory
parent=$HOME/testing
lower=${parent}/lower
upper=${parent}/upper
target=${parent}/union
mkdir -p $parent
cd $parent

# target
mkdir -p $target

# lower directory
mkdir -p $lower
# lower directory files
echo "lower_dir1_var1" > ${lower}/file1
echo "lower_dir1_var2" > ${lower}/file2

# upper directory
mkdir -p $upper
# lower directory files
echo "upper_dir1_var2" > ${upper}/file2
echo "upper_dir1_var3" > ${upper}/file3

# mount them
fuse-overlayfs -o auto_unmount,lowerdir=${lower},upperdir=${upper},workdir=${parent} $target

Case 1: delete a file common to both layers

Delete file2 in the upper directory. File2 exists in the lower directory too, but with different value.

rm ${upper}/file2

Expected result in target mount point

Since file2 is deleted in the upper directory and not from the target mount point, I expected to see file2 in the target mount point but with content from the lower directory.

# cat ${target}/file2
lower_dir1_var2

Result in target mount point

File2 is listed but "No such file or directory" is shown also

# ls -al ${target}
ls: /var/home/job/testing/union/file2: No such file or directory
total 16
drwxrwxr-x. 2 job 4096 feb 29 12:55 .
-rw-rw-r--. 1 job   16 feb 29 12:55 file1
-rw-rw-r--. 1 job   16 feb 29 12:55 file2
-rw-rw-r--. 1 job   16 feb 29 12:55 file3
# cat ${target}/file2
cat: /var/home/job/testing/union/file2: No such file or directory

Case 2: add new file in the lower layer

Create a new file in the lower layer. The file does not exist in the upper layer.

echo "lower_dir1_var4" > ${lower}/file4

Expected result

I expected to see a new file4 with content from the lower layer

# cat ${target}/file4
lower_dir1_var4

Result

There is no file4 in the target mount point

# cat ${target}/file4
cat: /var/home/job/testing/union/file4: No such file or directory

Case 3: modified file in the lower layer

Modified the content of file1 in the lower layer. File1 does not exist in the upper layer.

echo "lower_dir1_var1_line2" >> ${lower}/file1

Expected result

New content from file1 in lower layer

# cat ${lower}/file1
lower_dir1_var1
lower_dir1_var1_line2

Result

Old content

# cat ${lower}/file1
lower_dir1_var1

Info

# OS
NAME=Fedora
VERSION="31.20200225.0 (Workstation Edition)"
# fuse
fuse-2.9.9-8.fc31.x86_64
fuse-common-3.6.2-1.fc31.x86_64
fuse-libs-2.9.9-8.fc31.x86_64
fuse-overlayfs-0.7.5-2.fc31.x86_64
fuse3-3.6.2-1.fc31.x86_64
fuse3-libs-3.6.2-1.fc31.x86_64
gvfs-fuse-1.42.2-1.fc31.x86_64
giuseppe commented 4 years ago

fuse-overlayfs uses caches to not hit the underlying file system for lookups.

As the native overlay, you should not modify the underlying directories as the result is undefined.

To verify it is a caching issue, you can try to drop the caches with echo 3 > /proc/sys/vm/drop_caches and see if the mounted directory is reloaded