Commit 9903cd1c authored by Chuck Lever's avatar Chuck Lever Committed by Trond Myklebust

[PATCH] RPC: transport switch function naming

 Introduce block header comments and a function naming convention to the
 socket transport implementation.  Provide a debug setting for transports
 that is separate from RPCDBG_XPRT.  Eliminate xprt_default_timeout().

 Provide block comments for exposed interfaces in xprt.c, and eliminate
 the useless obvious comments.

 Convert printk's to dprintk's.

 Test-plan:
 Compile kernel with CONFIG_NFS enabled.

 Version: Thu, 11 Aug 2005 16:04:04 -0400
Signed-off-by: default avatarChuck Lever <cel@netapp.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent a246b010
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#define RPCDBG_AUTH 0x0010 #define RPCDBG_AUTH 0x0010
#define RPCDBG_PMAP 0x0020 #define RPCDBG_PMAP 0x0020
#define RPCDBG_SCHED 0x0040 #define RPCDBG_SCHED 0x0040
#define RPCDBG_TRANS 0x0080
#define RPCDBG_SVCSOCK 0x0100 #define RPCDBG_SVCSOCK 0x0100
#define RPCDBG_SVCDSP 0x0200 #define RPCDBG_SVCDSP 0x0200
#define RPCDBG_MISC 0x0400 #define RPCDBG_MISC 0x0400
......
...@@ -227,9 +227,6 @@ xprt_adjust_cwnd(struct rpc_xprt *xprt, int result) ...@@ -227,9 +227,6 @@ xprt_adjust_cwnd(struct rpc_xprt *xprt, int result)
xprt->cwnd = cwnd; xprt->cwnd = cwnd;
} }
/*
* Reset the major timeout value
*/
static void xprt_reset_majortimeo(struct rpc_rqst *req) static void xprt_reset_majortimeo(struct rpc_rqst *req)
{ {
struct rpc_timeout *to = &req->rq_xprt->timeout; struct rpc_timeout *to = &req->rq_xprt->timeout;
...@@ -244,8 +241,10 @@ static void xprt_reset_majortimeo(struct rpc_rqst *req) ...@@ -244,8 +241,10 @@ static void xprt_reset_majortimeo(struct rpc_rqst *req)
req->rq_majortimeo += jiffies; req->rq_majortimeo += jiffies;
} }
/* /**
* Adjust timeout values etc for next retransmit * xprt_adjust_timeout - adjust timeout values for next retransmit
* @req: RPC request containing parameters to use for the adjustment
*
*/ */
int xprt_adjust_timeout(struct rpc_rqst *req) int xprt_adjust_timeout(struct rpc_rqst *req)
{ {
...@@ -291,8 +290,10 @@ xprt_socket_autoclose(void *args) ...@@ -291,8 +290,10 @@ xprt_socket_autoclose(void *args)
xprt_release_write(xprt, NULL); xprt_release_write(xprt, NULL);
} }
/* /**
* Mark a transport as disconnected * xprt_disconnect - mark a transport as disconnected
* @xprt: transport to flag for disconnect
*
*/ */
void xprt_disconnect(struct rpc_xprt *xprt) void xprt_disconnect(struct rpc_xprt *xprt)
{ {
...@@ -303,9 +304,6 @@ void xprt_disconnect(struct rpc_xprt *xprt) ...@@ -303,9 +304,6 @@ void xprt_disconnect(struct rpc_xprt *xprt)
spin_unlock_bh(&xprt->sock_lock); spin_unlock_bh(&xprt->sock_lock);
} }
/*
* Used to allow disconnection when we've been idle
*/
static void static void
xprt_init_autodisconnect(unsigned long data) xprt_init_autodisconnect(unsigned long data)
{ {
...@@ -327,8 +325,9 @@ xprt_init_autodisconnect(unsigned long data) ...@@ -327,8 +325,9 @@ xprt_init_autodisconnect(unsigned long data)
spin_unlock(&xprt->sock_lock); spin_unlock(&xprt->sock_lock);
} }
/* /**
* Attempt to connect a TCP socket. * xprt_connect - schedule a transport connect operation
* @task: RPC task that is requesting the connect
* *
*/ */
void xprt_connect(struct rpc_task *task) void xprt_connect(struct rpc_task *task)
...@@ -361,11 +360,7 @@ void xprt_connect(struct rpc_task *task) ...@@ -361,11 +360,7 @@ void xprt_connect(struct rpc_task *task)
return; return;
} }
/* static void xprt_connect_status(struct rpc_task *task)
* We arrive here when awoken from waiting on connection establishment.
*/
static void
xprt_connect_status(struct rpc_task *task)
{ {
struct rpc_xprt *xprt = task->tk_xprt; struct rpc_xprt *xprt = task->tk_xprt;
...@@ -404,8 +399,11 @@ xprt_connect_status(struct rpc_task *task) ...@@ -404,8 +399,11 @@ xprt_connect_status(struct rpc_task *task)
} }
} }
/* /**
* Look up the RPC request corresponding to a reply, and then lock it. * xprt_lookup_rqst - find an RPC request corresponding to an XID
* @xprt: transport on which the original request was transmitted
* @xid: RPC XID of incoming reply
*
*/ */
struct rpc_rqst *xprt_lookup_rqst(struct rpc_xprt *xprt, u32 xid) struct rpc_rqst *xprt_lookup_rqst(struct rpc_xprt *xprt, u32 xid)
{ {
...@@ -422,9 +420,12 @@ struct rpc_rqst *xprt_lookup_rqst(struct rpc_xprt *xprt, u32 xid) ...@@ -422,9 +420,12 @@ struct rpc_rqst *xprt_lookup_rqst(struct rpc_xprt *xprt, u32 xid)
return req; return req;
} }
/* /**
* Complete reply received. * xprt_complete_rqst - called when reply processing is complete
* The TCP code relies on us to remove the request from xprt->pending. * @xprt: controlling transport
* @req: RPC request that just completed
* @copied: actual number of bytes received from the transport
*
*/ */
void xprt_complete_rqst(struct rpc_xprt *xprt, struct rpc_rqst *req, int copied) void xprt_complete_rqst(struct rpc_xprt *xprt, struct rpc_rqst *req, int copied)
{ {
...@@ -498,12 +499,12 @@ xprt_timer(struct rpc_task *task) ...@@ -498,12 +499,12 @@ xprt_timer(struct rpc_task *task)
spin_unlock(&xprt->sock_lock); spin_unlock(&xprt->sock_lock);
} }
/* /**
* Place the actual RPC call. * xprt_prepare_transmit - reserve the transport before sending a request
* We have to copy the iovec because sendmsg fiddles with its contents. * @task: RPC task about to send a request
*
*/ */
int int xprt_prepare_transmit(struct rpc_task *task)
xprt_prepare_transmit(struct rpc_task *task)
{ {
struct rpc_rqst *req = task->tk_rqstp; struct rpc_rqst *req = task->tk_rqstp;
struct rpc_xprt *xprt = req->rq_xprt; struct rpc_xprt *xprt = req->rq_xprt;
...@@ -533,8 +534,13 @@ xprt_prepare_transmit(struct rpc_task *task) ...@@ -533,8 +534,13 @@ xprt_prepare_transmit(struct rpc_task *task)
return err; return err;
} }
void /**
xprt_transmit(struct rpc_task *task) * xprt_transmit - send an RPC request on a transport
* @task: controlling RPC task
*
* We have to copy the iovec because sendmsg fiddles with its contents.
*/
void xprt_transmit(struct rpc_task *task)
{ {
struct rpc_clnt *clnt = task->tk_client; struct rpc_clnt *clnt = task->tk_client;
struct rpc_rqst *req = task->tk_rqstp; struct rpc_rqst *req = task->tk_rqstp;
...@@ -604,11 +610,7 @@ xprt_transmit(struct rpc_task *task) ...@@ -604,11 +610,7 @@ xprt_transmit(struct rpc_task *task)
spin_unlock_bh(&xprt->sock_lock); spin_unlock_bh(&xprt->sock_lock);
} }
/* static inline void do_xprt_reserve(struct rpc_task *task)
* Reserve an RPC call slot.
*/
static inline void
do_xprt_reserve(struct rpc_task *task)
{ {
struct rpc_xprt *xprt = task->tk_xprt; struct rpc_xprt *xprt = task->tk_xprt;
...@@ -628,8 +630,14 @@ do_xprt_reserve(struct rpc_task *task) ...@@ -628,8 +630,14 @@ do_xprt_reserve(struct rpc_task *task)
rpc_sleep_on(&xprt->backlog, task, NULL, NULL); rpc_sleep_on(&xprt->backlog, task, NULL, NULL);
} }
void /**
xprt_reserve(struct rpc_task *task) * xprt_reserve - allocate an RPC request slot
* @task: RPC task requesting a slot allocation
*
* If no more slots are available, place the task on the transport's
* backlog queue.
*/
void xprt_reserve(struct rpc_task *task)
{ {
struct rpc_xprt *xprt = task->tk_xprt; struct rpc_xprt *xprt = task->tk_xprt;
...@@ -641,9 +649,6 @@ xprt_reserve(struct rpc_task *task) ...@@ -641,9 +649,6 @@ xprt_reserve(struct rpc_task *task)
} }
} }
/*
* Allocate a 'unique' XID
*/
static inline u32 xprt_alloc_xid(struct rpc_xprt *xprt) static inline u32 xprt_alloc_xid(struct rpc_xprt *xprt)
{ {
return xprt->xid++; return xprt->xid++;
...@@ -654,11 +659,7 @@ static inline void xprt_init_xid(struct rpc_xprt *xprt) ...@@ -654,11 +659,7 @@ static inline void xprt_init_xid(struct rpc_xprt *xprt)
get_random_bytes(&xprt->xid, sizeof(xprt->xid)); get_random_bytes(&xprt->xid, sizeof(xprt->xid));
} }
/* static void xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt)
* Initialize RPC request
*/
static void
xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt)
{ {
struct rpc_rqst *req = task->tk_rqstp; struct rpc_rqst *req = task->tk_rqstp;
...@@ -670,11 +671,12 @@ xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt) ...@@ -670,11 +671,12 @@ xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt)
req, ntohl(req->rq_xid)); req, ntohl(req->rq_xid));
} }
/* /**
* Release an RPC call slot * xprt_release - release an RPC request slot
* @task: task which is finished with the slot
*
*/ */
void void xprt_release(struct rpc_task *task)
xprt_release(struct rpc_task *task)
{ {
struct rpc_xprt *xprt = task->tk_xprt; struct rpc_xprt *xprt = task->tk_xprt;
struct rpc_rqst *req; struct rpc_rqst *req;
...@@ -702,11 +704,14 @@ xprt_release(struct rpc_task *task) ...@@ -702,11 +704,14 @@ xprt_release(struct rpc_task *task)
spin_unlock(&xprt->xprt_lock); spin_unlock(&xprt->xprt_lock);
} }
/* /**
* Set constant timeout * xprt_set_timeout - set constant RPC timeout
* @to: RPC timeout parameters to set up
* @retr: number of retries
* @incr: amount of increase after each retry
*
*/ */
void void xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long incr)
xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long incr)
{ {
to->to_initval = to->to_initval =
to->to_increment = incr; to->to_increment = incr;
...@@ -715,11 +720,7 @@ xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long incr) ...@@ -715,11 +720,7 @@ xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long incr)
to->to_exponential = 0; to->to_exponential = 0;
} }
/* static struct rpc_xprt *xprt_setup(int proto, struct sockaddr_in *ap, struct rpc_timeout *to)
* Initialize an RPC client
*/
static struct rpc_xprt *
xprt_setup(int proto, struct sockaddr_in *ap, struct rpc_timeout *to)
{ {
int result; int result;
struct rpc_xprt *xprt; struct rpc_xprt *xprt;
...@@ -778,11 +779,14 @@ xprt_setup(int proto, struct sockaddr_in *ap, struct rpc_timeout *to) ...@@ -778,11 +779,14 @@ xprt_setup(int proto, struct sockaddr_in *ap, struct rpc_timeout *to)
return xprt; return xprt;
} }
/* /**
* Create an RPC client transport given the protocol and peer address. * xprt_create_proto - create an RPC client transport
* @proto: requested transport protocol
* @sap: remote peer's address
* @to: timeout parameters for new transport
*
*/ */
struct rpc_xprt * struct rpc_xprt *xprt_create_proto(int proto, struct sockaddr_in *sap, struct rpc_timeout *to)
xprt_create_proto(int proto, struct sockaddr_in *sap, struct rpc_timeout *to)
{ {
struct rpc_xprt *xprt; struct rpc_xprt *xprt;
...@@ -794,11 +798,7 @@ xprt_create_proto(int proto, struct sockaddr_in *sap, struct rpc_timeout *to) ...@@ -794,11 +798,7 @@ xprt_create_proto(int proto, struct sockaddr_in *sap, struct rpc_timeout *to)
return xprt; return xprt;
} }
/* static void xprt_shutdown(struct rpc_xprt *xprt)
* Prepare for transport shutdown.
*/
static void
xprt_shutdown(struct rpc_xprt *xprt)
{ {
xprt->shutdown = 1; xprt->shutdown = 1;
rpc_wake_up(&xprt->sending); rpc_wake_up(&xprt->sending);
...@@ -809,21 +809,18 @@ xprt_shutdown(struct rpc_xprt *xprt) ...@@ -809,21 +809,18 @@ xprt_shutdown(struct rpc_xprt *xprt)
del_timer_sync(&xprt->timer); del_timer_sync(&xprt->timer);
} }
/* static int xprt_clear_backlog(struct rpc_xprt *xprt) {
* Clear the xprt backlog queue
*/
static int
xprt_clear_backlog(struct rpc_xprt *xprt) {
rpc_wake_up_next(&xprt->backlog); rpc_wake_up_next(&xprt->backlog);
wake_up(&xprt->cong_wait); wake_up(&xprt->cong_wait);
return 1; return 1;
} }
/* /**
* Destroy an RPC transport, killing off all requests. * xprt_destroy - destroy an RPC transport, killing off all requests.
* @xprt: transport to destroy
*
*/ */
int int xprt_destroy(struct rpc_xprt *xprt)
xprt_destroy(struct rpc_xprt *xprt)
{ {
dprintk("RPC: destroying transport %p\n", xprt); dprintk("RPC: destroying transport %p\n", xprt);
xprt_shutdown(xprt); xprt_shutdown(xprt);
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment