Commit 84e64cc9 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

lib/scsi: Pass SCSI task to SCSI layer to get DIF context



By the recent refactoring, SCSI task is configured when getting
DIF context from SCSI layer. Passing not CDB and offset separately
but SCSI task to SCSI layer is more concise and do in this patch.

In iscsi_send_datain(), we have to update task->scsi.offset for the
case that data is split into a sequence, but the update is no harm
because task has completed what it must to do.

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


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
parent f924c94b
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -529,14 +529,13 @@ void spdk_scsi_lun_free_io_channel(struct spdk_scsi_lun_desc *desc);
 * Get DIF context for SCSI LUN and SCSI command.
 *
 * \param lun Logical unit.
 * \param cdb SCSI CDB.
 * \param data_offset Byte offset in the payload.
 * \param task SCSI task which has the payload.
 * \param dif_ctx Output parameter which will contain initialized DIF context.
 *
 * \return true on success or false otherwise.
 */
bool spdk_scsi_lun_get_dif_ctx(struct spdk_scsi_lun *lun, uint8_t *cdb,
			       uint32_t data_offset, struct spdk_dif_ctx *dif_ctx);
bool spdk_scsi_lun_get_dif_ctx(struct spdk_scsi_lun *lun, struct spdk_scsi_task *task,
			       struct spdk_dif_ctx *dif_ctx);

/**
 * Set iSCSI Initiator port TransportID
+4 −4
Original line number Diff line number Diff line
@@ -2992,6 +2992,7 @@ iscsi_send_datain(struct spdk_iscsi_conn *conn,
		offset += primary->scsi.data_transferred;
	}
	to_be32(&rsph->buffer_offset, (uint32_t)offset);
	task->scsi.offset = offset;

	if (F_bit && S_bit) {
		to_be32(&rsph->res_cnt, residual_len);
@@ -2999,7 +3000,7 @@ iscsi_send_datain(struct spdk_iscsi_conn *conn,

	lun_dev = spdk_scsi_dev_get_lun(conn->dev, task->lun_id);
	if (spdk_likely(lun_dev != NULL)) {
		if (spdk_unlikely(spdk_scsi_lun_get_dif_ctx(lun_dev, task->scsi.cdb, offset,
		if (spdk_unlikely(spdk_scsi_lun_get_dif_ctx(lun_dev, &task->scsi,
				  &rsp_pdu->dif_ctx))) {
			rsp_pdu->dif_insert_or_strip = true;
		}
@@ -3467,7 +3468,7 @@ iscsi_pdu_hdr_op_scsi(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
			return iscsi_reject(conn, pdu, ISCSI_REASON_PROTOCOL_ERROR);
		}

		if (spdk_unlikely(spdk_scsi_lun_get_dif_ctx(task->scsi.lun, cdb, 0, &pdu->dif_ctx))) {
		if (spdk_unlikely(spdk_scsi_lun_get_dif_ctx(task->scsi.lun, &task->scsi, &pdu->dif_ctx))) {
			pdu->dif_insert_or_strip = true;
		}
	} else {
@@ -4499,8 +4500,7 @@ iscsi_pdu_hdr_op_data(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
		return 0;
	}

	if (spdk_unlikely(spdk_scsi_lun_get_dif_ctx(lun_dev, subtask->scsi.cdb, buffer_offset,
			  &pdu->dif_ctx))) {
	if (spdk_unlikely(spdk_scsi_lun_get_dif_ctx(lun_dev, &subtask->scsi, &pdu->dif_ctx))) {
		pdu->dif_insert_or_strip = true;
	}

+3 −3
Original line number Diff line number Diff line
@@ -601,8 +601,8 @@ spdk_scsi_lun_is_removing(const struct spdk_scsi_lun *lun)
}

bool
spdk_scsi_lun_get_dif_ctx(struct spdk_scsi_lun *lun, uint8_t *cdb,
			  uint32_t data_offset, struct spdk_dif_ctx *dif_ctx)
spdk_scsi_lun_get_dif_ctx(struct spdk_scsi_lun *lun, struct spdk_scsi_task *task,
			  struct spdk_dif_ctx *dif_ctx)
{
	return spdk_scsi_bdev_get_dif_ctx(lun->bdev, cdb, data_offset, dif_ctx);
	return spdk_scsi_bdev_get_dif_ctx(lun->bdev, task, dif_ctx);
}
+7 −3
Original line number Diff line number Diff line
@@ -2008,16 +2008,20 @@ spdk_bdev_scsi_reset(struct spdk_scsi_task *task)
}

bool
spdk_scsi_bdev_get_dif_ctx(struct spdk_bdev *bdev, uint8_t *cdb,
			   uint32_t data_offset, struct spdk_dif_ctx *dif_ctx)
spdk_scsi_bdev_get_dif_ctx(struct spdk_bdev *bdev, struct spdk_scsi_task *task,
			   struct spdk_dif_ctx *dif_ctx)
{
	uint32_t ref_tag = 0, dif_check_flags = 0;
	uint32_t ref_tag = 0, dif_check_flags = 0, data_offset;
	uint8_t *cdb;
	int rc;

	if (spdk_likely(spdk_bdev_get_md_size(bdev) == 0)) {
		return false;
	}

	cdb = task->cdb;
	data_offset = task->offset;

	/* We use lower 32 bits of LBA as Reference. Tag */
	switch (cdb[0]) {
	case SPDK_SBC_READ_6:
+1 −1
Original line number Diff line number Diff line
@@ -203,7 +203,7 @@ void spdk_scsi_port_destruct(struct spdk_scsi_port *port);
int spdk_bdev_scsi_execute(struct spdk_scsi_task *task);
void spdk_bdev_scsi_reset(struct spdk_scsi_task *task);

bool spdk_scsi_bdev_get_dif_ctx(struct spdk_bdev *bdev, uint8_t *cdb, uint32_t data_offset,
bool spdk_scsi_bdev_get_dif_ctx(struct spdk_bdev *bdev, struct spdk_scsi_task *task,
				struct spdk_dif_ctx *dif_ctx);

int spdk_scsi_pr_out(struct spdk_scsi_task *task, uint8_t *cdb, uint8_t *data, uint16_t data_len);
Loading