Commit a7b721037f898b29a8083da59b1dccd3da385b07

Authored by Andy Adamson
Committed by Benny Halevy
1 parent 8e69514f29

nfs41: introduce get_state_renewal_cred

Use the machine cred for sending SEQUENCE to renew
the client's lease.

[revamp patch for new state management design starting 2.6.29]
[nfs41: support minorversion 1 for nfs4_check_lease]
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[nfs41: get cred in exchange_id when cred arg is NULL]
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[nfs41: use cl_machined_cred instead of cl_ex_cred]
    Since EXCHANGE_ID insists on using the machine credential, cl_ex_cred is
    not needed. nfs4_proc_exchange_id() is only called if the machine credential
    is available. Remove the credential logic from nfs4_proc_exchange_id.
Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>

Showing 4 changed files with 14 additions and 14 deletions Side-by-side Diff

... ... @@ -182,6 +182,7 @@
182 182  
183 183 struct nfs4_state_maintenance_ops {
184 184 int (*sched_state_renewal)(struct nfs_client *, struct rpc_cred *);
  185 + struct rpc_cred * (*get_state_renewal_cred_locked)(struct nfs_client *);
185 186 int (*renew_lease)(struct nfs_client *, struct rpc_cred *);
186 187 };
187 188  
188 189  
... ... @@ -240,7 +241,11 @@
240 241 extern void nfs4_renew_state(struct work_struct *);
241 242  
242 243 /* nfs4state.c */
  244 +struct rpc_cred *nfs4_get_setclientid_cred(struct nfs_client *clp);
243 245 struct rpc_cred *nfs4_get_renew_cred_locked(struct nfs_client *clp);
  246 +#if defined(CONFIG_NFS_V4_1)
  247 +struct rpc_cred *nfs4_get_machine_cred_locked(struct nfs_client *clp);
  248 +#endif /* CONFIG_NFS_V4_1 */
244 249  
245 250 extern struct nfs4_state_owner * nfs4_get_state_owner(struct nfs_server *, struct rpc_cred *);
246 251 extern void nfs4_put_state_owner(struct nfs4_state_owner *);
... ... @@ -4236,6 +4236,7 @@
4236 4236  
4237 4237 dprintk("--> %s\n", __func__);
4238 4238 BUG_ON(clp == NULL);
  4239 +
4239 4240 p = (u32 *)verifier.data;
4240 4241 *p++ = htonl((u32)clp->cl_boot_time.tv_sec);
4241 4242 *p = htonl((u32)clp->cl_boot_time.tv_nsec);
4242 4243  
... ... @@ -4795,12 +4796,14 @@
4795 4796  
4796 4797 struct nfs4_state_maintenance_ops nfs40_state_renewal_ops = {
4797 4798 .sched_state_renewal = nfs4_proc_async_renew,
  4799 + .get_state_renewal_cred_locked = nfs4_get_renew_cred_locked,
4798 4800 .renew_lease = nfs4_proc_renew,
4799 4801 };
4800 4802  
4801 4803 #if defined(CONFIG_NFS_V4_1)
4802 4804 struct nfs4_state_maintenance_ops nfs41_state_renewal_ops = {
4803 4805 .sched_state_renewal = nfs41_proc_async_sequence,
  4806 + .get_state_renewal_cred_locked = nfs4_get_machine_cred_locked,
4804 4807 .renew_lease = nfs4_proc_sequence,
4805 4808 };
4806 4809 #endif
... ... @@ -78,7 +78,7 @@
78 78 timeout = (2 * lease) / 3 + (long)last - (long)now;
79 79 /* Are we close to a lease timeout? */
80 80 if (time_after(now, last + lease/3)) {
81   - cred = nfs4_get_renew_cred_locked(clp);
  81 + cred = ops->get_state_renewal_cred_locked(clp);
82 82 spin_unlock(&clp->cl_lock);
83 83 if (cred == NULL) {
84 84 if (list_empty(&clp->cl_delegations)) {
... ... @@ -77,7 +77,7 @@
77 77 return status;
78 78 }
79 79  
80   -static struct rpc_cred *nfs4_get_machine_cred_locked(struct nfs_client *clp)
  80 +struct rpc_cred *nfs4_get_machine_cred_locked(struct nfs_client *clp)
81 81 {
82 82 struct rpc_cred *cred = NULL;
83 83  
84 84  
... ... @@ -114,18 +114,8 @@
114 114 return cred;
115 115 }
116 116  
117   -static struct rpc_cred *nfs4_get_renew_cred(struct nfs_client *clp)
  117 +struct rpc_cred *nfs4_get_setclientid_cred(struct nfs_client *clp)
118 118 {
119   - struct rpc_cred *cred;
120   -
121   - spin_lock(&clp->cl_lock);
122   - cred = nfs4_get_renew_cred_locked(clp);
123   - spin_unlock(&clp->cl_lock);
124   - return cred;
125   -}
126   -
127   -static struct rpc_cred *nfs4_get_setclientid_cred(struct nfs_client *clp)
128   -{
129 119 struct nfs4_state_owner *sp;
130 120 struct rb_node *pos;
131 121 struct rpc_cred *cred;
... ... @@ -1090,7 +1080,9 @@
1090 1080 /* Is the client already known to have an expired lease? */
1091 1081 if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state))
1092 1082 return 0;
1093   - cred = nfs4_get_renew_cred(clp);
  1083 + spin_lock(&clp->cl_lock);
  1084 + cred = ops->get_state_renewal_cred_locked(clp);
  1085 + spin_unlock(&clp->cl_lock);
1094 1086 if (cred == NULL) {
1095 1087 cred = nfs4_get_setclientid_cred(clp);
1096 1088 if (cred == NULL)