diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2009-06-17 22:23:00 +0200 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2009-06-17 22:23:00 +0200 |
commit | 3f09df70e3a33590ae5a97b8a15486d3711c7065 (patch) | |
tree | 18f5c9115aa79dd2cab5f87d7024bea5460ca0af /fs/nfs/delegation.c | |
parent | NFSv4: Handle more errors when recovering open file and locking state (diff) | |
download | linux-3f09df70e3a33590ae5a97b8a15486d3711c7065.tar.xz linux-3f09df70e3a33590ae5a97b8a15486d3711c7065.zip |
NFS: Ensure we always hold the BKL when dereferencing inode->i_flock
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/delegation.c')
-rw-r--r-- | fs/nfs/delegation.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index d4f669f0683e..af05b918cb5b 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -70,15 +70,24 @@ static int nfs_delegation_claim_locks(struct nfs_open_context *ctx, struct nfs4_ struct file_lock *fl; int status = 0; + if (inode->i_flock == NULL) + goto out; + + /* Protect inode->i_flock using the BKL */ + lock_kernel(); for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) { if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK))) continue; if (nfs_file_open_context(fl->fl_file) != ctx) continue; + unlock_kernel(); status = nfs4_lock_delegation_recall(state, fl); if (status < 0) - break; + goto out; + lock_kernel(); } + unlock_kernel(); +out: return status; } @@ -256,7 +265,10 @@ static int __nfs_inode_return_delegation(struct inode *inode, struct nfs_delegat struct nfs_inode *nfsi = NFS_I(inode); nfs_msync_inode(inode); - /* Guard against new delegated open calls */ + /* + * Guard against new delegated open/lock/unlock calls and against + * state recovery + */ down_write(&nfsi->rwsem); nfs_delegation_claim_opens(inode, &delegation->stateid); up_write(&nfsi->rwsem); |