Prechádzať zdrojové kódy

SUNRPC: Make freeing of struct xprt rcu-safe

Have it call kfree_rcu() to ensure that we can use it on rcu-protected
lists.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Trond Myklebust 10 rokov pred
rodič
commit
fda1bfef9e
2 zmenil súbory, kde vykonal 3 pridanie a 1 odobranie
  1. 1 0
      include/linux/sunrpc/xprt.h
  2. 2 1
      net/sunrpc/xprt.c

+ 1 - 0
include/linux/sunrpc/xprt.h

@@ -257,6 +257,7 @@ struct rpc_xprt {
 	struct dentry		*debugfs;		/* debugfs directory */
 	struct dentry		*debugfs;		/* debugfs directory */
 	atomic_t		inject_disconnect;
 	atomic_t		inject_disconnect;
 #endif
 #endif
+	struct rcu_head		rcu;
 };
 };
 
 
 #if defined(CONFIG_SUNRPC_BACKCHANNEL)
 #if defined(CONFIG_SUNRPC_BACKCHANNEL)

+ 2 - 1
net/sunrpc/xprt.c

@@ -48,6 +48,7 @@
 #include <linux/sunrpc/clnt.h>
 #include <linux/sunrpc/clnt.h>
 #include <linux/sunrpc/metrics.h>
 #include <linux/sunrpc/metrics.h>
 #include <linux/sunrpc/bc_xprt.h>
 #include <linux/sunrpc/bc_xprt.h>
+#include <linux/rcupdate.h>
 
 
 #include <trace/events/sunrpc.h>
 #include <trace/events/sunrpc.h>
 
 
@@ -1166,7 +1167,7 @@ void xprt_free(struct rpc_xprt *xprt)
 {
 {
 	put_net(xprt->xprt_net);
 	put_net(xprt->xprt_net);
 	xprt_free_all_slots(xprt);
 	xprt_free_all_slots(xprt);
-	kfree(xprt);
+	kfree_rcu(xprt, rcu);
 }
 }
 EXPORT_SYMBOL_GPL(xprt_free);
 EXPORT_SYMBOL_GPL(xprt_free);