Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ff0f962c authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull overlayfs updates from Miklos Szeredi:
 "This update contains:

   - try to clone on copy-up

   - allow renaming a directory

   - split source into managable chunks

   - misc cleanups and fixes

  It does not contain the read-only fd data inconsistency fix, which Al
  didn't like. I'll leave that to the next year..."

* 'overlayfs-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs: (36 commits)
  ovl: fix reStructuredText syntax errors in documentation
  ovl: fix return value of ovl_fill_super
  ovl: clean up kstat usage
  ovl: fold ovl_copy_up_truncate() into ovl_copy_up()
  ovl: create directories inside merged parent opaque
  ovl: opaque cleanup
  ovl: show redirect_dir mount option
  ovl: allow setting max size of redirect
  ovl: allow redirect_dir to default to "on"
  ovl: check for emptiness of redirect dir
  ovl: redirect on rename-dir
  ovl: lookup redirects
  ovl: consolidate lookup for underlying layers
  ovl: fix nested overlayfs mount
  ovl: check namelen
  ovl: split super.c
  ovl: use d_is_dir()
  ovl: simplify lookup
  ovl: check lower existence of rename target
  ovl: rename: simplify handling of lower/merged directory
  ...
parents 087a76d3 c3c86996
Loading
Loading
Loading
Loading
+22 −4
Original line number Diff line number Diff line
@@ -118,6 +118,7 @@ programs.

seek offsets are assigned sequentially when the directories are read.
Thus if

  - read part of a directory
  - remember an offset, and close the directory
  - re-open the directory some time later
@@ -130,6 +131,23 @@ directory.
Readdir on directories that are not merged is simply handled by the
underlying directory (upper or lower).

renaming directories
--------------------

When renaming a directory that is on the lower layer or merged (i.e. the
directory was not created on the upper layer to start with) overlayfs can
handle it in two different ways:

1. return EXDEV error: this error is returned by rename(2) when trying to
   move a file or directory across filesystem boundaries.  Hence
   applications are usually prepared to hande this error (mv(1) for example
   recursively copies the directory tree).  This is the default behavior.

2. If the "redirect_dir" feature is enabled, then the directory will be
   copied up (but not the contents).  Then the "trusted.overlay.redirect"
   extended attribute is set to the path of the original location from the
   root of the overlay.  Finally the directory is moved to the new
   location.

Non-directories
---------------
@@ -185,13 +203,13 @@ filesystem, so both st_dev and st_ino of the file may change.

Any open files referring to this inode will access the old data.

Any file locks (and leases) obtained before copy_up will not apply
to the copied up file.

If a file with multiple hard links is copied up, then this will
"break" the link.  Changes will not be propagated to other names
referring to the same inode.

Unless "redirect_dir" feature is enabled, rename(2) on a lower or merged
directory will fail with EXDEV.

Changes to underlying filesystems
---------------------------------

+5 −1
Original line number Diff line number Diff line
@@ -223,7 +223,11 @@ static long ioctl_file_clone(struct file *dst_file, unsigned long srcfd,

	if (!src_file.file)
		return -EBADF;
	ret = vfs_clone_file_range(src_file.file, off, dst_file, destoff, olen);
	ret = -EXDEV;
	if (src_file.file->f_path.mnt != dst_file->f_path.mnt)
		goto fdput;
	ret = do_clone_file_range(src_file.file, off, dst_file, destoff, olen);
fdput:
	fdput(src_file);
	return ret;
}
+1 −5
Original line number Diff line number Diff line
@@ -4306,11 +4306,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
	bool new_is_dir = false;
	unsigned max_links = new_dir->i_sb->s_max_links;

	/*
	 * Check source == target.
	 * On overlayfs need to look at underlying inodes.
	 */
	if (d_real_inode(old_dentry) == d_real_inode(new_dentry))
	if (source == target)
		return 0;

	error = may_delete(old_dir, old_dentry, is_dir);
+1 −2
Original line number Diff line number Diff line
@@ -509,8 +509,7 @@ __be32 nfsd4_set_nfs4_label(struct svc_rqst *rqstp, struct svc_fh *fhp,
__be32 nfsd4_clone_file_range(struct file *src, u64 src_pos, struct file *dst,
		u64 dst_pos, u64 count)
{
	return nfserrno(vfs_clone_file_range(src, src_pos, dst, dst_pos,
			count));
	return nfserrno(do_clone_file_range(src, src_pos, dst, dst_pos, count));
}

ssize_t nfsd_copy_file_range(struct file *src, u64 src_pos, struct file *dst,
+14 −0
Original line number Diff line number Diff line
@@ -8,3 +8,17 @@ config OVERLAY_FS
	  merged with the 'upper' object.

	  For more information see Documentation/filesystems/overlayfs.txt

config OVERLAY_FS_REDIRECT_DIR
	bool "Overlayfs: turn on redirect dir feature by default"
	depends on OVERLAY_FS
	help
	  If this config option is enabled then overlay filesystems will use
	  redirects when renaming directories by default.  In this case it is
	  still possible to turn off redirects globally with the
	  "redirect_dir=off" module option or on a filesystem instance basis
	  with the "redirect_dir=off" mount option.

	  Note, that redirects are not backward compatible.  That is, mounting
	  an overlay which has redirects on a kernel that doesn't support this
	  feature will have unexpected results.
Loading