diff options
author | J. Bruce Fields <bfields@redhat.com> | 2010-09-29 15:29:32 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2010-10-01 19:29:45 -0400 |
commit | db90681d6eff89efc1eee523e1cb77eb632a6cf7 (patch) | |
tree | 4923aae6dcdaa35c42b4f19f319266437b42d7ce /fs/nfsd/nfs4state.c | |
parent | 19cf5c026f3ee06027523e59478e3fa54f573e5e (diff) | |
download | linux-db90681d6eff89efc1eee523e1cb77eb632a6cf7.tar.bz2 |
nfsd4: refactor connection allocation
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4state.c')
-rw-r--r-- | fs/nfsd/nfs4state.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index b7e9793b58f5..3b4d74cbb6c8 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -644,25 +644,45 @@ static void nfsd4_conn_lost(struct svc_xpt_user *u) spin_unlock(&clp->cl_lock); } -static __be32 nfsd4_new_conn(struct svc_rqst *rqstp, struct nfsd4_session *ses) +static struct nfsd4_conn *alloc_conn(struct svc_rqst *rqstp) { - struct nfs4_client *clp = ses->se_client; struct nfsd4_conn *conn; conn = kmalloc(sizeof(struct nfsd4_conn), GFP_KERNEL); if (!conn) - return nfserr_jukebox; - conn->cn_flags = NFS4_CDFC4_FORE; + return NULL; svc_xprt_get(rqstp->rq_xprt); conn->cn_xprt = rqstp->rq_xprt; - conn->cn_session = ses; + conn->cn_flags = NFS4_CDFC4_FORE; + INIT_LIST_HEAD(&conn->cn_xpt_user.list); + return conn; +} + +static void nfsd4_hash_conn(struct nfsd4_conn *conn, struct nfsd4_session *ses) +{ + struct nfs4_client *clp = ses->se_client; spin_lock(&clp->cl_lock); + conn->cn_session = ses; list_add(&conn->cn_persession, &ses->se_conns); spin_unlock(&clp->cl_lock); +} +static void nfsd4_register_conn(struct nfsd4_conn *conn) +{ conn->cn_xpt_user.callback = nfsd4_conn_lost; - register_xpt_user(rqstp->rq_xprt, &conn->cn_xpt_user); + register_xpt_user(conn->cn_xprt, &conn->cn_xpt_user); +} + +static __be32 nfsd4_new_conn(struct svc_rqst *rqstp, struct nfsd4_session *ses) +{ + struct nfsd4_conn *conn; + + conn = alloc_conn(rqstp); + if (!conn) + return nfserr_jukebox; + nfsd4_hash_conn(conn, ses); + nfsd4_register_conn(conn); return nfs_ok; } |