From 12965bb6ce32582fe2755920d4282059eaa47574 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Mon, 1 May 2017 13:32:34 -0700 Subject: [PATCH] scsi: make spdk_scsi_lun definition private The contents of struct spdk_scsi_lun don't need to be part of the public API. Change-Id: I101b77871054557380610fd901ab38bada463202 Signed-off-by: Daniel Verkamp --- include/spdk/scsi.h | 41 +++---------------------------------- lib/iscsi/iscsi.c | 2 +- lib/iscsi/iscsi_rpc.c | 4 ++-- lib/iscsi/iscsi_subsystem.c | 4 ++-- lib/scsi/lun.c | 12 +++++++++++ lib/scsi/scsi_internal.h | 40 ++++++++++++++++++++++++++++++++++++ lib/vhost/vhost_rpc.c | 4 ++-- test/lib/iscsi/pdu/pdu.c | 7 +++++++ 8 files changed, 69 insertions(+), 45 deletions(-) diff --git a/include/spdk/scsi.h b/include/spdk/scsi.h index 73eafe6a07..0aa6c7954a 100644 --- a/include/spdk/scsi.h +++ b/include/spdk/scsi.h @@ -192,45 +192,10 @@ struct spdk_scsi_dev { * malloc LUNs will implement scsi_execute to translate the SCSI task and * copy the task's data into or out of the allocated memory buffer. */ -struct spdk_scsi_lun { - /** LUN id for this logical unit. */ - int id; +struct spdk_scsi_lun; - /** Pointer to the SCSI device containing this LUN. */ - struct spdk_scsi_dev *dev; - - /** The blockdev associated with this LUN. */ - struct spdk_bdev *bdev; - - /** I/O channel for the blockdev associated with this LUN. */ - struct spdk_io_channel *io_channel; - - /** Thread ID for the thread that allocated the I/O channel for this - * LUN. All I/O to this LUN must be performed from this thread. - */ - pthread_t thread_id; - - /** The reference number for this LUN, thus we can correctly free the io_channel */ - uint32_t ref; - - /** Name for this LUN. */ - char name[SPDK_SCSI_LUN_MAX_NAME_LENGTH]; - - /** Poller to release the resource of the lun when it is hot removed */ - struct spdk_poller *hotplug_poller; - - /** The core hotplug_poller is assigned */ - uint32_t lcore; - - /** The LUN is removed */ - bool removed; - - /** The LUN is clamed */ - bool claimed; - - TAILQ_HEAD(tasks, spdk_scsi_task) tasks; /* submitted tasks */ - TAILQ_HEAD(pending_tasks, spdk_scsi_task) pending_tasks; /* pending tasks */ -}; +int spdk_scsi_lun_get_id(const struct spdk_scsi_lun *lun); +const char *spdk_scsi_lun_get_name(const struct spdk_scsi_lun *lun); void spdk_scsi_dev_destruct(struct spdk_scsi_dev *dev); void spdk_scsi_dev_queue_mgmt_task(struct spdk_scsi_dev *dev, struct spdk_scsi_task *task); diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index f46810b449..347ce9d4a9 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -4162,7 +4162,7 @@ spdk_iscsi_send_r2t(struct spdk_iscsi_conn *conn, rsp_pdu->data = NULL; rsph->opcode = ISCSI_OP_R2T; rsph->flags |= 0x80; /* bit 0 is default to 1 */ - to_be64(&rsph->lun, task->scsi.lun->id); + to_be64(&rsph->lun, spdk_scsi_lun_get_id(task->scsi.lun)); to_be32(&rsph->itt, task->scsi.id); to_be32(&rsph->ttt, transfer_tag); diff --git a/lib/iscsi/iscsi_rpc.c b/lib/iscsi/iscsi_rpc.c index 63684c00cc..9e6eb8455b 100644 --- a/lib/iscsi/iscsi_rpc.c +++ b/lib/iscsi/iscsi_rpc.c @@ -349,9 +349,9 @@ spdk_rpc_get_target_nodes(struct spdk_jsonrpc_server_conn *conn, if (tgtnode->dev->lun[i]) { spdk_json_write_object_begin(w); spdk_json_write_name(w, "name"); - spdk_json_write_string(w, tgtnode->dev->lun[i]->name); + spdk_json_write_string(w, spdk_scsi_lun_get_name(tgtnode->dev->lun[i])); spdk_json_write_name(w, "id"); - spdk_json_write_int32(w, tgtnode->dev->lun[i]->id); + spdk_json_write_int32(w, spdk_scsi_lun_get_id(tgtnode->dev->lun[i])); spdk_json_write_object_end(w); } } diff --git a/lib/iscsi/iscsi_subsystem.c b/lib/iscsi/iscsi_subsystem.c index 608dac044b..2e9471c30c 100644 --- a/lib/iscsi/iscsi_subsystem.c +++ b/lib/iscsi/iscsi_subsystem.c @@ -289,8 +289,8 @@ spdk_iscsi_config_dump_target_nodes(FILE *fp) if (NULL == dev->lun[l]) continue; fprintf(fp, TARGET_NODE_LUN_TMPL, - dev->lun[l]->id, - dev->lun[l]->name); + spdk_scsi_lun_get_id(dev->lun[l]), + spdk_scsi_lun_get_name(dev->lun[l])); } fprintf(fp, TARGET_NODE_QD_TMPL, diff --git a/lib/scsi/lun.c b/lib/scsi/lun.c index 5890b7d5a2..41a0f58deb 100644 --- a/lib/scsi/lun.c +++ b/lib/scsi/lun.c @@ -431,3 +431,15 @@ void spdk_scsi_lun_free_io_channel(struct spdk_scsi_lun *lun) } } } + +int +spdk_scsi_lun_get_id(const struct spdk_scsi_lun *lun) +{ + return lun->id; +} + +const char * +spdk_scsi_lun_get_name(const struct spdk_scsi_lun *lun) +{ + return lun->name; +} diff --git a/lib/scsi/scsi_internal.h b/lib/scsi/scsi_internal.h index 0b4ea52054..c1000f572a 100644 --- a/lib/scsi/scsi_internal.h +++ b/lib/scsi/scsi_internal.h @@ -81,6 +81,46 @@ enum { SPDK_SCSI_TASK_PENDING, }; +struct spdk_scsi_lun { + /** LUN id for this logical unit. */ + int id; + + /** Pointer to the SCSI device containing this LUN. */ + struct spdk_scsi_dev *dev; + + /** The blockdev associated with this LUN. */ + struct spdk_bdev *bdev; + + /** I/O channel for the blockdev associated with this LUN. */ + struct spdk_io_channel *io_channel; + + /** Thread ID for the thread that allocated the I/O channel for this + * LUN. All I/O to this LUN must be performed from this thread. + */ + pthread_t thread_id; + + /** The reference number for this LUN, thus we can correctly free the io_channel */ + uint32_t ref; + + /** Name for this LUN. */ + char name[SPDK_SCSI_LUN_MAX_NAME_LENGTH]; + + /** Poller to release the resource of the lun when it is hot removed */ + struct spdk_poller *hotplug_poller; + + /** The core hotplug_poller is assigned */ + uint32_t lcore; + + /** The LUN is removed */ + bool removed; + + /** The LUN is clamed */ + bool claimed; + + TAILQ_HEAD(tasks, spdk_scsi_task) tasks; /* submitted tasks */ + TAILQ_HEAD(pending_tasks, spdk_scsi_task) pending_tasks; /* pending tasks */ +}; + struct spdk_lun_db_entry { struct spdk_scsi_lun *lun; struct spdk_lun_db_entry *next; diff --git a/lib/vhost/vhost_rpc.c b/lib/vhost/vhost_rpc.c index 670dcee24c..54aa03b8ea 100644 --- a/lib/vhost/vhost_rpc.c +++ b/lib/vhost/vhost_rpc.c @@ -60,10 +60,10 @@ json_scsi_dev_write(struct spdk_json_write_ctx *ctx, struct spdk_scsi_dev *dev) spdk_json_write_object_begin(ctx); spdk_json_write_name(ctx, "id"); - spdk_json_write_int32(ctx, (int32_t)dev->lun[l]->id); + spdk_json_write_int32(ctx, spdk_scsi_lun_get_id(dev->lun[l])); spdk_json_write_name(ctx, "name"); - spdk_json_write_string(ctx, dev->lun[l]->name); + spdk_json_write_string(ctx, spdk_scsi_lun_get_name(dev->lun[l])); spdk_json_write_object_end(ctx); } diff --git a/test/lib/iscsi/pdu/pdu.c b/test/lib/iscsi/pdu/pdu.c index 4461141802..68200e24e9 100644 --- a/test/lib/iscsi/pdu/pdu.c +++ b/test/lib/iscsi/pdu/pdu.c @@ -43,6 +43,7 @@ #include "../common.c" #include "iscsi/acceptor.h" #include "iscsi/portal_grp.h" +#include "scsi/scsi_internal.h" struct spdk_iscsi_tgt_node * spdk_iscsi_find_tgt_node(const char *target_name) @@ -82,6 +83,12 @@ spdk_iscsi_conn_free_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pd { } +int +spdk_scsi_lun_get_id(const struct spdk_scsi_lun *lun) +{ + return lun->id; +} + static void maxburstlength_test(void) {