aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid0.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-03-16 02:23:35 -0400
committerNeilBrown <neilb@suse.de>2010-05-18 01:27:47 -0400
commit84707f38e767ac470fd82af6c45a8cafe2bd1b9a (patch)
treebc480c9aeedccd735e144576284523da1406cb98 /drivers/md/raid0.c
parentc0cc75f84e0e413bce2dcabea74ef418da45c7c1 (diff)
md: don't use mddev->raid_disks in raid0 or raid10 while array is active.
In a subsequent patch we will make it possible to change mddev->raid_disks while a RAID0 or RAID10 array is active. This is part of the process of reshaping such an array. This means that we cannot use this value while processes requests (it is OK to use it during initialisation as we are locked against changes then). Both RAID0 and RAID10 have the same value stored in the private data structure, so use that value instead. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/raid0.c')
-rw-r--r--drivers/md/raid0.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 377cf2a3c333..c2e0d1d28102 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -28,9 +28,10 @@ static void raid0_unplug(struct request_queue *q)
28 mddev_t *mddev = q->queuedata; 28 mddev_t *mddev = q->queuedata;
29 raid0_conf_t *conf = mddev->private; 29 raid0_conf_t *conf = mddev->private;
30 mdk_rdev_t **devlist = conf->devlist; 30 mdk_rdev_t **devlist = conf->devlist;
31 int raid_disks = conf->strip_zone[0].nb_dev;
31 int i; 32 int i;
32 33
33 for (i=0; i<mddev->raid_disks; i++) { 34 for (i=0; i < raid_disks; i++) {
34 struct request_queue *r_queue = bdev_get_queue(devlist[i]->bdev); 35 struct request_queue *r_queue = bdev_get_queue(devlist[i]->bdev);
35 36
36 blk_unplug(r_queue); 37 blk_unplug(r_queue);
@@ -42,12 +43,13 @@ static int raid0_congested(void *data, int bits)
42 mddev_t *mddev = data; 43 mddev_t *mddev = data;
43 raid0_conf_t *conf = mddev->private; 44 raid0_conf_t *conf = mddev->private;
44 mdk_rdev_t **devlist = conf->devlist; 45 mdk_rdev_t **devlist = conf->devlist;
46 int raid_disks = conf->strip_zone[0].nb_dev;
45 int i, ret = 0; 47 int i, ret = 0;
46 48
47 if (mddev_congested(mddev, bits)) 49 if (mddev_congested(mddev, bits))
48 return 1; 50 return 1;
49 51
50 for (i = 0; i < mddev->raid_disks && !ret ; i++) { 52 for (i = 0; i < raid_disks && !ret ; i++) {
51 struct request_queue *q = bdev_get_queue(devlist[i]->bdev); 53 struct request_queue *q = bdev_get_queue(devlist[i]->bdev);
52 54
53 ret |= bdi_congested(&q->backing_dev_info, bits); 55 ret |= bdi_congested(&q->backing_dev_info, bits);
@@ -65,6 +67,7 @@ static void dump_zones(mddev_t *mddev)
65 sector_t zone_start = 0; 67 sector_t zone_start = 0;
66 char b[BDEVNAME_SIZE]; 68 char b[BDEVNAME_SIZE];
67 raid0_conf_t *conf = mddev->private; 69 raid0_conf_t *conf = mddev->private;
70 int raid_disks = conf->strip_zone[0].nb_dev;
68 printk(KERN_INFO "******* %s configuration *********\n", 71 printk(KERN_INFO "******* %s configuration *********\n",
69 mdname(mddev)); 72 mdname(mddev));
70 h = 0; 73 h = 0;
@@ -72,7 +75,7 @@ static void dump_zones(mddev_t *mddev)
72 printk(KERN_INFO "zone%d=[", j); 75 printk(KERN_INFO "zone%d=[", j);
73 for (k = 0; k < conf->strip_zone[j].nb_dev; k++) 76 for (k = 0; k < conf->strip_zone[j].nb_dev; k++)
74 printk("%s/", 77 printk("%s/",
75 bdevname(conf->devlist[j*mddev->raid_disks 78 bdevname(conf->devlist[j*raid_disks
76 + k]->bdev, b)); 79 + k]->bdev, b));
77 printk("]\n"); 80 printk("]\n");
78 81
@@ -401,6 +404,7 @@ static mdk_rdev_t *map_sector(mddev_t *mddev, struct strip_zone *zone,
401 unsigned int sect_in_chunk; 404 unsigned int sect_in_chunk;
402 sector_t chunk; 405 sector_t chunk;
403 raid0_conf_t *conf = mddev->private; 406 raid0_conf_t *conf = mddev->private;
407 int raid_disks = conf->strip_zone[0].nb_dev;
404 unsigned int chunk_sects = mddev->chunk_sectors; 408 unsigned int chunk_sects = mddev->chunk_sectors;
405 409
406 if (is_power_of_2(chunk_sects)) { 410 if (is_power_of_2(chunk_sects)) {
@@ -423,7 +427,7 @@ static mdk_rdev_t *map_sector(mddev_t *mddev, struct strip_zone *zone,
423 * + the position in the chunk 427 * + the position in the chunk
424 */ 428 */
425 *sector_offset = (chunk * chunk_sects) + sect_in_chunk; 429 *sector_offset = (chunk * chunk_sects) + sect_in_chunk;
426 return conf->devlist[(zone - conf->strip_zone)*mddev->raid_disks 430 return conf->devlist[(zone - conf->strip_zone)*raid_disks
427 + sector_div(sector, zone->nb_dev)]; 431 + sector_div(sector, zone->nb_dev)];
428} 432}
429 433
@@ -518,6 +522,7 @@ static void raid0_status(struct seq_file *seq, mddev_t *mddev)
518 int j, k, h; 522 int j, k, h;
519 char b[BDEVNAME_SIZE]; 523 char b[BDEVNAME_SIZE];
520 raid0_conf_t *conf = mddev->private; 524 raid0_conf_t *conf = mddev->private;
525 int raid_disks = conf->strip_zone[0].nb_dev;
521 526
522 sector_t zone_size; 527 sector_t zone_size;
523 sector_t zone_start = 0; 528 sector_t zone_start = 0;
@@ -528,7 +533,7 @@ static void raid0_status(struct seq_file *seq, mddev_t *mddev)
528 seq_printf(seq, "=["); 533 seq_printf(seq, "=[");
529 for (k = 0; k < conf->strip_zone[j].nb_dev; k++) 534 for (k = 0; k < conf->strip_zone[j].nb_dev; k++)
530 seq_printf(seq, "%s/", bdevname( 535 seq_printf(seq, "%s/", bdevname(
531 conf->devlist[j*mddev->raid_disks + k] 536 conf->devlist[j*raid_disks + k]
532 ->bdev, b)); 537 ->bdev, b));
533 538
534 zone_size = conf->strip_zone[j].zone_end - zone_start; 539 zone_size = conf->strip_zone[j].zone_end - zone_start;