From 5e87727596e206b19788a4de1105949c73afbe57 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Wed, 6 Oct 2021 23:59:37 +0900 Subject: [PATCH] scsi: SCSI device supports 256 LUNs at the maximum by default Most SCSI hosts, Linux, Windows, VMware, supports 256 LUNs per device now, and it is not easy to test even if any other non-free OS or driver supports more than 256 LUNs. Hence increase the macro constant SPDK_SCSI_DEV_MAX_LUN from 64 to 256. Then we do not need to expose it publicly now. So move it to lib/scsi/scsi_internal.h. Update the CHANGELOG together. Signed-off-by: Shuhei Matsumoto Change-Id: Iacde46c3854f326eebfb8befb47d41fce383b027 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9631 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Tomasz Zawadzki Reviewed-by: Jim Harris --- CHANGELOG.md | 3 +++ include/spdk/scsi.h | 1 - lib/scsi/scsi_internal.h | 2 ++ test/unit/lib/scsi/dev.c/dev_ut.c | 7 ++++++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8ea324acf..19b9d6b9f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -86,6 +86,9 @@ Updated DPDK submodule to DPDK 21.08. New functions, `spdk_scsi_dev_get_first_lun` and `spdk_scsi_dev_get_next_lun` have been added to iterate LUNs of a SCSI device. +Each SCSI device supports 256 LUNs at the maximum now and the macro constant +`SPDK_SCSI_DEV_MAX_LUN` was removed. + ### util The `spdk_fd_group_add` API now takes a `name` parameter. diff --git a/include/spdk/scsi.h b/include/spdk/scsi.h index 757a0aaa78..7426235d9c 100644 --- a/include/spdk/scsi.h +++ b/include/spdk/scsi.h @@ -56,7 +56,6 @@ extern "C" { #define TRACE_SCSI_TASK_START SPDK_TPOINT_ID(TRACE_GROUP_SCSI, 0x1) #define SPDK_SCSI_MAX_DEVS 1024 -#define SPDK_SCSI_DEV_MAX_LUN 64 #define SPDK_SCSI_DEV_MAX_PORTS 4 #define SPDK_SCSI_DEV_MAX_NAME 255 diff --git a/lib/scsi/scsi_internal.h b/lib/scsi/scsi_internal.h index 1ce36f0bfa..cf7249507a 100644 --- a/lib/scsi/scsi_internal.h +++ b/lib/scsi/scsi_internal.h @@ -45,6 +45,8 @@ #include "spdk/log.h" +#define SPDK_SCSI_DEV_MAX_LUN 256 + enum { SPDK_SCSI_TASK_UNKNOWN = -1, SPDK_SCSI_TASK_COMPLETE, diff --git a/test/unit/lib/scsi/dev.c/dev_ut.c b/test/unit/lib/scsi/dev.c/dev_ut.c index ca6b614c28..08ab5b0d8b 100644 --- a/test/unit/lib/scsi/dev.c/dev_ut.c +++ b/test/unit/lib/scsi/dev.c/dev_ut.c @@ -560,7 +560,10 @@ dev_add_lun_no_free_lun_id(void) int rc; int i; struct spdk_scsi_dev dev = { .luns = TAILQ_HEAD_INITIALIZER(dev.luns), }; - struct spdk_scsi_lun lun[SPDK_SCSI_DEV_MAX_LUN] = { 0 }; + struct spdk_scsi_lun *lun; + + lun = calloc(SPDK_SCSI_DEV_MAX_LUN, sizeof(*lun)); + SPDK_CU_ASSERT_FATAL(lun != NULL); for (i = 0; i < SPDK_SCSI_DEV_MAX_LUN; i++) { lun[i].id = i; @@ -570,6 +573,8 @@ dev_add_lun_no_free_lun_id(void) rc = spdk_scsi_dev_add_lun(&dev, "malloc0", -1, NULL, NULL); CU_ASSERT_NOT_EQUAL(rc, 0); + + free(lun); } static void