Spdk/lib/scsi
Shuhei Matsumoto a3f1502828 scsi: Manage LUNs per device by not fixed size array but linked list
Change a fixed size array to a linked list to manage LUNs per SCSI
device.

Keep the linked list sorted by LUN ID because this is necessary to
efficiently find the lowest free LUN ID or check the specified LUN is free.

To avoid traversing the linked list twice, change scsi_dev_find_free_lun()
to return the LUN which comes just before where we want to insert an new LUN.

Additionally, previously spdk_scsi_dev_add_lun_ext() had not checked if
the specified LUN ID was duplicated. Fix the bug in this patch.

Add unit test cases for the function scsi_dev_find_free_lun().

These changes will enable the following patches to increase
SPDK_SCSI_DEV_MAX_LUN from 64 to 256 without consuming additional memory.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I7f6f070ddc680127cf86ae255055da2d1d29e4ec
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9630
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2022-06-30 13:32:26 -04:00
..
dev.c scsi: Manage LUNs per device by not fixed size array but linked list 2022-06-30 13:32:26 -04:00
lun.c lib/trace: don't pass zero as a non-argument 2021-06-28 16:17:35 +00:00
Makefile scsi: Add spdk_scsi_dev_get_first/next_lun() to traverse all LUNs 2022-06-30 13:32:26 -04:00
port.c lib/scsi: Remove spdk_ prefix from internal APIs 2020-04-16 08:09:14 +00:00
scsi_bdev.c scsi: Report LUNs use spdk_scsi_dev_get_first/next_lun() to iterate LUNs 2022-06-30 13:32:26 -04:00
scsi_internal.h scsi: Manage LUNs per device by not fixed size array but linked list 2022-06-30 13:32:26 -04:00
scsi_pr.c scsi: return scsi error status for invalid SCSI CDB 2021-04-15 20:25:28 +00:00
scsi_rpc.c lib/scsi: Remove spdk prefix from private functions 2020-04-16 08:09:14 +00:00
scsi.c scsi: Delete mutex from spdk_scsi_globals 2021-06-17 08:59:18 +00:00
spdk_scsi.map scsi: Add spdk_scsi_dev_get_first/next_lun() to traverse all LUNs 2022-06-30 13:32:26 -04:00
task.c scsi: relax spdk_scsi_task_gather_data assert 2021-03-09 08:53:21 +00:00