iscsi: Fix LUN ID in Ready to Transfer PDUs
LUN ID is not converted from integer to structure and integer is set to R2T PDUs. Popular iSCSI initiators don't check this value and work correctly. This patch uses the public helper function of the SCSI library to fix the issue. Additionally, private helper function to convert structure to integer for LUN ID is replaced to the public helper function of the SCSI library. Change-Id: I9218c5ef7a8bfec43326c6584db7c6929fdd11a8 Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449963 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
12ab86e24d
commit
5a1dc44423
@ -279,26 +279,6 @@ hex2bin(uint8_t *data, size_t data_len, const char *str)
|
||||
return total;
|
||||
}
|
||||
|
||||
static int
|
||||
islun2lun(uint64_t islun)
|
||||
{
|
||||
uint64_t fmt_lun;
|
||||
uint64_t method;
|
||||
int lun_i;
|
||||
|
||||
fmt_lun = islun;
|
||||
method = (fmt_lun >> 62) & 0x03U;
|
||||
fmt_lun = fmt_lun >> 48;
|
||||
if (method == 0x00U) {
|
||||
lun_i = (int)(fmt_lun & 0x00ffU);
|
||||
} else if (method == 0x01U) {
|
||||
lun_i = (int)(fmt_lun & 0x3fffU);
|
||||
} else {
|
||||
lun_i = 0xffffU;
|
||||
}
|
||||
return lun_i;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
spdk_iscsi_pdu_calc_header_digest(struct spdk_iscsi_pdu *pdu)
|
||||
{
|
||||
@ -3004,7 +2984,7 @@ iscsi_op_scsi(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
||||
}
|
||||
|
||||
spdk_iscsi_task_associate_pdu(task, pdu);
|
||||
lun_i = islun2lun(lun);
|
||||
lun_i = spdk_scsi_lun_id_fmt_to_int(lun);
|
||||
task->lun_id = lun_i;
|
||||
dev = conn->dev;
|
||||
task->scsi.lun = spdk_scsi_dev_get_lun(dev, lun_i);
|
||||
@ -3462,7 +3442,7 @@ iscsi_op_task(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "StatSN=%u, ExpCmdSN=%u, MaxCmdSN=%u\n",
|
||||
conn->StatSN, conn->sess->ExpCmdSN, conn->sess->MaxCmdSN);
|
||||
|
||||
lun_i = islun2lun(lun);
|
||||
lun_i = spdk_scsi_lun_id_fmt_to_int(lun);
|
||||
dev = conn->dev;
|
||||
|
||||
task = spdk_iscsi_task_get(conn, NULL, spdk_iscsi_task_mgmt_cpl);
|
||||
@ -4372,6 +4352,7 @@ iscsi_send_r2t(struct spdk_iscsi_conn *conn,
|
||||
{
|
||||
struct spdk_iscsi_pdu *rsp_pdu;
|
||||
struct iscsi_bhs_r2t *rsph;
|
||||
uint64_t fmt_lun;
|
||||
|
||||
/* R2T PDU */
|
||||
rsp_pdu = spdk_get_pdu();
|
||||
@ -4382,7 +4363,8 @@ iscsi_send_r2t(struct spdk_iscsi_conn *conn,
|
||||
rsp_pdu->data = NULL;
|
||||
rsph->opcode = ISCSI_OP_R2T;
|
||||
rsph->flags |= 0x80; /* bit 0 is default to 1 */
|
||||
to_be64(&rsph->lun, task->lun_id);
|
||||
fmt_lun = spdk_scsi_lun_id_int_to_fmt(task->lun_id);
|
||||
to_be64(&rsph->lun, fmt_lun);
|
||||
to_be32(&rsph->itt, task->tag);
|
||||
to_be32(&rsph->ttt, transfer_tag);
|
||||
|
||||
@ -4662,7 +4644,7 @@ spdk_iscsi_get_dif_ctx(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu,
|
||||
offset = 0;
|
||||
cdb = sbhs->cdb;
|
||||
lun = from_be64(&sbhs->lun);
|
||||
lun_id = islun2lun(lun);
|
||||
lun_id = spdk_scsi_lun_id_fmt_to_int(lun);
|
||||
break;
|
||||
}
|
||||
case ISCSI_OP_SCSI_DATAOUT: {
|
||||
|
@ -111,6 +111,10 @@ spdk_scsi_dev_get_lun(struct spdk_scsi_dev *dev, int lun_id)
|
||||
return dev->lun[lun_id];
|
||||
}
|
||||
|
||||
DEFINE_STUB(spdk_scsi_lun_id_int_to_fmt, uint64_t, (int lun_id), 0);
|
||||
|
||||
DEFINE_STUB(spdk_scsi_lun_id_fmt_to_int, int, (uint64_t lun_fmt), 0);
|
||||
|
||||
static void
|
||||
op_login_check_target_test(void)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user