Skip to content

Commit 038efb6

Browse files
bcodding-rhamschuma-ntap
authored andcommitted
NFSv4.2: Fixup CLONE dest file size for zero-length count
When holding a delegation, the NFS client optimizes away setting the attributes of a file from the GETATTR in the compound after CLONE, and for a zero-length CLONE we will end up setting the inode's size to zero in nfs42_copy_dest_done(). Handle this case by computing the resulting count from the server's reported size after CLONE's GETATTR. Suggested-by: Trond Myklebust <[email protected]> Signed-off-by: Benjamin Coddington <[email protected]> Fixes: 94d202d ("NFSv42: Copy offload should update the file size when appropriate") Signed-off-by: Anna Schumaker <[email protected]>
1 parent 8a0fa3f commit 038efb6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/nfs/nfs42proc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,9 @@ static int _nfs42_proc_clone(struct rpc_message *msg, struct file *src_f,
10931093
&args.seq_args, &res.seq_res, 0);
10941094
trace_nfs4_clone(src_inode, dst_inode, &args, status);
10951095
if (status == 0) {
1096+
/* a zero-length count means clone to EOF in src */
1097+
if (count == 0 && res.dst_fattr->valid & NFS_ATTR_FATTR_SIZE)
1098+
count = nfs_size_to_loff_t(res.dst_fattr->size) - dst_offset;
10961099
nfs42_copy_dest_done(dst_inode, dst_offset, count);
10971100
status = nfs_post_op_update_inode(dst_inode, res.dst_fattr);
10981101
}

0 commit comments

Comments
 (0)