Skip to content

Commit

Permalink
NFSv4.1/pnfs: Ensure that writes respect the O_SYNC flag when doing O…
Browse files Browse the repository at this point in the history
…_DIRECT

If the caller does not specify the O_SYNC flag, then it is legitimate
to return from O_DIRECT without doing a pNFS layoutcommit operation.
However if the file is opened O_DIRECT|O_SYNC then we'd better get it
right.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
  • Loading branch information
Trond Myklebust committed Mar 27, 2015
1 parent 9e1681c commit a0815d5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions fs/nfs/direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,7 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter,
if (i_size_read(inode) < iocb->ki_pos)
i_size_write(inode, iocb->ki_pos);
spin_unlock(&inode->i_lock);
generic_write_sync(file, pos, result);
}
}
nfs_direct_req_release(dreq);
Expand Down
1 change: 1 addition & 0 deletions fs/nfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)

trace_nfs_fsync_enter(inode);

nfs_inode_dio_wait(inode);
do {
ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
if (ret != 0)
Expand Down
1 change: 1 addition & 0 deletions fs/nfs/nfs4file.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ nfs4_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)

trace_nfs_fsync_enter(inode);

nfs_inode_dio_wait(inode);
do {
ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
if (ret != 0)
Expand Down

0 comments on commit a0815d5

Please sign in to comment.