Commit 594f46d7 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

iscsi: iSCSI target uses spdk_scsi_dev_get_first/next_lun() to iterate LUNs



Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I99cc770c3637d79689d61f996ae40bb4be25cb00
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9626


Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarGangCao <gang.cao@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 8215c0ac
Loading
Loading
Loading
Loading
+10 −18
Original line number Diff line number Diff line
@@ -1226,16 +1226,11 @@ int
iscsi_tgt_node_cleanup_luns(struct spdk_iscsi_conn *conn,
			    struct spdk_iscsi_tgt_node *target)
{
	int i;
	struct spdk_scsi_lun *lun;
	struct spdk_iscsi_task *task;

	for (i = 0; i < SPDK_SCSI_DEV_MAX_LUN; i++) {
		struct spdk_scsi_lun *lun = spdk_scsi_dev_get_lun(target->dev, i);

		if (!lun) {
			continue;
		}

	for (lun = spdk_scsi_dev_get_first_lun(target->dev); lun != NULL;
	     lun = spdk_scsi_dev_get_next_lun(lun)) {
		/* we create a fake management task per LUN to cleanup */
		task = iscsi_task_get(conn, NULL, iscsi_task_mgmt_cpl);
		if (!task) {
@@ -1329,7 +1324,7 @@ iscsi_tgt_node_info_json(struct spdk_iscsi_tgt_node *target,
{
	struct spdk_iscsi_pg_map *pg_map;
	struct spdk_iscsi_ig_map *ig_map;
	int i;
	struct spdk_scsi_lun *lun;

	spdk_json_write_object_begin(w);

@@ -1351,16 +1346,13 @@ iscsi_tgt_node_info_json(struct spdk_iscsi_tgt_node *target,
	spdk_json_write_array_end(w);

	spdk_json_write_named_array_begin(w, "luns");
	for (i = 0; i < SPDK_SCSI_DEV_MAX_LUN; i++) {
		struct spdk_scsi_lun *lun = spdk_scsi_dev_get_lun(target->dev, i);

		if (lun) {
	for (lun = spdk_scsi_dev_get_first_lun(target->dev); lun != NULL;
	     lun = spdk_scsi_dev_get_next_lun(lun)) {
		spdk_json_write_object_begin(w);
		spdk_json_write_named_string(w, "bdev_name", spdk_scsi_lun_get_bdev_name(lun));
		spdk_json_write_named_int32(w, "lun_id", spdk_scsi_lun_get_id(lun));
		spdk_json_write_object_end(w);
	}
	}
	spdk_json_write_array_end(w);

	spdk_json_write_named_int32(w, "queue_depth", target->queue_depth);
+10 −0
Original line number Diff line number Diff line
@@ -110,6 +110,16 @@ spdk_scsi_dev_add_lun(struct spdk_scsi_dev *dev, const char *bdev_name, int lun_
	}
}

DEFINE_STUB(spdk_scsi_dev_get_first_lun,
	    struct spdk_scsi_lun *,
	    (struct spdk_scsi_dev *dev),
	    NULL);

DEFINE_STUB(spdk_scsi_dev_get_next_lun,
	    struct spdk_scsi_lun *,
	    (struct spdk_scsi_lun *prev_lun),
	    NULL);

static void
add_lun_test_cases(void)
{