aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/nfsd/nfs4callback.c19
-rw-r--r--include/linux/sunrpc/xprt.h13
-rw-r--r--net/sunrpc/xprt.c12
-rw-r--r--net/sunrpc/xprtsock.c9
4 files changed, 30 insertions, 23 deletions
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
index 7f05cd140de3..39c8ef875f91 100644
--- a/fs/nfsd/nfs4callback.c
+++ b/fs/nfsd/nfs4callback.c
@@ -32,6 +32,7 @@
32 */ 32 */
33 33
34#include <linux/sunrpc/clnt.h> 34#include <linux/sunrpc/clnt.h>
35#include <linux/sunrpc/xprt.h>
35#include <linux/sunrpc/svc_xprt.h> 36#include <linux/sunrpc/svc_xprt.h>
36#include <linux/slab.h> 37#include <linux/slab.h>
37#include "nfsd.h" 38#include "nfsd.h"
@@ -635,6 +636,22 @@ static struct rpc_cred *get_backchannel_cred(struct nfs4_client *clp, struct rpc
635 } 636 }
636} 637}
637 638
639static struct rpc_clnt *create_backchannel_client(struct rpc_create_args *args)
640{
641 struct rpc_xprt *xprt;
642
643 if (args->protocol != XPRT_TRANSPORT_BC_TCP)
644 return rpc_create(args);
645
646 xprt = args->bc_xprt->xpt_bc_xprt;
647 if (xprt) {
648 xprt_get(xprt);
649 return rpc_create_xprt(args, xprt);
650 }
651
652 return rpc_create(args);
653}
654
638static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *conn, struct nfsd4_session *ses) 655static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *conn, struct nfsd4_session *ses)
639{ 656{
640 struct rpc_timeout timeparms = { 657 struct rpc_timeout timeparms = {
@@ -674,7 +691,7 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c
674 args.authflavor = ses->se_cb_sec.flavor; 691 args.authflavor = ses->se_cb_sec.flavor;
675 } 692 }
676 /* Create RPC client */ 693 /* Create RPC client */
677 client = rpc_create(&args); 694 client = create_backchannel_client(&args);
678 if (IS_ERR(client)) { 695 if (IS_ERR(client)) {
679 dprintk("NFSD: couldn't create callback client: %ld\n", 696 dprintk("NFSD: couldn't create callback client: %ld\n",
680 PTR_ERR(client)); 697 PTR_ERR(client));
diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
index 8097b9df6773..3e5efb2b236e 100644
--- a/include/linux/sunrpc/xprt.h
+++ b/include/linux/sunrpc/xprt.h
@@ -295,13 +295,24 @@ int xprt_adjust_timeout(struct rpc_rqst *req);
295void xprt_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task); 295void xprt_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task);
296void xprt_release_xprt_cong(struct rpc_xprt *xprt, struct rpc_task *task); 296void xprt_release_xprt_cong(struct rpc_xprt *xprt, struct rpc_task *task);
297void xprt_release(struct rpc_task *task); 297void xprt_release(struct rpc_task *task);
298struct rpc_xprt * xprt_get(struct rpc_xprt *xprt);
299void xprt_put(struct rpc_xprt *xprt); 298void xprt_put(struct rpc_xprt *xprt);
300struct rpc_xprt * xprt_alloc(struct net *net, size_t size, 299struct rpc_xprt * xprt_alloc(struct net *net, size_t size,
301 unsigned int num_prealloc, 300 unsigned int num_prealloc,
302 unsigned int max_req); 301 unsigned int max_req);
303void xprt_free(struct rpc_xprt *); 302void xprt_free(struct rpc_xprt *);
304 303
304/**
305 * xprt_get - return a reference to an RPC transport.
306 * @xprt: pointer to the transport
307 *
308 */
309static inline struct rpc_xprt *xprt_get(struct rpc_xprt *xprt)
310{
311 if (atomic_inc_not_zero(&xprt->count))
312 return xprt;
313 return NULL;
314}
315
305static inline __be32 *xprt_skip_transport_header(struct rpc_xprt *xprt, __be32 *p) 316static inline __be32 *xprt_skip_transport_header(struct rpc_xprt *xprt, __be32 *p)
306{ 317{
307 return p + xprt->tsh_size; 318 return p + xprt->tsh_size;
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 7d4df99f761f..d173f79947c6 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -1383,15 +1383,3 @@ void xprt_put(struct rpc_xprt *xprt)
1383 if (atomic_dec_and_test(&xprt->count)) 1383 if (atomic_dec_and_test(&xprt->count))
1384 xprt_destroy(xprt); 1384 xprt_destroy(xprt);
1385} 1385}
1386
1387/**
1388 * xprt_get - return a reference to an RPC transport.
1389 * @xprt: pointer to the transport
1390 *
1391 */
1392struct rpc_xprt *xprt_get(struct rpc_xprt *xprt)
1393{
1394 if (atomic_inc_not_zero(&xprt->count))
1395 return xprt;
1396 return NULL;
1397}
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 63ae657f255b..1335239217cd 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -2923,15 +2923,6 @@ static struct rpc_xprt *xs_setup_bc_tcp(struct xprt_create *args)
2923 struct svc_sock *bc_sock; 2923 struct svc_sock *bc_sock;
2924 struct rpc_xprt *ret; 2924 struct rpc_xprt *ret;
2925 2925
2926 if (args->bc_xprt->xpt_bc_xprt) {
2927 /*
2928 * This server connection already has a backchannel
2929 * transport; we can't create a new one, as we wouldn't
2930 * be able to match replies based on xid any more. So,
2931 * reuse the already-existing one:
2932 */
2933 return args->bc_xprt->xpt_bc_xprt;
2934 }
2935 xprt = xs_setup_xprt(args, xprt_tcp_slot_table_entries, 2926 xprt = xs_setup_xprt(args, xprt_tcp_slot_table_entries,
2936 xprt_tcp_slot_table_entries); 2927 xprt_tcp_slot_table_entries);
2937 if (IS_ERR(xprt)) 2928 if (IS_ERR(xprt))