aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid0.c
diff options
context:
space:
mode:
authorAndre Noll <maan@systemlinux.org>2009-03-30 23:33:13 -0400
committerNeilBrown <neilb@suse.de>2009-03-30 23:33:13 -0400
commitdd8ac336c13fd8afdb082ebacb1cddd5cf727889 (patch)
tree0baa8111d7406774525a1053be461135257d73d2 /drivers/md/raid0.c
parent58c0fed400603a802968b23ddf78f029c5a84e41 (diff)
md: Represent raid device size in sectors.
This patch renames the "size" field of struct mdk_rdev_s to "sectors" and changes this field to store sectors instead of blocks. All users of this field, linear.c, raid0.c and md.c, are fixed up accordingly which gets rid of many multiplications and divisions. Signed-off-by: Andre Noll <maan@systemlinux.org> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/raid0.c')
-rw-r--r--drivers/md/raid0.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 3d06df86da87..9aebb4c93b60 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -76,16 +76,15 @@ static int create_strip_zones (mddev_t *mddev)
76 list_for_each_entry(rdev2, &mddev->disks, same_set) { 76 list_for_each_entry(rdev2, &mddev->disks, same_set) {
77 printk(KERN_INFO "raid0: comparing %s(%llu)", 77 printk(KERN_INFO "raid0: comparing %s(%llu)",
78 bdevname(rdev1->bdev,b), 78 bdevname(rdev1->bdev,b),
79 (unsigned long long)rdev1->size); 79 (unsigned long long)rdev1->sectors);
80 printk(KERN_INFO " with %s(%llu)\n", 80 printk(KERN_INFO " with %s(%llu)\n",
81 bdevname(rdev2->bdev,b), 81 bdevname(rdev2->bdev,b),
82 (unsigned long long)rdev2->size); 82 (unsigned long long)rdev2->sectors);
83 if (rdev2 == rdev1) { 83 if (rdev2 == rdev1) {
84 printk(KERN_INFO "raid0: END\n"); 84 printk(KERN_INFO "raid0: END\n");
85 break; 85 break;
86 } 86 }
87 if (rdev2->size == rdev1->size) 87 if (rdev2->sectors == rdev1->sectors) {
88 {
89 /* 88 /*
90 * Not unique, don't count it as a new 89 * Not unique, don't count it as a new
91 * group 90 * group
@@ -148,7 +147,7 @@ static int create_strip_zones (mddev_t *mddev)
148 mddev->queue->max_sectors > (PAGE_SIZE>>9)) 147 mddev->queue->max_sectors > (PAGE_SIZE>>9))
149 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); 148 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
150 149
151 if (!smallest || (rdev1->size <smallest->size)) 150 if (!smallest || (rdev1->sectors < smallest->sectors))
152 smallest = rdev1; 151 smallest = rdev1;
153 cnt++; 152 cnt++;
154 } 153 }
@@ -158,10 +157,10 @@ static int create_strip_zones (mddev_t *mddev)
158 goto abort; 157 goto abort;
159 } 158 }
160 zone->nb_dev = cnt; 159 zone->nb_dev = cnt;
161 zone->sectors = smallest->size * cnt * 2; 160 zone->sectors = smallest->sectors * cnt;
162 zone->zone_start = 0; 161 zone->zone_start = 0;
163 162
164 current_start = smallest->size * 2; 163 current_start = smallest->sectors;
165 curr_zone_start = zone->sectors; 164 curr_zone_start = zone->sectors;
166 165
167 /* now do the other zones */ 166 /* now do the other zones */
@@ -180,29 +179,29 @@ static int create_strip_zones (mddev_t *mddev)
180 rdev = conf->strip_zone[0].dev[j]; 179 rdev = conf->strip_zone[0].dev[j];
181 printk(KERN_INFO "raid0: checking %s ...", 180 printk(KERN_INFO "raid0: checking %s ...",
182 bdevname(rdev->bdev, b)); 181 bdevname(rdev->bdev, b));
183 if (rdev->size > current_start / 2) { 182 if (rdev->sectors <= current_start) {
184 printk(KERN_INFO " contained as device %d\n",
185 c);
186 zone->dev[c] = rdev;
187 c++;
188 if (!smallest || (rdev->size <smallest->size)) {
189 smallest = rdev;
190 printk(KERN_INFO " (%llu) is smallest!.\n",
191 (unsigned long long)rdev->size);
192 }
193 } else
194 printk(KERN_INFO " nope.\n"); 183 printk(KERN_INFO " nope.\n");
184 continue;
185 }
186 printk(KERN_INFO " contained as device %d\n", c);
187 zone->dev[c] = rdev;
188 c++;
189 if (!smallest || rdev->sectors < smallest->sectors) {
190 smallest = rdev;
191 printk(KERN_INFO " (%llu) is smallest!.\n",
192 (unsigned long long)rdev->sectors);
193 }
195 } 194 }
196 195
197 zone->nb_dev = c; 196 zone->nb_dev = c;
198 zone->sectors = (smallest->size * 2 - current_start) * c; 197 zone->sectors = (smallest->sectors - current_start) * c;
199 printk(KERN_INFO "raid0: zone->nb_dev: %d, sectors: %llu\n", 198 printk(KERN_INFO "raid0: zone->nb_dev: %d, sectors: %llu\n",
200 zone->nb_dev, (unsigned long long)zone->sectors); 199 zone->nb_dev, (unsigned long long)zone->sectors);
201 200
202 zone->zone_start = curr_zone_start; 201 zone->zone_start = curr_zone_start;
203 curr_zone_start += zone->sectors; 202 curr_zone_start += zone->sectors;
204 203
205 current_start = smallest->size * 2; 204 current_start = smallest->sectors;
206 printk(KERN_INFO "raid0: current zone start: %llu\n", 205 printk(KERN_INFO "raid0: current zone start: %llu\n",
207 (unsigned long long)current_start); 206 (unsigned long long)current_start);
208 } 207 }
@@ -296,7 +295,7 @@ static int raid0_run (mddev_t *mddev)
296 /* calculate array device size */ 295 /* calculate array device size */
297 mddev->array_sectors = 0; 296 mddev->array_sectors = 0;
298 list_for_each_entry(rdev, &mddev->disks, same_set) 297 list_for_each_entry(rdev, &mddev->disks, same_set)
299 mddev->array_sectors += rdev->size * 2; 298 mddev->array_sectors += rdev->sectors;
300 299
301 printk(KERN_INFO "raid0 : md_size is %llu sectors.\n", 300 printk(KERN_INFO "raid0 : md_size is %llu sectors.\n",
302 (unsigned long long)mddev->array_sectors); 301 (unsigned long long)mddev->array_sectors);