NFSv4.2: Fix writeback races in nfs4_copy_file_range
We need to ensure that any writes to the destination file are serialised with the copy, meaning that the writeback has to occur under the inode lock. Also relax the writeback requirement on the source, and rely on the stateid checking to tell us if the source rebooted. Add the helper nfs_filemap_write_and_wait_range() to call pnfs_sync_inode() as is appropriate for pNFS servers that may need a layoutcommit. Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
This commit is contained in:
@@ -133,21 +133,9 @@ static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in,
|
||||
struct file *file_out, loff_t pos_out,
|
||||
size_t count, unsigned int flags)
|
||||
{
|
||||
struct inode *in_inode = file_inode(file_in);
|
||||
struct inode *out_inode = file_inode(file_out);
|
||||
int ret;
|
||||
|
||||
if (in_inode == out_inode)
|
||||
if (file_inode(file_in) == file_inode(file_out))
|
||||
return -EINVAL;
|
||||
|
||||
/* flush any pending writes */
|
||||
ret = nfs_sync_inode(in_inode);
|
||||
if (ret)
|
||||
return ret;
|
||||
ret = nfs_sync_inode(out_inode);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return nfs42_proc_copy(file_in, pos_in, file_out, pos_out, count);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user