[RHEL7,COMMIT] sunrpc: bc_svc_flush_queue_net() helper introduced

Submitted by Konstantin Khorenko on Nov. 9, 2017, 11:12 a.m.

Details

Message ID 201711091112.vA9BCfvk009694@finist_ce7.work
State New
Series "nfs: fix race between callback shutdown and execution"
Headers show

Commit Message

Konstantin Khorenko Nov. 9, 2017, 11:12 a.m.
The commit is pushed to "branch-rh7-3.10.0-693.1.1.vz7.37.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.1.1.vz7.37.25
------>
commit 99bfffc43ae40204d445f2c138071176d3e7b03d
Author: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Date:   Thu Nov 9 14:12:41 2017 +0300

    sunrpc: bc_svc_flush_queue_net() helper introduced
    
    Patchset description:
    nfs: fix race between callback shutdown and execution
    
    The idea is to use mutex for protecting callback execution agains per-net
    callback shutdown and destroying all the net-related backchannel requests
    before transports destruction.
    
    Stanislav Kinsburskiy (2):
        sunrpc: bc_svc_flush_queue_net() helper introduced
        nfs: protect callback execution against per-net callback thread shutdown
    
    ===========================================
    This patch description:
    
    This helper can be used to remove backchannel requests from callback queue on
    per-net basis.
    
    Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
    Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 include/linux/sunrpc/svc.h |  2 ++
 net/sunrpc/svc.c           | 15 +++++++++++++++
 2 files changed, 17 insertions(+)

Patch hide | download patch | download mbox

diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
index 2b30868..fe70ff0 100644
--- a/include/linux/sunrpc/svc.h
+++ b/include/linux/sunrpc/svc.h
@@ -484,6 +484,8 @@  void		   svc_reserve(struct svc_rqst *rqstp, int space);
 struct svc_pool *  svc_pool_for_cpu(struct svc_serv *serv, int cpu);
 char *		   svc_print_addr(struct svc_rqst *, char *, size_t);
 
+void bc_svc_flush_queue_net(struct svc_serv *serv, struct net *net);
+
 #define	RPC_MAX_ADDRBUFLEN	(63U)
 
 /*
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index de8cded1..2ca4ff7 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -1338,6 +1338,21 @@  svc_process(struct svc_rqst *rqstp)
 EXPORT_SYMBOL_GPL(svc_process);
 
 #if defined(CONFIG_SUNRPC_BACKCHANNEL)
+void bc_svc_flush_queue_net(struct svc_serv *serv, struct net *net)
+{
+	struct rpc_rqst *req, *tmp;
+
+	spin_lock_bh(&serv->sv_cb_lock);
+	list_for_each_entry_safe(req, tmp, &serv->sv_cb_list, rq_bc_list) {
+		if (req->rq_xprt->xprt_net == net) {
+			list_del(&req->rq_bc_list);
+			xprt_free_bc_request(req);
+		}
+	}
+	spin_unlock_bh(&serv->sv_cb_lock);
+}
+EXPORT_SYMBOL_GPL(bc_svc_flush_queue_net);
+
 /*
  * Process a backchannel RPC request that arrived over an existing
  * outbound connection