Linux NFS development
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@redhat.com>
To: linux-nfs@vger.kernel.org
Cc: "J. Bruce Fields" <bfields@citi.umich.edu>
Subject: [PATCH 12/16] nfsd: provide callbacks on svc_xprt deletion
Date: Thu, 30 Sep 2010 12:19:09 -0400	[thread overview]
Message-ID: <1285863553-8945-13-git-send-email-bfields@redhat.com> (raw)
In-Reply-To: <1285863553-8945-1-git-send-email-bfields@redhat.com>

From: J. Bruce Fields <bfields@citi.umich.edu>

NFSv4.1 needs warning when a client tcp connection goes down, if that
connection is being used as a backchannel, so that it can warn the
client that it has lost the backchannel connection.

Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
---
 include/linux/sunrpc/svc_xprt.h |   25 +++++++++++++++++++++++++
 net/sunrpc/svc_xprt.c           |   15 +++++++++++++++
 2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/include/linux/sunrpc/svc_xprt.h b/include/linux/sunrpc/svc_xprt.h
index e50e3ec..cc90cce 100644
--- a/include/linux/sunrpc/svc_xprt.h
+++ b/include/linux/sunrpc/svc_xprt.h
@@ -32,6 +32,16 @@ struct svc_xprt_class {
 	u32			xcl_max_payload;
 };
 
+/*
+ * This is embedded in an object that wants a callback before deleting
+ * an xprt; intended for use by NFSv4.1, which needs to know when a
+ * client's tcp connection (and hence possibly a backchannel) goes away.
+ */
+struct svc_xpt_user {
+	struct list_head list;
+	void (*callback)(struct svc_xpt_user *);
+};
+
 struct svc_xprt {
 	struct svc_xprt_class	*xpt_class;
 	struct svc_xprt_ops	*xpt_ops;
@@ -66,10 +76,25 @@ struct svc_xprt {
 	struct sockaddr_storage	xpt_remote;	/* remote peer's address */
 	size_t			xpt_remotelen;	/* length of address */
 	struct rpc_wait_queue	xpt_bc_pending;	/* backchannel wait queue */
+	struct list_head	xpt_users;	/* callbacks on free */
 
 	struct net		*xpt_net;
 };
 
+static inline void register_xpt_user(struct svc_xprt *xpt, struct svc_xpt_user *u)
+{
+	spin_lock(&xpt->xpt_lock);
+	list_add(&u->list, &xpt->xpt_users);
+	spin_unlock(&xpt->xpt_lock);
+}
+
+static inline void unregister_xpt_user(struct svc_xprt *xpt, struct svc_xpt_user *u)
+{
+	spin_lock(&xpt->xpt_lock);
+	list_del_init(&u->list);
+	spin_unlock(&xpt->xpt_lock);
+}
+
 int	svc_reg_xprt_class(struct svc_xprt_class *);
 void	svc_unreg_xprt_class(struct svc_xprt_class *);
 void	svc_xprt_init(struct svc_xprt_class *, struct svc_xprt *,
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
index f7e8915..b37fd3a 100644
--- a/net/sunrpc/svc_xprt.c
+++ b/net/sunrpc/svc_xprt.c
@@ -156,6 +156,7 @@ void svc_xprt_init(struct svc_xprt_class *xcl, struct svc_xprt *xprt,
 	INIT_LIST_HEAD(&xprt->xpt_list);
 	INIT_LIST_HEAD(&xprt->xpt_ready);
 	INIT_LIST_HEAD(&xprt->xpt_deferred);
+	INIT_LIST_HEAD(&xprt->xpt_users);
 	mutex_init(&xprt->xpt_mutex);
 	spin_lock_init(&xprt->xpt_lock);
 	set_bit(XPT_BUSY, &xprt->xpt_flags);
@@ -880,6 +881,19 @@ static void svc_age_temp_xprts(unsigned long closure)
 	mod_timer(&serv->sv_temptimer, jiffies + svc_conn_age_period * HZ);
 }
 
+static void call_xpt_users(struct svc_xprt *xprt)
+{
+	struct svc_xpt_user *u;
+
+	spin_lock(&xprt->xpt_lock);
+	while (!list_empty(&xprt->xpt_users)) {
+		u = list_first_entry(&xprt->xpt_users, struct svc_xpt_user, list);
+		list_del(&u->list);
+		u->callback(u);
+	}
+	spin_unlock(&xprt->xpt_lock);
+}
+
 /*
  * Remove a dead transport
  */
@@ -912,6 +926,7 @@ void svc_delete_xprt(struct svc_xprt *xprt)
 	while ((dr = svc_deferred_dequeue(xprt)) != NULL)
 		kfree(dr);
 
+	call_xpt_users(xprt);
 	svc_xprt_put(xprt);
 }
 
-- 
1.7.0.4


  parent reply	other threads:[~2010-09-30 16:19 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-30 16:18 4.1 patches J. Bruce Fields
2010-09-30 16:18 ` [PATCH 01/16] nfsd4: minor variable renaming (cb -> conn) J. Bruce Fields
2010-09-30 16:18 ` [PATCH 02/16] nfsd4: combine nfs4_rpc_args and nfsd4_cb_sequence J. Bruce Fields
2010-09-30 16:19 ` [PATCH 03/16] nfsd4: rename nfs4_rpc_args->nfsd4_cb_args J. Bruce Fields
2010-09-30 16:19 ` [PATCH 04/16] nfsd4: generic callback code J. Bruce Fields
2010-09-30 16:19 ` [PATCH 05/16] nfsd4: use generic callback code in null case J. Bruce Fields
2010-09-30 16:19 ` [PATCH 06/16] nfsd4: remove separate cb_args struct J. Bruce Fields
2010-09-30 16:19 ` [PATCH 07/16] nfsd4: Move callback setup to callback queue J. Bruce Fields
2010-09-30 16:19 ` [PATCH 08/16] nfsd4: fix alloc_init_session BUILD_BUG_ON() J. Bruce Fields
2010-09-30 16:19 ` [PATCH 09/16] nfsd4: fix alloc_init_session return type J. Bruce Fields
2010-09-30 16:19 ` [PATCH 10/16] nfsd4: clean up session allocation J. Bruce Fields
2010-09-30 16:19 ` [PATCH 11/16] nfsd4: keep per-session list of connections J. Bruce Fields
2010-09-30 21:21   ` Benny Halevy
2010-09-30 21:38     ` J. Bruce Fields
2010-09-30 16:19 ` J. Bruce Fields [this message]
2010-09-30 16:19 ` [PATCH 13/16] nfsd4: use callbacks on svc_xprt_deletion J. Bruce Fields
2010-09-30 16:19 ` [PATCH 14/16] nfsd4: refactor connection allocation J. Bruce Fields
2010-09-30 16:19 ` [PATCH 15/16] nfsd4: add new connections to session J. Bruce Fields
2010-09-30 21:33   ` Benny Halevy
2010-09-30 21:57     ` J. Bruce Fields
2010-09-30 16:19 ` [PATCH 16/16] nfsd4: enforce DESTROY_SESSION connection requirement J. Bruce Fields

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1285863553-8945-13-git-send-email-bfields@redhat.com \
    --to=bfields@redhat.com \
    --cc=bfields@citi.umich.edu \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox