Skip to content

Commit 6b1c776

Browse files
committed
Merge branch 'overlayfs-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs
Pull overlayfs updates from Miklos Szeredi: "This work from Amir introduces the inodes index feature, which provides: - hardlinks are not broken on copy up - infrastructure for overlayfs NFS export This also fixes constant st_ino for samefs case for lower hardlinks" * 'overlayfs-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs: (33 commits) ovl: mark parent impure and restore timestamp on ovl_link_up() ovl: document copying layers restrictions with inodes index ovl: cleanup orphan index entries ovl: persistent overlay inode nlink for indexed inodes ovl: implement index dir copy up ovl: move copy up lock out ovl: rearrange copy up ovl: add flag for upper in ovl_entry ovl: use struct copy_up_ctx as function argument ovl: base tmpfile in workdir too ovl: factor out ovl_copy_up_inode() helper ovl: extract helper to get temp file in copy up ovl: defer upper dir lock to tempfile link ovl: hash overlay non-dir inodes by copy up origin ovl: cleanup bad and stale index entries on mount ovl: lookup index entry for copy up origin ovl: verify index dir matches upper dir ovl: verify upper root dir matches lower root dir ovl: introduce the inodes index dir feature ovl: generalize ovl_create_workdir() ...
2 parents 58c7ffc + f4439de commit 6b1c776

File tree

12 files changed

+1456
-383
lines changed

12 files changed

+1456
-383
lines changed

Documentation/filesystems/overlayfs.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,40 @@ rightmost one and going left. In the above example lower1 will be the
201201
top, lower2 the middle and lower3 the bottom layer.
202202

203203

204+
Sharing and copying layers
205+
--------------------------
206+
207+
Lower layers may be shared among several overlay mounts and that is indeed
208+
a very common practice. An overlay mount may use the same lower layer
209+
path as another overlay mount and it may use a lower layer path that is
210+
beneath or above the path of another overlay lower layer path.
211+
212+
Using an upper layer path and/or a workdir path that are already used by
213+
another overlay mount is not allowed and will fail with EBUSY. Using
214+
partially overlapping paths is not allowed but will not fail with EBUSY.
215+
216+
Mounting an overlay using an upper layer path, where the upper layer path
217+
was previously used by another mounted overlay in combination with a
218+
different lower layer path, is allowed, unless the "inodes index" feature
219+
is enabled.
220+
221+
With the "inodes index" feature, on the first time mount, an NFS file
222+
handle of the lower layer root directory, along with the UUID of the lower
223+
filesystem, are encoded and stored in the "trusted.overlay.origin" extended
224+
attribute on the upper layer root directory. On subsequent mount attempts,
225+
the lower root directory file handle and lower filesystem UUID are compared
226+
to the stored origin in upper root directory. On failure to verify the
227+
lower root origin, mount will fail with ESTALE. An overlayfs mount with
228+
"inodes index" enabled will fail with EOPNOTSUPP if the lower filesystem
229+
does not support NFS export, lower filesystem does not have a valid UUID or
230+
if the upper filesystem does not support extended attributes.
231+
232+
It is quite a common practice to copy overlay layers to a different
233+
directory tree on the same or different underlying filesystem, and even
234+
to a different machine. With the "inodes index" feature, trying to mount
235+
the copied layers will fail the verification of the lower root file handle.
236+
237+
204238
Non-standard behavior
205239
---------------------
206240

fs/overlayfs/Kconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,23 @@ config OVERLAY_FS_REDIRECT_DIR
2323
Note, that redirects are not backward compatible. That is, mounting
2424
an overlay which has redirects on a kernel that doesn't support this
2525
feature will have unexpected results.
26+
27+
config OVERLAY_FS_INDEX
28+
bool "Overlayfs: turn on inodes index feature by default"
29+
depends on OVERLAY_FS
30+
help
31+
If this config option is enabled then overlay filesystems will use
32+
the inodes index dir to map lower inodes to upper inodes by default.
33+
In this case it is still possible to turn off index globally with the
34+
"index=off" module option or on a filesystem instance basis with the
35+
"index=off" mount option.
36+
37+
The inodes index feature prevents breaking of lower hardlinks on copy
38+
up.
39+
40+
Note, that the inodes index feature is read-only backward compatible.
41+
That is, mounting an overlay which has an index dir on a kernel that
42+
doesn't support this feature read-only, will not have any negative
43+
outcomes. However, mounting the same overlay with an old kernel
44+
read-write and then mounting it again with a new kernel, will have
45+
unexpected results.

0 commit comments

Comments
 (0)