scsi: spdk_scsi_dev_add_lun() checks if lun_id is less than max by itself

This is an effort to remove the dependency on the macro constant
SPDK_SCSI_DEV_MAX_LUN from lib/iscsi.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ieeff4136b16cc6bfa92614248f150bc9dfe3dc74
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9609
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: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: GangCao <gang.cao@intel.com>
This commit is contained in:
Shuhei Matsumoto 2021-09-21 02:20:08 +09:00 committed by Tomasz Zawadzki
parent f61d81e47c
commit 8215c0acef
2 changed files with 7 additions and 2 deletions

View File

@ -1283,8 +1283,8 @@ iscsi_tgt_node_add_lun(struct spdk_iscsi_tgt_node *target,
return -1;
}
if (lun_id < -1 || lun_id >= SPDK_SCSI_DEV_MAX_LUN) {
SPDK_ERRLOG("Specified LUN ID (%d) is invalid\n", lun_id);
if (lun_id < -1) {
SPDK_ERRLOG("Specified LUN ID (%d) is negative\n", lun_id);
return -1;
}

View File

@ -153,6 +153,11 @@ spdk_scsi_dev_add_lun_ext(struct spdk_scsi_dev *dev, const char *bdev_name, int
{
struct spdk_scsi_lun *lun;
if (lun_id >= SPDK_SCSI_DEV_MAX_LUN) {
SPDK_ERRLOG("LUN ID %d is more than the maximum.\n", lun_id);
return -1;
}
/* Search the lowest free LUN ID if LUN ID is default */
if (lun_id == -1) {
lun_id = scsi_dev_find_lowest_free_lun_id(dev);