bdev/zone: Use spdk_bdev_open_ext() instead of spdk_bdev_open()
This is just a drop-in replacement. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I018ef60648122aa672430bb62dc7b1a2e1cd5d7c Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4648 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
bd190d88b3
commit
7a85820db3
@ -591,10 +591,9 @@ static const struct spdk_bdev_fn_table zone_block_fn_table = {
|
||||
};
|
||||
|
||||
static void
|
||||
zone_block_base_bdev_hotremove_cb(void *ctx)
|
||||
zone_block_base_bdev_hotremove_cb(struct spdk_bdev *bdev_find)
|
||||
{
|
||||
struct bdev_zone_block *bdev_node, *tmp;
|
||||
struct spdk_bdev *bdev_find = ctx;
|
||||
|
||||
TAILQ_FOREACH_SAFE(bdev_node, &g_bdev_nodes, link, tmp) {
|
||||
if (bdev_find == spdk_bdev_desc_get_bdev(bdev_node->base_desc)) {
|
||||
@ -603,6 +602,20 @@ zone_block_base_bdev_hotremove_cb(void *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
zone_block_base_bdev_event_cb(enum spdk_bdev_event_type type, struct spdk_bdev *bdev,
|
||||
void *event_ctx)
|
||||
{
|
||||
switch (type) {
|
||||
case SPDK_BDEV_EVENT_REMOVE:
|
||||
zone_block_base_bdev_hotremove_cb(bdev);
|
||||
break;
|
||||
default:
|
||||
SPDK_NOTICELOG("Unsupported bdev event: type %d\n", type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_zone_block_ch_create_cb(void *io_device, void *ctx_buf)
|
||||
{
|
||||
@ -803,8 +816,8 @@ zone_block_register(struct spdk_bdev *base_bdev)
|
||||
sizeof(struct zone_block_io_channel),
|
||||
name->vbdev_name);
|
||||
|
||||
rc = spdk_bdev_open(base_bdev, true, zone_block_base_bdev_hotremove_cb,
|
||||
base_bdev, &bdev_node->base_desc);
|
||||
rc = spdk_bdev_open_ext(spdk_bdev_get_name(base_bdev), true, zone_block_base_bdev_event_cb,
|
||||
NULL, &bdev_node->base_desc);
|
||||
if (rc) {
|
||||
SPDK_ERRLOG("could not open bdev %s\n", spdk_bdev_get_name(base_bdev));
|
||||
goto open_failed;
|
||||
|
@ -206,8 +206,8 @@ bdev_channel_get_io(struct spdk_bdev_channel *channel)
|
||||
}
|
||||
|
||||
int
|
||||
spdk_bdev_open(struct spdk_bdev *bdev, bool write, spdk_bdev_remove_cb_t remove_cb,
|
||||
void *remove_ctx, struct spdk_bdev_desc **_desc)
|
||||
spdk_bdev_open_ext(const char *bdev_name, bool write, spdk_bdev_event_cb_t event_cb,
|
||||
void *event_ctx, struct spdk_bdev_desc **_desc)
|
||||
{
|
||||
*_desc = (void *)0x1;
|
||||
return 0;
|
||||
@ -305,7 +305,7 @@ test_zone_get_operation(void)
|
||||
int rc; \
|
||||
memset(&bdev, 0, sizeof(bdev)); \
|
||||
bdev.name = "bdev_zone_ut"; \
|
||||
rc = spdk_bdev_open(&bdev, true, NULL, NULL, &desc); \
|
||||
rc = spdk_bdev_open_ext(bdev.name, true, NULL, NULL, &desc); \
|
||||
CU_ASSERT(rc == 0); \
|
||||
SPDK_CU_ASSERT_FATAL(desc != NULL); \
|
||||
ch = spdk_bdev_get_io_channel(desc); \
|
||||
|
@ -116,11 +116,19 @@ spdk_bdev_free_io(struct spdk_bdev_io *bdev_io)
|
||||
}
|
||||
|
||||
int
|
||||
spdk_bdev_open(struct spdk_bdev *bdev, bool write, spdk_bdev_remove_cb_t remove_cb,
|
||||
void *remove_ctx, struct spdk_bdev_desc **_desc)
|
||||
spdk_bdev_open_ext(const char *bdev_name, bool write, spdk_bdev_event_cb_t event_cb,
|
||||
void *event_ctx, struct spdk_bdev_desc **_desc)
|
||||
{
|
||||
*_desc = (void *)bdev;
|
||||
return 0;
|
||||
struct spdk_bdev *bdev;
|
||||
|
||||
TAILQ_FOREACH(bdev, &g_bdev_list, internal.link) {
|
||||
if (strcmp(bdev_name, bdev->name) == 0) {
|
||||
*_desc = (void *)bdev;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
struct spdk_bdev *
|
||||
|
Loading…
Reference in New Issue
Block a user