summaryrefslogtreecommitdiffstats
path: root/fs/nfs/write.c
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@primarydata.com>2016-06-25 18:12:03 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2016-07-05 19:11:07 -0400
commit837bb1d752d92ea4d870877ffbd6ec5cf76624b3 (patch)
treebc6efb2d8fff743b5dd56ed0848fa9f4f99c2e3c /fs/nfs/write.c
parent1e564d3dbd684a105582471cb9ff2aada64a9052 (diff)
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>
Diffstat (limited to 'fs/nfs/write.c')
-rw-r--r--fs/nfs/write.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 3087fb6f1983..538a473b324b 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -1913,6 +1913,24 @@ out_mark_dirty:
1913EXPORT_SYMBOL_GPL(nfs_write_inode); 1913EXPORT_SYMBOL_GPL(nfs_write_inode);
1914 1914
1915/* 1915/*
1916 * Wrapper for filemap_write_and_wait_range()
1917 *
1918 * Needed for pNFS in order to ensure data becomes visible to the
1919 * client.
1920 */
1921int nfs_filemap_write_and_wait_range(struct address_space *mapping,
1922 loff_t lstart, loff_t lend)
1923{
1924 int ret;
1925
1926 ret = filemap_write_and_wait_range(mapping, lstart, lend);
1927 if (ret == 0)
1928 ret = pnfs_sync_inode(mapping->host, true);
1929 return ret;
1930}
1931EXPORT_SYMBOL_GPL(nfs_filemap_write_and_wait_range);
1932
1933/*
1916 * flush the inode to disk. 1934 * flush the inode to disk.
1917 */ 1935 */
1918int nfs_wb_all(struct inode *inode) 1936int nfs_wb_all(struct inode *inode)