From: Chuck Lever Subject: [PATCH 04/10] SUNRPC: Remove sock and inet fields from rpc_xprt Date: Tue, 17 Oct 2006 14:44:31 -0400 Message-ID: <20061017184431.25704.90702.stgit@schiele.dsl.sfldmi.ameritech.net> References: <20061017184142.25704.44260.stgit@schiele.dsl.sfldmi.ameritech.net> Reply-To: Chuck Lever Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Cc: nfs@lists.sourceforge.net Return-path: Received: from sc8-sf-mx2-b.sourceforge.net ([10.3.1.92] helo=mail.sourceforge.net) by sc8-sf-list2-new.sourceforge.net with esmtp (Exim 4.43) id 1GZtw3-0000Pd-UY for nfs@lists.sourceforge.net; Tue, 17 Oct 2006 11:45:08 -0700 Received: from flpvm23.prodigy.net ([207.115.20.53]) by mail.sourceforge.net with esmtp (Exim 4.44) id 1GZtw2-0006EB-2K for nfs@lists.sourceforge.net; Tue, 17 Oct 2006 11:45:09 -0700 To: trond.myklebust@fys.uio.no In-Reply-To: <20061017184142.25704.44260.stgit@schiele.dsl.sfldmi.ameritech.net> List-Id: "Discussion of NFS under Linux development, interoperability, and testing." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: nfs-bounces@lists.sourceforge.net Errors-To: nfs-bounces@lists.sourceforge.net The "sock" and "inet" fields are socket-specific. Move them to a private data structure maintained entirely within net/sunrpc/xprtsock.c Test plan: Connectathon. Signed-off-by: Chuck Lever --- include/linux/sunrpc/xprt.h | 4 +-- net/sunrpc/xprtsock.c | 68 ++++++++++++++++++++++++++----------------- 2 files changed, 43 insertions(+), 29 deletions(-) diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index d791901..4c074a7 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h @@ -17,6 +17,8 @@ #include #include #include +#include + extern unsigned int xprt_udp_slot_table_entries; extern unsigned int xprt_tcp_slot_table_entries; @@ -126,8 +128,6 @@ struct rpc_xprt_ops { struct rpc_xprt { struct kref kref; /* Reference count */ struct rpc_xprt_ops * ops; /* transport methods */ - struct socket * sock; /* BSD socket layer */ - struct sock * inet; /* INET layer */ struct rpc_timeout timeout; /* timeout parms */ struct sockaddr_storage addr; /* server address */ diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 5ddb20d..79088e8 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -127,6 +127,12 @@ #endif struct xs_xprt { struct rpc_xprt xprt; + + /* + * Network layer + */ + struct socket * sock; + struct sock * inet; }; static inline struct xs_xprt *xs_private_data(struct rpc_xprt *xprt) @@ -134,6 +140,11 @@ static inline struct xs_xprt *xs_private return (struct xs_xprt *) xprt; } +static inline struct rpc_xprt *xprt_from_sock(struct sock *sk) +{ + return (struct rpc_xprt *) sk->sk_user_data; +} + static void xs_format_peer_addresses(struct rpc_xprt *xprt) { struct sockaddr_in *addr = (struct sockaddr_in *) &xprt->addr; @@ -300,19 +311,20 @@ static void xs_nospace(struct rpc_task * { struct rpc_rqst *req = task->tk_rqstp; struct rpc_xprt *xprt = req->rq_xprt; + struct socket *sock = xs_private_data(xprt)->sock; dprintk("RPC: %4d xmit incomplete (%u left of %u)\n", task->tk_pid, req->rq_slen - req->rq_bytes_sent, req->rq_slen); - if (test_bit(SOCK_ASYNC_NOSPACE, &xprt->sock->flags)) { + if (test_bit(SOCK_ASYNC_NOSPACE, &sock->flags)) { /* Protect against races with write_space */ spin_lock_bh(&xprt->transport_lock); /* Don't race with disconnect */ if (!xprt_connected(xprt)) task->tk_status = -ENOTCONN; - else if (test_bit(SOCK_NOSPACE, &xprt->sock->flags)) + else if (test_bit(SOCK_NOSPACE, &sock->flags)) xprt_wait_for_buffer_space(task); spin_unlock_bh(&xprt->transport_lock); @@ -344,8 +356,10 @@ static int xs_udp_send_request(struct rp req->rq_svec->iov_len); req->rq_xtime = jiffies; - status = xs_sendpages(xprt->sock, (struct sockaddr *) &xprt->addr, - xprt->addrlen, xdr, req->rq_bytes_sent); + status = xs_sendpages(xs_private_data(xprt)->sock, + (struct sockaddr *) &xprt->addr, + xprt->addrlen, xdr, + req->rq_bytes_sent); dprintk("RPC: xs_udp_send_request(%u) = %d\n", xdr->len - req->rq_bytes_sent, status); @@ -415,8 +429,8 @@ static int xs_tcp_send_request(struct rp * called sendmsg(). */ while (1) { req->rq_xtime = jiffies; - status = xs_sendpages(xprt->sock, NULL, 0, xdr, - req->rq_bytes_sent); + status = xs_sendpages(xs_private_data(xprt)->sock, + NULL, 0, xdr, req->rq_bytes_sent); dprintk("RPC: xs_tcp_send_request(%u) = %d\n", xdr->len - req->rq_bytes_sent, status); @@ -494,8 +508,9 @@ out_release: */ static void xs_close(struct rpc_xprt *xprt) { - struct socket *sock = xprt->sock; - struct sock *sk = xprt->inet; + struct xs_xprt *private = xs_private_data(xprt); + struct socket *sock = private->sock; + struct sock *sk = private->inet; if (!sk) goto clear_close_wait; @@ -503,8 +518,8 @@ static void xs_close(struct rpc_xprt *xp dprintk("RPC: xs_close xprt %p\n", xprt); write_lock_bh(&sk->sk_callback_lock); - xprt->inet = NULL; - xprt->sock = NULL; + private->inet = NULL; + private->sock = NULL; sk->sk_user_data = NULL; sk->sk_data_ready = xprt->old_data_ready; @@ -540,11 +555,6 @@ static void xs_destroy(struct rpc_xprt * kfree(xprt); } -static inline struct rpc_xprt *xprt_from_sock(struct sock *sk) -{ - return (struct rpc_xprt *) sk->sk_user_data; -} - /** * xs_udp_data_ready - "data ready" callback for UDP sockets * @sk: socket with data to read @@ -961,7 +971,8 @@ static void xs_tcp_write_space(struct so static void xs_udp_do_set_buffer_size(struct rpc_xprt *xprt) { - struct sock *sk = xprt->inet; + struct xs_xprt *private = xs_private_data(xprt); + struct sock *sk = private->inet; if (xprt->rcvsize) { sk->sk_userlocks |= SOCK_RCVBUF_LOCK; @@ -1077,7 +1088,8 @@ static int xs_bindresvport(struct rpc_xp static void xs_udp_connect_worker(void *args) { struct rpc_xprt *xprt = (struct rpc_xprt *) args; - struct socket *sock = xprt->sock; + struct xs_xprt *private = xs_private_data(xprt); + struct socket *sock = private->sock; int err, status = -EIO; if (xprt->shutdown || !xprt_bound(xprt)) @@ -1099,7 +1111,7 @@ static void xs_udp_connect_worker(void * dprintk("RPC: worker connecting xprt %p to address: %s\n", xprt, xs_print_peer_address(xprt, RPC_DISPLAY_ALL)); - if (!xprt->inet) { + if (!private->inet) { struct sock *sk = sock->sk; write_lock_bh(&sk->sk_callback_lock); @@ -1116,8 +1128,8 @@ static void xs_udp_connect_worker(void * xprt_set_connected(xprt); /* Reset to new socket */ - xprt->sock = sock; - xprt->inet = sk; + private->sock = sock; + private->inet = sk; write_unlock_bh(&sk->sk_callback_lock); } @@ -1135,7 +1147,7 @@ out: static void xs_tcp_reuse_connection(struct rpc_xprt *xprt) { int result; - struct socket *sock = xprt->sock; + struct socket *sock = xs_private_data(xprt)->sock; struct sockaddr any; dprintk("RPC: disconnecting xprt %p to reuse port\n", xprt); @@ -1161,13 +1173,14 @@ static void xs_tcp_reuse_connection(stru static void xs_tcp_connect_worker(void *args) { struct rpc_xprt *xprt = (struct rpc_xprt *)args; - struct socket *sock = xprt->sock; + struct xs_xprt *private = xs_private_data(xprt); + struct socket *sock = private->sock; int err, status = -EIO; if (xprt->shutdown || !xprt_bound(xprt)) goto out; - if (!xprt->sock) { + if (!private->sock) { /* start from scratch */ if ((err = sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock)) < 0) { dprintk("RPC: can't create TCP transport socket (%d).\n", -err); @@ -1185,7 +1198,7 @@ static void xs_tcp_connect_worker(void * dprintk("RPC: worker connecting xprt %p to address: %s\n", xprt, xs_print_peer_address(xprt, RPC_DISPLAY_ALL)); - if (!xprt->inet) { + if (!private->inet) { struct sock *sk = sock->sk; write_lock_bh(&sk->sk_callback_lock); @@ -1208,8 +1221,8 @@ static void xs_tcp_connect_worker(void * xprt_clear_connected(xprt); /* Reset to new socket */ - xprt->sock = sock; - xprt->inet = sk; + private->sock = sock; + private->inet = sk; write_unlock_bh(&sk->sk_callback_lock); } @@ -1258,11 +1271,12 @@ out_clear: static void xs_connect(struct rpc_task *task) { struct rpc_xprt *xprt = task->tk_xprt; + struct xs_xprt *private = xs_private_data(xprt); if (xprt_test_and_set_connecting(xprt)) return; - if (xprt->sock != NULL) { + if (private->sock != NULL) { dprintk("RPC: xs_connect delayed xprt %p for %lu seconds\n", xprt, xprt->reestablish_timeout / HZ); schedule_delayed_work(&xprt->connect_worker, ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs