module/virtio_blk/sci: remove legacy config support

This patch removes legacy config support in virtio_blk and virtio_scsi bdev modules.
Most of the options through the legacy config are already reflected in JSON.

Exception to that is "[VirtioPci] Enable" option, which worked for virtio_blk
and virtio_scsi. It then on initialization scanned virtio_pci devices for
presence of blk/scsi. There is no RPC that scans it on demand, nor was it used
in any of the tests. So this patch removes that functionality,
if needed this can be reintroduced as new RPC (or two for each backend).

Module initialization for bdev_virtio_scsi changed to be synchronous.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Ib0978a4a084795e94993bb9122bd73ed49e14b96
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4667
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Tomasz Zawadzki 2020-10-12 08:05:56 -04:00 committed by Jim Harris
parent dbc7e89f58
commit d3e99f4891
3 changed files with 2 additions and 213 deletions

View File

@ -141,13 +141,12 @@ DEPDIRS-bdev_pmem := $(BDEV_DEPS_THREAD)
DEPDIRS-bdev_raid := $(BDEV_DEPS_THREAD)
DEPDIRS-bdev_rbd := $(BDEV_DEPS_THREAD)
DEPDIRS-bdev_uring := $(BDEV_DEPS_THREAD)
DEPDIRS-bdev_virtio := $(BDEV_DEPS_THREAD) virtio
DEPDIRS-bdev_zone_block := $(BDEV_DEPS_THREAD)
ifeq ($(OS),Linux)
DEPDIRS-bdev_ftl := $(BDEV_DEPS_THREAD) ftl
endif
DEPDIRS-bdev_virtio := $(BDEV_DEPS_CONF_THREAD) virtio
# module/event
# module/event/subsystems

View File

@ -34,7 +34,6 @@
#include "spdk/stdinc.h"
#include "spdk/bdev.h"
#include "spdk/conf.h"
#include "spdk/endian.h"
#include "spdk/env.h"
#include "spdk/thread.h"
@ -656,81 +655,10 @@ bdev_virtio_pci_blk_dev_create(const char *name, struct spdk_pci_addr *pci_addr)
return &create_ctx.ret->bdev;
}
static int
virtio_pci_blk_dev_enumerate_cb(struct virtio_pci_ctx *pci_ctx, void *ctx)
{
struct virtio_blk_dev *bvdev;
bvdev = virtio_pci_blk_dev_create(NULL, pci_ctx);
return bvdev == NULL ? -1 : 0;
}
static int
bdev_virtio_initialize(void)
{
struct spdk_conf_section *sp;
struct virtio_blk_dev *bvdev;
char *default_name = NULL;
char *path, *type, *name;
unsigned vdev_num;
int num_queues;
bool enable_pci;
int rc = 0;
for (sp = spdk_conf_first_section(NULL); sp != NULL; sp = spdk_conf_next_section(sp)) {
if (!spdk_conf_section_match_prefix(sp, "VirtioUser")) {
continue;
}
if (sscanf(spdk_conf_section_get_name(sp), "VirtioUser%u", &vdev_num) != 1) {
SPDK_ERRLOG("Section '%s' has non-numeric suffix.\n",
spdk_conf_section_get_name(sp));
return -1;
}
path = spdk_conf_section_get_val(sp, "Path");
if (path == NULL) {
SPDK_ERRLOG("VirtioUserBlk%u: missing Path\n", vdev_num);
return -1;
}
type = spdk_conf_section_get_val(sp, "Type");
if (type == NULL || strcmp(type, "Blk") != 0) {
continue;
}
num_queues = spdk_conf_section_get_intval(sp, "Queues");
if (num_queues < 1) {
num_queues = 1;
}
name = spdk_conf_section_get_val(sp, "Name");
if (name == NULL) {
default_name = spdk_sprintf_alloc("VirtioBlk%u", vdev_num);
name = default_name;
}
bvdev = virtio_user_blk_dev_create(name, path, num_queues, 512);
free(default_name);
default_name = NULL;
if (bvdev == NULL) {
return -1;
}
}
sp = spdk_conf_find_section(NULL, "VirtioPci");
if (sp == NULL) {
return 0;
}
enable_pci = spdk_conf_section_get_boolval(sp, "Enable", false);
if (enable_pci) {
rc = virtio_pci_dev_enumerate(virtio_pci_blk_dev_enumerate_cb, NULL,
PCI_DEVICE_ID_VIRTIO_BLK_MODERN);
}
return rc;
return 0;
}
struct spdk_bdev *

View File

