aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4state.c
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@primarydata.com>2014-07-30 08:27:05 -0400
committerJ. Bruce Fields <bfields@redhat.com>2014-08-01 16:28:20 -0400
commit5cc40fd7b623b306adfe1eba1b509e95890358f5 (patch)
tree61bb583c0d5b39c7827ab8b0a9485f711fbb5345 /fs/nfsd/nfs4state.c
parent425510f5c8f1643a01668f48c43c77b8275e9227 (diff)
nfsd: Move create_client() call outside the lock
For efficiency reasons, and because we want to use spin locks instead of relying on the client_mutex. Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4state.c')
-rw-r--r--fs/nfsd/nfs4state.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 256e9032f49c..4b42cb95e315 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -2181,6 +2181,10 @@ nfsd4_exchange_id(struct svc_rqst *rqstp,
2181 return nfserr_encr_alg_unsupp; 2181 return nfserr_encr_alg_unsupp;
2182 } 2182 }
2183 2183
2184 new = create_client(exid->clname, rqstp, &verf);
2185 if (new == NULL)
2186 return nfserr_jukebox;
2187
2184 /* Cases below refer to rfc 5661 section 18.35.4: */ 2188 /* Cases below refer to rfc 5661 section 18.35.4: */
2185 nfs4_lock_state(); 2189 nfs4_lock_state();
2186 conf = find_confirmed_client_by_name(&exid->clname, nn); 2190 conf = find_confirmed_client_by_name(&exid->clname, nn);
@@ -2207,7 +2211,6 @@ nfsd4_exchange_id(struct svc_rqst *rqstp,
2207 } 2211 }
2208 /* case 6 */ 2212 /* case 6 */
2209 exid->flags |= EXCHGID4_FLAG_CONFIRMED_R; 2213 exid->flags |= EXCHGID4_FLAG_CONFIRMED_R;
2210 new = conf;
2211 goto out_copy; 2214 goto out_copy;
2212 } 2215 }
2213 if (!creds_match) { /* case 3 */ 2216 if (!creds_match) { /* case 3 */
@@ -2220,7 +2223,6 @@ nfsd4_exchange_id(struct svc_rqst *rqstp,
2220 } 2223 }
2221 if (verfs_match) { /* case 2 */ 2224 if (verfs_match) { /* case 2 */
2222 conf->cl_exchange_flags |= EXCHGID4_FLAG_CONFIRMED_R; 2225 conf->cl_exchange_flags |= EXCHGID4_FLAG_CONFIRMED_R;
2223 new = conf;
2224 goto out_copy; 2226 goto out_copy;
2225 } 2227 }
2226 /* case 5, client reboot */ 2228 /* case 5, client reboot */
@@ -2238,29 +2240,28 @@ nfsd4_exchange_id(struct svc_rqst *rqstp,
2238 2240
2239 /* case 1 (normal case) */ 2241 /* case 1 (normal case) */
2240out_new: 2242out_new:
2241 new = create_client(exid->clname, rqstp, &verf);
2242 if (new == NULL) {
2243 status = nfserr_jukebox;
2244 goto out;
2245 }
2246 new->cl_minorversion = cstate->minorversion; 2243 new->cl_minorversion = cstate->minorversion;
2247 new->cl_mach_cred = (exid->spa_how == SP4_MACH_CRED); 2244 new->cl_mach_cred = (exid->spa_how == SP4_MACH_CRED);
2248 2245
2249 gen_clid(new, nn); 2246 gen_clid(new, nn);
2250 add_to_unconfirmed(new); 2247 add_to_unconfirmed(new);
2248 conf = new;
2249 new = NULL;
2251out_copy: 2250out_copy:
2252 exid->clientid.cl_boot = new->cl_clientid.cl_boot; 2251 exid->clientid.cl_boot = conf->cl_clientid.cl_boot;
2253 exid->clientid.cl_id = new->cl_clientid.cl_id; 2252 exid->clientid.cl_id = conf->cl_clientid.cl_id;
2254 2253
2255 exid->seqid = new->cl_cs_slot.sl_seqid + 1; 2254 exid->seqid = conf->cl_cs_slot.sl_seqid + 1;
2256 nfsd4_set_ex_flags(new, exid); 2255 nfsd4_set_ex_flags(conf, exid);
2257 2256
2258 dprintk("nfsd4_exchange_id seqid %d flags %x\n", 2257 dprintk("nfsd4_exchange_id seqid %d flags %x\n",
2259 new->cl_cs_slot.sl_seqid, new->cl_exchange_flags); 2258 conf->cl_cs_slot.sl_seqid, conf->cl_exchange_flags);
2260 status = nfs_ok; 2259 status = nfs_ok;
2261 2260
2262out: 2261out:
2263 nfs4_unlock_state(); 2262 nfs4_unlock_state();
2263 if (new)
2264 free_client(new);
2264 return status; 2265 return status;
2265} 2266}
2266 2267
@@ -2903,6 +2904,9 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
2903 __be32 status; 2904 __be32 status;
2904 struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); 2905 struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
2905 2906
2907 new = create_client(clname, rqstp, &clverifier);
2908 if (new == NULL)
2909 return nfserr_jukebox;
2906 /* Cases below refer to rfc 3530 section 14.2.33: */ 2910 /* Cases below refer to rfc 3530 section 14.2.33: */
2907 nfs4_lock_state(); 2911 nfs4_lock_state();
2908 conf = find_confirmed_client_by_name(&clname, nn); 2912 conf = find_confirmed_client_by_name(&clname, nn);
@@ -2923,10 +2927,6 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
2923 unconf = find_unconfirmed_client_by_name(&clname, nn); 2927 unconf = find_unconfirmed_client_by_name(&clname, nn);
2924 if (unconf) 2928 if (unconf)
2925 expire_client(unconf); 2929 expire_client(unconf);
2926 status = nfserr_jukebox;
2927 new = create_client(clname, rqstp, &clverifier);
2928 if (new == NULL)
2929 goto out;
2930 if (conf && same_verf(&conf->cl_verifier, &clverifier)) 2930 if (conf && same_verf(&conf->cl_verifier, &clverifier))
2931 /* case 1: probable callback update */ 2931 /* case 1: probable callback update */
2932 copy_clid(new, conf); 2932 copy_clid(new, conf);
@@ -2938,9 +2938,12 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
2938 setclid->se_clientid.cl_boot = new->cl_clientid.cl_boot; 2938 setclid->se_clientid.cl_boot = new->cl_clientid.cl_boot;
2939 setclid->se_clientid.cl_id = new->cl_clientid.cl_id; 2939 setclid->se_clientid.cl_id = new->cl_clientid.cl_id;
2940 memcpy(setclid->se_confirm.data, new->cl_confirm.data, sizeof(setclid->se_confirm.data)); 2940 memcpy(setclid->se_confirm.data, new->cl_confirm.data, sizeof(setclid->se_confirm.data));
2941 new = NULL;
2941 status = nfs_ok; 2942 status = nfs_ok;
2942out: 2943out:
2943 nfs4_unlock_state(); 2944 nfs4_unlock_state();
2945 if (new)
2946 free_client(new);
2944 return status; 2947 return status;
2945} 2948}
2946 2949