the implementation of flock(2) was wrong and it caused a deadlock when
multiple processes tried to lock the same file.
Drop it and let FUSE handle locking for us.
Closes: https://github.com/containers/fuse-overlayfs/issues/80
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
if we are looking for a path in a lower component, skip ENOTDIR as a
component might be a whiteout.
This happens only when running as root, as the whiteout takes the same
name of the deleted file/directory.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Use reflinks if they are supported by the underlying file system.
On my system, using XFS and reflinks, chowning recursively a directory
passed from:
User time (seconds): 0.02
System time (seconds): 0.34
Percent of CPU this job got: 8%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:04.52
to:
User time (seconds): 0.02
System time (seconds): 0.22
Percent of CPU this job got: 17%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:01.45
the performance improvement can be higher if the directory is made of
few but bigger files.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
fix a regression introduced by f64f65287817fecd0 that prevents a
whiteout file to be created on the first unlink.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
when looking up multiple layers and we have already found a file, do
not check if whiteouts are present in lower layers. The lookup in the
lower layers is needed only to correctly propagate the inode number.
Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1686889
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
it solves this error on copy_xattrs when the underlying file system is
overlay:
flistxattr(9, "security.selinux\0", 1048576) = 17
fgetxattr(9, "security.selinux", "system_u:object_r:container_file"..., 256) = 48
fsetxattr(10, "security.selinux", "system_u:object_r:container_file"..., 48, 0) = -1
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
ensure the node was not moved and that its parent is the same as the
directory we are reading.
Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
let's start using __attribute__((cleanup)), it helps to simplify
a lot of code, and hopefully avoid some bugs.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
in case of failures when we open the temporary file, we don't do any
modification to the file system.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
fix an interesting interaction between unlink(2) and readdir(2) that
can confuse the cache.
If a file is unlinked before the readdir(2) is done, it is not removed
from the list generated when the directory was first opened. Thus the
result is that readdir(2) will return the file even if it was unlinked
and moved to the work dir until the cache is released.
The fix is to skip dentries that are hidden while iterating the list.
Closes: https://github.com/containers/libpod/issues/2342
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
When a file is created with restricted permissions (like 000), ftruncate() should
still work as long as the fd is open. If fi->fh is available, use it to fix that
and avoid the call to openat() which failed in that case.