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 <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ifa6a3b66431f5e1eade326348dd99b8b9653408b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9664
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Shuhei Matsumoto 2021-10-06 18:09:44 +09:00 committed by Tomasz Zawadzki
parent 5e87727596
commit 45dddbc891

View File

@ -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;