From 380b3fc878dd8fbb4f5730a76e19abc881a97c6c Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Thu, 28 Dec 2017 15:31:46 -0700 Subject: [PATCH] scsi, iscsi: accumulate data_transferred in iSCSI Each SCSI task should only report its data_transferred; the parent/subtask relationship should be handled in iSCSI. Change-Id: Ibece110fd8cca4e94648942fe6b5e004a4fd8a80 Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/393212 Tested-by: SPDK Automated Test System Reviewed-by: Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/iscsi/conn.c | 3 +++ lib/scsi/scsi_bdev.c | 10 +++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/iscsi/conn.c b/lib/iscsi/conn.c index c36178fff..d22412f21 100644 --- a/lib/iscsi/conn.c +++ b/lib/iscsi/conn.c @@ -1070,6 +1070,9 @@ spdk_iscsi_task_cpl(struct spdk_scsi_task *scsi_task) if (spdk_iscsi_task_is_read(primary)) { process_read_task_completion(conn, task, primary); } else { + if (task != primary) { + primary->scsi.data_transferred += task->scsi.data_transferred; + } primary->bytes_completed += task->scsi.length; if ((task != primary) && (task->scsi.status != SPDK_SCSI_STATUS_GOOD)) { diff --git a/lib/scsi/scsi_bdev.c b/lib/scsi/scsi_bdev.c index 02dcd2185..fe66708b9 100644 --- a/lib/scsi/scsi_bdev.c +++ b/lib/scsi/scsi_bdev.c @@ -1362,7 +1362,6 @@ spdk_bdev_scsi_write(struct spdk_bdev *bdev, uint64_t offset; uint64_t nbytes; int rc; - struct spdk_scsi_task *primary = task->parent; blen = spdk_bdev_get_block_size(bdev); offset = lba * blen; @@ -1395,17 +1394,12 @@ spdk_bdev_scsi_write(struct spdk_bdev *bdev, SPDK_SCSI_ASC_NO_ADDITIONAL_SENSE, SPDK_SCSI_ASCQ_CAUSE_NOT_REPORTABLE); return SPDK_SCSI_TASK_COMPLETE; - } else { - if (!primary) { - task->data_transferred += task->length; - } else { - primary->data_transferred += task->length; - } } SPDK_DEBUGLOG(SPDK_LOG_SCSI, "Wrote %"PRIu64"/%"PRIu64" bytes\n", (uint64_t)task->length, nbytes); + task->data_transferred = task->length; task->status = SPDK_SCSI_STATUS_GOOD; return SPDK_SCSI_TASK_PENDING; } @@ -1456,6 +1450,8 @@ spdk_bdev_scsi_readwrite(struct spdk_bdev *bdev, { uint32_t max_xfer_len; + task->data_transferred = 0; + if (task->dxfer_dir != SPDK_SCSI_DIR_NONE && task->dxfer_dir != (is_read ? SPDK_SCSI_DIR_FROM_DEV : SPDK_SCSI_DIR_TO_DEV)) { SPDK_ERRLOG("Incorrect data direction\n");