Skip to content

Commit 5cc40fd

Browse files
trondmypdJ. Bruce Fields
authored andcommitted
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 <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
1 parent 425510f commit 5cc40fd

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

fs/nfsd/nfs4state.c

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,6 +2181,10 @@ nfsd4_exchange_id(struct svc_rqst *rqstp,
21812181
return nfserr_encr_alg_unsupp;
21822182
}
21832183

2184+
new = create_client(exid->clname, rqstp, &verf);
2185+
if (new == NULL)
2186+
return nfserr_jukebox;
2187+
21842188
/* Cases below refer to rfc 5661 section 18.35.4: */
21852189
nfs4_lock_state();
21862190
conf = find_confirmed_client_by_name(&exid->clname, nn);
@@ -2207,7 +2211,6 @@ nfsd4_exchange_id(struct svc_rqst *rqstp,
22072211
}
22082212
/* case 6 */
22092213
exid->flags |= EXCHGID4_FLAG_CONFIRMED_R;
2210-
new = conf;
22112214
goto out_copy;
22122215
}
22132216
if (!creds_match) { /* case 3 */
@@ -2220,7 +2223,6 @@ nfsd4_exchange_id(struct svc_rqst *rqstp,
22202223
}
22212224
if (verfs_match) { /* case 2 */
22222225
conf->cl_exchange_flags |= EXCHGID4_FLAG_CONFIRMED_R;
2223-
new = conf;
22242226
goto out_copy;
22252227
}
22262228
/* case 5, client reboot */
@@ -2238,29 +2240,28 @@ nfsd4_exchange_id(struct svc_rqst *rqstp,
22382240

22392241
/* case 1 (normal case) */
22402242
out_new:
2241-
new = create_client(exid->clname, rqstp, &verf);
2242-
if (new == NULL) {
2243-
status = nfserr_jukebox;
2244-
goto out;
2245-
}
22462243
new->cl_minorversion = cstate->minorversion;
22472244
new->cl_mach_cred = (exid->spa_how == SP4_MACH_CRED);
22482245

22492246
gen_clid(new, nn);
22502247
add_to_unconfirmed(new);
2248+
conf = new;
2249+
new = NULL;
22512250
out_copy:
2252-
exid->clientid.cl_boot = new->cl_clientid.cl_boot;
2253-
exid->clientid.cl_id = new->cl_clientid.cl_id;
2251+
exid->clientid.cl_boot = conf->cl_clientid.cl_boot;
2252+
exid->clientid.cl_id = conf->cl_clientid.cl_id;
22542253

2255-
exid->seqid = new->cl_cs_slot.sl_seqid + 1;
2256-
nfsd4_set_ex_flags(new, exid);
2254+
exid->seqid = conf->cl_cs_slot.sl_seqid + 1;
2255+
nfsd4_set_ex_flags(conf, exid);
22572256

22582257
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);
22602259
status = nfs_ok;
22612260

22622261
out:
22632262
nfs4_unlock_state();
2263+
if (new)
2264+
free_client(new);
22642265
return status;
22652266
}
22662267

@@ -2903,6 +2904,9 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
29032904
__be32 status;
29042905
struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
29052906

2907+
new = create_client(clname, rqstp, &clverifier);
2908+
if (new == NULL)
2909+
return nfserr_jukebox;
29062910
/* Cases below refer to rfc 3530 section 14.2.33: */
29072911
nfs4_lock_state();
29082912
conf = find_confirmed_client_by_name(&clname, nn);
@@ -2923,10 +2927,6 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
29232927
unconf = find_unconfirmed_client_by_name(&clname, nn);
29242928
if (unconf)
29252929
expire_client(unconf);
2926-
status = nfserr_jukebox;
2927-
new = create_client(clname, rqstp, &clverifier);
2928-
if (new == NULL)
2929-
goto out;
29302930
if (conf && same_verf(&conf->cl_verifier, &clverifier))
29312931
/* case 1: probable callback update */
29322932
copy_clid(new, conf);
@@ -2938,9 +2938,12 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
29382938
setclid->se_clientid.cl_boot = new->cl_clientid.cl_boot;
29392939
setclid->se_clientid.cl_id = new->cl_clientid.cl_id;
29402940
memcpy(setclid->se_confirm.data, new->cl_confirm.data, sizeof(setclid->se_confirm.data));
2941+
new = NULL;
29412942
status = nfs_ok;
29422943
out:
29432944
nfs4_unlock_state();
2945+
if (new)
2946+
free_client(new);
29442947
return status;
29452948
}
29462949

0 commit comments

Comments
 (0)