aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@citi.umich.edu>2010-06-06 18:37:16 -0400
committerJ. Bruce Fields <bfields@redhat.com>2010-10-01 19:29:44 -0400
commit19cf5c026f3ee06027523e59478e3fa54f573e5e (patch)
treee1162b69d7a558193b740344794d647a3d15e121 /fs/nfsd
parentedc7a894034acb4c7ff8305716ca5df8aaf8e642 (diff)
downloadkernel_samsung_smdk4412-19cf5c026f3ee06027523e59478e3fa54f573e5e.zip
kernel_samsung_smdk4412-19cf5c026f3ee06027523e59478e3fa54f573e5e.tar.gz
kernel_samsung_smdk4412-19cf5c026f3ee06027523e59478e3fa54f573e5e.tar.bz2
nfsd4: use callbacks on svc_xprt_deletion
Remove connections from the list when they go down. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Diffstat (limited to 'fs/nfsd')
-rw-r--r--fs/nfsd/nfs4state.c51
-rw-r--r--fs/nfsd/state.h3
2 files changed, 45 insertions, 9 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index c7c1a7a..b7e9793 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -625,6 +625,25 @@ static void init_forechannel_attrs(struct nfsd4_channel_attrs *new, struct nfsd4
new->maxops = min_t(u32, req->maxops, NFSD_MAX_OPS_PER_COMPOUND);
}
+static void free_conn(struct nfsd4_conn *c)
+{
+ svc_xprt_put(c->cn_xprt);
+ kfree(c);
+}
+
+static void nfsd4_conn_lost(struct svc_xpt_user *u)
+{
+ struct nfsd4_conn *c = container_of(u, struct nfsd4_conn, cn_xpt_user);
+ struct nfs4_client *clp = c->cn_session->se_client;
+
+ spin_lock(&clp->cl_lock);
+ if (!list_empty(&c->cn_persession)) {
+ list_del(&c->cn_persession);
+ free_conn(c);
+ }
+ spin_unlock(&clp->cl_lock);
+}
+
static __be32 nfsd4_new_conn(struct svc_rqst *rqstp, struct nfsd4_session *ses)
{
struct nfs4_client *clp = ses->se_client;
@@ -636,18 +655,34 @@ static __be32 nfsd4_new_conn(struct svc_rqst *rqstp, struct nfsd4_session *ses)
conn->cn_flags = NFS4_CDFC4_FORE;
svc_xprt_get(rqstp->rq_xprt);
conn->cn_xprt = rqstp->rq_xprt;
+ conn->cn_session = ses;
spin_lock(&clp->cl_lock);
list_add(&conn->cn_persession, &ses->se_conns);
spin_unlock(&clp->cl_lock);
+ conn->cn_xpt_user.callback = nfsd4_conn_lost;
+ register_xpt_user(rqstp->rq_xprt, &conn->cn_xpt_user);
return nfs_ok;
}
-static void free_conn(struct nfsd4_conn *c)
+static void nfsd4_del_conns(struct nfsd4_session *s)
{
- svc_xprt_put(c->cn_xprt);
- kfree(c);
+ struct nfs4_client *clp = s->se_client;
+ struct nfsd4_conn *c;
+
+ spin_lock(&clp->cl_lock);
+ while (!list_empty(&s->se_conns)) {
+ c = list_first_entry(&s->se_conns, struct nfsd4_conn, cn_persession);
+ list_del_init(&c->cn_persession);
+ spin_unlock(&clp->cl_lock);
+
+ unregister_xpt_user(c->cn_xprt, &c->cn_xpt_user);
+ free_conn(c);
+
+ spin_lock(&clp->cl_lock);
+ }
+ spin_unlock(&clp->cl_lock);
}
void free_session(struct kref *kref)
@@ -656,12 +691,7 @@ void free_session(struct kref *kref)
int mem;
ses = container_of(kref, struct nfsd4_session, se_ref);
- while (!list_empty(&ses->se_conns)) {
- struct nfsd4_conn *c;
- c = list_first_entry(&ses->se_conns, struct nfsd4_conn, cn_persession);
- list_del(&c->cn_persession);
- free_conn(c);
- }
+ nfsd4_del_conns(ses);
spin_lock(&nfsd_drc_lock);
mem = ses->se_fchannel.maxreqs * slot_bytes(&ses->se_fchannel);
nfsd_drc_mem_used -= mem;
@@ -1552,6 +1582,9 @@ nfsd4_destroy_session(struct svc_rqst *r,
/* wait for callbacks */
nfsd4_shutdown_callback(ses->se_client);
nfs4_unlock_state();
+
+ nfsd4_del_conns(ses);
+
nfsd4_put_session(ses);
status = nfs_ok;
out:
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h
index 29413c2..8d5e237 100644
--- a/fs/nfsd/state.h
+++ b/fs/nfsd/state.h
@@ -35,6 +35,7 @@
#ifndef _NFSD4_STATE_H
#define _NFSD4_STATE_H
+#include <linux/sunrpc/svc_xprt.h>
#include <linux/nfsd/nfsfh.h>
#include "nfsfh.h"
@@ -155,6 +156,8 @@ struct nfsd4_clid_slot {
struct nfsd4_conn {
struct list_head cn_persession;
struct svc_xprt *cn_xprt;
+ struct svc_xpt_user cn_xpt_user;
+ struct nfsd4_session *cn_session;
/* CDFC4_FORE, CDFC4_BACK: */
unsigned char cn_flags;
};