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 <dariusz.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/434835 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com>
This commit is contained in:
parent
4d1894b3c4
commit
eb20b890a7
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user