提交 55aa4f58 编写于 作者: C Chuck Lever 提交者: Trond Myklebust

[PATCH] RPC: client-side transport switch cleanup

 Clean-up: change some comments to reflect the realities of the new RPC
 transport switch mechanism.  Get rid of unused xprt_receive() prototype.

 Also, organize function prototypes in xprt.h by usage and scope.

 Test-plan:
 Compile kernel with CONFIG_NFS enabled.

 Version: Thu, 11 Aug 2005 16:07:21 -0400
Signed-off-by: NChuck Lever <cel@netapp.com>
Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
上级 44fbac22
/* /*
* linux/include/linux/sunrpc/clnt_xprt.h * linux/include/linux/sunrpc/xprt.h
* *
* Declarations for the RPC transport interface. * Declarations for the RPC transport interface.
* *
...@@ -150,8 +150,8 @@ struct rpc_xprt { ...@@ -150,8 +150,8 @@ struct rpc_xprt {
unsigned long cong; /* current congestion */ unsigned long cong; /* current congestion */
unsigned long cwnd; /* congestion window */ unsigned long cwnd; /* congestion window */
unsigned int rcvsize, /* socket receive buffer size */ unsigned int rcvsize, /* transport rcv buffer size */
sndsize; /* socket send buffer size */ sndsize; /* transport send buffer size */
size_t max_payload; /* largest RPC payload size, size_t max_payload; /* largest RPC payload size,
in bytes */ in bytes */
...@@ -184,12 +184,12 @@ struct rpc_xprt { ...@@ -184,12 +184,12 @@ struct rpc_xprt {
unsigned long tcp_copied, /* copied to request */ unsigned long tcp_copied, /* copied to request */
tcp_flags; tcp_flags;
/* /*
* Connection of sockets * Connection of transports
*/ */
struct work_struct sock_connect; struct work_struct connect_worker;
unsigned short port; unsigned short port;
/* /*
* Disconnection of idle sockets * Disconnection of idle transports
*/ */
struct work_struct task_cleanup; struct work_struct task_cleanup;
struct timer_list timer; struct timer_list timer;
...@@ -219,27 +219,36 @@ struct rpc_xprt { ...@@ -219,27 +219,36 @@ struct rpc_xprt {
#ifdef __KERNEL__ #ifdef __KERNEL__
struct rpc_xprt * xprt_create_proto(int proto, struct sockaddr_in *addr, /*
struct rpc_timeout *toparms); * Transport operations used by ULPs
void xprt_disconnect(struct rpc_xprt *); */
int xprt_destroy(struct rpc_xprt *); struct rpc_xprt * xprt_create_proto(int proto, struct sockaddr_in *addr, struct rpc_timeout *to);
void xprt_set_timeout(struct rpc_timeout *, unsigned int, void xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long incr);
unsigned long);
struct rpc_rqst * xprt_lookup_rqst(struct rpc_xprt *, u32); /*
void xprt_complete_rqst(struct rpc_xprt *, * Generic internal transport functions
struct rpc_rqst *, int); */
void xprt_reserve(struct rpc_task *); void xprt_connect(struct rpc_task *task);
int xprt_prepare_transmit(struct rpc_task *); void xprt_reserve(struct rpc_task *task);
void xprt_transmit(struct rpc_task *); int xprt_prepare_transmit(struct rpc_task *task);
void xprt_receive(struct rpc_task *); void xprt_transmit(struct rpc_task *task);
void xprt_wake_pending_tasks(struct rpc_xprt *, int);
int xprt_adjust_timeout(struct rpc_rqst *req); int xprt_adjust_timeout(struct rpc_rqst *req);
void xprt_release(struct rpc_task *); void xprt_release(struct rpc_task *task);
void xprt_connect(struct rpc_task *); int xprt_destroy(struct rpc_xprt *xprt);
int xs_setup_udp(struct rpc_xprt *,
struct rpc_timeout *); /*
int xs_setup_tcp(struct rpc_xprt *, * Transport switch helper functions
struct rpc_timeout *); */
void xprt_wake_pending_tasks(struct rpc_xprt *xprt, int status);
struct rpc_rqst * xprt_lookup_rqst(struct rpc_xprt *xprt, u32 xid);
void xprt_complete_rqst(struct rpc_xprt *xprt, struct rpc_rqst *req, int copied);
void xprt_disconnect(struct rpc_xprt *xprt);
/*
* Socket transport setup operations
*/
int xs_setup_udp(struct rpc_xprt *xprt, struct rpc_timeout *to);
int xs_setup_tcp(struct rpc_xprt *xprt, struct rpc_timeout *to);
/* /*
* Reserved bit positions in xprt->state * Reserved bit positions in xprt->state
......
/* /*
* linux/net/sunrpc/rpcclnt.c * linux/net/sunrpc/clnt.c
* *
* This file contains the high-level RPC interface. * This file contains the high-level RPC interface.
* It is modeled as a finite state machine to support both synchronous * It is modeled as a finite state machine to support both synchronous
......
...@@ -10,12 +10,12 @@ ...@@ -10,12 +10,12 @@
* one is available. Otherwise, it sleeps on the backlog queue * one is available. Otherwise, it sleeps on the backlog queue
* (xprt_reserve). * (xprt_reserve).
* - Next, the caller puts together the RPC message, stuffs it into * - Next, the caller puts together the RPC message, stuffs it into
* the request struct, and calls xprt_call(). * the request struct, and calls xprt_transmit().
* - xprt_call transmits the message and installs the caller on the * - xprt_transmit sends the message and installs the caller on the
* socket's wait list. At the same time, it installs a timer that * transport's wait list. At the same time, it installs a timer that
* is run after the packet's timeout has expired. * is run after the packet's timeout has expired.
* - When a packet arrives, the data_ready handler walks the list of * - When a packet arrives, the data_ready handler walks the list of
* pending requests for that socket. If a matching XID is found, the * pending requests for that transport. If a matching XID is found, the
* caller is woken up, and the timer removed. * caller is woken up, and the timer removed.
* - When no reply arrives within the timeout interval, the timer is * - When no reply arrives within the timeout interval, the timer is
* fired by the kernel and runs xprt_timer(). It either adjusts the * fired by the kernel and runs xprt_timer(). It either adjusts the
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
* tasks that rely on callbacks. * tasks that rely on callbacks.
* *
* Copyright (C) 1995-1997, Olaf Kirch <okir@monad.swb.de> * Copyright (C) 1995-1997, Olaf Kirch <okir@monad.swb.de>
*
* Transport switch API copyright (C) 2005, Chuck Lever <cel@netapp.com>
*/ */
#include <linux/module.h> #include <linux/module.h>
...@@ -52,8 +54,6 @@ ...@@ -52,8 +54,6 @@
# define RPCDBG_FACILITY RPCDBG_XPRT # define RPCDBG_FACILITY RPCDBG_XPRT
#endif #endif
#define XPRT_MAX_BACKOFF (8)
/* /*
* Local functions * Local functions
*/ */
...@@ -65,9 +65,9 @@ static int __xprt_get_cong(struct rpc_xprt *, struct rpc_task *); ...@@ -65,9 +65,9 @@ static int __xprt_get_cong(struct rpc_xprt *, struct rpc_task *);
static int xprt_clear_backlog(struct rpc_xprt *xprt); static int xprt_clear_backlog(struct rpc_xprt *xprt);
/* /*
* Serialize write access to sockets, in order to prevent different * Serialize write access to transports, in order to prevent different
* requests from interfering with each other. * requests from interfering with each other.
* Also prevents TCP socket connects from colliding with writes. * Also prevents transport connects from colliding with writes.
*/ */
static int static int
__xprt_lock_write(struct rpc_xprt *xprt, struct rpc_task *task) __xprt_lock_write(struct rpc_xprt *xprt, struct rpc_task *task)
...@@ -91,7 +91,7 @@ __xprt_lock_write(struct rpc_xprt *xprt, struct rpc_task *task) ...@@ -91,7 +91,7 @@ __xprt_lock_write(struct rpc_xprt *xprt, struct rpc_task *task)
clear_bit(XPRT_LOCKED, &xprt->state); clear_bit(XPRT_LOCKED, &xprt->state);
smp_mb__after_clear_bit(); smp_mb__after_clear_bit();
out_sleep: out_sleep:
dprintk("RPC: %4d failed to lock socket %p\n", task->tk_pid, xprt); dprintk("RPC: %4d failed to lock transport %p\n", task->tk_pid, xprt);
task->tk_timeout = 0; task->tk_timeout = 0;
task->tk_status = -EAGAIN; task->tk_status = -EAGAIN;
if (req && req->rq_ntrans) if (req && req->rq_ntrans)
...@@ -144,7 +144,7 @@ __xprt_lock_write_next(struct rpc_xprt *xprt) ...@@ -144,7 +144,7 @@ __xprt_lock_write_next(struct rpc_xprt *xprt)
} }
/* /*
* Releases the socket for use by other requests. * Releases the transport for use by other requests.
*/ */
static void static void
__xprt_release_write(struct rpc_xprt *xprt, struct rpc_task *task) __xprt_release_write(struct rpc_xprt *xprt, struct rpc_task *task)
...@@ -294,8 +294,7 @@ int xprt_adjust_timeout(struct rpc_rqst *req) ...@@ -294,8 +294,7 @@ int xprt_adjust_timeout(struct rpc_rqst *req)
return status; return status;
} }
static void static void xprt_autoclose(void *args)
xprt_socket_autoclose(void *args)
{ {
struct rpc_xprt *xprt = (struct rpc_xprt *)args; struct rpc_xprt *xprt = (struct rpc_xprt *)args;
...@@ -329,7 +328,6 @@ xprt_init_autodisconnect(unsigned long data) ...@@ -329,7 +328,6 @@ xprt_init_autodisconnect(unsigned long data)
if (test_and_set_bit(XPRT_LOCKED, &xprt->state)) if (test_and_set_bit(XPRT_LOCKED, &xprt->state))
goto out_abort; goto out_abort;
spin_unlock(&xprt->transport_lock); spin_unlock(&xprt->transport_lock);
/* Let keventd close the socket */
if (xprt_connecting(xprt)) if (xprt_connecting(xprt))
xprt_release_write(xprt, NULL); xprt_release_write(xprt, NULL);
else else
...@@ -770,7 +768,7 @@ static struct rpc_xprt *xprt_setup(int proto, struct sockaddr_in *ap, struct rpc ...@@ -770,7 +768,7 @@ static struct rpc_xprt *xprt_setup(int proto, struct sockaddr_in *ap, struct rpc
INIT_LIST_HEAD(&xprt->free); INIT_LIST_HEAD(&xprt->free);
INIT_LIST_HEAD(&xprt->recv); INIT_LIST_HEAD(&xprt->recv);
INIT_WORK(&xprt->task_cleanup, xprt_socket_autoclose, xprt); INIT_WORK(&xprt->task_cleanup, xprt_autoclose, xprt);
init_timer(&xprt->timer); init_timer(&xprt->timer);
xprt->timer.function = xprt_init_autodisconnect; xprt->timer.function = xprt_init_autodisconnect;
xprt->timer.data = (unsigned long) xprt; xprt->timer.data = (unsigned long) xprt;
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
* Rewrite of larges part of the code in order to stabilize TCP stuff. * Rewrite of larges part of the code in order to stabilize TCP stuff.
* Fix behaviour when socket buffer is full. * Fix behaviour when socket buffer is full.
* (C) 1999 Trond Myklebust <trond.myklebust@fys.uio.no> * (C) 1999 Trond Myklebust <trond.myklebust@fys.uio.no>
*
* IP socket transport implementation, (C) 2005 Chuck Lever <cel@netapp.com>
*/ */
#include <linux/types.h> #include <linux/types.h>
...@@ -363,7 +365,7 @@ static void xs_destroy(struct rpc_xprt *xprt) ...@@ -363,7 +365,7 @@ static void xs_destroy(struct rpc_xprt *xprt)
{ {
dprintk("RPC: xs_destroy xprt %p\n", xprt); dprintk("RPC: xs_destroy xprt %p\n", xprt);
cancel_delayed_work(&xprt->sock_connect); cancel_delayed_work(&xprt->connect_worker);
flush_scheduled_work(); flush_scheduled_work();
xprt_disconnect(xprt); xprt_disconnect(xprt);
...@@ -938,11 +940,11 @@ static void xs_connect(struct rpc_task *task) ...@@ -938,11 +940,11 @@ static void xs_connect(struct rpc_task *task)
if (!xprt_test_and_set_connecting(xprt)) { if (!xprt_test_and_set_connecting(xprt)) {
if (xprt->sock != NULL) { if (xprt->sock != NULL) {
dprintk("RPC: xs_connect delayed xprt %p\n", xprt); dprintk("RPC: xs_connect delayed xprt %p\n", xprt);
schedule_delayed_work(&xprt->sock_connect, schedule_delayed_work(&xprt->connect_worker,
RPC_REESTABLISH_TIMEOUT); RPC_REESTABLISH_TIMEOUT);
} else { } else {
dprintk("RPC: xs_connect scheduled xprt %p\n", xprt); dprintk("RPC: xs_connect scheduled xprt %p\n", xprt);
schedule_work(&xprt->sock_connect); schedule_work(&xprt->connect_worker);
/* flush_scheduled_work can sleep... */ /* flush_scheduled_work can sleep... */
if (!RPC_IS_ASYNC(task)) if (!RPC_IS_ASYNC(task))
flush_scheduled_work(); flush_scheduled_work();
...@@ -989,7 +991,7 @@ int xs_setup_udp(struct rpc_xprt *xprt, struct rpc_timeout *to) ...@@ -989,7 +991,7 @@ int xs_setup_udp(struct rpc_xprt *xprt, struct rpc_timeout *to)
/* XXX: header size can vary due to auth type, IPv6, etc. */ /* XXX: header size can vary due to auth type, IPv6, etc. */
xprt->max_payload = (1U << 16) - (MAX_HEADER << 3); xprt->max_payload = (1U << 16) - (MAX_HEADER << 3);
INIT_WORK(&xprt->sock_connect, xs_connect_worker, xprt); INIT_WORK(&xprt->connect_worker, xs_connect_worker, xprt);
xprt->ops = &xs_ops; xprt->ops = &xs_ops;
...@@ -1028,7 +1030,7 @@ int xs_setup_tcp(struct rpc_xprt *xprt, struct rpc_timeout *to) ...@@ -1028,7 +1030,7 @@ int xs_setup_tcp(struct rpc_xprt *xprt, struct rpc_timeout *to)
xprt->resvport = capable(CAP_NET_BIND_SERVICE) ? 1 : 0; xprt->resvport = capable(CAP_NET_BIND_SERVICE) ? 1 : 0;
xprt->max_payload = (1U << 31) - 1; xprt->max_payload = (1U << 31) - 1;
INIT_WORK(&xprt->sock_connect, xs_connect_worker, xprt); INIT_WORK(&xprt->connect_worker, xs_connect_worker, xprt);
xprt->ops = &xs_ops; xprt->ops = &xs_ops;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册