gpt/split: implemented hotremove
Hotremove event was detected on base bdev, but wasn't propagated to vbdevs. This patch makes base bdev destroy all it's children once hotremove is triggered. This fixes hotremove segfaults and adds full support for split/gpt hotremove. Change-Id: I7f8b0b109ef237783b6b2e33a18f68c59a8bbe72 Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/367824 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
afe860aeb1
commit
8c3fadc282
@ -93,6 +93,19 @@ spdk_gpt_bdev_free(struct spdk_gpt_bdev *gpt_bdev)
|
||||
free(gpt_bdev);
|
||||
}
|
||||
|
||||
static void
|
||||
spdk_gpt_base_bdev_hotremove_cb(void *remove_ctx)
|
||||
{
|
||||
struct spdk_bdev *base_bdev = remove_ctx;
|
||||
struct gpt_partition_disk *gpt_partition_disk, *tmp;
|
||||
|
||||
TAILQ_FOREACH_SAFE(gpt_partition_disk, &g_gpt_partition_disks, tailq, tmp) {
|
||||
if (gpt_partition_disk->base_bdev == base_bdev) {
|
||||
spdk_bdev_unregister(&gpt_partition_disk->disk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static struct spdk_gpt_bdev *
|
||||
spdk_gpt_base_bdev_init(struct spdk_bdev *bdev)
|
||||
{
|
||||
@ -122,7 +135,8 @@ spdk_gpt_base_bdev_init(struct spdk_bdev *bdev)
|
||||
gpt->lba_start = 0;
|
||||
gpt->lba_end = gpt->total_sectors - 1;
|
||||
|
||||
rc = spdk_bdev_open(gpt_bdev->bdev, false, NULL, NULL, &gpt_bdev->bdev_desc);
|
||||
rc = spdk_bdev_open(gpt_bdev->bdev, false, spdk_gpt_base_bdev_hotremove_cb, bdev,
|
||||
&gpt_bdev->bdev_desc);
|
||||
if (rc != 0) {
|
||||
SPDK_ERRLOG("Could not open bdev %s, error=%d\n",
|
||||
spdk_bdev_get_name(gpt_bdev->bdev), rc);
|
||||
|
@ -200,6 +200,19 @@ vbdev_split_destruct(void *ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
vbdev_split_base_bdev_hotremove_cb(void *remove_ctx)
|
||||
{
|
||||
struct spdk_bdev *base_bdev = remove_ctx;
|
||||
struct split_disk *split_disk, *tmp;
|
||||
|
||||
TAILQ_FOREACH_SAFE(split_disk, &g_split_disks, tailq, tmp) {
|
||||
if (split_disk->base_bdev == base_bdev) {
|
||||
spdk_bdev_unregister(&split_disk->disk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
vbdev_split_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
|
||||
{
|
||||
@ -288,7 +301,8 @@ vbdev_split_create(struct spdk_bdev *base_bdev, uint64_t split_count, uint64_t s
|
||||
split_base->base_bdev = base_bdev;
|
||||
split_base->ref = 0;
|
||||
|
||||
rc = spdk_bdev_open(base_bdev, false, NULL, NULL, &split_base->desc);
|
||||
rc = spdk_bdev_open(base_bdev, false, vbdev_split_base_bdev_hotremove_cb, base_bdev,
|
||||
&split_base->desc);
|
||||
if (rc) {
|
||||
SPDK_ERRLOG("could not open bdev %s\n", spdk_bdev_get_name(base_bdev));
|
||||
free(split_base);
|
||||
|
Loading…
Reference in New Issue
Block a user