[PATCH-RFC-RESEND 7/9] nfs42: respect clone_blksize

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

 



draft-ietf-nfsv4-minorversion2-38.txt says:
   Both cl_src_offset and
   cl_dst_offset must be aligned to the clone block size Section 12.2.1.
   The number of bytes to be cloned must be a multiple of the clone
   block size, except in the case in which cl_src_offset plus the number
   of bytes to be cloned is equal to the source file size.

Signed-off-by: Peng Tao <tao.peng@xxxxxxxxxxxxxxx>
---
 fs/nfs/nfs4file.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c
index c335cb0..ee8c014 100644
--- a/fs/nfs/nfs4file.c
+++ b/fs/nfs/nfs4file.c
@@ -174,12 +174,20 @@ nfs42_file_clone_range(struct file *src_file, struct file *dst_file,
 {
 	struct inode *dst_inode = file_inode(dst_file);
 	struct inode *src_inode = file_inode(src_file);
+	struct nfs_server *server = NFS_SERVER(dst_inode);
+	unsigned int bs = server->clone_blksize;
 	int ret;
 
 	/* src and dst must be different files */
 	if (src_inode == dst_inode)
 		return -EINVAL;
 
+	/* check alignment w.r.t. clone_blksize */
+	if (bs)
+		if (!IS_ALIGNED(src_off, bs) || !IS_ALIGNED(dst_off, bs) ||
+		    (!IS_ALIGNED(count, bs) && i_size_read(src_inode) != (src_off + count)))
+			return -EINVAL;
+
 	/* XXX: do we lock at all? what if server needs CB_RECALL_LAYOUT? */
 	if (dst_inode < src_inode) {
 		mutex_lock_nested(&dst_inode->i_mutex, I_MUTEX_PARENT);
-- 
1.8.3.1

--
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