From 6b27d36dcf30384aeb0de196ca88428c7f209eca Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Wed, 6 Oct 2021 18:09:44 +0900 Subject: [PATCH] scsi: Decide LUN format for each LUN ID Previously we decided which LUN format is used by the macro constant SPDK_SCSI_DEV_MAX_LUN. However, as long as we read SAM, the LUN format can be decided per LUN ID. Linux host SCSI driver supports 256 LUNs per SCSI device at the maximum. So we cannot test this fix on any actual system but we apply this fix for the potential future cases. Signed-off-by: Shuhei Matsumoto Change-Id: Ifa6a3b66431f5e1eade326348dd99b8b9653408b Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9664 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Tomasz Zawadzki Reviewed-by: Jim Harris --- lib/scsi/scsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/scsi/scsi.c b/lib/scsi/scsi.c index 90a76e3fd..d690d531f 100644 --- a/lib/scsi/scsi.c +++ b/lib/scsi/scsi.c @@ -62,12 +62,12 @@ spdk_scsi_lun_id_int_to_fmt(int lun_id) { uint64_t fmt_lun, method; - if (SPDK_SCSI_DEV_MAX_LUN <= 0x0100) { + if (lun_id < 0x0100) { /* below 256 */ method = 0x00U; fmt_lun = (method & 0x03U) << 62; fmt_lun |= ((uint64_t)lun_id & 0x00ffU) << 48; - } else if (SPDK_SCSI_DEV_MAX_LUN <= 0x4000) { + } else if (lun_id < 0x4000) { /* below 16384 */ method = 0x01U; fmt_lun = (method & 0x03U) << 62;