From 30c4390ea0dd27c14d261985823010832c65712c Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Thu, 11 Apr 2019 11:56:30 +0900 Subject: [PATCH] bdev/raid: Process only the first call of destroy_raid_bdev RPC We have to process only the first call of destroy_raid_bdev RPC for the same RAID bdev. The existing flag destruct_called cannot be used for that purpose because of the following reason. destruct_called is set to true in both of - destroy_raid_bdev RPC - hot removal of any base bdev. If destruct_called is set in destroy_raid_bdev RPC, destroy_raid_bdev RPC must return immediately, but if destruct_called is set in hot removal of any base bdev, destroy_raid_bdev RPC must go forward with the current logic. Hence add another flag destroy_started to struct raid_bdev and use it. Signed-off-by: Shuhei Matsumoto Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450885 (master) (cherry picked from commit 0d9a2b504a3671ebb3e53135b48f6222c6b151b0) Change-Id: Ifeefcaa1d289499342d8bb9bc162ded65e0368dd Signed-off-by: Tomasz Zawadzki Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457560 Tested-by: SPDK CI Jenkins Reviewed-by: Darek Stojaczyk --- lib/bdev/raid/bdev_raid.c | 11 +++++++++++ lib/bdev/raid/bdev_raid.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/lib/bdev/raid/bdev_raid.c b/lib/bdev/raid/bdev_raid.c index b0c6fd61c..ec90ff377 100644 --- a/lib/bdev/raid/bdev_raid.c +++ b/lib/bdev/raid/bdev_raid.c @@ -1848,6 +1848,17 @@ raid_bdev_remove_base_devices(struct raid_bdev_config *raid_cfg, return; } + if (raid_bdev->destroy_started) { + SPDK_DEBUGLOG(SPDK_LOG_BDEV_RAID, "destroying raid bdev %s is already started\n", + raid_cfg->name); + if (cb_fn) { + cb_fn(cb_arg, -EALREADY); + } + return; + } + + raid_bdev->destroy_started = true; + for (i = 0; i < raid_bdev->num_base_bdevs; i++) { info = &raid_bdev->base_bdev_info[i]; diff --git a/lib/bdev/raid/bdev_raid.h b/lib/bdev/raid/bdev_raid.h index 36b396ac4..8f055100f 100644 --- a/lib/bdev/raid/bdev_raid.h +++ b/lib/bdev/raid/bdev_raid.h @@ -127,6 +127,9 @@ struct raid_bdev { /* Set to true if destruct is called for this raid bdev */ bool destruct_called; + + /* Set to true if destroy of this raid bdev is started. */ + bool destroy_started; }; /*