Commit 1bec7d57 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Jim Harris
Browse files

iscsi: Fix the bug when querying DIF context for Data In PDU



spdk_iscsi_get_dif_ctx() didn't work correctly for Data In PDU
because we had to get iSCSI task from PDU directly for Data In PDU,
and lun_id was not copied in spdk_iscsi_task_get().

This patch fixes these bugs and the DIF strip feature was verified
after applying this patch.

Change-Id: I74d404b82c4a9502a9a8e166748f817d3c2e4368
Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/447884


Reviewed-by: default avatarZiye Yang <ziye.yang@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 1151e65d
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -4686,16 +4686,12 @@ spdk_iscsi_get_dif_ctx(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu,
		lun_id = spdk_islun2lun(lun);
		break;
	}
	case ISCSI_OP_SCSI_DATAIN:
	case ISCSI_OP_SCSI_DATAOUT: {
		/* Location of Buffer Offset and TTT in PDU are same
		 * for Data In and Out, so unify them.
		 */
		struct iscsi_bhs_data_in *dbhs;
		struct iscsi_bhs_data_out *dbhs;
		struct spdk_iscsi_task *task;
		int transfer_tag;

		dbhs = (struct iscsi_bhs_data_in *)bhs;
		dbhs = (struct iscsi_bhs_data_out *)bhs;
		offset = from_be32(&dbhs->buffer_offset);
		transfer_tag = from_be32(&dbhs->ttt);
		task = spdk_get_transfer_task(conn, transfer_tag);
@@ -4706,6 +4702,18 @@ spdk_iscsi_get_dif_ctx(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu,
		lun_id = task->lun_id;
		break;
	}
	case ISCSI_OP_SCSI_DATAIN: {
		struct iscsi_bhs_data_in *dbhs;
		struct spdk_iscsi_task *task;

		dbhs = (struct iscsi_bhs_data_in *)bhs;
		offset = from_be32(&dbhs->buffer_offset);
		task = pdu->task;
		assert(task != NULL);
		cdb = task->scsi.cdb;
		lun_id = task->lun_id;
		break;
	}
	default:
		return false;
	}
+1 −0
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ spdk_iscsi_task_get(struct spdk_iscsi_conn *conn, struct spdk_iscsi_task *parent
		parent->scsi.ref++;
		task->parent = parent;
		task->tag = parent->tag;
		task->lun_id = parent->lun_id;
		task->scsi.dxfer_dir = parent->scsi.dxfer_dir;
		task->scsi.transfer_len = parent->scsi.transfer_len;
		task->scsi.lun = parent->scsi.lun;