@ -34,7 +34,6 @@
#include "spdk/stdinc.h"
#include "spdk/bdev.h"
#include "spdk/conf.h"
#include "spdk/endian.h"
#include "spdk/env.h"
#include "spdk/thread.h"
@ -456,7 +455,6 @@ static struct spdk_bdev_module virtio_scsi_if = {
.module_fini = bdev_virtio_finish,
.get_ctx_size = bdev_virtio_get_ctx_size,
.config_json = bdev_virtio_scsi_config_json,
.async_init = true,
.async_fini = true,
};
@ -1568,89 +1566,6 @@ _virtio_scsi_dev_scan_next(struct virtio_scsi_scan_base *base, int rc)
return 0;
}
static int
virtio_pci_scsi_dev_enumerate_cb(struct virtio_pci_ctx *pci_ctx, void *ctx)
{
struct virtio_scsi_dev *svdev;
svdev = virtio_pci_scsi_dev_create(NULL, pci_ctx);
return svdev == NULL ? -1 : 0;
}
static int
bdev_virtio_process_config(void)
{
struct spdk_conf_section *sp;
struct virtio_scsi_dev *svdev;
char *default_name = NULL;
char *path, *type, *name;
unsigned vdev_num;
int num_queues;
bool enable_pci;
int rc = 0;
for (sp = spdk_conf_first_section(NULL); sp != NULL; sp = spdk_conf_next_section(sp)) {
if (!spdk_conf_section_match_prefix(sp, "VirtioUser")) {
continue;
}
if (sscanf(spdk_conf_section_get_name(sp), "VirtioUser%u", &vdev_num) != 1) {
SPDK_ERRLOG("Section '%s' has non-numeric suffix.\n",
spdk_conf_section_get_name(sp));
rc = -1;
goto out;
}
path = spdk_conf_section_get_val(sp, "Path");
if (path == NULL) {
SPDK_ERRLOG("VirtioUser%u: missing Path\n", vdev_num);
rc = -1;
goto out;
}
type = spdk_conf_section_get_val(sp, "Type");
if (type != NULL && strcmp(type, "SCSI") != 0) {
continue;
}
num_queues = spdk_conf_section_get_intval(sp, "Queues");
if (num_queues < 1) {
num_queues = 1;
} else if (num_queues > SPDK_VIRTIO_MAX_VIRTQUEUES) {
num_queues = SPDK_VIRTIO_MAX_VIRTQUEUES;
}
name = spdk_conf_section_get_val(sp, "Name");
if (name == NULL) {
default_name = spdk_sprintf_alloc("VirtioScsi%u", vdev_num);
name = default_name;
}
svdev = virtio_user_scsi_dev_create(name, path, num_queues, 512);
free(default_name);
default_name = NULL;
if (svdev == NULL) {
rc = -1;
goto out;
}
}
sp = spdk_conf_find_section(NULL, "VirtioPci");
if (sp == NULL) {
return 0;
}
enable_pci = spdk_conf_section_get_boolval(sp, "Enable", false);
if (enable_pci) {
rc = virtio_pci_dev_enumerate(virtio_pci_scsi_dev_enumerate_cb, NULL,
PCI_DEVICE_ID_VIRTIO_SCSI_MODERN);
}
out:
return rc;
}
static int
_virtio_scsi_dev_scan_init(struct virtio_scsi_dev *svdev)
{
@ -1777,63 +1692,10 @@ virtio_scsi_dev_scan_tgt(struct virtio_scsi_dev *svdev, uint8_t target)
return 0;
}
static void
bdev_virtio_initial_scan_complete(void *ctx, int result,
struct spdk_bdev **bdevs, size_t bdevs_cnt)
{
struct virtio_scsi_dev *svdev;
pthread_mutex_lock(&g_virtio_scsi_mutex);
TAILQ_FOREACH(svdev, &g_virtio_scsi_devs, tailq) {
if (svdev->scan_ctx) {
/* another device is still being scanned */
pthread_mutex_unlock(&g_virtio_scsi_mutex);
return;
}
}
pthread_mutex_unlock(&g_virtio_scsi_mutex);
spdk_bdev_module_init_done(&virtio_scsi_if);
}
static int
bdev_virtio_initialize(void)
{
struct virtio_scsi_dev *svdev, *next_svdev;
int rc;
rc = bdev_virtio_process_config();
pthread_mutex_lock(&g_virtio_scsi_mutex);
if (rc != 0) {
goto err_unlock;
}
if (TAILQ_EMPTY(&g_virtio_scsi_devs)) {
goto out_unlock;
}
/* Initialize all created devices and scan available targets */
TAILQ_FOREACH(svdev, &g_virtio_scsi_devs, tailq) {
rc = virtio_scsi_dev_scan(svdev, bdev_virtio_initial_scan_complete, NULL);
if (rc != 0) {
goto err_unlock;
}
}
pthread_mutex_unlock(&g_virtio_scsi_mutex);
return 0;
err_unlock:
/* Remove any created devices */
TAILQ_FOREACH_SAFE(svdev, &g_virtio_scsi_devs, tailq, next_svdev) {
virtio_scsi_dev_remove(svdev, NULL, NULL);
}
out_unlock:
pthread_mutex_unlock(&g_virtio_scsi_mutex);
spdk_bdev_module_init_done(&virtio_scsi_if);
return rc;
}
static void