scsi: remove spdk_scsi_dev_print() function

Replace the single call to spdk_scsi_dev_print() with a reimplementation
using public SCSI API functions, and also using the SPDK logging
framework instead of printf().

Change-Id: Ifa455f9e6a4a07a35d5dec311a61e9a8afaa0227
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/391320
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Daniel Verkamp 2017-12-11 16:22:26 -07:00
parent 474fcf64b2
commit c2009e9e85
6 changed files with 27 additions and 38 deletions

View File

@ -185,7 +185,6 @@ void spdk_scsi_dev_queue_task(struct spdk_scsi_dev *dev, struct spdk_scsi_task *
int spdk_scsi_dev_add_port(struct spdk_scsi_dev *dev, uint64_t id, const char *name);
int spdk_scsi_dev_delete_port(struct spdk_scsi_dev *dev, uint64_t id);
struct spdk_scsi_port *spdk_scsi_dev_find_port_by_id(struct spdk_scsi_dev *dev, uint64_t id);
void spdk_scsi_dev_print(struct spdk_scsi_dev *dev);
int spdk_scsi_dev_allocate_io_channels(struct spdk_scsi_dev *dev);
void spdk_scsi_dev_free_io_channels(struct spdk_scsi_dev *dev);

View File

@ -1176,7 +1176,17 @@ spdk_cf_add_iscsi_tgt_node(struct spdk_conf_section *sp)
return -1;
}
spdk_scsi_dev_print(target->dev);
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) {
SPDK_INFOLOG(SPDK_LOG_ISCSI, "device %d: LUN%d %s\n",
spdk_scsi_dev_get_id(target->dev),
spdk_scsi_lun_get_id(lun),
spdk_scsi_lun_get_name(lun));
}
}
return 0;
}

View File

@ -289,23 +289,6 @@ spdk_scsi_dev_find_port_by_id(struct spdk_scsi_dev *dev, uint64_t id)
return NULL;
}
void
spdk_scsi_dev_print(struct spdk_scsi_dev *dev)
{
struct spdk_scsi_lun *lun;
int i;
printf("device %d HDD UNIT\n", dev->id);
for (i = 0; i < SPDK_SCSI_DEV_MAX_LUN; i++) {
lun = dev->lun[i];
if (lun == NULL) {
continue;
}
printf("device %d: LUN%d %s\n", dev->id, i, lun->name);
}
}
void
spdk_scsi_dev_free_io_channels(struct spdk_scsi_dev *dev)
{

View File

@ -174,11 +174,6 @@ spdk_iscsi_conn_logout(struct spdk_iscsi_conn *conn)
{
}
void
spdk_scsi_dev_print(struct spdk_scsi_dev *dev)
{
}
void
spdk_scsi_task_set_status(struct spdk_scsi_task *task, int sc, int sk, int asc, int ascq)
{

View File

@ -36,6 +36,7 @@
#include "spdk/scsi.h"
#include "CUnit/Basic.h"
#include "spdk_internal/mock.h"
#include "../common.c"
#include "iscsi/tgt_node.c"
@ -45,6 +46,21 @@ struct spdk_iscsi_globals g_spdk_iscsi;
const char *config_file;
DEFINE_STUB(spdk_scsi_dev_get_id,
int,
(const struct spdk_scsi_dev *dev),
0);
DEFINE_STUB(spdk_scsi_lun_get_name,
const char *,
(const struct spdk_scsi_lun *lun),
NULL);
DEFINE_STUB(spdk_scsi_lun_get_id,
int,
(const struct spdk_scsi_lun *lun),
0);
bool
spdk_sock_is_ipv6(int sock)
{

View File

@ -622,19 +622,6 @@ dev_find_port_by_id_success(void)
}
}
static void
dev_print_success(void)
{
struct spdk_scsi_dev dev = { 0 };
struct spdk_scsi_lun lun = { 0 };
dev.lun[0] = &lun;
/* Prints the dev and a list of the LUNs associated with
* the dev */
spdk_scsi_dev_print(&dev);
}
int
main(int argc, char **argv)
{
@ -693,7 +680,6 @@ main(int argc, char **argv)
dev_find_port_by_id_id_not_found_failure) == NULL
|| CU_add_test(suite, "dev find port by id - success",
dev_find_port_by_id_success) == NULL
|| CU_add_test(suite, "dev print - success", dev_print_success) == NULL
) {
CU_cleanup_registry();
return CU_get_error();