summaryrefslogtreecommitdiffstats
path: root/include/linux/nfs_fs.h
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2006-03-20 13:44:51 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-03-20 13:44:51 -0500
commitc42de9dd67250fe984e0e31c9b542d721af6454b (patch)
treea4079b25a044f7124837f572e5342dc7614ca75d /include/linux/nfs_fs.h
parent7d46a49f512e8d10b23353781a8ba85edd4fa640 (diff)
downloadop-kernel-dev-c42de9dd67250fe984e0e31c9b542d721af6454b.zip
op-kernel-dev-c42de9dd67250fe984e0e31c9b542d721af6454b.tar.gz
NFS: Fix a race in nfs_sync_inode()
Kudos to Neil Brown for spotting the problem: "in nfs_sync_inode, there is effectively the sequence: nfs_wait_on_requests nfs_flush_inode nfs_commit_inode This seems a bit racy to me as if the only requests are on the ->commit list, and nfs_commit_inode is called separately after nfs_wait_on_requests completes, and before nfs_commit_inode start (say: by nfs_write_inode) then none of these function will return >0, yet there will be some pending request that aren't waited for." The solution is to search for requests to wait upon, search for dirty requests, and search for uncommitted requests while holding the nfsi->req_lock The patch also cleans up nfs_sync_inode(), getting rid of the redundant FLUSH_WAIT flag. It turns out that we were always setting it. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'include/linux/nfs_fs.h')
-rw-r--r--include/linux/nfs_fs.h10
1 files changed, 4 insertions, 6 deletions
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 55de077..cbebd7d 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -56,9 +56,7 @@
* When flushing a cluster of dirty pages, there can be different
* strategies:
*/
-#define FLUSH_AGING 0 /* only flush old buffers */
#define FLUSH_SYNC 1 /* file being synced, or contention */
-#define FLUSH_WAIT 2 /* wait for completion */
#define FLUSH_STABLE 4 /* commit to stable storage */
#define FLUSH_LOWPRI 8 /* low priority background flush */
#define FLUSH_HIGHPRI 16 /* high priority memory reclaim flush */
@@ -419,7 +417,7 @@ void nfs_commit_free(struct nfs_write_data *p);
* Try to write back everything synchronously (but check the
* return value!)
*/
-extern int nfs_sync_inode(struct inode *, unsigned long, unsigned int, int);
+extern int nfs_sync_inode_wait(struct inode *, unsigned long, unsigned int, int);
#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
extern int nfs_commit_inode(struct inode *, int);
extern void nfs_commit_release(void *wdata);
@@ -440,7 +438,7 @@ nfs_have_writebacks(struct inode *inode)
static inline int
nfs_wb_all(struct inode *inode)
{
- int error = nfs_sync_inode(inode, 0, 0, FLUSH_WAIT);
+ int error = nfs_sync_inode_wait(inode, 0, 0, 0);
return (error < 0) ? error : 0;
}
@@ -449,8 +447,8 @@ nfs_wb_all(struct inode *inode)
*/
static inline int nfs_wb_page_priority(struct inode *inode, struct page* page, int how)
{
- int error = nfs_sync_inode(inode, page->index, 1,
- how | FLUSH_WAIT | FLUSH_STABLE);
+ int error = nfs_sync_inode_wait(inode, page->index, 1,
+ how | FLUSH_STABLE);
return (error < 0) ? error : 0;
}
OpenPOWER on IntegriCloud