diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2008-12-23 15:21:43 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2008-12-23 15:21:43 -0500 |
commit | 7eff03aec917e17f733471d7e12c262c0c96409f (patch) | |
tree | 6f0e7b53cbf55689cd37cfe3b1b087b8c61ac4cd /fs/nfs | |
parent | 0f605b56008c4b6b075217480c36ba395ca4eaa4 (diff) |
NFSv4: Add a recovery marking scheme for state owners
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/nfs4_fs.h | 7 | ||||
-rw-r--r-- | fs/nfs/nfs4proc.c | 2 | ||||
-rw-r--r-- | fs/nfs/nfs4state.c | 21 |
3 files changed, 26 insertions, 4 deletions
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 76eda46b5a17..a4e7b3feef8f 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h | |||
@@ -94,12 +94,18 @@ struct nfs4_state_owner { | |||
94 | 94 | ||
95 | spinlock_t so_lock; | 95 | spinlock_t so_lock; |
96 | atomic_t so_count; | 96 | atomic_t so_count; |
97 | unsigned long so_flags; | ||
97 | struct list_head so_states; | 98 | struct list_head so_states; |
98 | struct list_head so_delegations; | 99 | struct list_head so_delegations; |
99 | struct nfs_seqid_counter so_seqid; | 100 | struct nfs_seqid_counter so_seqid; |
100 | struct rpc_sequence so_sequence; | 101 | struct rpc_sequence so_sequence; |
101 | }; | 102 | }; |
102 | 103 | ||
104 | enum { | ||
105 | NFS_OWNER_RECLAIM_REBOOT, | ||
106 | NFS_OWNER_RECLAIM_NOGRACE | ||
107 | }; | ||
108 | |||
103 | /* | 109 | /* |
104 | * struct nfs4_state maintains the client-side state for a given | 110 | * struct nfs4_state maintains the client-side state for a given |
105 | * (state_owner,inode) tuple (OPEN) or state_owner (LOCK). | 111 | * (state_owner,inode) tuple (OPEN) or state_owner (LOCK). |
@@ -166,6 +172,7 @@ struct nfs4_exception { | |||
166 | }; | 172 | }; |
167 | 173 | ||
168 | struct nfs4_state_recovery_ops { | 174 | struct nfs4_state_recovery_ops { |
175 | int owner_flag_bit; | ||
169 | int state_flag_bit; | 176 | int state_flag_bit; |
170 | int (*recover_open)(struct nfs4_state_owner *, struct nfs4_state *); | 177 | int (*recover_open)(struct nfs4_state_owner *, struct nfs4_state *); |
171 | int (*recover_lock)(struct nfs4_state *, struct file_lock *); | 178 | int (*recover_lock)(struct nfs4_state *, struct file_lock *); |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 780ba004b3dd..019c8d67e145 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -3690,12 +3690,14 @@ int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name, | |||
3690 | } | 3690 | } |
3691 | 3691 | ||
3692 | struct nfs4_state_recovery_ops nfs4_reboot_recovery_ops = { | 3692 | struct nfs4_state_recovery_ops nfs4_reboot_recovery_ops = { |
3693 | .owner_flag_bit = NFS_OWNER_RECLAIM_REBOOT, | ||
3693 | .state_flag_bit = NFS_STATE_RECLAIM_REBOOT, | 3694 | .state_flag_bit = NFS_STATE_RECLAIM_REBOOT, |
3694 | .recover_open = nfs4_open_reclaim, | 3695 | .recover_open = nfs4_open_reclaim, |
3695 | .recover_lock = nfs4_lock_reclaim, | 3696 | .recover_lock = nfs4_lock_reclaim, |
3696 | }; | 3697 | }; |
3697 | 3698 | ||
3698 | struct nfs4_state_recovery_ops nfs4_nograce_recovery_ops = { | 3699 | struct nfs4_state_recovery_ops nfs4_nograce_recovery_ops = { |
3700 | .owner_flag_bit = NFS_OWNER_RECLAIM_NOGRACE, | ||
3699 | .state_flag_bit = NFS_STATE_RECLAIM_NOGRACE, | 3701 | .state_flag_bit = NFS_STATE_RECLAIM_NOGRACE, |
3700 | .recover_open = nfs4_open_expired, | 3702 | .recover_open = nfs4_open_expired, |
3701 | .recover_lock = nfs4_lock_expired, | 3703 | .recover_lock = nfs4_lock_expired, |
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index a780518c5c3f..7dcca23167dd 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c | |||
@@ -832,6 +832,7 @@ static int nfs4_state_mark_reclaim_reboot(struct nfs_client *clp, struct nfs4_st | |||
832 | clear_bit(NFS_STATE_RECLAIM_REBOOT, &state->flags); | 832 | clear_bit(NFS_STATE_RECLAIM_REBOOT, &state->flags); |
833 | return 0; | 833 | return 0; |
834 | } | 834 | } |
835 | set_bit(NFS_OWNER_RECLAIM_REBOOT, &state->owner->so_flags); | ||
835 | set_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state); | 836 | set_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state); |
836 | return 1; | 837 | return 1; |
837 | } | 838 | } |
@@ -840,6 +841,7 @@ static int nfs4_state_mark_reclaim_nograce(struct nfs_client *clp, struct nfs4_s | |||
840 | { | 841 | { |
841 | set_bit(NFS_STATE_RECLAIM_NOGRACE, &state->flags); | 842 | set_bit(NFS_STATE_RECLAIM_NOGRACE, &state->flags); |
842 | clear_bit(NFS_STATE_RECLAIM_REBOOT, &state->flags); | 843 | clear_bit(NFS_STATE_RECLAIM_REBOOT, &state->flags); |
844 | set_bit(NFS_OWNER_RECLAIM_NOGRACE, &state->owner->so_flags); | ||
843 | set_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state); | 845 | set_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state); |
844 | return 1; | 846 | return 1; |
845 | } | 847 | } |
@@ -1043,14 +1045,25 @@ static int nfs4_do_reclaim(struct nfs_client *clp, const struct nfs4_state_recov | |||
1043 | struct rb_node *pos; | 1045 | struct rb_node *pos; |
1044 | int status = 0; | 1046 | int status = 0; |
1045 | 1047 | ||
1046 | /* Note: list is protected by exclusive lock on cl->cl_sem */ | 1048 | restart: |
1049 | spin_lock(&clp->cl_lock); | ||
1047 | for (pos = rb_first(&clp->cl_state_owners); pos != NULL; pos = rb_next(pos)) { | 1050 | for (pos = rb_first(&clp->cl_state_owners); pos != NULL; pos = rb_next(pos)) { |
1048 | struct nfs4_state_owner *sp = rb_entry(pos, struct nfs4_state_owner, so_client_node); | 1051 | struct nfs4_state_owner *sp = rb_entry(pos, struct nfs4_state_owner, so_client_node); |
1052 | if (!test_and_clear_bit(ops->owner_flag_bit, &sp->so_flags)) | ||
1053 | continue; | ||
1054 | atomic_inc(&sp->so_count); | ||
1055 | spin_unlock(&clp->cl_lock); | ||
1049 | status = nfs4_reclaim_open_state(sp, ops); | 1056 | status = nfs4_reclaim_open_state(sp, ops); |
1050 | if (status < 0) | 1057 | if (status < 0) { |
1051 | break; | 1058 | set_bit(ops->owner_flag_bit, &sp->so_flags); |
1059 | nfs4_put_state_owner(sp); | ||
1060 | nfs4_recovery_handle_error(clp, status); | ||
1061 | return status; | ||
1062 | } | ||
1063 | nfs4_put_state_owner(sp); | ||
1064 | goto restart; | ||
1052 | } | 1065 | } |
1053 | nfs4_recovery_handle_error(clp, status); | 1066 | spin_unlock(&clp->cl_lock); |
1054 | return status; | 1067 | return status; |
1055 | } | 1068 | } |
1056 | 1069 | ||