iscsi: iSCSI target uses spdk_scsi_dev_get_first/next_lun() to iterate LUNs
Signed-off-by: Shuhei 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: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: GangCao <gang.cao@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
15ee8e043b
commit
c4a5d5813f
@ -1226,16 +1226,11 @@ int
|
|||||||
iscsi_tgt_node_cleanup_luns(struct spdk_iscsi_conn *conn,
|
iscsi_tgt_node_cleanup_luns(struct spdk_iscsi_conn *conn,
|
||||||
struct spdk_iscsi_tgt_node *target)
|
struct spdk_iscsi_tgt_node *target)
|
||||||
{
|
{
|
||||||
int i;
|
struct spdk_scsi_lun *lun;
|
||||||
struct spdk_iscsi_task *task;
|
struct spdk_iscsi_task *task;
|
||||||
|
|
||||||
for (i = 0; i < SPDK_SCSI_DEV_MAX_LUN; i++) {
|
for (lun = spdk_scsi_dev_get_first_lun(target->dev); lun != NULL;
|
||||||
struct spdk_scsi_lun *lun = spdk_scsi_dev_get_lun(target->dev, i);
|
lun = spdk_scsi_dev_get_next_lun(lun)) {
|
||||||
|
|
||||||
if (!lun) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* we create a fake management task per LUN to cleanup */
|
/* we create a fake management task per LUN to cleanup */
|
||||||
task = iscsi_task_get(conn, NULL, iscsi_task_mgmt_cpl);
|
task = iscsi_task_get(conn, NULL, iscsi_task_mgmt_cpl);
|
||||||
if (!task) {
|
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_pg_map *pg_map;
|
||||||
struct spdk_iscsi_ig_map *ig_map;
|
struct spdk_iscsi_ig_map *ig_map;
|
||||||
int i;
|
struct spdk_scsi_lun *lun;
|
||||||
|
|
||||||
spdk_json_write_object_begin(w);
|
spdk_json_write_object_begin(w);
|
||||||
|
|
||||||
@ -1351,15 +1346,12 @@ iscsi_tgt_node_info_json(struct spdk_iscsi_tgt_node *target,
|
|||||||
spdk_json_write_array_end(w);
|
spdk_json_write_array_end(w);
|
||||||
|
|
||||||
spdk_json_write_named_array_begin(w, "luns");
|
spdk_json_write_named_array_begin(w, "luns");
|
||||||
for (i = 0; i < SPDK_SCSI_DEV_MAX_LUN; i++) {
|
for (lun = spdk_scsi_dev_get_first_lun(target->dev); lun != NULL;
|
||||||
struct spdk_scsi_lun *lun = spdk_scsi_dev_get_lun(target->dev, i);
|
lun = spdk_scsi_dev_get_next_lun(lun)) {
|
||||||
|
spdk_json_write_object_begin(w);
|
||||||
if (lun) {
|
spdk_json_write_named_string(w, "bdev_name", spdk_scsi_lun_get_bdev_name(lun));
|
||||||
spdk_json_write_object_begin(w);
|
spdk_json_write_named_int32(w, "lun_id", spdk_scsi_lun_get_id(lun));
|
||||||
spdk_json_write_named_string(w, "bdev_name", spdk_scsi_lun_get_bdev_name(lun));
|
spdk_json_write_object_end(w);
|
||||||
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_array_end(w);
|
||||||
|
|
||||||
|
@ -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
|
static void
|
||||||
add_lun_test_cases(void)
|
add_lun_test_cases(void)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user