diff options
author | NeilBrown <neilb@suse.de> | 2009-06-16 02:50:35 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2009-06-16 02:50:35 -0400 |
commit | 49f357a22b3fa3eeac042dfa0a6cae920c174e48 (patch) | |
tree | 55d90a158e990ea38c2487167c3d9a4f7f7943cf /drivers/md | |
parent | fb5ab4b5d6e16fd5006c9f800d0116f3547cb760 (diff) |
md: raid0: remove ->sectors from the strip_zone structure.
storing ->sectors is redundant as is can be computed from the
difference z->zone_end - (z-1)->zone_end
The one place where it is used, it is just as efficient to use
a zone_end value instead.
And removing it makes strip_zone smaller, so they array of these that
is searched on every request has a better chance to say in cache.
So discard the field and get the value from elsewhere.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/raid0.c | 33 | ||||
-rw-r--r-- | drivers/md/raid0.h | 1 |
2 files changed, 19 insertions, 15 deletions
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index 0d62ad6df212..07ef936afc71 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c | |||
@@ -55,7 +55,7 @@ static int raid0_congested(void *data, int bits) | |||
55 | static int create_strip_zones(mddev_t *mddev) | 55 | static int create_strip_zones(mddev_t *mddev) |
56 | { | 56 | { |
57 | int i, c, j, err; | 57 | int i, c, j, err; |
58 | sector_t curr_zone_end; | 58 | sector_t curr_zone_end, sectors; |
59 | mdk_rdev_t *smallest, *rdev1, *rdev2, *rdev; | 59 | mdk_rdev_t *smallest, *rdev1, *rdev2, *rdev; |
60 | struct strip_zone *zone; | 60 | struct strip_zone *zone; |
61 | int cnt; | 61 | int cnt; |
@@ -153,10 +153,9 @@ static int create_strip_zones(mddev_t *mddev) | |||
153 | goto abort; | 153 | goto abort; |
154 | } | 154 | } |
155 | zone->nb_dev = cnt; | 155 | zone->nb_dev = cnt; |
156 | zone->sectors = smallest->sectors * cnt; | 156 | zone->zone_end = smallest->sectors * cnt; |
157 | zone->zone_end = zone->sectors; | ||
158 | 157 | ||
159 | curr_zone_end = zone->sectors; | 158 | curr_zone_end = zone->zone_end; |
160 | 159 | ||
161 | /* now do the other zones */ | 160 | /* now do the other zones */ |
162 | for (i = 1; i < conf->nr_strip_zones; i++) | 161 | for (i = 1; i < conf->nr_strip_zones; i++) |
@@ -189,11 +188,11 @@ static int create_strip_zones(mddev_t *mddev) | |||
189 | } | 188 | } |
190 | 189 | ||
191 | zone->nb_dev = c; | 190 | zone->nb_dev = c; |
192 | zone->sectors = (smallest->sectors - zone->dev_start) * c; | 191 | sectors = (smallest->sectors - zone->dev_start) * c; |
193 | printk(KERN_INFO "raid0: zone->nb_dev: %d, sectors: %llu\n", | 192 | printk(KERN_INFO "raid0: zone->nb_dev: %d, sectors: %llu\n", |
194 | zone->nb_dev, (unsigned long long)zone->sectors); | 193 | zone->nb_dev, (unsigned long long)sectors); |
195 | 194 | ||
196 | curr_zone_end += zone->sectors; | 195 | curr_zone_end += sectors; |
197 | zone->zone_end = curr_zone_end; | 196 | zone->zone_end = curr_zone_end; |
198 | 197 | ||
199 | printk(KERN_INFO "raid0: current zone start: %llu\n", | 198 | printk(KERN_INFO "raid0: current zone start: %llu\n", |
@@ -310,16 +309,22 @@ static int raid0_stop(mddev_t *mddev) | |||
310 | return 0; | 309 | return 0; |
311 | } | 310 | } |
312 | 311 | ||
313 | /* Find the zone which holds a particular offset */ | 312 | /* Find the zone which holds a particular offset |
313 | * Update *sectorp to be an offset in that zone | ||
314 | */ | ||
314 | static struct strip_zone *find_zone(struct raid0_private_data *conf, | 315 | static struct strip_zone *find_zone(struct raid0_private_data *conf, |
315 | sector_t sector) | 316 | sector_t *sectorp) |
316 | { | 317 | { |
317 | int i; | 318 | int i; |
318 | struct strip_zone *z = conf->strip_zone; | 319 | struct strip_zone *z = conf->strip_zone; |
320 | sector_t sector = *sectorp; | ||
319 | 321 | ||
320 | for (i = 0; i < conf->nr_strip_zones; i++) | 322 | for (i = 0; i < conf->nr_strip_zones; i++) |
321 | if (sector < z[i].zone_end) | 323 | if (sector < z[i].zone_end) { |
324 | if (i) | ||
325 | *sectorp = sector - z[i-1].zone_end; | ||
322 | return z + i; | 326 | return z + i; |
327 | } | ||
323 | BUG(); | 328 | BUG(); |
324 | } | 329 | } |
325 | 330 | ||
@@ -331,7 +336,7 @@ static int raid0_make_request (struct request_queue *q, struct bio *bio) | |||
331 | struct strip_zone *zone; | 336 | struct strip_zone *zone; |
332 | mdk_rdev_t *tmp_dev; | 337 | mdk_rdev_t *tmp_dev; |
333 | sector_t chunk; | 338 | sector_t chunk; |
334 | sector_t sector, rsect; | 339 | sector_t sector, rsect, sector_offset; |
335 | const int rw = bio_data_dir(bio); | 340 | const int rw = bio_data_dir(bio); |
336 | int cpu; | 341 | int cpu; |
337 | 342 | ||
@@ -368,11 +373,11 @@ static int raid0_make_request (struct request_queue *q, struct bio *bio) | |||
368 | bio_pair_release(bp); | 373 | bio_pair_release(bp); |
369 | return 0; | 374 | return 0; |
370 | } | 375 | } |
371 | zone = find_zone(conf, sector); | 376 | sector_offset = sector; |
377 | zone = find_zone(conf, §or_offset); | ||
372 | sect_in_chunk = bio->bi_sector & (chunk_sects - 1); | 378 | sect_in_chunk = bio->bi_sector & (chunk_sects - 1); |
373 | { | 379 | { |
374 | sector_t x = (zone->sectors + sector - zone->zone_end) | 380 | sector_t x = sector_offset >> chunksect_bits; |
375 | >> chunksect_bits; | ||
376 | 381 | ||
377 | sector_div(x, zone->nb_dev); | 382 | sector_div(x, zone->nb_dev); |
378 | chunk = x; | 383 | chunk = x; |
diff --git a/drivers/md/raid0.h b/drivers/md/raid0.h index dbcf1da916b7..124ba34c8eed 100644 --- a/drivers/md/raid0.h +++ b/drivers/md/raid0.h | |||
@@ -5,7 +5,6 @@ struct strip_zone | |||
5 | { | 5 | { |
6 | sector_t zone_end; /* Start of the next zone (in sectors) */ | 6 | sector_t zone_end; /* Start of the next zone (in sectors) */ |
7 | sector_t dev_start; /* Zone offset in real dev (in sectors) */ | 7 | sector_t dev_start; /* Zone offset in real dev (in sectors) */ |
8 | sector_t sectors; /* Zone size in sectors */ | ||
9 | int nb_dev; /* # of devices attached to the zone */ | 8 | int nb_dev; /* # of devices attached to the zone */ |
10 | mdk_rdev_t **dev; /* Devices attached to the zone */ | 9 | mdk_rdev_t **dev; /* Devices attached to the zone */ |
11 | }; | 10 | }; |