@@ -73,7 +73,7 @@ static void xprt_init(struct rpc_xprt *xprt, struct net *net);
73
73
static __be32 xprt_alloc_xid (struct rpc_xprt * xprt );
74
74
static void xprt_destroy (struct rpc_xprt * xprt );
75
75
static 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 );
77
77
78
78
static DEFINE_SPINLOCK (xprt_list_lock );
79
79
static LIST_HEAD (xprt_list );
@@ -1149,7 +1149,7 @@ xprt_request_enqueue_receive(struct rpc_task *task)
1149
1149
if (!xprt_request_need_enqueue_receive (task , req ))
1150
1150
return 0 ;
1151
1151
1152
- ret = xprt_request_prepare (task -> tk_rqstp );
1152
+ ret = xprt_request_prepare (task -> tk_rqstp , & req -> rq_rcv_buf );
1153
1153
if (ret )
1154
1154
return ret ;
1155
1155
spin_lock (& xprt -> queue_lock );
@@ -1179,8 +1179,11 @@ xprt_request_dequeue_receive_locked(struct rpc_task *task)
1179
1179
{
1180
1180
struct rpc_rqst * req = task -> tk_rqstp ;
1181
1181
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 )) {
1183
1183
xprt_request_rb_remove (req -> rq_xprt , req );
1184
+ xdr_free_bvec (& req -> rq_rcv_buf );
1185
+ req -> rq_private_buf .bvec = NULL ;
1186
+ }
1184
1187
}
1185
1188
1186
1189
/**
@@ -1336,8 +1339,14 @@ xprt_request_enqueue_transmit(struct rpc_task *task)
1336
1339
{
1337
1340
struct rpc_rqst * pos , * req = task -> tk_rqstp ;
1338
1341
struct rpc_xprt * xprt = req -> rq_xprt ;
1342
+ int ret ;
1339
1343
1340
1344
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
+ }
1341
1350
req -> rq_bytes_sent = 0 ;
1342
1351
spin_lock (& xprt -> queue_lock );
1343
1352
/*
@@ -1397,6 +1406,7 @@ xprt_request_dequeue_transmit_locked(struct rpc_task *task)
1397
1406
} else
1398
1407
list_del (& req -> rq_xmit2 );
1399
1408
atomic_long_dec (& req -> rq_xprt -> xmit_queuelen );
1409
+ xdr_free_bvec (& req -> rq_snd_buf );
1400
1410
}
1401
1411
1402
1412
/**
@@ -1433,34 +1443,35 @@ xprt_request_dequeue_xprt(struct rpc_task *task)
1433
1443
test_bit (RPC_TASK_NEED_RECV , & task -> tk_runstate ) ||
1434
1444
xprt_is_pinned_rqst (req )) {
1435
1445
spin_lock (& xprt -> queue_lock );
1436
- xprt_request_dequeue_transmit_locked (task );
1437
- xprt_request_dequeue_receive_locked (task );
1438
1446
while (xprt_is_pinned_rqst (req )) {
1439
1447
set_bit (RPC_TASK_MSG_PIN_WAIT , & task -> tk_runstate );
1440
1448
spin_unlock (& xprt -> queue_lock );
1441
1449
xprt_wait_on_pinned_rqst (req );
1442
1450
spin_lock (& xprt -> queue_lock );
1443
1451
clear_bit (RPC_TASK_MSG_PIN_WAIT , & task -> tk_runstate );
1444
1452
}
1453
+ xprt_request_dequeue_transmit_locked (task );
1454
+ xprt_request_dequeue_receive_locked (task );
1445
1455
spin_unlock (& xprt -> queue_lock );
1446
1456
}
1447
1457
}
1448
1458
1449
1459
/**
1450
1460
* xprt_request_prepare - prepare an encoded request for transport
1451
1461
* @req: pointer to rpc_rqst
1462
+ * @buf: pointer to send/rcv xdr_buf
1452
1463
*
1453
1464
* Calls into the transport layer to do whatever is needed to prepare
1454
1465
* the request for transmission or receive.
1455
1466
* Returns error, or zero.
1456
1467
*/
1457
1468
static int
1458
- xprt_request_prepare (struct rpc_rqst * req )
1469
+ xprt_request_prepare (struct rpc_rqst * req , struct xdr_buf * buf )
1459
1470
{
1460
1471
struct rpc_xprt * xprt = req -> rq_xprt ;
1461
1472
1462
1473
if (xprt -> ops -> prepare_request )
1463
- return xprt -> ops -> prepare_request (req );
1474
+ return xprt -> ops -> prepare_request (req , buf );
1464
1475
return 0 ;
1465
1476
}
1466
1477
@@ -1961,8 +1972,6 @@ void xprt_release(struct rpc_task *task)
1961
1972
spin_unlock (& xprt -> transport_lock );
1962
1973
if (req -> rq_buffer )
1963
1974
xprt -> ops -> buf_free (task );
1964
- xdr_free_bvec (& req -> rq_rcv_buf );
1965
- xdr_free_bvec (& req -> rq_snd_buf );
1966
1975
if (req -> rq_cred != NULL )
1967
1976
put_rpccred (req -> rq_cred );
1968
1977
if (req -> rq_release_snd_buf )
0 commit comments