{
return rt->level == 6;
}
+
+/* Return true, if raid type in @rt is raid4/5/6 */
+static bool rt_is_raid456(struct raid_type *rt)
+{
+ return _in_range(rt->level, 4, 6);
+}
/* END: raid level bools */
/*
* First, parse the in-order required arguments
* "chunk_size" is the only argument of this type.
*/
- if (rs->raid_type->level == 1) {
+ if (rt_is_raid1(rs->raid_type)) {
if (value)
DMERR("Ignoring chunk size parameter for RAID 1");
value = 0;
if (!strcasecmp(key, _argname_by_flag(CTR_FLAG_RAID10_FORMAT))) {
if (_test_and_set_flag(CTR_FLAG_RAID10_FORMAT, &rs->ctr_flags))
return ti_error_einval(rs->ti, "Only one raid10_format argument pair allowed");
- if (rs->raid_type->level != 10)
+ if (!rt_is_raid10(rs->raid_type))
return ti_error_einval(rs->ti, "'raid10_format' is an invalid parameter for this RAID type");
if (strcmp("near", arg) &&
strcmp("far", arg) &&
rd->rdev.recovery_offset = 0;
_set_flag(CTR_FLAG_REBUILD, &rs->ctr_flags);
} else if (!strcasecmp(key, _argname_by_flag(CTR_FLAG_WRITE_MOSTLY))) {
- if (rs->raid_type->level != 1)
+ if (!rt_is_raid1(rs->raid_type))
return ti_error_einval(rs->ti, "write_mostly option is only valid for RAID1");
if (!_in_range(value, 0, rs->md.raid_disks - 1))
set_bit(WriteMostly, &rs->dev[value].rdev.flags);
_set_flag(CTR_FLAG_WRITE_MOSTLY, &rs->ctr_flags);
} else if (!strcasecmp(key, _argname_by_flag(CTR_FLAG_MAX_WRITE_BEHIND))) {
- if (rs->raid_type->level != 1)
+ if (!rt_is_raid1(rs->raid_type))
return ti_error_einval(rs->ti, "max_write_behind option is only valid for RAID1");
if (_test_and_set_flag(CTR_FLAG_MAX_WRITE_BEHIND, &rs->ctr_flags))
*/
value /= 2;
- if (!_in_range(rs->raid_type->level, 4, 6))
+ if (!rt_is_raid456(rs->raid_type))
return ti_error_einval(rs->ti, "Inappropriate argument: stripe_cache");
if (raid5_set_cache_size(&rs->md, (int)value))
return ti_error_einval(rs->ti, "Bad stripe_cache size");
if (dm_set_target_max_io_len(rs->ti, max_io_len))
return -EINVAL;
- if (rs->raid_type->level == 10) {
+ if (rt_is_raid10(rs->raid_type)) {
if (raid10_copies > rs->md.raid_disks)
return ti_error_einval(rs->ti, "Not enough devices to satisfy specification");
rs->md.layout = raid10_format_to_md_layout(raid10_format,
raid10_copies);
rs->md.new_layout = rs->md.layout;
- } else if ((!rs->raid_type->level || rs->raid_type->level > 1) &&
+ } else if (!rt_is_raid1(rs->raid_type) &&
sector_div(sectors_per_dev,
(rs->md.raid_disks - rs->raid_type->parity_devs)))
return ti_error_einval(rs->ti, "Target length not divisible by number of data devices");
}
/* We can only change the number of devices in RAID1 right now */
- if ((rs->raid_type->level != 1) &&
+ if (!rt_is_raid1(rs->raid_type) &&
(le32_to_cpu(sb->num_devices) != mddev->raid_disks)) {
DMERR("Reshaping arrays not yet supported. (device count change)");
return -EINVAL;
if (!test_bit(FirstUse, &r->flags) && (r->raid_disk >= 0)) {
role = le32_to_cpu(sb2->array_position);
if (role != r->raid_disk) {
- if (rs->raid_type->level != 1)
+ if (!rt_is_raid1(rs->raid_type))
return ti_error_einval(rs->ti, "Cannot change device "
"positions in RAID array");
DMINFO("RAID1 device #%d now at position #%d",
}
/* Enable bitmap creation for RAID levels != 0 */
- mddev->bitmap_info.offset = (rs->raid_type->level) ? to_sector(4096) : 0;
+ mddev->bitmap_info.offset = rt_is_raid0(rs->raid_type) ? 0 : to_sector(4096);
rdev->mddev->bitmap_info.default_offset = mddev->bitmap_info.offset;
if (!test_bit(FirstUse, &rdev->flags)) {
case STATUSTYPE_INFO:
DMEMIT("%s %d ", rs->raid_type->name, rs->md.raid_disks);
- if (rs->raid_type->level) {
+ if (!rt_is_raid0(rs->raid_type)) {
if (test_bit(MD_RECOVERY_RUNNING, &rs->md.recovery))
sync = rs->md.curr_resync_completed;
else
{
struct raid_set *rs = ti->private;
- if (rs->raid_type->level) {
+ if (!rt_is_raid0(rs->raid_type)) {
set_bit(MD_CHANGE_DEVS, &rs->md.flags);
if (!rs->bitmap_loaded) {