bdev/raid: Use spdk_bdev_open_ext() instead of spdk_bdev_open()
This is a drop-in replacement. Update unit test together, and the idea of the update was from the unit test for zone bdev module. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: Ia8d0644f42b9d0a0ad502eebbe3e414abd1de4cf Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4591 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> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
parent
491e6c4309
commit
d8a1892422
@ -97,7 +97,8 @@ static void raid_bdev_examine(struct spdk_bdev *bdev);
|
|||||||
static int raid_bdev_init(void);
|
static int raid_bdev_init(void);
|
||||||
static void raid_bdev_deconfigure(struct raid_bdev *raid_bdev,
|
static void raid_bdev_deconfigure(struct raid_bdev *raid_bdev,
|
||||||
raid_bdev_destruct_cb cb_fn, void *cb_arg);
|
raid_bdev_destruct_cb cb_fn, void *cb_arg);
|
||||||
static void raid_bdev_remove_base_bdev(void *ctx);
|
static void raid_bdev_event_base_bdev(enum spdk_bdev_event_type type, struct spdk_bdev *bdev,
|
||||||
|
void *event_ctx);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* brief:
|
* brief:
|
||||||
@ -1316,7 +1317,7 @@ raid_bdev_alloc_base_bdev_resource(struct raid_bdev *raid_bdev, struct spdk_bdev
|
|||||||
struct spdk_bdev_desc *desc;
|
struct spdk_bdev_desc *desc;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = spdk_bdev_open(bdev, true, raid_bdev_remove_base_bdev, bdev, &desc);
|
rc = spdk_bdev_open_ext(bdev->name, true, raid_bdev_event_base_bdev, NULL, &desc);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
SPDK_ERRLOG("Unable to create desc on bdev '%s'\n", bdev->name);
|
SPDK_ERRLOG("Unable to create desc on bdev '%s'\n", bdev->name);
|
||||||
return rc;
|
return rc;
|
||||||
@ -1495,14 +1496,13 @@ raid_bdev_find_by_base_bdev(struct spdk_bdev *base_bdev, struct raid_bdev **_rai
|
|||||||
* is removed. This function checks if this base bdev is part of any raid bdev
|
* is removed. This function checks if this base bdev is part of any raid bdev
|
||||||
* or not. If yes, it takes necessary action on that particular raid bdev.
|
* or not. If yes, it takes necessary action on that particular raid bdev.
|
||||||
* params:
|
* params:
|
||||||
* ctx - pointer to base bdev pointer which got removed
|
* base_bdev - pointer to base bdev pointer which got removed
|
||||||
* returns:
|
* returns:
|
||||||
* none
|
* none
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
raid_bdev_remove_base_bdev(void *ctx)
|
raid_bdev_remove_base_bdev(struct spdk_bdev *base_bdev)
|
||||||
{
|
{
|
||||||
struct spdk_bdev *base_bdev = ctx;
|
|
||||||
struct raid_bdev *raid_bdev = NULL;
|
struct raid_bdev *raid_bdev = NULL;
|
||||||
struct raid_base_bdev_info *base_info;
|
struct raid_base_bdev_info *base_info;
|
||||||
|
|
||||||
@ -1534,6 +1534,31 @@ raid_bdev_remove_base_bdev(void *ctx)
|
|||||||
raid_bdev_deconfigure(raid_bdev, NULL, NULL);
|
raid_bdev_deconfigure(raid_bdev, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* brief:
|
||||||
|
* raid_bdev_event_base_bdev function is called by below layers when base_bdev
|
||||||
|
* triggers asynchronous event.
|
||||||
|
* params:
|
||||||
|
* type - event details.
|
||||||
|
* bdev - bdev that triggered event.
|
||||||
|
* event_ctx - context for event.
|
||||||
|
* returns:
|
||||||
|
* none
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
raid_bdev_event_base_bdev(enum spdk_bdev_event_type type, struct spdk_bdev *bdev,
|
||||||
|
void *event_ctx)
|
||||||
|
{
|
||||||
|
switch (type) {
|
||||||
|
case SPDK_BDEV_EVENT_REMOVE:
|
||||||
|
raid_bdev_remove_base_bdev(bdev);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
SPDK_NOTICELOG("Unsupported bdev event: type %d\n", type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* brief:
|
* brief:
|
||||||
* Remove base bdevs from the raid bdev one by one. Skip any base bdev which
|
* Remove base bdevs from the raid bdev one by one. Skip any base bdev which
|
||||||
|
@ -50,6 +50,10 @@ struct spdk_bdev_channel {
|
|||||||
struct spdk_io_channel *channel;
|
struct spdk_io_channel *channel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct spdk_bdev_desc {
|
||||||
|
struct spdk_bdev *bdev;
|
||||||
|
};
|
||||||
|
|
||||||
/* Data structure to capture the output of IO for verification */
|
/* Data structure to capture the output of IO for verification */
|
||||||
struct io_output {
|
struct io_output {
|
||||||
struct spdk_bdev_desc *desc;
|
struct spdk_bdev_desc *desc;
|
||||||
@ -363,13 +367,26 @@ spdk_bdev_unregister(struct spdk_bdev *bdev, spdk_bdev_unregister_cb cb_fn, void
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
spdk_bdev_open(struct spdk_bdev *bdev, bool write, spdk_bdev_remove_cb_t remove_cb,
|
spdk_bdev_open_ext(const char *bdev_name, bool write, spdk_bdev_event_cb_t event_cb,
|
||||||
void *remove_ctx, struct spdk_bdev_desc **_desc)
|
void *event_ctx, struct spdk_bdev_desc **_desc)
|
||||||
{
|
{
|
||||||
*_desc = (void *)0x1;
|
struct spdk_bdev *bdev;
|
||||||
|
|
||||||
|
bdev = spdk_bdev_get_by_name(bdev_name);
|
||||||
|
if (bdev == NULL) {
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
*_desc = (void *)bdev;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct spdk_bdev *
|
||||||
|
spdk_bdev_desc_get_bdev(struct spdk_bdev_desc *desc)
|
||||||
|
{
|
||||||
|
return (void *)desc;
|
||||||
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
spdk_sprintf_alloc(const char *format, ...)
|
spdk_sprintf_alloc(const char *format, ...)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user