]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
NFSv4.2: Fixup CLONE dest file size for zero-length count
authorBenjamin Coddington <bcodding@redhat.com>
Thu, 13 Oct 2022 15:58:01 +0000 (11:58 -0400)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 6 Dec 2022 13:45:30 +0000 (14:45 +0100)
BugLink: https://bugs.launchpad.net/bugs/1998843
[ Upstream commit 038efb6348ce96228f6828354cb809c22a661681 ]

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 <trond.myklebust@hammerspace.com>
Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Fixes: 94d202d5ca39 ("NFSv42: Copy offload should update the file size when appropriate")
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
fs/nfs/nfs42proc.c

index 93f4d8257525b983ff569432d59179b90ca245c7..da94bf2afd07096f93a7f870f209acfcaea5e333 100644 (file)
@@ -1077,6 +1077,9 @@ static int _nfs42_proc_clone(struct rpc_message *msg, struct file *src_f,
        status = nfs4_call_sync(server->client, server, msg,
                                &args.seq_args, &res.seq_res, 0);
        if (status == 0) {
+               /* a zero-length count means clone to EOF in src */
+               if (count == 0 && res.dst_fattr->valid & NFS_ATTR_FATTR_SIZE)
+                       count = nfs_size_to_loff_t(res.dst_fattr->size) - dst_offset;
                nfs42_copy_dest_done(dst_inode, dst_offset, count);
                status = nfs_post_op_update_inode(dst_inode, res.dst_fattr);
        }