From eb20b890a70ea441e84ef966e6d871b09e195807 Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Mon, 26 Nov 2018 14:07:28 +0100 Subject: [PATCH] bdev/part: use spdk_bdev_part_base instead of spdk_bdev as an API param Considering it's the part base object that's now accessible in its remove callback, we can simplify the part API by making it accept the part base object directly. Change-Id: I87c3278929a063c115828d02e0def7fa536e6682 Signed-off-by: Darek Stojaczyk Reviewed-on: https://review.gerrithub.io/434835 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Jim Harris Reviewed-by: Paul Luse --- include/spdk/bdev_module.h | 5 +++-- lib/bdev/error/vbdev_error.c | 3 +-- lib/bdev/gpt/vbdev_gpt.c | 3 +-- lib/bdev/part.c | 4 ++-- lib/bdev/split/vbdev_split.c | 11 +++-------- test/unit/lib/bdev/part.c/part_ut.c | 2 +- 6 files changed, 11 insertions(+), 17 deletions(-) diff --git a/include/spdk/bdev_module.h b/include/spdk/bdev_module.h index bfc4013c0..afde316ad 100644 --- a/include/spdk/bdev_module.h +++ b/include/spdk/bdev_module.h @@ -860,10 +860,11 @@ int spdk_bdev_part_free(struct spdk_bdev_part *part); /** * Calls spdk_bdev_unregister on the bdev for each part associated with base_bdev. * - * \param base_bdev The spdk_bdev upon which an spdk_bdev-part_base is built + * \param part_base The part base object built on top of an spdk_bdev * \param tailq The list of spdk_bdev_part bdevs associated with this base bdev. */ -void spdk_bdev_part_base_hotremove(struct spdk_bdev *base_bdev, struct bdev_part_tailq *tailq); +void spdk_bdev_part_base_hotremove(struct spdk_bdev_part_base *part_base, + struct bdev_part_tailq *tailq); /** * Construct a new spdk_bdev_part_base on top of the provided bdev. diff --git a/lib/bdev/error/vbdev_error.c b/lib/bdev/error/vbdev_error.c index 58f7b79a4..f89960a86 100644 --- a/lib/bdev/error/vbdev_error.c +++ b/lib/bdev/error/vbdev_error.c @@ -257,9 +257,8 @@ static void spdk_vbdev_error_base_bdev_hotremove_cb(void *_part_base) { struct spdk_bdev_part_base *part_base = _part_base; - struct spdk_bdev *base_bdev = spdk_bdev_part_base_get_bdev(part_base); - spdk_bdev_part_base_hotremove(base_bdev, &g_error_disks); + spdk_bdev_part_base_hotremove(part_base, &g_error_disks); } static int diff --git a/lib/bdev/gpt/vbdev_gpt.c b/lib/bdev/gpt/vbdev_gpt.c index e5e5d02ce..f4c2d6d9e 100644 --- a/lib/bdev/gpt/vbdev_gpt.c +++ b/lib/bdev/gpt/vbdev_gpt.c @@ -106,9 +106,8 @@ static void spdk_gpt_base_bdev_hotremove_cb(void *_part_base) { struct spdk_bdev_part_base *part_base = _part_base; - struct spdk_bdev *base_bdev = spdk_bdev_part_base_get_bdev(part_base); - spdk_bdev_part_base_hotremove(base_bdev, &g_gpt_disks); + spdk_bdev_part_base_hotremove(part_base, &g_gpt_disks); } static int vbdev_gpt_destruct(void *ctx); diff --git a/lib/bdev/part.c b/lib/bdev/part.c index ed4d76731..21f4d8a82 100644 --- a/lib/bdev/part.c +++ b/lib/bdev/part.c @@ -130,12 +130,12 @@ spdk_bdev_part_free(struct spdk_bdev_part *part) } void -spdk_bdev_part_base_hotremove(struct spdk_bdev *base_bdev, struct bdev_part_tailq *tailq) +spdk_bdev_part_base_hotremove(struct spdk_bdev_part_base *part_base, struct bdev_part_tailq *tailq) { struct spdk_bdev_part *part, *tmp; TAILQ_FOREACH_SAFE(part, tailq, tailq, tmp) { - if (part->internal.base->bdev == base_bdev) { + if (part->internal.base == part_base) { spdk_bdev_unregister(&part->internal.bdev, NULL, NULL); } } diff --git a/lib/bdev/split/vbdev_split.c b/lib/bdev/split/vbdev_split.c index 3e313df0c..f0df3b283 100644 --- a/lib/bdev/split/vbdev_split.c +++ b/lib/bdev/split/vbdev_split.c @@ -120,9 +120,8 @@ static void vbdev_split_base_bdev_hotremove_cb(void *_part_base) { struct spdk_bdev_part_base *part_base = _part_base; - struct spdk_bdev *base_bdev = spdk_bdev_part_base_get_bdev(part_base); - spdk_bdev_part_base_hotremove(base_bdev, &g_split_disks); + spdk_bdev_part_base_hotremove(part_base, &g_split_disks); } static void @@ -214,7 +213,6 @@ vbdev_split_create(struct spdk_vbdev_split_config *cfg) int rc; char *name; struct spdk_bdev *base_bdev; - struct spdk_bdev *split_base_bdev; struct bdev_part_tailq *split_base_tailq; assert(cfg->split_count > 0); @@ -296,10 +294,9 @@ vbdev_split_create(struct spdk_vbdev_split_config *cfg) return 0; err: - split_base_bdev = spdk_bdev_part_base_get_bdev(cfg->split_base); split_base_tailq = spdk_bdev_part_base_get_tailq(cfg->split_base); cfg->removed = true; - spdk_bdev_part_base_hotremove(split_base_bdev, split_base_tailq); + spdk_bdev_part_base_hotremove(cfg->split_base, split_base_tailq); return rc; } @@ -314,14 +311,12 @@ vbdev_split_del_config(struct spdk_vbdev_split_config *cfg) static void vbdev_split_destruct_config(struct spdk_vbdev_split_config *cfg) { - struct spdk_bdev *split_base_bdev; struct bdev_part_tailq *split_base_tailq; cfg->removed = true; if (cfg->split_base != NULL) { - split_base_bdev = spdk_bdev_part_base_get_bdev(cfg->split_base); split_base_tailq = spdk_bdev_part_base_get_tailq(cfg->split_base); - spdk_bdev_part_base_hotremove(split_base_bdev, split_base_tailq); + spdk_bdev_part_base_hotremove(cfg->split_base, split_base_tailq); } else { vbdev_split_del_config(cfg); } diff --git a/test/unit/lib/bdev/part.c/part_ut.c b/test/unit/lib/bdev/part.c/part_ut.c index fd251f4c3..7dfcd433f 100644 --- a/test/unit/lib/bdev/part.c/part_ut.c +++ b/test/unit/lib/bdev/part.c/part_ut.c @@ -138,7 +138,7 @@ part_test(void) rc = spdk_bdev_part_construct(&part2, base, "test2", 100, 100, "test"); SPDK_CU_ASSERT_FATAL(rc == 0); - spdk_bdev_part_base_hotremove(&bdev_base, &tailq); + spdk_bdev_part_base_hotremove(base, &tailq); spdk_bdev_part_base_free(base); _part_cleanup(&part1);