Skip to content

Commit 9903cd1

Browse files
Chuck LeverTrond Myklebust
authored andcommitted
[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: Chuck Lever <cel@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1 parent a246b01 commit 9903cd1

3 files changed

Lines changed: 311 additions & 301 deletions

File tree

‎include/linux/sunrpc/debug.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#define RPCDBG_AUTH 0x0010
3333
#define RPCDBG_PMAP 0x0020
3434
#define RPCDBG_SCHED 0x0040
35+
#define RPCDBG_TRANS 0x0080
3536
#define RPCDBG_SVCSOCK 0x0100
3637
#define RPCDBG_SVCDSP 0x0200
3738
#define RPCDBG_MISC 0x0400

‎net/sunrpc/xprt.c‎

Lines changed: 72 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,6 @@ xprt_adjust_cwnd(struct rpc_xprt *xprt, int result)
227227
xprt->cwnd = cwnd;
228228
}
229229

230-
/*
231-
* Reset the major timeout value
232-
*/
233230
static void xprt_reset_majortimeo(struct rpc_rqst *req)
234231
{
235232
struct rpc_timeout *to = &req->rq_xprt->timeout;
@@ -244,8 +241,10 @@ static void xprt_reset_majortimeo(struct rpc_rqst *req)
244241
req->rq_majortimeo += jiffies;
245242
}
246243

247-
/*
248-
* Adjust timeout values etc for next retransmit
244+
/**
245+
* xprt_adjust_timeout - adjust timeout values for next retransmit
246+
* @req: RPC request containing parameters to use for the adjustment
247+
*
249248
*/
250249
int xprt_adjust_timeout(struct rpc_rqst *req)
251250
{
@@ -291,8 +290,10 @@ xprt_socket_autoclose(void *args)
291290
xprt_release_write(xprt, NULL);
292291
}
293292

294-
/*
295-
* Mark a transport as disconnected
293+
/**
294+
* xprt_disconnect - mark a transport as disconnected
295+
* @xprt: transport to flag for disconnect
296+
*
296297
*/
297298
void xprt_disconnect(struct rpc_xprt *xprt)
298299
{
@@ -303,9 +304,6 @@ void xprt_disconnect(struct rpc_xprt *xprt)
303304
spin_unlock_bh(&xprt->sock_lock);
304305
}
305306

306-
/*
307-
* Used to allow disconnection when we've been idle
308-
*/
309307
static void
310308
xprt_init_autodisconnect(unsigned long data)
311309
{
@@ -327,8 +325,9 @@ xprt_init_autodisconnect(unsigned long data)
327325
spin_unlock(&xprt->sock_lock);
328326
}
329327

330-
/*
331-
* Attempt to connect a TCP socket.
328+
/**
329+
* xprt_connect - schedule a transport connect operation
330+
* @task: RPC task that is requesting the connect
332331
*
333332
*/
334333
void xprt_connect(struct rpc_task *task)
@@ -361,11 +360,7 @@ void xprt_connect(struct rpc_task *task)
361360
return;
362361
}
363362

364-
/*
365-
* We arrive here when awoken from waiting on connection establishment.
366-
*/
367-
static void
368-
xprt_connect_status(struct rpc_task *task)
363+
static void xprt_connect_status(struct rpc_task *task)
369364
{
370365
struct rpc_xprt *xprt = task->tk_xprt;
371366

@@ -404,8 +399,11 @@ xprt_connect_status(struct rpc_task *task)
404399
}
405400
}
406401

407-
/*
408-
* Look up the RPC request corresponding to a reply, and then lock it.
402+
/**
403+
* xprt_lookup_rqst - find an RPC request corresponding to an XID
404+
* @xprt: transport on which the original request was transmitted
405+
* @xid: RPC XID of incoming reply
406+
*
409407
*/
410408
struct rpc_rqst *xprt_lookup_rqst(struct rpc_xprt *xprt, u32 xid)
411409
{
@@ -422,9 +420,12 @@ struct rpc_rqst *xprt_lookup_rqst(struct rpc_xprt *xprt, u32 xid)
422420
return req;
423421
}
424422

