Skip to content

Commit

Permalink
NFS: Ensure that buffered writes wait for O_DIRECT writes to complete
Browse files Browse the repository at this point in the history
The O_DIRECT code will grab the inode->i_mutex and flush out buffered
writes, before scheduling a read or a write. However there is no
equivalent in the buffered write code to wait for O_DIRECT to complete.

Fixes a reported issue in xfstests generic/133, when first performing an
O_DIRECT write followed by a buffered write.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Tested-by: Chuck Lever <chuck.lever@oracle.com>
  • Loading branch information
trondmypd committed Mar 2, 2015
1 parent be36e18 commit aa5acce
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/nfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ static int nfs_write_begin(struct file *file, struct address_space *mapping,
nfs_wait_bit_killable, TASK_KILLABLE);
if (ret)
return ret;
/*
* Wait for O_DIRECT to complete
*/
nfs_inode_dio_wait(mapping->host);

page = grab_cache_page_write_begin(mapping, index, flags);
if (!page)
Expand Down

0 comments on commit aa5acce

Please sign in to comment.