module/raid: max degraded bdevs constraint changed
Attribute base_bdevs_max_degraded of raid_bdev_module struct is replaced with more generic structure allowing implementation of raid levels for which constraint is by number of operational drives instead of maximum number of failed drives. Signed-off-by: Krzysztof Smolinski <krzysztof.smolinski@intel.com> Change-Id: Ie7079993d27d32118b865c3aabd92252a2807b94 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14411 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Krzysztof Karas <krzysztof.karas@intel.com>
This commit is contained in:
parent
4dd2a0d3c5
commit
ad94094fc5
@ -918,13 +918,14 @@ raid_bdev_create(const char *name, uint32_t strip_size, uint8_t num_base_bdevs,
|
||||
struct raid_bdev *raid_bdev;
|
||||
struct spdk_bdev *raid_bdev_gen;
|
||||
struct raid_bdev_module *module;
|
||||
uint8_t min_operational;
|
||||
|
||||
if (raid_bdev_find_by_name(name) != NULL) {
|
||||
SPDK_ERRLOG("Duplicate raid bdev name found: %s\n", name);
|
||||
return -EEXIST;
|
||||
}
|
||||
|
||||
if (spdk_u32_is_pow2(strip_size) == false) {
|
||||
if (strip_size && spdk_u32_is_pow2(strip_size) == false) {
|
||||
SPDK_ERRLOG("Invalid strip size %" PRIu32 "\n", strip_size);
|
||||
return -EINVAL;
|
||||
}
|
||||
@ -943,6 +944,34 @@ raid_bdev_create(const char *name, uint32_t strip_size, uint8_t num_base_bdevs,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
switch (module->base_bdevs_constraint.type) {
|
||||
case CONSTRAINT_MAX_BASE_BDEVS_REMOVED:
|
||||
min_operational = num_base_bdevs - module->base_bdevs_constraint.value;
|
||||
break;
|
||||
case CONSTRAINT_MIN_BASE_BDEVS_OPERATIONAL:
|
||||
min_operational = module->base_bdevs_constraint.value;
|
||||
break;
|
||||
case CONSTRAINT_UNSET:
|
||||
if (module->base_bdevs_constraint.value != 0) {
|
||||
SPDK_ERRLOG("Unexpected constraint value '%u' provided for raid bdev '%s'.\n",
|
||||
(uint8_t)module->base_bdevs_constraint.value, name);
|
||||
return -EINVAL;
|
||||
}
|
||||
min_operational = num_base_bdevs;
|
||||
break;
|
||||
default:
|
||||
SPDK_ERRLOG("Unrecognised constraint type '%u' in module for raid level '%s'.\n",
|
||||
(uint8_t)module->base_bdevs_constraint.type,
|
||||
raid_bdev_level_to_str(module->level));
|
||||
return -EINVAL;
|
||||
};
|
||||
|
||||
if (min_operational == 0 || min_operational > num_base_bdevs) {
|
||||
SPDK_ERRLOG("Wrong constraint value for raid level '%s'.\n",
|
||||
raid_bdev_level_to_str(module->level));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
raid_bdev = calloc(1, sizeof(*raid_bdev));
|
||||
if (!raid_bdev) {
|
||||
SPDK_ERRLOG("Unable to allocate memory for raid bdev\n");
|
||||
@ -966,6 +995,7 @@ raid_bdev_create(const char *name, uint32_t strip_size, uint8_t num_base_bdevs,
|
||||
raid_bdev->strip_size_kb = strip_size;
|
||||
raid_bdev->state = RAID_BDEV_STATE_CONFIGURING;
|
||||
raid_bdev->level = level;
|
||||
raid_bdev->min_base_bdevs_operational = min_operational;
|
||||
|
||||
raid_bdev_gen = &raid_bdev->bdev;
|
||||
|
||||
|
@ -121,6 +121,9 @@ struct raid_bdev {
|
||||
/* number of base bdevs discovered */
|
||||
uint8_t num_base_bdevs_discovered;
|
||||
|
||||
/* minimum number of viable base bdevs that are required by array to operate */
|
||||
uint8_t min_base_bdevs_operational;
|
||||
|
||||
/* Raid Level of this raid bdev */
|
||||
enum raid_level level;
|
||||
|
||||
@ -181,10 +184,17 @@ struct raid_bdev_module {
|
||||
uint8_t base_bdevs_min;
|
||||
|
||||
/*
|
||||
* Maximum number of base bdevs that can be removed without failing
|
||||
* the array.
|
||||
* RAID constraint. Determines number of base bdevs that can be removed
|
||||
* without failing the array.
|
||||
*/
|
||||
uint8_t base_bdevs_max_degraded;
|
||||
struct {
|
||||
enum {
|
||||
CONSTRAINT_UNSET = 0,
|
||||
CONSTRAINT_MAX_BASE_BDEVS_REMOVED,
|
||||
CONSTRAINT_MIN_BASE_BDEVS_OPERATIONAL,
|
||||
} type;
|
||||
uint8_t value;
|
||||
} base_bdevs_constraint;
|
||||
|
||||
/*
|
||||
* Called when the raid is starting, right before changing the state to
|
||||
|
@ -115,7 +115,7 @@ raid5f_chunk_stripe_req(struct chunk *chunk)
|
||||
static inline uint8_t
|
||||
raid5f_stripe_data_chunks_num(const struct raid_bdev *raid_bdev)
|
||||
{
|
||||
return raid_bdev->num_base_bdevs - raid_bdev->module->base_bdevs_max_degraded;
|
||||
return raid_bdev->min_base_bdevs_operational;
|
||||
}
|
||||
|
||||
static inline uint8_t
|
||||
@ -697,7 +697,7 @@ raid5f_get_io_channel(struct raid_bdev *raid_bdev)
|
||||
static struct raid_bdev_module g_raid5f_module = {
|
||||
.level = RAID5F,
|
||||
.base_bdevs_min = 3,
|
||||
.base_bdevs_max_degraded = 1,
|
||||
.base_bdevs_constraint = {CONSTRAINT_MAX_BASE_BDEVS_REMOVED, 1},
|
||||
.start = raid5f_start,
|
||||
.stop = raid5f_stop,
|
||||
.submit_rw_request = raid5f_submit_rw_request,
|
||||
|
@ -128,6 +128,22 @@ create_raid_bdev(struct raid5f_params *params)
|
||||
|
||||
raid_bdev->module = &g_raid5f_module;
|
||||
raid_bdev->num_base_bdevs = params->num_base_bdevs;
|
||||
|
||||
switch (raid_bdev->module->base_bdevs_constraint.type) {
|
||||
case CONSTRAINT_MAX_BASE_BDEVS_REMOVED:
|
||||
raid_bdev->min_base_bdevs_operational = raid_bdev->num_base_bdevs -
|
||||
raid_bdev->module->base_bdevs_constraint.value;
|
||||
break;
|
||||
case CONSTRAINT_MIN_BASE_BDEVS_OPERATIONAL:
|
||||
raid_bdev->min_base_bdevs_operational = raid_bdev->module->base_bdevs_constraint.value;
|
||||
break;
|
||||
case CONSTRAINT_UNSET:
|
||||
raid_bdev->min_base_bdevs_operational = raid_bdev->num_base_bdevs;
|
||||
break;
|
||||
default:
|
||||
CU_FAIL_FATAL("unsupported raid constraint type");
|
||||
};
|
||||
|
||||
raid_bdev->base_bdev_info = calloc(raid_bdev->num_base_bdevs,
|
||||
sizeof(struct raid_base_bdev_info));
|
||||
SPDK_CU_ASSERT_FATAL(raid_bdev->base_bdev_info != NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user