]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
NFSv4.2: Serialise O_DIRECT i/o and clone range
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Sat, 6 Sep 2025 14:40:24 +0000 (10:40 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 19 Sep 2025 14:35:44 +0000 (16:35 +0200)
[ Upstream commit c80ebeba1198eac8811ab0dba36ecc13d51e4438 ]

Ensure that all O_DIRECT reads and writes complete before cloning a file
range, so that both the source and destination are up to date.

Fixes: a5864c999de6 ("NFS: Do not serialise O_DIRECT reads and writes")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/nfs/nfs4file.c

index 1cd9652f3c280358209f22503ea573a906a6194e..453d08a9c4b4dc3f2a1173bd87ac6d6dc5e59e70 100644 (file)
@@ -283,9 +283,11 @@ static loff_t nfs42_remap_file_range(struct file *src_file, loff_t src_off,
 
        /* flush all pending writes on both src and dst so that server
         * has the latest data */
+       nfs_file_block_o_direct(NFS_I(src_inode));
        ret = nfs_sync_inode(src_inode);
        if (ret)
                goto out_unlock;
+       nfs_file_block_o_direct(NFS_I(dst_inode));
        ret = nfs_sync_inode(dst_inode);
        if (ret)
                goto out_unlock;