Skip to content

Commit 7f85193

Browse files
committed
Merge tag 'ovl-update-6.7' of git://git.kernel.org/pub/scm/linux/kernel/git/overlayfs/vfs
Pull overlayfs updates from Amir Goldstein: - Overlayfs aio cleanups and fixes Cleanups and minor fixes in preparation for factoring out of read/write passthrough code. - Overlayfs lock ordering changes Hold mnt_writers only throughout copy up instead of a long lived elevated refcount. - Add support for nesting overlayfs private xattrs There are cases where you want to use an overlayfs mount as a lowerdir for another overlayfs mount. For example, if the system rootfs is on overlayfs due to composefs, or to make it volatile (via tmpfs), then you cannot currently store a lowerdir on the rootfs, because the inner overlayfs will eat all the whiteouts and overlay xattrs. This means you can't e.g. store on the rootfs a prepared container image for use with overlayfs. This adds support for nesting of overlayfs mounts by escaping the problematic features and unescaping them when exposing to the overlayfs user. - Add new mount options for appending lowerdirs * tag 'ovl-update-6.7' of git://git.kernel.org/pub/scm/linux/kernel/git/overlayfs/vfs: ovl: add support for appending lowerdirs one by one ovl: refactor layer parsing helpers ovl: store and show the user provided lowerdir mount option ovl: remove unused code in lowerdir param parsing ovl: Add documentation on nesting of overlayfs mounts ovl: Add an alternative type of whiteout ovl: Support escaped overlay.* xattrs ovl: Add OVL_XATTR_TRUSTED/USER_PREFIX_LEN macros ovl: Move xattr support to new xattrs.c file ovl: do not encode lower fh with upper sb_writers held ovl: do not open/llseek lower file with upper sb_writers held ovl: reorder ovl_want_write() after ovl_inode_lock() ovl: split ovl_want_write() into two helpers ovl: add helper ovl_file_modified() ovl: protect copying of realinode attributes to ovl inode ovl: punt write aio completion to workqueue ovl: propagate IOCB_APPEND flag on writes to realfile ovl: use simpler function to convert iocb to rw flags
2 parents c9d0117 + 24e16e3 commit 7f85193

File tree

16 files changed

+929
-532
lines changed

16 files changed

+929
-532
lines changed

Documentation/filesystems/overlayfs.rst

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,11 @@ escaping the colons with a single backslash. For example:
344344

345345
mount -t overlay overlay -olowerdir=/a\:lower\:\:dir /merged
346346

347-
Since kernel version v6.5, directory names containing colons can also
348-
be provided as lower layer using the fsconfig syscall from new mount api:
347+
Since kernel version v6.8, directory names containing colons can also
348+
be configured as lower layer using the "lowerdir+" mount options and the
349+
fsconfig syscall from new mount api. For example:
349350

350-
fsconfig(fs_fd, FSCONFIG_SET_STRING, "lowerdir", "/a:lower::dir", 0);
351+
fsconfig(fs_fd, FSCONFIG_SET_STRING, "lowerdir+", "/a:lower::dir", 0);
351352

352353
In the latter case, colons in lower layer directory names will be escaped
353354
as an octal characters (\072) when displayed in /proc/self/mountinfo.
@@ -416,6 +417,16 @@ Only the data of the files in the "data-only" lower layers may be visible
416417
when a "metacopy" file in one of the lower layers above it, has a "redirect"
417418
to the absolute path of the "lower data" file in the "data-only" lower layer.
418419

420+
Since kernel version v6.8, "data-only" lower layers can also be added using
421+
the "datadir+" mount options and the fsconfig syscall from new mount api.
422+
For example:
423+
424+
fsconfig(fs_fd, FSCONFIG_SET_STRING, "lowerdir+", "/l1", 0);
425+
fsconfig(fs_fd, FSCONFIG_SET_STRING, "lowerdir+", "/l2", 0);
426+
fsconfig(fs_fd, FSCONFIG_SET_STRING, "lowerdir+", "/l3", 0);
427+
fsconfig(fs_fd, FSCONFIG_SET_STRING, "datadir+", "/do1", 0);
428+
fsconfig(fs_fd, FSCONFIG_SET_STRING, "datadir+", "/do2", 0);
429+
419430

420431
fs-verity support
421432
----------------------
@@ -504,6 +515,29 @@ directory tree on the same or different underlying filesystem, and even
504515
to a different machine. With the "inodes index" feature, trying to mount
505516
the copied layers will fail the verification of the lower root file handle.
506517

518+
Nesting overlayfs mounts
519+
------------------------
520+
521+
It is possible to use a lower directory that is stored on an overlayfs
522+
mount. For regular files this does not need any special care. However, files
523+
that have overlayfs attributes, such as whiteouts or "overlay.*" xattrs will be
524+
interpreted by the underlying overlayfs mount and stripped out. In order to
525+
allow the second overlayfs mount to see the attributes they must be escaped.
526+
527+
Overlayfs specific xattrs are escaped by using a special prefix of
528+
"overlay.overlay.". So, a file with a "trusted.overlay.overlay.metacopy" xattr
529+
in the lower dir will be exposed as a regular file with a
530+
"trusted.overlay.metacopy" xattr in the overlayfs mount. This can be nested by
531+
repeating the prefix multiple time, as each instance only removes one prefix.
532+
533+
A lower dir with a regular whiteout will always be handled by the overlayfs
534+
mount, so to support storing an effective whiteout file in an overlayfs mount an
535+
alternative form of whiteout is supported. This form is a regular, zero-size
536+
file with the "overlay.whiteout" xattr set, inside a directory with the
537+
"overlay.whiteouts" xattr set. Such whiteouts are never created by overlayfs,
538+
but can be used by userspace tools (like containers) that generate lower layers.
539+
These alternative whiteouts can be escaped using the standard xattr escape
540+
mechanism in order to properly nest to any depth.
507541

508542
Non-standard behavior
509543
---------------------

fs/overlayfs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
obj-$(CONFIG_OVERLAY_FS) += overlay.o
77

88
overlay-objs := super.o namei.o util.o inode.o file.o dir.o readdir.o \
9-
copy_up.o export.o params.o
9+
copy_up.o export.o params.o xattrs.o

0 commit comments

Comments
 (0)