425-
/*
426-
* Complete reply received.
427-
* The TCP code relies on us to remove the request from xprt->pending.
423+
/**
424+
* xprt_complete_rqst - called when reply processing is complete
425+
* @xprt: controlling transport
426+
* @req: RPC request that just completed
427+
* @copied: actual number of bytes received from the transport
428+
*
428429
*/
429430
void xprt_complete_rqst(struct rpc_xprt *xprt, struct rpc_rqst *req, int copied)
430431
{
@@ -498,12 +499,12 @@ xprt_timer(struct rpc_task *task)
498499
spin_unlock(&xprt->sock_lock);
499500
}
500501

501-
/*
502-
* Place the actual RPC call.
503-
* We have to copy the iovec because sendmsg fiddles with its contents.
502+
/**
503+
* xprt_prepare_transmit - reserve the transport before sending a request
504+
* @task: RPC task about to send a request
505+
*
504506
*/
505-
int
506-
xprt_prepare_transmit(struct rpc_task *task)
507+
int xprt_prepare_transmit(struct rpc_task *task)
507508
{
508509
struct rpc_rqst *req = task->tk_rqstp;
509510
struct rpc_xprt *xprt = req->rq_xprt;
@@ -533,8 +534,13 @@ xprt_prepare_transmit(struct rpc_task *task)
533534
return err;
534535
}
535536

536-
void
537-
xprt_transmit(struct rpc_task *task)
537+
/**
538+
* xprt_transmit - send an RPC request on a transport
539+
* @task: controlling RPC task
540+
*
541+
* We have to copy the iovec because sendmsg fiddles with its contents.
542+
*/
543+
void xprt_transmit(struct rpc_task *task)
538544
{
539545
struct rpc_clnt *clnt = task->tk_client;
540546
struct rpc_rqst *req = task->tk_rqstp;
@@ -604,11 +610,7 @@ xprt_transmit(struct rpc_task *task)
604610
spin_unlock_bh(&xprt->sock_lock);
605611
}
606612

607-
/*
608-
* Reserve an RPC call slot.
609-
*/
610-
static inline void
611-
do_xprt_reserve(struct rpc_task *task)
613+
static inline void do_xprt_reserve(struct rpc_task *task)
612614
{
613615
struct rpc_xprt *xprt = task->tk_xprt;
614616

@@ -628,8 +630,14 @@ do_xprt_reserve(struct rpc_task *task)
628630
rpc_sleep_on(&xprt->backlog, task, NULL, NULL);
629631
}
630632

631-
void
632-
xprt_reserve(struct rpc_task *task)
633+
/**
634+
* xprt_reserve - allocate an RPC request slot
635+
* @task: RPC task requesting a slot allocation
636+
*
637+
* If no more slots are available, place the task on the transport's
638+
* backlog queue.
639+
*/
640+
void xprt_reserve(struct rpc_task *task)
633641
{
634642
struct rpc_xprt *xprt = task->tk_xprt;
635643

@@ -641,9 +649,6 @@ xprt_reserve(struct rpc_task *task)
641649
}
642650
}
643651

644-
/*
645-
* Allocate a 'unique' XID
646-
*/
647652
static inline u32 xprt_alloc_xid(struct rpc_xprt *xprt)
648653
{
649654
return xprt->xid++;
@@ -654,11 +659,7 @@ static inline void xprt_init_xid(struct rpc_xprt *xprt)
654659
get_random_bytes(&xprt->xid, sizeof(xprt->xid));
655660
}
656661

657-
/*
658-
* Initialize RPC request
659-
*/
660-
static void
661-
xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt)
662+
static void xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt)
662663
{
663664
struct rpc_rqst *req = task->tk_rqstp;
664665

@@ -670,11 +671,12 @@ xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt)
670671
req, ntohl(req->rq_xid));
671672
}
672673

