Commit 3f1e18cb authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

lib/iscsi: Factor out operation to open each LUN for connection



This is a preparation to the subsequent patches.

Subsequent patches will introduce struct spdk_iscsi_lun
to refine LUN hotplug process and fix critical issues of it.

This change will make us easy to introduce struct spdk_iscsi_lun.

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


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarZiye Yang <ziye.yang@intel.com>
parent 22adcd14
Loading
Loading
Loading
Loading
+24 −10
Original line number Diff line number Diff line
@@ -506,12 +506,34 @@ iscsi_conn_remove_lun(struct spdk_scsi_lun *lun, void *remove_ctx)
			     _iscsi_conn_remove_lun, ctx);
}

static int
iscsi_conn_open_lun(struct spdk_iscsi_conn *conn, int lun_id,
		    struct spdk_scsi_lun *lun)
{
	int rc;
	struct spdk_scsi_lun_desc *desc;

	rc = spdk_scsi_lun_open(lun, iscsi_conn_remove_lun, conn, &desc);
	if (rc != 0) {
		return rc;
	}

	rc = spdk_scsi_lun_allocate_io_channel(desc);
	if (rc != 0) {
		spdk_scsi_lun_close(desc);
		return rc;
	}

	conn->open_lun_descs[lun_id] = desc;

	return 0;
}

static void
iscsi_conn_open_luns(struct spdk_iscsi_conn *conn)
{
	int i, rc;
	struct spdk_scsi_lun *lun;
	struct spdk_scsi_lun_desc *desc;

	for (i = 0; i < SPDK_SCSI_DEV_MAX_LUN; i++) {
		lun = spdk_scsi_dev_get_lun(conn->dev, i);
@@ -519,18 +541,10 @@ iscsi_conn_open_luns(struct spdk_iscsi_conn *conn)
			continue;
		}

		rc = spdk_scsi_lun_open(lun, iscsi_conn_remove_lun, conn, &desc);
		if (rc != 0) {
			goto error;
		}

		rc = spdk_scsi_lun_allocate_io_channel(desc);
		rc = iscsi_conn_open_lun(conn, i, lun);
		if (rc != 0) {
			spdk_scsi_lun_close(desc);
			goto error;
		}

		conn->open_lun_descs[i] = desc;
	}

	return;