aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-raid.c
diff options
context:
space:
mode:
authorHeinz Mauelshagen <heinzm@redhat.com>2017-12-13 11:13:17 -0500
committerMike Snitzer <snitzer@redhat.com>2017-12-13 11:50:52 -0500
commit53bf5384f9b9e37c628f171366959a38c89779ca (patch)
tree5fa79fefd5cd37cebdb9b1ddbf78ac8c48bf4446 /drivers/md/dm-raid.c
parentb84cf26924cfe405993fc45fa2911cde38f3c3ac (diff)
dm raid: validate current raid sets redundancy
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 <heinzm@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md/dm-raid.c')
-rw-r--r--drivers/md/dm-raid.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 764baa9665bb..b82b7095a671 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -1007,7 +1007,7 @@ static int validate_raid_redundancy(struct raid_set *rs)
1007 !rs->dev[i].rdev.sb_page) 1007 !rs->dev[i].rdev.sb_page)
1008 rebuild_cnt++; 1008 rebuild_cnt++;
1009 1009
1010 switch (rs->raid_type->level) { 1010 switch (rs->md.level) {
1011 case 0: 1011 case 0:
1012 break; 1012 break;
1013 case 1: 1013 case 1:
@@ -1022,6 +1022,11 @@ static int validate_raid_redundancy(struct raid_set *rs)
1022 break; 1022 break;
1023 case 10: 1023 case 10:
1024 copies = raid10_md_layout_to_copies(rs->md.new_layout); 1024 copies = raid10_md_layout_to_copies(rs->md.new_layout);
1025 if (copies < 2) {
1026 DMERR("Bogus raid10 data copies < 2!");
1027 return -EINVAL;
1028 }
1029
1025 if (rebuild_cnt < copies) 1030 if (rebuild_cnt < copies)
1026 break; 1031 break;
1027 1032