Skip to content

Commit e9be9d5

Browse files
author
Miklos Szeredi
committed
overlay filesystem
Overlayfs allows one, usually read-write, directory tree to be overlaid onto another, read-only directory tree. All modifications go to the upper, writable layer. This type of mechanism is most often used for live CDs but there's a wide variety of other uses. The implementation differs from other "union filesystem" implementations in that after a file is opened all operations go directly to the underlying, lower or upper, filesystems. This simplifies the implementation and allows native performance in these cases. The dentry tree is duplicated from the underlying filesystems, this enables fast cached lookups without adding special support into the VFS. This uses slightly more memory than union mounts, but dentries are relatively small. Currently inodes are duplicated as well, but it is a possible optimization to share inodes for non-directories. Opening non directories results in the open forwarded to the underlying filesystem. This makes the behavior very similar to union mounts (with the same limitations vs. fchmod/fchown on O_RDONLY file descriptors). Usage: mount -t overlayfs overlayfs -olowerdir=/lower,upperdir=/upper/upper,workdir=/upper/work /overlay The following cotributions have been folded into this patch: Neil Brown <[email protected]>: - minimal remount support - use correct seek function for directories - initialise is_real before use - rename ovl_fill_cache to ovl_dir_read Felix Fietkau <[email protected]>: - fix a deadlock in ovl_dir_read_merged - fix a deadlock in ovl_remove_whiteouts Erez Zadok <[email protected]> - fix cleanup after WARN_ON Sedat Dilek <[email protected]> - fix up permission to confirm to new API Robin Dong <[email protected]> - fix possible leak in ovl_new_inode - create new inode in ovl_link Andy Whitcroft <[email protected]> - switch to __inode_permission() - copy up i_uid/i_gid from the underlying inode AV: - ovl_copy_up_locked() - dput(ERR_PTR(...)) on two failure exits - ovl_clear_empty() - one failure exit forgetting to do unlock_rename(), lack of check for udir being the parent of upper, dropping and regaining the lock on udir (which would require _another_ check for parent being right). - bogus d_drop() in copyup and rename [fix from your mail] - copyup/remove and copyup/rename races [fix from your mail] - ovl_dir_fsync() leaving ERR_PTR() in ->realfile - ovl_entry_free() is pointless - it's just a kfree_rcu() - fold ovl_do_lookup() into ovl_lookup() - manually assigning ->d_op is wrong. Just use ->s_d_op. [patches picked from Miklos]: * copyup/remove and copyup/rename races * bogus d_drop() in copyup and rename Also thanks to the following people for testing and reporting bugs: Jordi Pujol <[email protected]> Andy Whitcroft <[email protected]> Michal Suchanek <[email protected]> Felix Fietkau <[email protected]> Erez Zadok <[email protected]> Randy Dunlap <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 46fdb79 commit e9be9d5

File tree

10 files changed

+3284
-0
lines changed

10 files changed

+3284
-0
lines changed

fs/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ source "fs/quota/Kconfig"
6767

6868
source "fs/autofs4/Kconfig"
6969
source "fs/fuse/Kconfig"
70+
source "fs/overlayfs/Kconfig"
7071

7172
menu "Caches"
7273

fs/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ obj-$(CONFIG_QNX6FS_FS) += qnx6/
104104
obj-$(CONFIG_AUTOFS4_FS) += autofs4/
105105
obj-$(CONFIG_ADFS_FS) += adfs/
106106
obj-$(CONFIG_FUSE_FS) += fuse/
107+
obj-$(CONFIG_OVERLAYFS_FS) += overlayfs/
107108
obj-$(CONFIG_UDF_FS) += udf/
108109
obj-$(CONFIG_SUN_OPENPROMFS) += openpromfs/
109110
obj-$(CONFIG_OMFS_FS) += omfs/

fs/overlayfs/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
config OVERLAYFS_FS
2+
tristate "Overlay filesystem support"
3+
help
4+
An overlay filesystem combines two filesystems - an 'upper' filesystem
5+
and a 'lower' filesystem. When a name exists in both filesystems, the
6+
object in the 'upper' filesystem is visible while the object in the
7+
'lower' filesystem is either hidden or, in the case of directories,
8+
merged with the 'upper' object.
9+
10+
For more information see Documentation/filesystems/overlayfs.txt

fs/overlayfs/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#
2+
# Makefile for the overlay filesystem.
3+
#
4+
5+
obj-$(CONFIG_OVERLAYFS_FS) += overlayfs.o
6+
7+
overlayfs-objs := super.o inode.o dir.o readdir.o copy_up.o

0 commit comments

Comments
 (0)