Skip to content

Commit

Permalink
dm raid: validate current raid sets redundancy
Browse files Browse the repository at this point in the history
Verifying the current raid sets redundancy based on retrieved
superblock content has to use the superblock's raid level (e.g. raid0),
not the constructor requested one (e.g. raid10).

Using the requested raid level of raid10 lead to a "divide error"
on raid0 which defines data copies divided by to be zero.

Also check for bogus data copies.

Signed-off-by: Heinz Mauelshagen <[email protected]>
Signed-off-by: Mike Snitzer <[email protected]>
  • Loading branch information
mauelsha authored and snitm committed Dec 13, 2017
1 parent b84cf26 commit 53bf538
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/md/dm-raid.c
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ static int validate_raid_redundancy(struct raid_set *rs)
!rs->dev[i].rdev.sb_page)
rebuild_cnt++;

switch (rs->raid_type->level) {
switch (rs->md.level) {
case 0:
break;
case 1:
Expand All @@ -1022,6 +1022,11 @@ static int validate_raid_redundancy(struct raid_set *rs)
break;
case 10:
copies = raid10_md_layout_to_copies(rs->md.new_layout);
if (copies < 2) {
DMERR("Bogus raid10 data copies < 2!");
return -EINVAL;
}

if (rebuild_cnt < copies)
break;

Expand Down

0 comments on commit 53bf538

Please sign in to comment.