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: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I75db59d88bb09ee2ea94e8c02e0e87003352850c Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/476112 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ziye Yang <ziye.yang@intel.com>
This commit is contained in:
parent
22adcd1487
commit
3f1e18cbbf
@ -506,12 +506,34 @@ iscsi_conn_remove_lun(struct spdk_scsi_lun *lun, void *remove_ctx)
|
|||||||
_iscsi_conn_remove_lun, 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
|
static void
|
||||||
iscsi_conn_open_luns(struct spdk_iscsi_conn *conn)
|
iscsi_conn_open_luns(struct spdk_iscsi_conn *conn)
|
||||||
{
|
{
|
||||||
int i, rc;
|
int i, rc;
|
||||||
struct spdk_scsi_lun *lun;
|
struct spdk_scsi_lun *lun;
|
||||||
struct spdk_scsi_lun_desc *desc;
|
|
||||||
|
|
||||||
for (i = 0; i < SPDK_SCSI_DEV_MAX_LUN; i++) {
|
for (i = 0; i < SPDK_SCSI_DEV_MAX_LUN; i++) {
|
||||||
lun = spdk_scsi_dev_get_lun(conn->dev, i);
|
lun = spdk_scsi_dev_get_lun(conn->dev, i);
|
||||||
@ -519,18 +541,10 @@ iscsi_conn_open_luns(struct spdk_iscsi_conn *conn)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = spdk_scsi_lun_open(lun, iscsi_conn_remove_lun, conn, &desc);
|
rc = iscsi_conn_open_lun(conn, i, lun);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = spdk_scsi_lun_allocate_io_channel(desc);
|
|
||||||
if (rc != 0) {
|
|
||||||
spdk_scsi_lun_close(desc);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
conn->open_lun_descs[i] = desc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user