[PATCH v4 2/3] vfs: call vfs_clone_file_range() under mnt_want_write()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Move mnt_want_write() out of the vfs helper and up into
the ioctl handler.
Taking mnt_want_write() outside the vfs helper is the standard
in most namei.c syscalls.
This change will allow overlayfs code to use the helper for
copy up.

Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx>
---
 fs/ioctl.c      | 9 +++++++++
 fs/read_write.c | 5 -----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/fs/ioctl.c b/fs/ioctl.c
index 34d2994..9299832 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -15,6 +15,7 @@
 #include <linux/writeback.h>
 #include <linux/buffer_head.h>
 #include <linux/falloc.h>
+#include <linux/mount.h>
 #include "internal.h"
 
 #include <asm/ioctls.h>
@@ -225,7 +226,15 @@ static long ioctl_file_clone(struct file *dst_file, unsigned long srcfd,
 		return -EBADF;
 	if (src_file.file->f_path.mnt != dst_file->f_path.mnt)
 		return -EXDEV;
+
+	ret = mnt_want_write_file(dst_file);
+	if (ret)
+		goto out_fput;
+
 	ret = vfs_clone_file_range(src_file.file, off, dst_file, destoff, olen);
+
+	mnt_drop_write_file(dst_file);
+out_fput:
 	fdput(src_file);
 	return ret;
 }
diff --git a/fs/read_write.c b/fs/read_write.c
index 9dc6e52..90bc18b 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1660,10 +1660,6 @@ int vfs_clone_file_range(struct file *file_in, loff_t pos_in,
 	if (pos_in + len > i_size_read(inode_in))
 		return -EINVAL;
 
-	ret = mnt_want_write_file(file_out);
-	if (ret)
-		return ret;
-
 	ret = file_in->f_op->clone_file_range(file_in, pos_in,
 			file_out, pos_out, len);
 	if (!ret) {
@@ -1671,7 +1667,6 @@ int vfs_clone_file_range(struct file *file_in, loff_t pos_in,
 		fsnotify_modify(file_out);
 	}
 
-	mnt_drop_write_file(file_out);
 	return ret;
 }
 EXPORT_SYMBOL(vfs_clone_file_range);
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux