aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2010-12-08 13:48:19 -0500
committerJ. Bruce Fields <bfields@redhat.com>2011-01-11 15:04:10 -0500
commitf0418aa4b1103f959d64dc18273efa04ee0140e9 (patch)
tree01457cfe70d614dcdb12759247212602c2c2c008 /net
parent99de8ea962bbc11a51ad4c52e3dc93bee5f6ba70 (diff)
rpc: allow xprt_class->setup to return a preexisting xprt
This allows us to reuse the xprt associated with a server connection if one has already been set up. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'net')
-rw-r--r--net/sunrpc/xprt.c3
-rw-r--r--net/sunrpc/xprtsock.c18
2 files changed, 12 insertions, 9 deletions
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 749ad15ae305..856274d7e85c 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -1102,6 +1102,9 @@ found:
1102 -PTR_ERR(xprt)); 1102 -PTR_ERR(xprt));
1103 return xprt; 1103 return xprt;
1104 } 1104 }
1105 if (test_and_set_bit(XPRT_INITIALIZED, &xprt->state))
1106 /* ->setup returned a pre-initialized xprt: */
1107 return xprt;
1105 1108
1106 spin_lock_init(&xprt->transport_lock); 1109 spin_lock_init(&xprt->transport_lock);
1107 spin_lock_init(&xprt->reserve_lock); 1110 spin_lock_init(&xprt->reserve_lock);
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 0ef4dd4414ec..ee091c869fcd 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -2359,6 +2359,15 @@ static struct rpc_xprt *xs_setup_bc_tcp(struct xprt_create *args)
2359 struct svc_sock *bc_sock; 2359 struct svc_sock *bc_sock;
2360 struct rpc_xprt *ret; 2360 struct rpc_xprt *ret;
2361 2361
2362 if (args->bc_xprt->xpt_bc_xprt) {
2363 /*
2364 * This server connection already has a backchannel
2365 * export; we can't create a new one, as we wouldn't be
2366 * able to match replies based on xid any more. So,
2367 * reuse the already-existing one:
2368 */
2369 return args->bc_xprt->xpt_bc_xprt;
2370 }
2362 xprt = xs_setup_xprt(args, xprt_tcp_slot_table_entries); 2371 xprt = xs_setup_xprt(args, xprt_tcp_slot_table_entries);
2363 if (IS_ERR(xprt)) 2372 if (IS_ERR(xprt))
2364 return xprt; 2373 return xprt;
@@ -2397,15 +2406,6 @@ static struct rpc_xprt *xs_setup_bc_tcp(struct xprt_create *args)
2397 xprt->address_strings[RPC_DISPLAY_PROTO]); 2406 xprt->address_strings[RPC_DISPLAY_PROTO]);
2398 2407
2399 /* 2408 /*
2400 * The backchannel uses the same socket connection as the
2401 * forechannel
2402 */
2403 if (args->bc_xprt->xpt_bc_xprt) {
2404 /* XXX: actually, want to catch this case... */
2405 ret = ERR_PTR(-EINVAL);
2406 goto out_err;
2407 }
2408 /*
2409 * Once we've associated a backchannel xprt with a connection, 2409 * Once we've associated a backchannel xprt with a connection,
2410 * we want to keep it around as long as long as the connection 2410 * we want to keep it around as long as long as the connection
2411 * lasts, in case we need to start using it for a backchannel 2411 * lasts, in case we need to start using it for a backchannel