aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorSandeep K Sinha <sandeepksinha@gmail.com>2009-06-16 02:56:13 -0400
committerNeilBrown <neilb@suse.de>2009-06-16 02:56:13 -0400
commit4db7cdc859f56ecf0a186e0cfb238b5bb3af2efb (patch)
tree1ab673db74f584f0c954e0556db63304bc3de81c /drivers/md
parent45d4582f219619e368ea91ea1189085e1c5f1969 (diff)
md: Removing num_sector and replacing start_sector with end_sector
Remove num_sectors from dev_info and replace start_sector with end_sector. This makes a lot of comparisons much simpler. Signed-off-by: Sandeep K Sinha <sandeepksinha@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/linear.c37
-rw-r--r--drivers/md/linear.h3
2 files changed, 19 insertions, 21 deletions
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index 92bcd3dd52cc..529a3d37e3fe 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -32,7 +32,7 @@ static inline dev_info_t *which_dev(mddev_t *mddev, sector_t sector)
32 32
33 hash = conf->disks; 33 hash = conf->disks;
34 34
35 while (sector >= hash->num_sectors + hash->start_sector) 35 while (sector >= hash->end_sector)
36 hash++; 36 hash++;
37 return hash; 37 return hash;
38} 38}
@@ -55,7 +55,7 @@ static int linear_mergeable_bvec(struct request_queue *q,
55 sector_t sector = bvm->bi_sector + get_start_sect(bvm->bi_bdev); 55 sector_t sector = bvm->bi_sector + get_start_sect(bvm->bi_bdev);
56 56
57 dev0 = which_dev(mddev, sector); 57 dev0 = which_dev(mddev, sector);
58 maxsectors = dev0->num_sectors - (sector - dev0->start_sector); 58 maxsectors = dev0->end_sector - sector;
59 59
60 if (maxsectors < bio_sectors) 60 if (maxsectors < bio_sectors)
61 maxsectors = 0; 61 maxsectors = 0;
@@ -141,10 +141,9 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
141 queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9)) 141 queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9))
142 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); 142 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
143 143
144 disk->num_sectors = rdev->sectors;
145 conf->array_sectors += rdev->sectors; 144 conf->array_sectors += rdev->sectors;
146
147 cnt++; 145 cnt++;
146
148 } 147 }
149 if (cnt != raid_disks) { 148 if (cnt != raid_disks) {
150 printk("linear: not enough drives present. Aborting!\n"); 149 printk("linear: not enough drives present. Aborting!\n");
@@ -154,11 +153,12 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
154 /* 153 /*
155 * Here we calculate the device offsets. 154 * Here we calculate the device offsets.
156 */ 155 */
157 conf->disks[0].start_sector = 0; 156 conf->disks[0].end_sector = conf->disks[0].rdev->sectors;
157
158 for (i = 1; i < raid_disks; i++) 158 for (i = 1; i < raid_disks; i++)
159 conf->disks[i].start_sector = 159 conf->disks[i].end_sector =
160 conf->disks[i-1].start_sector + 160 conf->disks[i-1].end_sector +
161 conf->disks[i-1].num_sectors; 161 conf->disks[i].rdev->sectors;
162 162
163 return conf; 163 return conf;
164 164
@@ -235,6 +235,7 @@ static int linear_make_request (struct request_queue *q, struct bio *bio)
235 const int rw = bio_data_dir(bio); 235 const int rw = bio_data_dir(bio);
236 mddev_t *mddev = q->queuedata; 236 mddev_t *mddev = q->queuedata;
237 dev_info_t *tmp_dev; 237 dev_info_t *tmp_dev;
238 sector_t start_sector;
238 int cpu; 239 int cpu;
239 240
240 if (unlikely(bio_barrier(bio))) { 241 if (unlikely(bio_barrier(bio))) {
@@ -249,32 +250,30 @@ static int linear_make_request (struct request_queue *q, struct bio *bio)
249 part_stat_unlock(); 250 part_stat_unlock();
250 251
251 tmp_dev = which_dev(mddev, bio->bi_sector); 252 tmp_dev = which_dev(mddev, bio->bi_sector);
252 253 start_sector = tmp_dev->end_sector - tmp_dev->rdev->sectors;
253 if (unlikely(bio->bi_sector >= (tmp_dev->num_sectors + 254
254 tmp_dev->start_sector) 255 if (unlikely(bio->bi_sector >= (tmp_dev->end_sector)
255 || (bio->bi_sector < 256 || (bio->bi_sector < start_sector))) {
256 tmp_dev->start_sector))) {
257 char b[BDEVNAME_SIZE]; 257 char b[BDEVNAME_SIZE];
258 258
259 printk("linear_make_request: Sector %llu out of bounds on " 259 printk("linear_make_request: Sector %llu out of bounds on "
260 "dev %s: %llu sectors, offset %llu\n", 260 "dev %s: %llu sectors, offset %llu\n",
261 (unsigned long long)bio->bi_sector, 261 (unsigned long long)bio->bi_sector,
262 bdevname(tmp_dev->rdev->bdev, b), 262 bdevname(tmp_dev->rdev->bdev, b),
263 (unsigned long long)tmp_dev->num_sectors, 263 (unsigned long long)tmp_dev->rdev->sectors,
264 (unsigned long long)tmp_dev->start_sector); 264 (unsigned long long)start_sector);
265 bio_io_error(bio); 265 bio_io_error(bio);
266 return 0; 266 return 0;
267 } 267 }
268 if (unlikely(bio->bi_sector + (bio->bi_size >> 9) > 268 if (unlikely(bio->bi_sector + (bio->bi_size >> 9) >
269 tmp_dev->start_sector + tmp_dev->num_sectors)) { 269 tmp_dev->end_sector)) {
270 /* This bio crosses a device boundary, so we have to 270 /* This bio crosses a device boundary, so we have to
271 * split it. 271 * split it.
272 */ 272 */
273 struct bio_pair *bp; 273 struct bio_pair *bp;
274 274
275 bp = bio_split(bio, 275 bp = bio_split(bio,
276 tmp_dev->start_sector + tmp_dev->num_sectors 276 tmp_dev->end_sector - bio->bi_sector);
277 - bio->bi_sector);
278 277
279 if (linear_make_request(q, &bp->bio1)) 278 if (linear_make_request(q, &bp->bio1))
280 generic_make_request(&bp->bio1); 279 generic_make_request(&bp->bio1);
@@ -285,7 +284,7 @@ static int linear_make_request (struct request_queue *q, struct bio *bio)
285 } 284 }
286 285
287 bio->bi_bdev = tmp_dev->rdev->bdev; 286 bio->bi_bdev = tmp_dev->rdev->bdev;
288 bio->bi_sector = bio->bi_sector - tmp_dev->start_sector 287 bio->bi_sector = bio->bi_sector - start_sector
289 + tmp_dev->rdev->data_offset; 288 + tmp_dev->rdev->data_offset;
290 289
291 return 1; 290 return 1;
diff --git a/drivers/md/linear.h b/drivers/md/linear.h
index 721a878403d1..599e5c1bbb01 100644
--- a/drivers/md/linear.h
+++ b/drivers/md/linear.h
@@ -3,8 +3,7 @@
3 3
4struct dev_info { 4struct dev_info {
5 mdk_rdev_t *rdev; 5 mdk_rdev_t *rdev;
6 sector_t num_sectors; 6 sector_t end_sector;
7 sector_t start_sector;
8}; 7};
9 8
10typedef struct dev_info dev_info_t; 9typedef struct dev_info dev_info_t;