Skip to content

Commit 5694c93

Browse files
trondmypdJ. Bruce Fields
authored and
J. Bruce Fields
committed
NFSd: Move default initialisers from create_client() to alloc_client()
Aside from making it clearer what is non-trivial in create_client(), it also fixes a bug whereby we can call free_client() before idr_init() has been called. Signed-off-by: Trond Myklebust <[email protected]> Cc: [email protected] Signed-off-by: J. Bruce Fields <[email protected]>
1 parent fc208d0 commit 5694c93

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

fs/nfsd/nfs4state.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,18 @@ static struct nfs4_client *alloc_client(struct xdr_netobj name)
10781078
return NULL;
10791079
}
10801080
clp->cl_name.len = name.len;
1081+
INIT_LIST_HEAD(&clp->cl_sessions);
1082+
idr_init(&clp->cl_stateids);
1083+
atomic_set(&clp->cl_refcount, 0);
1084+
clp->cl_cb_state = NFSD4_CB_UNKNOWN;
1085+
INIT_LIST_HEAD(&clp->cl_idhash);
1086+
INIT_LIST_HEAD(&clp->cl_openowners);
1087+
INIT_LIST_HEAD(&clp->cl_delegations);
1088+
INIT_LIST_HEAD(&clp->cl_lru);
1089+
INIT_LIST_HEAD(&clp->cl_callbacks);
1090+
INIT_LIST_HEAD(&clp->cl_revoked);
1091+
spin_lock_init(&clp->cl_lock);
1092+
rpc_init_wait_queue(&clp->cl_cb_waitq, "Backchannel slot table");
10811093
return clp;
10821094
}
10831095

@@ -1347,28 +1359,16 @@ static struct nfs4_client *create_client(struct xdr_netobj name,
13471359
if (clp == NULL)
13481360
return NULL;
13491361

1350-
INIT_LIST_HEAD(&clp->cl_sessions);
13511362
ret = copy_cred(&clp->cl_cred, &rqstp->rq_cred);
13521363
if (ret) {
13531364
spin_lock(&nn->client_lock);
13541365
free_client(clp);
13551366
spin_unlock(&nn->client_lock);
13561367
return NULL;
13571368
}
1358-
idr_init(&clp->cl_stateids);
1359-
atomic_set(&clp->cl_refcount, 0);
1360-
clp->cl_cb_state = NFSD4_CB_UNKNOWN;
1361-
INIT_LIST_HEAD(&clp->cl_idhash);
1362-
INIT_LIST_HEAD(&clp->cl_openowners);
1363-
INIT_LIST_HEAD(&clp->cl_delegations);
1364-
INIT_LIST_HEAD(&clp->cl_lru);
1365-
INIT_LIST_HEAD(&clp->cl_callbacks);
1366-
INIT_LIST_HEAD(&clp->cl_revoked);
1367-
spin_lock_init(&clp->cl_lock);
13681369
nfsd4_init_callback(&clp->cl_cb_null);
13691370
clp->cl_time = get_seconds();
13701371
clear_bit(0, &clp->cl_cb_slot_busy);
1371-
rpc_init_wait_queue(&clp->cl_cb_waitq, "Backchannel slot table");
13721372
copy_verf(clp, verf);
13731373
rpc_copy_addr((struct sockaddr *) &clp->cl_addr, sa);
13741374
gen_confirm(clp);

0 commit comments

Comments
 (0)