Commit 4f6e6c17 authored by J. Bruce Fields's avatar J. Bruce Fields

nfsd4: simplify bind_conn_to_session locking

The locking here is very fiddly, and there's no reason for us to be
setting cstate->session, since this is the only op in the compound.
Let's just take the state lock and drop the reference counting.
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent abcdff09
...@@ -1887,30 +1887,30 @@ __be32 nfsd4_bind_conn_to_session(struct svc_rqst *rqstp, ...@@ -1887,30 +1887,30 @@ __be32 nfsd4_bind_conn_to_session(struct svc_rqst *rqstp,
{ {
__be32 status; __be32 status;
struct nfsd4_conn *conn; struct nfsd4_conn *conn;
struct nfsd4_session *session;
struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
if (!nfsd4_last_compound_op(rqstp)) if (!nfsd4_last_compound_op(rqstp))
return nfserr_not_only_op; return nfserr_not_only_op;
nfs4_lock_state();
spin_lock(&nn->client_lock); spin_lock(&nn->client_lock);
cstate->session = find_in_sessionid_hashtbl(&bcts->sessionid, SVC_NET(rqstp)); session = find_in_sessionid_hashtbl(&bcts->sessionid, SVC_NET(rqstp));
/* Sorta weird: we only need the refcnt'ing because new_conn acquires
* client_lock iself: */
if (cstate->session) {
nfsd4_get_session(cstate->session);
atomic_inc(&cstate->session->se_client->cl_refcount);
}
spin_unlock(&nn->client_lock); spin_unlock(&nn->client_lock);
if (!cstate->session) status = nfserr_badsession;
return nfserr_badsession; if (!session)
goto out;
status = nfsd4_map_bcts_dir(&bcts->dir); status = nfsd4_map_bcts_dir(&bcts->dir);
if (status) if (status)
return status; goto out;
conn = alloc_conn(rqstp, bcts->dir); conn = alloc_conn(rqstp, bcts->dir);
status = nfserr_jukebox;
if (!conn) if (!conn)
return nfserr_jukebox; goto out;
nfsd4_init_conn(rqstp, conn, cstate->session); nfsd4_init_conn(rqstp, conn, session);
return nfs_ok; status = nfs_ok;
out:
nfs4_unlock_state();
return status;
} }
static bool nfsd4_compound_in_session(struct nfsd4_session *session, struct nfs4_sessionid *sid) static bool nfsd4_compound_in_session(struct nfsd4_session *session, struct nfs4_sessionid *sid)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment