aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4state.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2007-07-09 10:45:42 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2007-07-10 23:40:43 -0400
commit8bda4e4c98d14566fc1a354c62fb59d70cc49b97 (patch)
treed137e784db33d1347a6b03d22044e9a41e10967f /fs/nfs/nfs4state.c
parent1ac7e2fd35905f3d44df06568bca5f9d140369b3 (diff)
NFSv4: Fix up stateid locking...
We really don't need to grab both the state->so_owner and the inode->i_lock. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4state.c')
-rw-r--r--fs/nfs/nfs4state.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 4fa4054cdf34..523cc2cbb5e1 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -307,6 +307,7 @@ nfs4_alloc_open_state(void)
307 atomic_set(&state->count, 1); 307 atomic_set(&state->count, 1);
308 INIT_LIST_HEAD(&state->lock_states); 308 INIT_LIST_HEAD(&state->lock_states);
309 spin_lock_init(&state->state_lock); 309 spin_lock_init(&state->state_lock);
310 seqlock_init(&state->seqlock);
310 return state; 311 return state;
311} 312}
312 313
@@ -411,7 +412,6 @@ void nfs4_put_open_state(struct nfs4_state *state)
411 */ 412 */
412void nfs4_close_state(struct path *path, struct nfs4_state *state, mode_t mode) 413void nfs4_close_state(struct path *path, struct nfs4_state *state, mode_t mode)
413{ 414{
414 struct inode *inode = state->inode;
415 struct nfs4_state_owner *owner = state->owner; 415 struct nfs4_state_owner *owner = state->owner;
416 int call_close = 0; 416 int call_close = 0;
417 int newstate; 417 int newstate;
@@ -419,7 +419,6 @@ void nfs4_close_state(struct path *path, struct nfs4_state *state, mode_t mode)
419 atomic_inc(&owner->so_count); 419 atomic_inc(&owner->so_count);
420 /* Protect against nfs4_find_state() */ 420 /* Protect against nfs4_find_state() */
421 spin_lock(&owner->so_lock); 421 spin_lock(&owner->so_lock);
422 spin_lock(&inode->i_lock);
423 switch (mode & (FMODE_READ | FMODE_WRITE)) { 422 switch (mode & (FMODE_READ | FMODE_WRITE)) {
424 case FMODE_READ: 423 case FMODE_READ:
425 state->n_rdonly--; 424 state->n_rdonly--;
@@ -446,7 +445,6 @@ void nfs4_close_state(struct path *path, struct nfs4_state *state, mode_t mode)
446 clear_bit(NFS_DELEGATED_STATE, &state->flags); 445 clear_bit(NFS_DELEGATED_STATE, &state->flags);
447 } 446 }
448 nfs4_state_set_mode_locked(state, newstate); 447 nfs4_state_set_mode_locked(state, newstate);
449 spin_unlock(&inode->i_lock);
450 spin_unlock(&owner->so_lock); 448 spin_unlock(&owner->so_lock);
451 449
452 if (!call_close) { 450 if (!call_close) {
@@ -599,8 +597,12 @@ int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl)
599void nfs4_copy_stateid(nfs4_stateid *dst, struct nfs4_state *state, fl_owner_t fl_owner) 597void nfs4_copy_stateid(nfs4_stateid *dst, struct nfs4_state *state, fl_owner_t fl_owner)
600{ 598{
601 struct nfs4_lock_state *lsp; 599 struct nfs4_lock_state *lsp;
600 int seq;
602 601
603 memcpy(dst, &state->stateid, sizeof(*dst)); 602 do {
603 seq = read_seqbegin(&state->seqlock);
604 memcpy(dst, &state->stateid, sizeof(*dst));
605 } while (read_seqretry(&state->seqlock, seq));
604 if (test_bit(LK_STATE_IN_USE, &state->flags) == 0) 606 if (test_bit(LK_STATE_IN_USE, &state->flags) == 0)
605 return; 607 return;
606 608