bdev: rework bdev module registration
Currently SPDK_BDEV_MODULE_REGISTER() take many parameters. Extending it (eg for incoming JSON configuration dump/load) is quite challenging and error prone. As we are already here in next patches, rework this macro to take one parameter - the pointer to struct spdk_bdev_module_if. This patch also remove following macros: SPDK_GET_BDEV_MODULE - this is not really needed, to find module outside module translation unit use spdk_bdev_module_list_find() SPDK_BDEV_MODULE_ASYNC_INIT and SPDK_BDEV_MODULE_ASYNC_FINI - replaced by bool fields in spdk_bdev_module_if struct. Change-Id: Ief88e023fbbaee7d5402c838dbecbdffd4dfb259 Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com> Reviewed-on: https://review.gerrithub.io/402883 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
4294719ed7
commit
4d36735401
@ -25,13 +25,17 @@ module, add a new directory with a single C file and a Makefile. A great
|
||||
starting point is to copy the existing 'null' bdev module.
|
||||
|
||||
The primary interface that bdev modules will interact with is in
|
||||
include/spdk_internal/bdev.h. In that header a macro is defined that declares
|
||||
a new bdev module named SPDK_BDEV_MODULE_REGISTER. This macro takes as
|
||||
arguments a number of function pointers that are used to initialize, tear
|
||||
down, and get the configuration of the module. There are also arguments to
|
||||
specify context size, which is scratch space that will be allocated in each
|
||||
I/O request for use by this module, and a callback that will be called each
|
||||
time a new bdev is registered by another module.
|
||||
include/spdk_internal/bdev.h. In that header a macro is defined that registers
|
||||
a new bdev module - SPDK_BDEV_MODULE_REGISTER. This macro take as argument a
|
||||
pointer spdk_bdev_module_if structure that is used to register new bdev module.
|
||||
|
||||
The spdk_bdev_module_if structure describes the module properties like
|
||||
initialization (`module_init`) and teardown (`module_fini`) functions,
|
||||
the function that returns context size (`get_ctx_size`) - scratch space that
|
||||
will be allocated in each I/O request for use by this module, and a callback
|
||||
that will be called each time a new bdev is registered by another module
|
||||
(`examine`). Please check the documentation of struct spdk_bdev_module_if for
|
||||
more details.
|
||||
|
||||
## Creating Bdevs
|
||||
|
||||
|
@ -119,11 +119,22 @@ struct spdk_bdev_module_if {
|
||||
/**
|
||||
* Count of bdev inits/examinations in progress. Used by generic bdev
|
||||
* layer and must not be modified by bdev modules.
|
||||
*
|
||||
* \note Used internally by bdev subsystem, don't change this value in bdev module.
|
||||
*/
|
||||
uint32_t action_in_progress;
|
||||
|
||||
/**
|
||||
* Denotes if the module_init function may complete asynchronously. If set to true,
|
||||
* the module initialization has to be explicitly completed by calling
|
||||
* spdk_bdev_module_init_done().
|
||||
*/
|
||||
bool async_init;
|
||||
|
||||
/**
|
||||
* Denotes if the module_fini function may complete asynchronously.
|
||||
* If set to true finishing has to be explicitly completed by calling
|
||||
* spdk_bdev_module_fini_done().
|
||||
*/
|
||||
bool async_fini;
|
||||
|
||||
@ -515,6 +526,14 @@ void spdk_scsi_nvme_translate(const struct spdk_bdev_io *bdev_io,
|
||||
|
||||
void spdk_bdev_module_list_add(struct spdk_bdev_module_if *bdev_module);
|
||||
|
||||
/**
|
||||
* Find registered module with name pointed by \c name.
|
||||
*
|
||||
* \param name name of module to be searched for.
|
||||
* \return pointer to module or NULL if no module with \c name exist
|
||||
*/
|
||||
struct spdk_bdev_module_if *spdk_bdev_module_list_find(const char *name);
|
||||
|
||||
static inline struct spdk_bdev_io *
|
||||
spdk_bdev_io_from_ctx(void *ctx)
|
||||
{
|
||||
@ -571,47 +590,26 @@ int spdk_bdev_part_construct(struct spdk_bdev_part *part, struct spdk_bdev_part_
|
||||
char *product_name);
|
||||
void spdk_bdev_part_submit_request(struct spdk_bdev_part_channel *ch, struct spdk_bdev_io *bdev_io);
|
||||
|
||||
#define SPDK_BDEV_MODULE_REGISTER(_name, init_fn, fini_fn, config_fn, ctx_size_fn, examine_fn) \
|
||||
static struct spdk_bdev_module_if _name ## _if = { \
|
||||
.name = #_name, \
|
||||
.module_init = init_fn, \
|
||||
.module_fini = fini_fn, \
|
||||
.config_text = config_fn, \
|
||||
.get_ctx_size = ctx_size_fn, \
|
||||
.examine = examine_fn, \
|
||||
}; \
|
||||
__attribute__((constructor)) static void _name ## _init(void) \
|
||||
{ \
|
||||
spdk_bdev_module_list_add(&_name ## _if); \
|
||||
}
|
||||
|
||||
#define SPDK_GET_BDEV_MODULE(name) (&name ## _if)
|
||||
|
||||
/*
|
||||
* Set module initialization to be asynchronous. After using this macro, the module
|
||||
* initialization has to be explicitly completed by calling spdk_bdev_module_init_done().
|
||||
* Macro used to register module for later initialization.
|
||||
*/
|
||||
#define SPDK_BDEV_MODULE_ASYNC_INIT(name) \
|
||||
__attribute__((constructor)) static void name ## _async_init(void) \
|
||||
#define SPDK_BDEV_MODULE_REGISTER(_module) \
|
||||
__attribute__((constructor)) static void \
|
||||
SPDK_BDEV_MODULE_REGISTER_FN_NAME(__LINE__) (void) \
|
||||
{ \
|
||||
SPDK_GET_BDEV_MODULE(name)->action_in_progress = 1; \
|
||||
spdk_bdev_module_list_add(_module); \
|
||||
}
|
||||
|
||||
/*
|
||||
* Set module finish to be asynchronous. After using this macro, the module
|
||||
* finishing has to be explicitly completed by calling spdk_bdev_module_fini_done().
|
||||
* This is helper macro for automatic function generation.
|
||||
*
|
||||
*/
|
||||
#define SPDK_BDEV_MODULE_ASYNC_FINI(name) \
|
||||
__attribute__((constructor)) static void name ## _async_fini(void) \
|
||||
{ \
|
||||
SPDK_GET_BDEV_MODULE(name)->async_fini = true; \
|
||||
}
|
||||
#define SPDK_BDEV_MODULE_REGISTER_FN_NAME(line) SPDK_BDEV_MODULE_REGISTER_FN_NAME_(line)
|
||||
|
||||
/*
|
||||
* Modules are not required to use this macro. It allows modules to reference the module with
|
||||
* SPDK_GET_BDEV_MODULE() before it is defined by SPDK_BDEV_MODULE_REGISTER.
|
||||
* Second helper macro for "stringize" trick to work.
|
||||
*/
|
||||
#define SPDK_DECLARE_BDEV_MODULE(name) \
|
||||
static struct spdk_bdev_module_if name ## _if;
|
||||
#define SPDK_BDEV_MODULE_REGISTER_FN_NAME_(line) spdk_bdev_module_if_register_ ## line
|
||||
|
||||
#endif /* SPDK_INTERNAL_BDEV_H */
|
||||
|
@ -59,8 +59,16 @@ bdev_aio_get_ctx_size(void)
|
||||
return sizeof(struct bdev_aio_task);
|
||||
}
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(aio, bdev_aio_initialize, NULL, bdev_aio_get_spdk_running_config,
|
||||
bdev_aio_get_ctx_size, NULL)
|
||||
static struct spdk_bdev_module_if aio_if = {
|
||||
.name = "aio",
|
||||
.module_init = bdev_aio_initialize,
|
||||
.module_fini = NULL,
|
||||
.config_text = bdev_aio_get_spdk_running_config,
|
||||
.get_ctx_size = bdev_aio_get_ctx_size,
|
||||
.examine = NULL,
|
||||
};
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(&aio_if)
|
||||
|
||||
static int
|
||||
bdev_aio_open(struct file_disk *disk)
|
||||
@ -450,7 +458,7 @@ create_aio_disk(const char *name, const char *filename, uint32_t block_size)
|
||||
goto error_return;
|
||||
}
|
||||
fdisk->disk.product_name = "AIO disk";
|
||||
fdisk->disk.module = SPDK_GET_BDEV_MODULE(aio);
|
||||
fdisk->disk.module = &aio_if;
|
||||
|
||||
fdisk->disk.need_aligned_buffer = 1;
|
||||
fdisk->disk.write_cache = 1;
|
||||
|
@ -2391,6 +2391,16 @@ spdk_bdev_io_get_iovec(struct spdk_bdev_io *bdev_io, struct iovec **iovp, int *i
|
||||
void
|
||||
spdk_bdev_module_list_add(struct spdk_bdev_module_if *bdev_module)
|
||||
{
|
||||
|
||||
if (spdk_bdev_module_list_find(bdev_module->name)) {
|
||||
fprintf(stderr, "ERROR: module '%s' already registered.\n", bdev_module->name);
|
||||
assert(false);
|
||||
}
|
||||
|
||||
if (bdev_module->async_init) {
|
||||
bdev_module->action_in_progress = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Modules with examine callbacks must be initialized first, so they are
|
||||
* ready to handle examine callbacks from later modules that will
|
||||
@ -2403,6 +2413,20 @@ spdk_bdev_module_list_add(struct spdk_bdev_module_if *bdev_module)
|
||||
}
|
||||
}
|
||||
|
||||
struct spdk_bdev_module_if *
|
||||
spdk_bdev_module_list_find(const char *name)
|
||||
{
|
||||
struct spdk_bdev_module_if *bdev_module;
|
||||
|
||||
TAILQ_FOREACH(bdev_module, &g_bdev_mgr.bdev_modules, tailq) {
|
||||
if (strcmp(name, bdev_module->name) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return bdev_module;
|
||||
}
|
||||
|
||||
static void
|
||||
spdk_bdev_write_zeroes_split(struct spdk_bdev_io *bdev_io, bool success, void *cb_arg)
|
||||
{
|
||||
|
@ -48,8 +48,6 @@
|
||||
|
||||
#include "vbdev_error.h"
|
||||
|
||||
SPDK_DECLARE_BDEV_MODULE(error);
|
||||
|
||||
struct vbdev_error_info {
|
||||
bool enabled;
|
||||
uint32_t error_type;
|
||||
@ -70,6 +68,20 @@ struct error_channel {
|
||||
static pthread_mutex_t g_vbdev_error_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static SPDK_BDEV_PART_TAILQ g_error_disks = TAILQ_HEAD_INITIALIZER(g_error_disks);
|
||||
|
||||
static int vbdev_error_init(void);
|
||||
|
||||
static void vbdev_error_examine(struct spdk_bdev *bdev);
|
||||
|
||||
static struct spdk_bdev_module_if error_if = {
|
||||
.name = "error",
|
||||
.module_init = vbdev_error_init,
|
||||
.module_fini = NULL,
|
||||
.examine = vbdev_error_examine,
|
||||
|
||||
};
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(&error_if)
|
||||
|
||||
static void
|
||||
spdk_error_free_base(struct spdk_bdev_part_base *base)
|
||||
{
|
||||
@ -235,7 +247,7 @@ spdk_vbdev_error_create(struct spdk_bdev *base_bdev)
|
||||
|
||||
rc = spdk_bdev_part_base_construct(base, base_bdev,
|
||||
spdk_vbdev_error_base_bdev_hotremove_cb,
|
||||
SPDK_GET_BDEV_MODULE(error), &vbdev_error_fn_table,
|
||||
&error_if, &vbdev_error_fn_table,
|
||||
&g_error_disks, spdk_error_free_base,
|
||||
sizeof(struct error_channel), NULL, NULL);
|
||||
if (rc) {
|
||||
@ -288,7 +300,7 @@ vbdev_error_examine(struct spdk_bdev *bdev)
|
||||
|
||||
sp = spdk_conf_find_section(NULL, "BdevError");
|
||||
if (sp == NULL) {
|
||||
spdk_bdev_module_examine_done(SPDK_GET_BDEV_MODULE(error));
|
||||
spdk_bdev_module_examine_done(&error_if);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -313,8 +325,5 @@ vbdev_error_examine(struct spdk_bdev *bdev)
|
||||
}
|
||||
}
|
||||
|
||||
spdk_bdev_module_examine_done(SPDK_GET_BDEV_MODULE(error));
|
||||
spdk_bdev_module_examine_done(&error_if);
|
||||
}
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(error, vbdev_error_init, NULL, NULL, NULL,
|
||||
vbdev_error_examine)
|
||||
|
@ -49,7 +49,16 @@
|
||||
#include "spdk_internal/bdev.h"
|
||||
#include "spdk_internal/log.h"
|
||||
|
||||
SPDK_DECLARE_BDEV_MODULE(gpt);
|
||||
static int vbdev_gpt_init(void);
|
||||
static void vbdev_gpt_examine(struct spdk_bdev *bdev);
|
||||
|
||||
static struct spdk_bdev_module_if gpt_if = {
|
||||
.name = "gpt",
|
||||
.module_init = vbdev_gpt_init,
|
||||
.examine = vbdev_gpt_examine,
|
||||
|
||||
};
|
||||
SPDK_BDEV_MODULE_REGISTER(&gpt_if)
|
||||
|
||||
/* Base block device gpt context */
|
||||
struct gpt_base {
|
||||
@ -114,7 +123,7 @@ spdk_gpt_base_bdev_init(struct spdk_bdev *bdev)
|
||||
|
||||
rc = spdk_bdev_part_base_construct(&gpt_base->part_base, bdev,
|
||||
spdk_gpt_base_bdev_hotremove_cb,
|
||||
SPDK_GET_BDEV_MODULE(gpt), &vbdev_gpt_fn_table,
|
||||
&gpt_if, &vbdev_gpt_fn_table,
|
||||
&g_gpt_disks, spdk_gpt_base_free,
|
||||
sizeof(struct gpt_channel), NULL, NULL);
|
||||
if (rc) {
|
||||
@ -306,7 +315,7 @@ end:
|
||||
* Notify the generic bdev layer that the actions related to the original examine
|
||||
* callback are now completed.
|
||||
*/
|
||||
spdk_bdev_module_examine_done(SPDK_GET_BDEV_MODULE(gpt));
|
||||
spdk_bdev_module_examine_done(&gpt_if);
|
||||
|
||||
if (gpt_base->part_base.ref == 0) {
|
||||
/* If no gpt_disk instances were created, free the base context */
|
||||
@ -364,17 +373,15 @@ vbdev_gpt_examine(struct spdk_bdev *bdev)
|
||||
int rc;
|
||||
|
||||
if (g_gpt_disabled) {
|
||||
spdk_bdev_module_examine_done(SPDK_GET_BDEV_MODULE(gpt));
|
||||
spdk_bdev_module_examine_done(&gpt_if);
|
||||
return;
|
||||
}
|
||||
|
||||
rc = vbdev_gpt_read_gpt(bdev);
|
||||
if (rc) {
|
||||
spdk_bdev_module_examine_done(SPDK_GET_BDEV_MODULE(gpt));
|
||||
spdk_bdev_module_examine_done(&gpt_if);
|
||||
SPDK_ERRLOG("Failed to read info from bdev %s\n", spdk_bdev_get_name(bdev));
|
||||
}
|
||||
}
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(gpt, vbdev_gpt_init, NULL, NULL,
|
||||
NULL, vbdev_gpt_examine)
|
||||
SPDK_LOG_REGISTER_COMPONENT("vbdev_gpt", SPDK_LOG_VBDEV_GPT)
|
||||
|
@ -40,11 +40,23 @@
|
||||
|
||||
#include "vbdev_lvol.h"
|
||||
|
||||
SPDK_DECLARE_BDEV_MODULE(lvol);
|
||||
|
||||
static TAILQ_HEAD(, lvol_store_bdev) g_spdk_lvol_pairs = TAILQ_HEAD_INITIALIZER(
|
||||
g_spdk_lvol_pairs);
|
||||
|
||||
static int vbdev_lvs_init(void);
|
||||
static int vbdev_lvs_get_ctx_size(void);
|
||||
static void vbdev_lvs_examine(struct spdk_bdev *bdev);
|
||||
|
||||
static struct spdk_bdev_module_if g_lvol_if = {
|
||||
.name = "lvol",
|
||||
.module_init = vbdev_lvs_init,
|
||||
.examine = vbdev_lvs_examine,
|
||||
.get_ctx_size = vbdev_lvs_get_ctx_size,
|
||||
|
||||
};
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(&g_lvol_if)
|
||||
|
||||
struct lvol_store_bdev *
|
||||
vbdev_get_lvs_bdev_by_lvs(struct spdk_lvol_store *lvs_orig)
|
||||
{
|
||||
@ -163,7 +175,7 @@ _vbdev_lvs_create_cb(void *cb_arg, struct spdk_lvol_store *lvs, int lvserrno)
|
||||
goto end;
|
||||
}
|
||||
|
||||
lvserrno = spdk_bs_bdev_claim(bs_dev, SPDK_GET_BDEV_MODULE(lvol));
|
||||
lvserrno = spdk_bs_bdev_claim(bs_dev, &g_lvol_if);
|
||||
if (lvserrno != 0) {
|
||||
SPDK_INFOLOG(SPDK_LOG_VBDEV_LVOL, "Lvol store base bdev already claimed by another bdev\n");
|
||||
req->bs_dev->destroy(req->bs_dev);
|
||||
@ -502,7 +514,7 @@ _vbdev_lvol_close_cb(void *cb_arg, int lvserrno)
|
||||
|
||||
if (lvs->lvols_opened >= lvs->lvol_count) {
|
||||
SPDK_INFOLOG(SPDK_LOG_VBDEV_LVOL, "Opening lvols finished\n");
|
||||
spdk_bdev_module_examine_done(SPDK_GET_BDEV_MODULE(lvol));
|
||||
spdk_bdev_module_examine_done(&g_lvol_if);
|
||||
}
|
||||
}
|
||||
|
||||
@ -800,7 +812,7 @@ _create_lvol_disk(struct spdk_lvol *lvol)
|
||||
|
||||
bdev->ctxt = lvol;
|
||||
bdev->fn_table = &vbdev_lvol_fn_table;
|
||||
bdev->module = SPDK_GET_BDEV_MODULE(lvol);
|
||||
bdev->module = &g_lvol_if;
|
||||
|
||||
rc = spdk_vbdev_register(bdev, &lvs_bdev->bdev, 1);
|
||||
if (rc) {
|
||||
@ -1014,7 +1026,7 @@ end:
|
||||
|
||||
if (lvs->lvols_opened >= lvs->lvol_count) {
|
||||
SPDK_INFOLOG(SPDK_LOG_VBDEV_LVOL, "Opening lvols finished\n");
|
||||
spdk_bdev_module_examine_done(SPDK_GET_BDEV_MODULE(lvol));
|
||||
spdk_bdev_module_examine_done(&g_lvol_if);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1029,26 +1041,26 @@ _vbdev_lvs_examine_cb(void *arg, struct spdk_lvol_store *lvol_store, int lvserrn
|
||||
SPDK_INFOLOG(SPDK_LOG_VBDEV_LVOL,
|
||||
"Name for lvolstore on device %s conflicts with name for already loaded lvs\n",
|
||||
req->base_bdev->name);
|
||||
spdk_bdev_module_examine_done(SPDK_GET_BDEV_MODULE(lvol));
|
||||
spdk_bdev_module_examine_done(&g_lvol_if);
|
||||
goto end;
|
||||
} else if (lvserrno != 0) {
|
||||
SPDK_INFOLOG(SPDK_LOG_VBDEV_LVOL, "Lvol store not found on %s\n", req->base_bdev->name);
|
||||
spdk_bdev_module_examine_done(SPDK_GET_BDEV_MODULE(lvol));
|
||||
spdk_bdev_module_examine_done(&g_lvol_if);
|
||||
goto end;
|
||||
}
|
||||
|
||||
lvserrno = spdk_bs_bdev_claim(lvol_store->bs_dev, SPDK_GET_BDEV_MODULE(lvol));
|
||||
lvserrno = spdk_bs_bdev_claim(lvol_store->bs_dev, &g_lvol_if);
|
||||
if (lvserrno != 0) {
|
||||
SPDK_INFOLOG(SPDK_LOG_VBDEV_LVOL, "Lvol store base bdev already claimed by another bdev\n");
|
||||
lvol_store->bs_dev->destroy(lvol_store->bs_dev);
|
||||
spdk_bdev_module_examine_done(SPDK_GET_BDEV_MODULE(lvol));
|
||||
spdk_bdev_module_examine_done(&g_lvol_if);
|
||||
goto end;
|
||||
}
|
||||
|
||||
lvs_bdev = calloc(1, sizeof(*lvs_bdev));
|
||||
if (!lvs_bdev) {
|
||||
SPDK_ERRLOG("Cannot alloc memory for lvs_bdev\n");
|
||||
spdk_bdev_module_examine_done(SPDK_GET_BDEV_MODULE(lvol));
|
||||
spdk_bdev_module_examine_done(&g_lvol_if);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@ -1064,7 +1076,7 @@ _vbdev_lvs_examine_cb(void *arg, struct spdk_lvol_store *lvol_store, int lvserrn
|
||||
|
||||
if (TAILQ_EMPTY(&lvol_store->lvols)) {
|
||||
SPDK_INFOLOG(SPDK_LOG_VBDEV_LVOL, "Lvol store examination done\n");
|
||||
spdk_bdev_module_examine_done(SPDK_GET_BDEV_MODULE(lvol));
|
||||
spdk_bdev_module_examine_done(&g_lvol_if);
|
||||
} else {
|
||||
/* Open all lvols */
|
||||
TAILQ_FOREACH_SAFE(lvol, &lvol_store->lvols, link, tmp) {
|
||||
@ -1084,7 +1096,7 @@ vbdev_lvs_examine(struct spdk_bdev *bdev)
|
||||
|
||||
req = calloc(1, sizeof(*req));
|
||||
if (req == NULL) {
|
||||
spdk_bdev_module_examine_done(SPDK_GET_BDEV_MODULE(lvol));
|
||||
spdk_bdev_module_examine_done(&g_lvol_if);
|
||||
SPDK_ERRLOG("Cannot alloc memory for vbdev lvol store request pointer\n");
|
||||
return;
|
||||
}
|
||||
@ -1092,7 +1104,7 @@ vbdev_lvs_examine(struct spdk_bdev *bdev)
|
||||
bs_dev = spdk_bdev_create_bs_dev(bdev, vbdev_lvs_hotremove_cb, bdev);
|
||||
if (!bs_dev) {
|
||||
SPDK_INFOLOG(SPDK_LOG_VBDEV_LVOL, "Cannot create bs dev on %s\n", bdev->name);
|
||||
spdk_bdev_module_examine_done(SPDK_GET_BDEV_MODULE(lvol));
|
||||
spdk_bdev_module_examine_done(&g_lvol_if);
|
||||
free(req);
|
||||
return;
|
||||
}
|
||||
@ -1105,7 +1117,7 @@ vbdev_lvs_examine(struct spdk_bdev *bdev)
|
||||
struct spdk_lvol *
|
||||
vbdev_lvol_get_from_bdev(struct spdk_bdev *bdev)
|
||||
{
|
||||
if (!bdev || bdev->module != SPDK_GET_BDEV_MODULE(lvol)) {
|
||||
if (!bdev || bdev->module != &g_lvol_if) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -1117,6 +1129,4 @@ vbdev_lvol_get_from_bdev(struct spdk_bdev *bdev)
|
||||
return (struct spdk_lvol *)bdev->ctxt;
|
||||
}
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(lvol, vbdev_lvs_init, NULL, NULL, vbdev_lvs_get_ctx_size,
|
||||
vbdev_lvs_examine)
|
||||
SPDK_LOG_REGISTER_COMPONENT("vbdev_lvol", SPDK_LOG_VBDEV_LVOL);
|
||||
|
@ -101,8 +101,15 @@ bdev_malloc_get_ctx_size(void)
|
||||
return sizeof(struct malloc_task) + spdk_copy_task_size();
|
||||
}
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(malloc, bdev_malloc_initialize, NULL,
|
||||
bdev_malloc_get_spdk_running_config, bdev_malloc_get_ctx_size, NULL)
|
||||
static struct spdk_bdev_module_if malloc_if = {
|
||||
.name = "malloc",
|
||||
.module_init = bdev_malloc_initialize,
|
||||
.config_text = bdev_malloc_get_spdk_running_config,
|
||||
.get_ctx_size = bdev_malloc_get_ctx_size,
|
||||
|
||||
};
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(&malloc_if)
|
||||
|
||||
static void
|
||||
malloc_disk_free(struct malloc_disk *malloc_disk)
|
||||
@ -405,7 +412,7 @@ struct spdk_bdev *create_malloc_disk(const char *name, const struct spdk_uuid *u
|
||||
|
||||
mdisk->disk.ctxt = mdisk;
|
||||
mdisk->disk.fn_table = &malloc_fn_table;
|
||||
mdisk->disk.module = SPDK_GET_BDEV_MODULE(malloc);
|
||||
mdisk->disk.module = &malloc_if;
|
||||
|
||||
rc = spdk_bdev_register(&mdisk->disk);
|
||||
if (rc) {
|
||||
|
@ -43,8 +43,6 @@
|
||||
|
||||
#include "bdev_null.h"
|
||||
|
||||
SPDK_DECLARE_BDEV_MODULE(null);
|
||||
|
||||
struct null_bdev {
|
||||
struct spdk_bdev bdev;
|
||||
TAILQ_ENTRY(null_bdev) tailq;
|
||||
@ -58,6 +56,19 @@ struct null_io_channel {
|
||||
static TAILQ_HEAD(, null_bdev) g_null_bdev_head;
|
||||
static void *g_null_read_buf;
|
||||
|
||||
static int bdev_null_initialize(void);
|
||||
static void bdev_null_finish(void);
|
||||
static void bdev_null_get_spdk_running_config(FILE *fp);
|
||||
|
||||
static struct spdk_bdev_module_if null_if = {
|
||||
.name = "null",
|
||||
.module_init = bdev_null_initialize,
|
||||
.module_fini = bdev_null_finish,
|
||||
.config_text = bdev_null_get_spdk_running_config,
|
||||
};
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(&null_if)
|
||||
|
||||
static int
|
||||
bdev_null_destruct(void *ctx)
|
||||
{
|
||||
@ -167,7 +178,7 @@ create_null_bdev(const char *name, const struct spdk_uuid *uuid,
|
||||
|
||||
bdev->bdev.ctxt = bdev;
|
||||
bdev->bdev.fn_table = &null_fn_table;
|
||||
bdev->bdev.module = SPDK_GET_BDEV_MODULE(null);
|
||||
bdev->bdev.module = &null_if;
|
||||
|
||||
rc = spdk_bdev_register(&bdev->bdev);
|
||||
if (rc) {
|
||||
@ -326,7 +337,4 @@ bdev_null_get_spdk_running_config(FILE *fp)
|
||||
}
|
||||
}
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(null, bdev_null_initialize, bdev_null_finish,
|
||||
bdev_null_get_spdk_running_config, NULL, NULL)
|
||||
|
||||
SPDK_LOG_REGISTER_COMPONENT("bdev_null", SPDK_LOG_BDEV_NULL)
|
||||
|
@ -158,9 +158,15 @@ bdev_nvme_get_ctx_size(void)
|
||||
return sizeof(struct nvme_bdev_io);
|
||||
}
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(nvme, bdev_nvme_library_init, bdev_nvme_library_fini,
|
||||
bdev_nvme_get_spdk_running_config,
|
||||
bdev_nvme_get_ctx_size, NULL)
|
||||
static struct spdk_bdev_module_if nvme_if = {
|
||||
.name = "nvme",
|
||||
.module_init = bdev_nvme_library_init,
|
||||
.module_fini = bdev_nvme_library_fini,
|
||||
.config_text = bdev_nvme_get_spdk_running_config,
|
||||
.get_ctx_size = bdev_nvme_get_ctx_size,
|
||||
|
||||
};
|
||||
SPDK_BDEV_MODULE_REGISTER(&nvme_if)
|
||||
|
||||
static int
|
||||
bdev_nvme_readv(struct nvme_bdev *nbdev, struct spdk_io_channel *ch,
|
||||
@ -1138,7 +1144,7 @@ nvme_ctrlr_create_bdevs(struct nvme_ctrlr *nvme_ctrlr)
|
||||
bdev->disk.optimal_io_boundary = spdk_nvme_ns_get_optimal_io_boundary(ns);
|
||||
bdev->disk.ctxt = bdev;
|
||||
bdev->disk.fn_table = &nvmelib_fn_table;
|
||||
bdev->disk.module = SPDK_GET_BDEV_MODULE(nvme);
|
||||
bdev->disk.module = &nvme_if;
|
||||
rc = spdk_bdev_register(&bdev->disk);
|
||||
if (rc) {
|
||||
free(bdev->disk.name);
|
||||
@ -1445,7 +1451,7 @@ bdev_nvme_get_spdk_running_config(FILE *fp)
|
||||
struct spdk_nvme_ctrlr *
|
||||
spdk_bdev_nvme_get_ctrlr(struct spdk_bdev *bdev)
|
||||
{
|
||||
if (!bdev || bdev->module != SPDK_GET_BDEV_MODULE(nvme)) {
|
||||
if (!bdev || bdev->module != &nvme_if) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -54,10 +54,15 @@ static TAILQ_HEAD(, pmem_disk) g_pmem_disks = TAILQ_HEAD_INITIALIZER(g_pmem_disk
|
||||
static int bdev_pmem_initialize(void);
|
||||
static void bdev_pmem_finish(void);
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(pmem, bdev_pmem_initialize, bdev_pmem_finish,
|
||||
NULL, NULL, NULL)
|
||||
SPDK_BDEV_MODULE_ASYNC_FINI(pmem);
|
||||
static struct spdk_bdev_module_if pmem_if = {
|
||||
.name = "pmem",
|
||||
.module_init = bdev_pmem_initialize,
|
||||
.module_fini = bdev_pmem_finish,
|
||||
.async_fini = true,
|
||||
|
||||
};
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(&pmem_if)
|
||||
|
||||
typedef int(*spdk_bdev_pmem_io_request)(PMEMblkpool *pbp, void *buf, long long blockno);
|
||||
|
||||
@ -345,7 +350,7 @@ spdk_create_pmem_disk(const char *pmem_file, const char *name, struct spdk_bdev
|
||||
|
||||
pdisk->disk.ctxt = pdisk;
|
||||
pdisk->disk.fn_table = &pmem_fn_table;
|
||||
pdisk->disk.module = SPDK_GET_BDEV_MODULE(pmem);
|
||||
pdisk->disk.module = &pmem_if;
|
||||
|
||||
rc = spdk_bdev_register(&pdisk->disk);
|
||||
if (rc) {
|
||||
|
@ -214,8 +214,13 @@ bdev_rbd_get_ctx_size(void)
|
||||
return sizeof(struct bdev_rbd_io);
|
||||
}
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(rbd, bdev_rbd_library_init, NULL, NULL,
|
||||
bdev_rbd_get_ctx_size, NULL)
|
||||
static struct spdk_bdev_module_if rbd_if = {
|
||||
.name = "rbd",
|
||||
.module_init = bdev_rbd_library_init,
|
||||
.get_ctx_size = bdev_rbd_get_ctx_size,
|
||||
|
||||
};
|
||||
SPDK_BDEV_MODULE_REGISTER(&rbd_if)
|
||||
|
||||
static int64_t
|
||||
bdev_rbd_rw(struct bdev_rbd *disk, struct spdk_io_channel *ch,
|
||||
@ -604,7 +609,7 @@ spdk_bdev_rbd_create(const char *pool_name, const char *rbd_name, uint32_t block
|
||||
rbd->disk.blockcnt = rbd->info.size / rbd->disk.blocklen;
|
||||
rbd->disk.ctxt = rbd;
|
||||
rbd->disk.fn_table = &rbd_fn_table;
|
||||
rbd->disk.module = SPDK_GET_BDEV_MODULE(rbd);
|
||||
rbd->disk.module = &rbd_if;
|
||||
|
||||
SPDK_NOTICELOG("Add %s rbd disk to lun\n", rbd->disk.name);
|
||||
|
||||
|
@ -48,14 +48,23 @@
|
||||
#include "spdk_internal/bdev.h"
|
||||
#include "spdk_internal/log.h"
|
||||
|
||||
SPDK_DECLARE_BDEV_MODULE(split);
|
||||
|
||||
static SPDK_BDEV_PART_TAILQ g_split_disks = TAILQ_HEAD_INITIALIZER(g_split_disks);
|
||||
|
||||
struct vbdev_split_channel {
|
||||
struct spdk_bdev_part_channel part_ch;
|
||||
};
|
||||
|
||||
static int vbdev_split_init(void);
|
||||
static void vbdev_split_examine(struct spdk_bdev *bdev);
|
||||
|
||||
static struct spdk_bdev_module_if split_if = {
|
||||
.name = "split",
|
||||
.module_init = vbdev_split_init,
|
||||
.examine = vbdev_split_examine,
|
||||
};
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(&split_if)
|
||||
|
||||
static void
|
||||
vbdev_split_base_free(struct spdk_bdev_part_base *base)
|
||||
{
|
||||
@ -156,7 +165,7 @@ vbdev_split_create(struct spdk_bdev *base_bdev, uint64_t split_count, uint64_t s
|
||||
|
||||
rc = spdk_bdev_part_base_construct(split_base, base_bdev,
|
||||
vbdev_split_base_bdev_hotremove_cb,
|
||||
SPDK_GET_BDEV_MODULE(split), &vbdev_split_fn_table,
|
||||
&split_if, &vbdev_split_fn_table,
|
||||
&g_split_disks, vbdev_split_base_free,
|
||||
sizeof(struct vbdev_split_channel), NULL, NULL);
|
||||
if (rc) {
|
||||
@ -213,7 +222,7 @@ vbdev_split_examine(struct spdk_bdev *bdev)
|
||||
|
||||
sp = spdk_conf_find_section(NULL, "Split");
|
||||
if (sp == NULL) {
|
||||
spdk_bdev_module_examine_done(SPDK_GET_BDEV_MODULE(split));
|
||||
spdk_bdev_module_examine_done(&split_if);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -261,10 +270,7 @@ vbdev_split_examine(struct spdk_bdev *bdev)
|
||||
}
|
||||
}
|
||||
|
||||
spdk_bdev_module_examine_done(SPDK_GET_BDEV_MODULE(split));
|
||||
spdk_bdev_module_examine_done(&split_if);
|
||||
}
|
||||
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(split, vbdev_split_init, NULL, NULL,
|
||||
NULL, vbdev_split_examine)
|
||||
SPDK_LOG_REGISTER_COMPONENT("vbdev_split", SPDK_LOG_VBDEV_SPLIT)
|
||||
|
@ -79,7 +79,16 @@ struct bdev_virtio_blk_io_channel {
|
||||
1ULL << VIRTIO_BLK_F_TOPOLOGY | \
|
||||
1ULL << VIRTIO_BLK_F_MQ)
|
||||
|
||||
SPDK_DECLARE_BDEV_MODULE(virtio_blk);
|
||||
static int bdev_virtio_initialize(void);
|
||||
static int bdev_virtio_blk_get_ctx_size(void);
|
||||
|
||||
static struct spdk_bdev_module_if virtio_blk_if = {
|
||||
.name = "virtio_blk",
|
||||
.module_init = bdev_virtio_initialize,
|
||||
.get_ctx_size = bdev_virtio_blk_get_ctx_size,
|
||||
};
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(&virtio_blk_if)
|
||||
|
||||
static int bdev_virtio_blk_ch_create_cb(void *io_device, void *ctx_buf);
|
||||
static void bdev_virtio_blk_ch_destroy_cb(void *io_device, void *ctx_buf);
|
||||
@ -374,7 +383,7 @@ virtio_blk_dev_init(struct virtio_blk_dev *bvdev, uint16_t max_queues)
|
||||
|
||||
bdev->ctxt = bvdev;
|
||||
bdev->fn_table = &virtio_fn_table;
|
||||
bdev->module = SPDK_GET_BDEV_MODULE(virtio_blk);
|
||||
bdev->module = &virtio_blk_if;
|
||||
|
||||
spdk_io_device_register(bvdev, bdev_virtio_blk_ch_create_cb,
|
||||
bdev_virtio_blk_ch_destroy_cb,
|
||||
@ -619,7 +628,4 @@ bdev_virtio_blk_get_ctx_size(void)
|
||||
return sizeof(struct virtio_blk_io_ctx);
|
||||
}
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(virtio_blk, bdev_virtio_initialize, NULL,
|
||||
NULL, bdev_virtio_blk_get_ctx_size, NULL)
|
||||
|
||||
SPDK_LOG_REGISTER_COMPONENT("virtio_blk", SPDK_LOG_VIRTIO_BLK)
|
||||
|
@ -399,11 +399,16 @@ bdev_virtio_get_ctx_size(void)
|
||||
return sizeof(struct virtio_scsi_io_ctx);
|
||||
}
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(virtio_scsi, bdev_virtio_initialize, bdev_virtio_finish,
|
||||
NULL, bdev_virtio_get_ctx_size, NULL)
|
||||
static struct spdk_bdev_module_if virtio_scsi_if = {
|
||||
.name = "virtio_scsi",
|
||||
.module_init = bdev_virtio_initialize,
|
||||
.module_fini = bdev_virtio_finish,
|
||||
.get_ctx_size = bdev_virtio_get_ctx_size,
|
||||
.async_init = true,
|
||||
.async_fini = true,
|
||||
};
|
||||
|
||||
SPDK_BDEV_MODULE_ASYNC_INIT(virtio_scsi)
|
||||
SPDK_BDEV_MODULE_ASYNC_FINI(virtio_scsi);
|
||||
SPDK_BDEV_MODULE_REGISTER(&virtio_scsi_if)
|
||||
|
||||
static struct virtio_scsi_dev *
|
||||
virtio_dev_to_scsi(struct virtio_dev *vdev)
|
||||
@ -1271,7 +1276,7 @@ virtio_scsi_dev_add_tgt(struct virtio_scsi_dev *svdev, struct virtio_scsi_scan_i
|
||||
|
||||
bdev->ctxt = disk;
|
||||
bdev->fn_table = &virtio_fn_table;
|
||||
bdev->module = SPDK_GET_BDEV_MODULE(virtio_scsi);
|
||||
bdev->module = &virtio_scsi_if;
|
||||
|
||||
rc = spdk_bdev_register(&disk->bdev);
|
||||
if (rc) {
|
||||
@ -1667,7 +1672,7 @@ bdev_virtio_initial_scan_complete(void *ctx __attribute__((unused)),
|
||||
}
|
||||
}
|
||||
|
||||
spdk_bdev_module_init_done(SPDK_GET_BDEV_MODULE(virtio_scsi));
|
||||
spdk_bdev_module_init_done(&virtio_scsi_if);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1683,7 +1688,7 @@ bdev_virtio_initialize(void)
|
||||
}
|
||||
|
||||
if (TAILQ_EMPTY(&g_virtio_driver.scsi_devs)) {
|
||||
spdk_bdev_module_init_done(SPDK_GET_BDEV_MODULE(virtio_scsi));
|
||||
spdk_bdev_module_init_done(&virtio_scsi_if);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1706,7 +1711,7 @@ out:
|
||||
virtio_scsi_dev_remove(svdev, NULL, NULL);
|
||||
}
|
||||
|
||||
spdk_bdev_module_init_done(SPDK_GET_BDEV_MODULE(virtio_scsi));
|
||||
spdk_bdev_module_init_done(&virtio_scsi_if);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -40,8 +40,6 @@
|
||||
|
||||
#include "bdev/bdev.c"
|
||||
|
||||
SPDK_DECLARE_BDEV_MODULE(vbdev_ut);
|
||||
|
||||
void
|
||||
spdk_scsi_nvme_translate(const struct spdk_bdev_io *bdev_io,
|
||||
int *sc, int *sk, int *asc, int *ascq)
|
||||
@ -70,15 +68,26 @@ static struct spdk_bdev_fn_table fn_table = {
|
||||
.destruct = stub_destruct,
|
||||
};
|
||||
|
||||
struct spdk_bdev_module_if bdev_ut_if = {
|
||||
.name = "bdev_ut",
|
||||
};
|
||||
|
||||
static void vbdev_ut_examine(struct spdk_bdev *bdev);
|
||||
|
||||
struct spdk_bdev_module_if vbdev_ut_if = {
|
||||
.name = "vbdev_ut",
|
||||
.examine = vbdev_ut_examine,
|
||||
};
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(&bdev_ut_if)
|
||||
SPDK_BDEV_MODULE_REGISTER(&vbdev_ut_if)
|
||||
|
||||
static void
|
||||
vbdev_ut_examine(struct spdk_bdev *bdev)
|
||||
{
|
||||
spdk_bdev_module_examine_done(SPDK_GET_BDEV_MODULE(vbdev_ut));
|
||||
spdk_bdev_module_examine_done(&vbdev_ut_if);
|
||||
}
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(bdev_ut, NULL, NULL, NULL, NULL, NULL)
|
||||
SPDK_BDEV_MODULE_REGISTER(vbdev_ut, NULL, NULL, NULL, NULL, vbdev_ut_examine)
|
||||
|
||||
static struct spdk_bdev *
|
||||
allocate_bdev(char *name)
|
||||
{
|
||||
@ -90,7 +99,7 @@ allocate_bdev(char *name)
|
||||
|
||||
bdev->name = name;
|
||||
bdev->fn_table = &fn_table;
|
||||
bdev->module = SPDK_GET_BDEV_MODULE(bdev_ut);
|
||||
bdev->module = &bdev_ut_if;
|
||||
|
||||
rc = spdk_bdev_register(bdev);
|
||||
CU_ASSERT(rc == 0);
|
||||
@ -112,7 +121,7 @@ allocate_vbdev(char *name, struct spdk_bdev *base1, struct spdk_bdev *base2)
|
||||
|
||||
bdev->name = name;
|
||||
bdev->fn_table = &fn_table;
|
||||
bdev->module = SPDK_GET_BDEV_MODULE(vbdev_ut);
|
||||
bdev->module = &vbdev_ut_if;
|
||||
|
||||
/* vbdev must have at least one base bdev */
|
||||
CU_ASSERT(base1 != NULL);
|
||||
@ -177,23 +186,23 @@ open_write_test(void)
|
||||
*/
|
||||
|
||||
bdev[0] = allocate_bdev("bdev0");
|
||||
rc = spdk_bdev_module_claim_bdev(bdev[0], NULL, SPDK_GET_BDEV_MODULE(bdev_ut));
|
||||
rc = spdk_bdev_module_claim_bdev(bdev[0], NULL, &bdev_ut_if);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
bdev[1] = allocate_bdev("bdev1");
|
||||
rc = spdk_bdev_module_claim_bdev(bdev[1], NULL, SPDK_GET_BDEV_MODULE(bdev_ut));
|
||||
rc = spdk_bdev_module_claim_bdev(bdev[1], NULL, &bdev_ut_if);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
bdev[2] = allocate_bdev("bdev2");
|
||||
rc = spdk_bdev_module_claim_bdev(bdev[2], NULL, SPDK_GET_BDEV_MODULE(bdev_ut));
|
||||
rc = spdk_bdev_module_claim_bdev(bdev[2], NULL, &bdev_ut_if);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
bdev[3] = allocate_vbdev("bdev3", bdev[0], bdev[1]);
|
||||
rc = spdk_bdev_module_claim_bdev(bdev[3], NULL, SPDK_GET_BDEV_MODULE(bdev_ut));
|
||||
rc = spdk_bdev_module_claim_bdev(bdev[3], NULL, &bdev_ut_if);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
bdev[4] = allocate_vbdev("bdev4", bdev[2], NULL);
|
||||
rc = spdk_bdev_module_claim_bdev(bdev[4], NULL, SPDK_GET_BDEV_MODULE(bdev_ut));
|
||||
rc = spdk_bdev_module_claim_bdev(bdev[4], NULL, &bdev_ut_if);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
bdev[5] = allocate_vbdev("bdev5", bdev[2], NULL);
|
||||
@ -295,7 +304,7 @@ num_blocks_test(void)
|
||||
memset(&bdev, 0, sizeof(bdev));
|
||||
bdev.name = "num_blocks";
|
||||
bdev.fn_table = &fn_table;
|
||||
bdev.module = SPDK_GET_BDEV_MODULE(bdev_ut);
|
||||
bdev.module = &bdev_ut_if;
|
||||
spdk_bdev_register(&bdev);
|
||||
spdk_bdev_notify_blockcnt_change(&bdev, 50);
|
||||
|
||||
|
@ -176,7 +176,13 @@ module_fini(void)
|
||||
{
|
||||
}
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(bdev_ut, module_init, module_fini, NULL, NULL, NULL)
|
||||
struct spdk_bdev_module_if bdev_ut_if = {
|
||||
.name = "bdev_ut",
|
||||
.module_init = module_init,
|
||||
.module_fini = module_fini,
|
||||
};
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(&bdev_ut_if)
|
||||
|
||||
static void
|
||||
register_bdev(struct ut_bdev *ut_bdev, char *name, void *io_target)
|
||||
@ -187,7 +193,7 @@ register_bdev(struct ut_bdev *ut_bdev, char *name, void *io_target)
|
||||
ut_bdev->bdev.ctxt = ut_bdev;
|
||||
ut_bdev->bdev.name = name;
|
||||
ut_bdev->bdev.fn_table = &fn_table;
|
||||
ut_bdev->bdev.module = SPDK_GET_BDEV_MODULE(bdev_ut);
|
||||
ut_bdev->bdev.module = &bdev_ut_if;
|
||||
ut_bdev->bdev.blocklen = 4096;
|
||||
ut_bdev->bdev.blockcnt = 1024;
|
||||
|
||||
|
@ -47,17 +47,26 @@ spdk_scsi_nvme_translate(const struct spdk_bdev_io *bdev_io,
|
||||
{
|
||||
}
|
||||
|
||||
SPDK_DECLARE_BDEV_MODULE(vbdev_ut);
|
||||
struct spdk_bdev_module_if bdev_ut_if = {
|
||||
.name = "bdev_ut",
|
||||
};
|
||||
|
||||
static void vbdev_ut_examine(struct spdk_bdev *bdev);
|
||||
|
||||
struct spdk_bdev_module_if vbdev_ut_if = {
|
||||
.name = "vbdev_ut",
|
||||
.examine = vbdev_ut_examine,
|
||||
};
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(&bdev_ut_if)
|
||||
SPDK_BDEV_MODULE_REGISTER(&vbdev_ut_if)
|
||||
|
||||
static void
|
||||
vbdev_ut_examine(struct spdk_bdev *bdev)
|
||||
{
|
||||
spdk_bdev_module_examine_done(SPDK_GET_BDEV_MODULE(vbdev_ut));
|
||||
spdk_bdev_module_examine_done(&vbdev_ut_if);
|
||||
}
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(bdev_ut, NULL, NULL, NULL, NULL, NULL)
|
||||
SPDK_BDEV_MODULE_REGISTER(vbdev_ut, NULL, NULL, NULL, NULL, vbdev_ut_examine)
|
||||
|
||||
static int
|
||||
__destruct(void *ctx)
|
||||
{
|
||||
@ -91,10 +100,10 @@ part_test(void)
|
||||
|
||||
bdev_base.name = "base";
|
||||
bdev_base.fn_table = &base_fn_table;
|
||||
bdev_base.module = SPDK_GET_BDEV_MODULE(bdev_ut);
|
||||
bdev_base.module = &bdev_ut_if;
|
||||
rc = spdk_bdev_register(&bdev_base);
|
||||
CU_ASSERT(rc == 0);
|
||||
spdk_bdev_part_base_construct(base, &bdev_base, NULL, SPDK_GET_BDEV_MODULE(vbdev_ut),
|
||||
spdk_bdev_part_base_construct(base, &bdev_base, NULL, &vbdev_ut_if,
|
||||
&part_fn_table, &tailq, __base_free, 0, NULL, NULL);
|
||||
|
||||
spdk_bdev_part_construct(&part1, base, "test1", 0, 100, "test");
|
||||
|
Loading…
Reference in New Issue
Block a user