345 Commits

Author SHA1 Message Date
Giuseppe Scrivano
7e59e3ba08
fuse-overlayfs: add new option "timeout"
allow to override the default timeout value we specify for an entry
validity.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-06-05 00:25:56 +02:00
Daniel J Walsh
e32f71698a
Merge pull request #82 from giuseppe/fix-flock-hang
main: drop code to handle flock
2019-06-04 07:44:48 +02:00
Giuseppe Scrivano
b43ed1b391
main: drop code to handle flock
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>
2019-06-03 15:14:20 +02:00
Giuseppe Scrivano
7374427d33
main: fix compiler warning
fix this warning:

main.c:3870:13: warning: initialization of ‘void (*)(struct fuse_req
 *, fuse_ino_t,  unsigned int,  void *, struct fuse_file_info *,
 unsigned int,  const void *, size_t,  size_t)’ {aka ‘void (*)(struct
 fuse_req *, long unsigned int,  unsigned int,  void *, struct
 fuse_file_info *, unsigned int,  const void *, long unsigned int,
 long unsigned int)’} from incompatible pointer type ‘void (*)(struct
 fuse_req *, fuse_ino_t,  long unsigned int,  void *, struct
 fuse_file_info *, unsigned int,  const void *, size_t,  size_t)’ {aka
 ‘void (*)(struct fuse_req *, long unsigned int,  long unsigned int,
 void *, struct fuse_file_info *, unsigned int,  const void *, long
 unsigned int,  long unsigned int)’} [-Wincompatible-pointer-types]

 3870 |    .ioctl = ovl_ioctl,
      |             ^~~~~~~~~

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-06-03 14:37:58 +02:00
Giuseppe Scrivano
b4ef7a8fff
main: add helper function to get fd to the upper layer
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-05-24 17:21:53 +02:00
Giuseppe Scrivano
7dcef0769b
rename: create whiteout before doing the renameat
so we don't uncover files from the lower layers if the whiteout cannot
be created.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-05-24 14:26:59 +02:00
Giuseppe Scrivano
6c74e33cca
main: do not open twice the same file
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-05-24 12:58:31 +02:00
Giuseppe Scrivano
a468981104
main.c: fix typo
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-05-24 12:00:15 +02:00
Giuseppe Scrivano
3732249217
main: skip ENOTDIR in a lookup
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>
2019-05-15 17:08:16 +02:00
Giuseppe Scrivano
89bd69ba91
Merge pull request #70 from thiell/sendfile-minorfix
copyup: minor fixes for sendfile()
2019-05-06 14:51:05 +02:00
Stephane Thiell
a558c9ab3c copyup: minor fixes for sendfile() 2019-05-05 20:27:03 -07:00
Giuseppe Scrivano
02dcd8a3e1
fuse-overlayfs: do not copyup a whiteout on rename
Closes: https://github.com/containers/fuse-overlayfs/issues/69

Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
2019-05-03 13:02:16 +02:00
Giuseppe Scrivano
480d27ff3a
fuse-overlayfs: fix error messages prefix
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-04-27 10:13:22 +02:00
Giuseppe Scrivano
29877f7edf
fuse-overlayfs: create opaque whiteout file for dirs
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-04-27 10:13:21 +02:00
Giuseppe Scrivano
064452bfba
fuse-overlayfs: not override the ret from fstatat
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-04-27 00:19:26 +02:00
Giuseppe Scrivano
eee6a48738
fuse-overlayfs: support opaque whiteouts
Support the .wh..wh..opq variant.

