[Stgt-devel] [PATCH 6/7] iser rounding
Pete Wyckoff
pw
Mon Jul 30 21:00:51 CEST 2007
RDMA data packets are not padded up to 4 byte boundaries, unlike TCP.
Reasons for this can be found in doc/README.iser.
Signed-off-by: Pete Wyckoff <pw at osc.edu>
---
usr/iscsi/iscsid.c | 24 +++++++++++++++++-------
1 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index 4a37c6f..4f9194a 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -1125,7 +1125,9 @@ static int iscsi_target_cmd_queue(struct iscsi_task *task)
uint32_t len;
void *buf;
- len = roundup(task->read_len, 4);
+ len = task->read_len;
+ if (!conn->tp->rdma)
+ len = roundup(len, 4);
buf = conn->tp->ep_malloc(len);
if (!buf)
return -ENOMEM;
@@ -1392,8 +1394,12 @@ static int iscsi_scsi_cmd_rx_start(struct iscsi_connection *conn)
int ahs_len, imm_len, data_len, task_len;
ahs_len = roundup(req->hlength * 4, 4);
- imm_len = roundup(ntoh24(req->dlength), 4);
- data_len = roundup(ntohl(req->data_length), 4);
+ imm_len = ntoh24(req->dlength);
+ data_len = ntohl(req->data_length);
+ if (!conn->tp->rdma) {
+ imm_len = roundup(imm_len, 4);
+ data_len = roundup(data_len, 4);
+ }
dprintf("%u %x %d %d %d %x %x\n", conn->session->tsih,
req->cdb[0], ahs_len, imm_len, data_len,
@@ -1770,7 +1776,7 @@ again:
}
conn->req.ahssize = conn->req.bhs.hlength * 4;
conn->req.datasize = ntoh24(conn->req.bhs.dlength);
- conn->rx_size = roundup(conn->req.ahssize, 4);
+ conn->rx_size = conn->req.ahssize;
if (conn->rx_size) {
conn->rx_buffer = conn->req.ahs;
conn->rx_iostate = IOSTATE_RX_AHS;
@@ -1819,7 +1825,10 @@ again:
}
conn->rx_iostate = IOSTATE_RX_INIT_DATA;
case IOSTATE_RX_INIT_DATA:
- conn->rx_size = roundup(conn->req.datasize, 4);
+ if (conn->tp->rdma)
+ conn->rx_size = conn->req.datasize;
+ else
+ conn->rx_size = roundup(conn->req.datasize, 4);
if (conn->rx_size) {
conn->rx_iostate = IOSTATE_RX_DATA;
conn->rx_buffer = conn->req.data;
@@ -1959,12 +1968,13 @@ void iscsi_tx_handler(int fd, struct iscsi_connection *conn)
break;
case IOSTATE_TX_INIT_DATA:
if (conn->rsp.datasize) {
- int pad;
+ int pad = 0;
conn->tx_iostate = IOSTATE_TX_DATA;
conn->tx_buffer = conn->rsp.data;
conn->tx_size = conn->rsp.datasize;
- pad = conn->tx_size & (PAD_WORD_LEN - 1);
+ if (!conn->tp->rdma)
+ pad = conn->tx_size & (PAD_WORD_LEN - 1);
if (pad) {
pad = PAD_WORD_LEN - pad;
memset(conn->tx_buffer + conn->tx_size, 0, pad);
--
1.5.2.4
More information about the stgt
mailing list