Commit c210a81f authored by Tomasz Zawadzki's avatar Tomasz Zawadzki
Browse files

scsi: spdk_scsi_lun_construct should return only new objects



This patch makes spdk_scsi_lun_construct behave as documented.
spdk_scsi_lun_construct will return only newly created LUN.
If LUN with that name already exists, NULL will be returned.

Unit test relevant to this behaviour is now changed to show
this functionality is now working.

Signed-off-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I002903d6f96555c638aba3fa99cc2c2504ced603
parent 90b08736
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -280,7 +280,8 @@ spdk_scsi_lun_construct(const char *name, struct spdk_bdev *bdev)

	lun = spdk_lun_db_get_lun(name, 0);
	if (lun) {
		return lun;
		SPDK_ERRLOG("LUN %s already created\n", lun->name);
		return NULL;
	}

	lun = calloc(1, sizeof(*lun));
+1 −1
Original line number Diff line number Diff line
@@ -621,7 +621,7 @@ lun_construct_same_same_twice(void)
	lun2 = spdk_scsi_lun_construct("lun0", &bdev2);

	/* Fails to construct the same lun on another bdev and returns NULL */
	CU_ASSERT(lun2 != NULL); /* lun2 should be NULL, this shows it is not currently working */
	CU_ASSERT(lun2 == NULL);

	lun_destruct(lun);