Skip to content

Commit

Permalink
NFSv4: Truncating file opens should also sync O_DIRECT writes
Browse files Browse the repository at this point in the history
We don't just want to sync out buffered writes, but also O_DIRECT ones.

Signed-off-by: Trond Myklebust <[email protected]>
  • Loading branch information
trondmypd committed Mar 27, 2015
1 parent d9dabc1 commit 9e1681c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion fs/nfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,12 @@ void nfs_evict_inode(struct inode *inode)
nfs_clear_inode(inode);
}

static int nfs_sync_inode(struct inode *inode)
int nfs_sync_inode(struct inode *inode)
{
nfs_inode_dio_wait(inode);
return nfs_wb_all(inode);
}
EXPORT_SYMBOL_GPL(nfs_sync_inode);

/**
* nfs_sync_mapping - helper to flush all mmapped dirty data to disk
Expand Down
2 changes: 1 addition & 1 deletion fs/nfs/nfs4file.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ nfs4_file_open(struct inode *inode, struct file *filp)
if (openflags & O_TRUNC) {
attr.ia_valid |= ATTR_SIZE;
attr.ia_size = 0;
nfs_wb_all(inode);
nfs_sync_inode(inode);
}

inode = NFS_PROTO(dir)->open_context(dir, ctx, openflags, &attr, &opened);
Expand Down
1 change: 1 addition & 0 deletions include/linux/nfs_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ extern int nfs_updatepage(struct file *, struct page *, unsigned int, unsigned
* Try to write back everything synchronously (but check the
* return value!)
*/
extern int nfs_sync_inode(struct inode *inode);
extern int nfs_wb_all(struct inode *inode);
extern int nfs_wb_page(struct inode *inode, struct page* page);
extern int nfs_wb_page_cancel(struct inode *inode, struct page* page);
Expand Down

0 comments on commit 9e1681c

Please sign in to comment.