diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2005-12-13 16:13:54 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2005-12-19 23:12:09 -0500 |
commit | 29884df0d89c1df0dec3449405bc41569bb44800 (patch) | |
tree | b836dc3ece80a901d1b7a9e946bf0d51ec0c8c4f /fs/nfs/direct.c | |
parent | b079fa7baa86b47579f3f60f86d03d21c76159b8 (diff) |
NFS: Fix another O_DIRECT race
Ensure we call unmap_mapping_range() and sync dirty pages to disk before
doing an NFS direct write.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/direct.c')
-rw-r--r-- | fs/nfs/direct.c | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index b497c71384e..07922881760 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c | |||
@@ -678,15 +678,9 @@ nfs_file_direct_read(struct kiocb *iocb, char __user *buf, size_t count, loff_t | |||
678 | if (!count) | 678 | if (!count) |
679 | goto out; | 679 | goto out; |
680 | 680 | ||
681 | if (mapping->nrpages) { | 681 | retval = nfs_sync_mapping(mapping); |
682 | retval = filemap_fdatawrite(mapping); | 682 | if (retval) |
683 | if (retval == 0) | 683 | goto out; |
684 | retval = nfs_wb_all(inode); | ||
685 | if (retval == 0) | ||
686 | retval = filemap_fdatawait(mapping); | ||
687 | if (retval) | ||
688 | goto out; | ||
689 | } | ||
690 | 684 | ||
691 | retval = nfs_direct_read(inode, ctx, &iov, pos, 1); | 685 | retval = nfs_direct_read(inode, ctx, &iov, pos, 1); |
692 | if (retval > 0) | 686 | if (retval > 0) |
@@ -764,15 +758,9 @@ nfs_file_direct_write(struct kiocb *iocb, const char __user *buf, size_t count, | |||
764 | if (!count) | 758 | if (!count) |
765 | goto out; | 759 | goto out; |
766 | 760 | ||
767 | if (mapping->nrpages) { | 761 | retval = nfs_sync_mapping(mapping); |
768 | retval = filemap_fdatawrite(mapping); | 762 | if (retval) |
769 | if (retval == 0) | 763 | goto out; |
770 | retval = nfs_wb_all(inode); | ||
771 | if (retval == 0) | ||
772 | retval = filemap_fdatawait(mapping); | ||
773 | if (retval) | ||
774 | goto out; | ||
775 | } | ||
776 | 764 | ||
777 | retval = nfs_direct_write(inode, ctx, &iov, pos, 1); | 765 | retval = nfs_direct_write(inode, ctx, &iov, pos, 1); |
778 | if (mapping->nrpages) | 766 | if (mapping->nrpages) |