Closes: https://github.com/containers/libpod/issues/3021

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-04-27 00:19:25 +02:00
Giuseppe Scrivano
69165c8a84
Merge pull request #66 from 3XX0/opaque-xattr-notsup
fuse-overlayfs: skip opaque whiteouts on unsupported filesystems (e.g…
2019-04-12 10:16:22 +02:00
Jonathan Calmels
bff9fd9e22 fuse-overlayfs: change ovl_statfs to use the upper layer fd instead of its path
Signed-off-by: Jonathan Calmels <jcalmels@nvidia.com>
2019-04-11 16:42:29 -07:00
Jonathan Calmels
d371739254 fuse-overlayfs: skip opaque whiteouts on unsupported filesystems (e.g. tmpfs)
Signed-off-by: Jonathan Calmels <jcalmels@nvidia.com>
2019-04-11 16:40:22 -07:00
Giuseppe Scrivano
e108eee92c
fuse-overlayfs: write uses SPLICE_MOVE|SPLICE_NONBLOCK
don't block on writing to the pipe.  It has a significant impact on
the performance.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-04-08 22:12:07 +02:00
Giuseppe Scrivano
e4f219a14d
ioctl: return immediately with not implemented ioctls
avoid to send an error response twice.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-04-04 22:21:05 +02:00
Giuseppe Scrivano
1f04143cdc
fuse-overlayfs: support some ioctls
Closes: https://github.com/containers/fuse-overlayfs/issues/59

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-04-03 17:58:36 +02:00
Giuseppe Scrivano
65e504cda8
copyup: use sendfile(2) if available
attempt to use sendfile(2) before falling back to a read/write loop.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-04-03 14:52:47 +02:00
Giuseppe Scrivano
844766d667
main: copyup uses reflinks if possible
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>
2019-04-02 10:19:22 +02:00
Giuseppe Scrivano
ba05f2e351
main: print configuration settings only with --debug
Closes: https://github.com/containers/fuse-overlayfs/issues/57

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-29 10:23:15 +01:00
Giuseppe Scrivano
a6958ce78f
Merge pull request #56 from giuseppe/uid-mapping-docs
docs: document the uid/gid mapping
2019-03-28 17:18:40 +01:00
Giuseppe Scrivano
0f52165ae6
fuse-overlayfs: do not hardcode overflow ids
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-28 09:47:39 +01:00
Giuseppe Scrivano
3a921aa5d7
fuse-overlayfs: fix first unlink done
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>
2019-03-27 21:26:45 +01:00
Giuseppe Scrivano
8ec68aee52
Merge pull request #53 from giuseppe/fix-lookup-if-whiteout-lower-layer
fuse-overlayfs: fix lookup with multiple layers
2019-03-08 20:06:27 +01:00
Giuseppe Scrivano
44d23bc07e
fuse-overlayfs: fix lookup with multiple layers
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>
2019-03-08 18:13:55 +01:00
Giuseppe Scrivano
f17f15a48b
build: provide replacement for TEMP_FAILURE_RETRY if not present
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-07 10:22:26 +01:00
Giuseppe Scrivano
57b1e98d69
build: provide replacement for open_by_handle_at(2) if not present
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-07 10:22:12 +01:00
Giuseppe Scrivano
40ba2786d2
build: provide replacement for error(3) if not present
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-07 10:21:20 +01:00
Giuseppe Scrivano
1a5ba7a3ef
fuse-overlayfs: ignore xattrs copy errors when not supported
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>
2019-02-22 10:37:18 +01:00
Giuseppe Scrivano
1533c9f596
fuse-overlayfs: skip whiteout if not present in lower layers
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-02-18 20:13:50 +01:00
Giuseppe Scrivano
130e0000e5
fuse-overlayfs: accept nosuid,nodev,exec,noexec
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-02-18 20:05:41 +01:00
Giuseppe Scrivano
7f21f8fcf9
fuse-overlayfs: add cleanup for layers
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-02-17 21:16:47 +01:00
Giuseppe Scrivano
67fa787735
fuse-overlayfs: use cleanup function for initializing node
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-02-17 21:16:46 +01:00
Giuseppe Scrivano
f1b1e52a15
fuse-overlayfs: refactor some xattrs common code
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-02-17 20:44:55 +01:00
Giuseppe Scrivano
f64f652878
fuse-overlayfs: drop usage of static arrays for paths
now that we are using autocleanup macros, there are no excuses for
using static arrays.

Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
2019-02-17 20:44:53 +01:00
Giuseppe Scrivano
346067ab87
fuse-overlayfs: accept option "dev"
Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
2019-02-17 20:44:53 +01:00
Giuseppe Scrivano
43b6b2ecf9
fuse-overlayfs: add check to readdir for the node parent
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>
2019-02-17 20:44:52 +01:00
Giuseppe Scrivano
3ff2c01cbb
main: add missing debug messages
Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
2019-02-17 20:44:51 +01:00
Giuseppe Scrivano
37d91db36e
fuse-overlayfs: start using GCC autocleanup
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>
2019-02-17 20:44:50 +01:00
Giuseppe Scrivano
090f9e11c2
main: do the unlink only after we created the temporary file
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>
2019-02-15 22:13:16 +01:00
Giuseppe Scrivano
cf17de5a8a
main: fix a fd leak
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-02-15 22:13:12 +01:00
Giuseppe Scrivano
bbf631d046
fuse-overlays: fix interaction of unlink(2) with readdir(2)
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>
2019-02-15 19:19:21 +01:00
Giuseppe Scrivano
81e220147a
main: ignore EINVAL when copying xattrs
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-02-12 11:33:18 +01:00
Stephane Thiell
a9091e4bd8 setattr: use fd from fi->fh for ftruncate() whenever possible
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.
2019-02-07 16:16:45 -08:00
Stephane Thiell
f0cd15ec64 create_directory: do not redeclare variable buf 2019-02-04 14:46:29 -08:00