[Stgt-devel] [PATCH 2/3] iscsi ahs bugfixes
Pete Wyckoff
pw
Thu Mar 15 19:58:52 CET 2007
Set scb in case of exthdr but not AHS exthdr (like non-extended bidir).
Return -errno for consistency, even though nothing actually looks at it.
Repair precedence problem with ?:.
Read into ahs buffer when ahs exists.
Use unrounded immediate length value when considering how much more data
to fetch.
Signed-off-by: Pete Wyckoff <pw at osc.edu>
---
usr/iscsi/iscsid.c | 29 ++++++++++++++---------------
1 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index bad9888..804177b 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -968,17 +968,19 @@ static int iscsi_target_cmd_queue(struct iscsi_task *task)
scmd->cmd_nexus_id = conn->session->iscsi_nexus_id;
+ scmd->scb = req->cdb;
+ scmd->scb_len = sizeof(req->cdb);
+
if (task->ahs) {
struct iscsi_ecdb_ahdr *ahs_extcdb = task->ahs;
- char *p = (void *)task->extdata;
if (ahs_extcdb->ahstype == ISCSI_AHSTYPE_CDB) {
int extcdb_len = ntohs(ahs_extcdb->ahslength) - 1;
+ uint8_t *p = (void *)task->extdata;
if (extcdb_len + sizeof(req->cdb) > 260) {
eprintf("invalid extcdb len %d\n", extcdb_len);
-
- return EINVAL;
+ return -EINVAL;
}
memcpy(p, req->cdb, sizeof(req->cdb));
@@ -988,9 +990,6 @@ static int iscsi_target_cmd_queue(struct iscsi_task *task)
scmd->scb = p;
scmd->scb_len = sizeof(req->cdb) + extcdb_len;
}
- } else {
- scmd->scb = req->cdb;
- scmd->scb_len = sizeof(req->cdb);
}
memcpy(scmd->lun, task->req.lun, sizeof(scmd->lun));
@@ -1240,7 +1239,7 @@ static int iscsi_scsi_cmd_rx_start(struct iscsi_connection *conn)
req->cdb[0], ahs_len, imm_len, data_len,
req->flags & ISCSI_FLAG_CMD_ATTR_MASK, req->itt);
- task_len = ahs_len ? sizeof(req->cdb) + ahs_len : 0
+ task_len = (ahs_len ? sizeof(req->cdb) + ahs_len : 0)
+ max(imm_len, data_len);
task = iscsi_alloc_task(conn, task_len);
@@ -1251,20 +1250,20 @@ static int iscsi_scsi_cmd_rx_start(struct iscsi_connection *conn)
task->tag = req->itt;
- if (ahs_len || data_len) {
- if (ahs_len) {
- task->ahs = task->data + sizeof(req->cdb);
- task->data = task->ahs + ahs_len;
- }
-
+ if (ahs_len) {
+ task->ahs = task->data + sizeof(req->cdb);
+ task->data = task->ahs + ahs_len;
+ conn->rx_buffer = task->ahs;
conn->rx_size = ahs_len + imm_len;
+ } else if (data_len) {
conn->rx_buffer = task->data;
+ conn->rx_size = imm_len;
}
if (req->flags & ISCSI_FLAG_CMD_WRITE) {
- task->r2t_count = data_len - imm_len;
+ task->offset = ntoh24(req->dlength);
+ task->r2t_count = data_len - task->offset;
task->unsol_count = !(req->flags & ISCSI_FLAG_CMD_FINAL);
- task->offset = imm_len;
dprintf("%d %d %d %d\n", conn->rx_size, task->r2t_count,
task->unsol_count, task->offset);
More information about the stgt
mailing list