diff options
author | Dave Chinner <dchinner@redhat.com> | 2011-04-12 19:18:08 +1000 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-04-12 14:17:24 -0700 |
commit | 0d88f6e804c824454b5ed0d3034ed3dcf7467a87 (patch) | |
tree | 3323e2860f7bf892c889270cf936a3c4a45f3b80 /fs/nfs/write.c | |
parent | 95042f9eb78a8d9a17455e2ef263f2f310ecef15 (diff) | |
download | kernel_goldelico_gta04-0d88f6e804c824454b5ed0d3034ed3dcf7467a87.zip kernel_goldelico_gta04-0d88f6e804c824454b5ed0d3034ed3dcf7467a87.tar.gz kernel_goldelico_gta04-0d88f6e804c824454b5ed0d3034ed3dcf7467a87.tar.bz2 |
nfs: don't call __mark_inode_dirty while holding i_lock
nfs_scan_commit() is called with the inode->i_lock held, but it then
calls __mark_inode_dirty() while still holding the lock. This causes
a deadlock.
Push the inode->i_lock into nfs_scan_commit() so it can protect only
the parts of the code it needs to and can be dropped before the call
to __mark_inode_dirty() to avoid the deadlock.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Tested-by: Will Simoneau <simoneau@ele.uri.edu>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/nfs/write.c')
-rw-r--r-- | fs/nfs/write.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index af0c627..e4cbc11 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -542,11 +542,15 @@ nfs_scan_commit(struct inode *inode, struct list_head *dst, pgoff_t idx_start, u if (!nfs_need_commit(nfsi)) return 0; + spin_lock(&inode->i_lock); ret = nfs_scan_list(nfsi, dst, idx_start, npages, NFS_PAGE_TAG_COMMIT); if (ret > 0) nfsi->ncommit -= ret; + spin_unlock(&inode->i_lock); + if (nfs_need_commit(NFS_I(inode))) __mark_inode_dirty(inode, I_DIRTY_DATASYNC); + return ret; } #else @@ -1483,9 +1487,7 @@ int nfs_commit_inode(struct inode *inode, int how) res = nfs_commit_set_lock(NFS_I(inode), may_wait); if (res <= 0) goto out_mark_dirty; - spin_lock(&inode->i_lock); res = nfs_scan_commit(inode, &head, 0, 0); - spin_unlock(&inode->i_lock); if (res) { int error; |