diff options
Diffstat (limited to 'fs/nfs/nfs4state.c')
-rw-r--r-- | fs/nfs/nfs4state.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index da0861db57fb..c59ef90e956b 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c | |||
@@ -670,15 +670,12 @@ void nfs4_copy_stateid(nfs4_stateid *dst, struct nfs4_state *state, fl_owner_t f | |||
670 | 670 | ||
671 | struct nfs_seqid *nfs_alloc_seqid(struct nfs_seqid_counter *counter) | 671 | struct nfs_seqid *nfs_alloc_seqid(struct nfs_seqid_counter *counter) |
672 | { | 672 | { |
673 | struct rpc_sequence *sequence = counter->sequence; | ||
674 | struct nfs_seqid *new; | 673 | struct nfs_seqid *new; |
675 | 674 | ||
676 | new = kmalloc(sizeof(*new), GFP_KERNEL); | 675 | new = kmalloc(sizeof(*new), GFP_KERNEL); |
677 | if (new != NULL) { | 676 | if (new != NULL) { |
678 | new->sequence = counter; | 677 | new->sequence = counter; |
679 | spin_lock(&sequence->lock); | 678 | INIT_LIST_HEAD(&new->list); |
680 | list_add_tail(&new->list, &sequence->list); | ||
681 | spin_unlock(&sequence->lock); | ||
682 | } | 679 | } |
683 | return new; | 680 | return new; |
684 | } | 681 | } |
@@ -687,10 +684,12 @@ void nfs_free_seqid(struct nfs_seqid *seqid) | |||
687 | { | 684 | { |
688 | struct rpc_sequence *sequence = seqid->sequence->sequence; | 685 | struct rpc_sequence *sequence = seqid->sequence->sequence; |
689 | 686 | ||
690 | spin_lock(&sequence->lock); | 687 | if (!list_empty(&seqid->list)) { |
691 | list_del(&seqid->list); | 688 | spin_lock(&sequence->lock); |
692 | rpc_wake_up(&sequence->wait); | 689 | list_del(&seqid->list); |
693 | spin_unlock(&sequence->lock); | 690 | spin_unlock(&sequence->lock); |
691 | } | ||
692 | rpc_wake_up_next(&sequence->wait); | ||
694 | kfree(seqid); | 693 | kfree(seqid); |
695 | } | 694 | } |
696 | 695 | ||
@@ -746,12 +745,16 @@ int nfs_wait_on_sequence(struct nfs_seqid *seqid, struct rpc_task *task) | |||
746 | struct rpc_sequence *sequence = seqid->sequence->sequence; | 745 | struct rpc_sequence *sequence = seqid->sequence->sequence; |
747 | int status = 0; | 746 | int status = 0; |
748 | 747 | ||
748 | if (sequence->list.next == &seqid->list) | ||
749 | goto out; | ||
749 | spin_lock(&sequence->lock); | 750 | spin_lock(&sequence->lock); |
750 | if (sequence->list.next != &seqid->list) { | 751 | if (!list_empty(&sequence->list)) { |
751 | rpc_sleep_on(&sequence->wait, task, NULL, NULL); | 752 | rpc_sleep_on(&sequence->wait, task, NULL, NULL); |
752 | status = -EAGAIN; | 753 | status = -EAGAIN; |
753 | } | 754 | } else |
755 | list_add(&seqid->list, &sequence->list); | ||
754 | spin_unlock(&sequence->lock); | 756 | spin_unlock(&sequence->lock); |
757 | out: | ||
755 | return status; | 758 | return status; |
756 | } | 759 | } |
757 | 760 | ||