673-
/*
674-
* Release an RPC call slot
674+
/**
675+
* xprt_release - release an RPC request slot
676+
* @task: task which is finished with the slot
677+
*
675678
*/
676-
void
677-
xprt_release(struct rpc_task *task)
679+
void xprt_release(struct rpc_task *task)
678680
{
679681
struct rpc_xprt *xprt = task->tk_xprt;
680682
struct rpc_rqst *req;
@@ -702,11 +704,14 @@ xprt_release(struct rpc_task *task)
702704
spin_unlock(&xprt->xprt_lock);
703705
}
704706

705-
/*
706-
* Set constant timeout
707+
/**
708+
* xprt_set_timeout - set constant RPC timeout
709+
* @to: RPC timeout parameters to set up
710+
* @retr: number of retries
711+
* @incr: amount of increase after each retry
712+
*
707713
*/
708-
void
709-
xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long incr)
714+
void xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long incr)
710715
{
711716
to->to_initval =
712717
to->to_increment = incr;
@@ -715,11 +720,7 @@ xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long incr)
715720
to->to_exponential = 0;
716721
}
717722

718-
/*
719-
* Initialize an RPC client
720-
*/
721-
static struct rpc_xprt *
722-
xprt_setup(int proto, struct sockaddr_in *ap, struct rpc_timeout *to)
723+
static struct rpc_xprt *xprt_setup(int proto, struct sockaddr_in *ap, struct rpc_timeout *to)
723724
{
724725
int result;
725726
struct rpc_xprt *xprt;
@@ -778,11 +779,14 @@ xprt_setup(int proto, struct sockaddr_in *ap, struct rpc_timeout *to)
778779
return xprt;
779780
}
780781

781-
/*
782-
* Create an RPC client transport given the protocol and peer address.
782+
/**
783+
* xprt_create_proto - create an RPC client transport
784+
* @proto: requested transport protocol
785+
* @sap: remote peer's address
786+
* @to: timeout parameters for new transport
787+
*
783788
*/
784-
struct rpc_xprt *
785-
xprt_create_proto(int proto, struct sockaddr_in *sap, struct rpc_timeout *to)
789+
struct rpc_xprt *xprt_create_proto(int proto, struct sockaddr_in *sap, struct rpc_timeout *to)
786790
{
787791
struct rpc_xprt *xprt;
788792

@@ -794,11 +798,7 @@ xprt_create_proto(int proto, struct sockaddr_in *sap, struct rpc_timeout *to)
794798
return xprt;
795799
}
796800

797-
/*
798-
* Prepare for transport shutdown.
799-
*/
800-
static void
801-
xprt_shutdown(struct rpc_xprt *xprt)
801+
static void xprt_shutdown(struct rpc_xprt *xprt)
802802
{
803803
xprt->shutdown = 1;
804804
rpc_wake_up(&xprt->sending);
@@ -809,21 +809,18 @@ xprt_shutdown(struct rpc_xprt *xprt)
809809
del_timer_sync(&xprt->timer);
810810
}
811811

812-
/*
813-
* Clear the xprt backlog queue
814-
*/
815-
static int
816-
xprt_clear_backlog(struct rpc_xprt *xprt) {
812+
static int xprt_clear_backlog(struct rpc_xprt *xprt) {
817813
rpc_wake_up_next(&xprt->backlog);
818814
wake_up(&xprt->cong_wait);
819815
return 1;
820816
}
821817

822-
/*
823-
* Destroy an RPC transport, killing off all requests.
818+
/**
819+
* xprt_destroy - destroy an RPC transport, killing off all requests.
820+
* @xprt: transport to destroy
821+
*
824822
*/
825-
int
826-
xprt_destroy(struct rpc_xprt *xprt)
823+
int xprt_destroy(struct rpc_xprt *xprt)
827824
{
828825
dprintk("RPC: destroying transport %p\n", xprt);
829826
xprt_shutdown(xprt);

0 commit comments

Comments
 (0)