@@ -73,7 +73,7 @@ static void xprt_init(struct rpc_xprt *xprt, struct net *net);
7373static __be32 xprt_alloc_xid (struct rpc_xprt * xprt );
7474static void xprt_destroy (struct rpc_xprt * xprt );
7575static void xprt_request_init (struct rpc_task * task );
76- static int xprt_request_prepare (struct rpc_rqst * req );
76+ static int xprt_request_prepare (struct rpc_rqst * req , struct xdr_buf * buf );
7777
7878static DEFINE_SPINLOCK (xprt_list_lock );
7979static LIST_HEAD (xprt_list );
@@ -1149,7 +1149,7 @@ xprt_request_enqueue_receive(struct rpc_task *task)
11491149 if (!xprt_request_need_enqueue_receive (task , req ))
11501150 return 0 ;
11511151
1152- ret = xprt_request_prepare (task -> tk_rqstp );
1152+ ret = xprt_request_prepare (task -> tk_rqstp , & req -> rq_rcv_buf );
11531153 if (ret )
11541154 return ret ;
11551155 spin_lock (& xprt -> queue_lock );
@@ -1179,8 +1179,11 @@ xprt_request_dequeue_receive_locked(struct rpc_task *task)
11791179{
11801180 struct rpc_rqst * req = task -> tk_rqstp ;
11811181
1182- if (test_and_clear_bit (RPC_TASK_NEED_RECV , & task -> tk_runstate ))
1182+ if (test_and_clear_bit (RPC_TASK_NEED_RECV , & task -> tk_runstate )) {
11831183 xprt_request_rb_remove (req -> rq_xprt , req );
1184+ xdr_free_bvec (& req -> rq_rcv_buf );
1185+ req -> rq_private_buf .bvec = NULL ;
1186+ }
11841187}
11851188
11861189/**
@@ -1336,8 +1339,14 @@ xprt_request_enqueue_transmit(struct rpc_task *task)
13361339{
13371340 struct rpc_rqst * pos , * req = task -> tk_rqstp ;
13381341 struct rpc_xprt * xprt = req -> rq_xprt ;
1342+ int ret ;
13391343
13401344 if (xprt_request_need_enqueue_transmit (task , req )) {
1345+ ret = xprt_request_prepare (task -> tk_rqstp , & req -> rq_snd_buf );
1346+ if (ret ) {
1347+ task -> tk_status = ret ;
1348+ return ;
1349+ }
13411350 req -> rq_bytes_sent = 0 ;
13421351 spin_lock (& xprt -> queue_lock );
13431352 /*
@@ -1397,6 +1406,7 @@ xprt_request_dequeue_transmit_locked(struct rpc_task *task)
13971406 } else
13981407 list_del (& req -> rq_xmit2 );
13991408 atomic_long_dec (& req -> rq_xprt -> xmit_queuelen );
1409+ xdr_free_bvec (& req -> rq_snd_buf );
14001410}
14011411
14021412/**
@@ -1433,34 +1443,35 @@ xprt_request_dequeue_xprt(struct rpc_task *task)
14331443 test_bit (RPC_TASK_NEED_RECV , & task -> tk_runstate ) ||
14341444 xprt_is_pinned_rqst (req )) {
14351445 spin_lock (& xprt -> queue_lock );
1436- xprt_request_dequeue_transmit_locked (task );
1437- xprt_request_dequeue_receive_locked (task );
14381446 while (xprt_is_pinned_rqst (req )) {
14391447 set_bit (RPC_TASK_MSG_PIN_WAIT , & task -> tk_runstate );
14401448 spin_unlock (& xprt -> queue_lock );
14411449 xprt_wait_on_pinned_rqst (req );
14421450 spin_lock (& xprt -> queue_lock );
14431451 clear_bit (RPC_TASK_MSG_PIN_WAIT , & task -> tk_runstate );
14441452 }
1453+ xprt_request_dequeue_transmit_locked (task );
1454+ xprt_request_dequeue_receive_locked (task );
14451455 spin_unlock (& xprt -> queue_lock );
14461456 }
14471457}
14481458
14491459/**
14501460 * xprt_request_prepare - prepare an encoded request for transport
14511461 * @req: pointer to rpc_rqst
1462+ * @buf: pointer to send/rcv xdr_buf
14521463 *
14531464 * Calls into the transport layer to do whatever is needed to prepare
14541465 * the request for transmission or receive.
14551466 * Returns error, or zero.
14561467 */
14571468static int
1458- xprt_request_prepare (struct rpc_rqst * req )
1469+ xprt_request_prepare (struct rpc_rqst * req , struct xdr_buf * buf )
14591470{
14601471 struct rpc_xprt * xprt = req -> rq_xprt ;
14611472
14621473 if (xprt -> ops -> prepare_request )
1463- return xprt -> ops -> prepare_request (req );
1474+ return xprt -> ops -> prepare_request (req , buf );
14641475 return 0 ;
14651476}
14661477
@@ -1961,8 +1972,6 @@ void xprt_release(struct rpc_task *task)
19611972 spin_unlock (& xprt -> transport_lock );
19621973 if (req -> rq_buffer )
19631974 xprt -> ops -> buf_free (task );
1964- xdr_free_bvec (& req -> rq_rcv_buf );
1965- xdr_free_bvec (& req -> rq_snd_buf );
19661975 if (req -> rq_cred != NULL )
19671976 put_rpccred (req -> rq_cred );
19681977 if (req -> rq_release_snd_buf )
0 commit comments