aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--block/blk-core.c2
-rw-r--r--block/cfq-iosched.c7
-rw-r--r--block/deadline-iosched.c2
-rw-r--r--drivers/block/brd.c3
-rw-r--r--drivers/block/pktcdvd.c6
-rw-r--r--drivers/md/dm-stripe.c2
-rw-r--r--drivers/md/dm-verity.c2
-rw-r--r--drivers/md/faulty.c6
-rw-r--r--drivers/md/linear.c3
-rw-r--r--drivers/md/raid1.c4
-rw-r--r--drivers/md/raid5.c14
-rw-r--r--drivers/s390/block/dcssblk.c3
-rw-r--r--fs/btrfs/extent_io.c3
-rw-r--r--fs/gfs2/lops.c2
-rw-r--r--include/linux/bio.h1
15 files changed, 26 insertions, 34 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index 86a1afeef606..7236b826f4a1 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1586,7 +1586,7 @@ static void handle_bad_sector(struct bio *bio)
1586 printk(KERN_INFO "%s: rw=%ld, want=%Lu, limit=%Lu\n", 1586 printk(KERN_INFO "%s: rw=%ld, want=%Lu, limit=%Lu\n",
1587 bdevname(bio->bi_bdev, b), 1587 bdevname(bio->bi_bdev, b),
1588 bio->bi_rw, 1588 bio->bi_rw,
1589 (unsigned long long)bio->bi_sector + bio_sectors(bio), 1589 (unsigned long long)bio_end_sector(bio),
1590 (long long)(i_size_read(bio->bi_bdev->bd_inode) >> 9)); 1590 (long long)(i_size_read(bio->bi_bdev->bd_inode) >> 9));
1591 1591
1592 set_bit(BIO_EOF, &bio->bi_flags); 1592 set_bit(BIO_EOF, &bio->bi_flags);
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 4f0ade74cfd0..d5cd3131c57a 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -2270,11 +2270,8 @@ cfq_find_rq_fmerge(struct cfq_data *cfqd, struct bio *bio)
2270 return NULL; 2270 return NULL;
2271 2271
2272 cfqq = cic_to_cfqq(cic, cfq_bio_sync(bio)); 2272 cfqq = cic_to_cfqq(cic, cfq_bio_sync(bio));
2273 if (cfqq) { 2273 if (cfqq)
2274 sector_t sector = bio->bi_sector + bio_sectors(bio); 2274 return elv_rb_find(&cfqq->sort_list, bio_end_sector(bio));
2275
2276 return elv_rb_find(&cfqq->sort_list, sector);
2277 }
2278 2275
2279 return NULL; 2276 return NULL;
2280} 2277}
diff --git a/block/deadline-iosched.c b/block/deadline-iosched.c
index 90037b5eb17f..ba19a3afab79 100644
--- a/block/deadline-iosched.c
+++ b/block/deadline-iosched.c
@@ -132,7 +132,7 @@ deadline_merge(struct request_queue *q, struct request **req, struct bio *bio)
132 * check for front merge 132 * check for front merge
133 */ 133 */
134 if (dd->front_merges) { 134 if (dd->front_merges) {
135 sector_t sector = bio->bi_sector + bio_sectors(bio); 135 sector_t sector = bio_end_sector(bio);
136 136
137 __rq = elv_rb_find(&dd->sort_list[bio_data_dir(bio)], sector); 137 __rq = elv_rb_find(&dd->sort_list[bio_data_dir(bio)], sector);
138 if (__rq) { 138 if (__rq) {
diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index 531ceb31d0ff..f1a29f8e9d33 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -334,8 +334,7 @@ static void brd_make_request(struct request_queue *q, struct bio *bio)
334 int err = -EIO; 334 int err = -EIO;
335 335
336 sector = bio->bi_sector; 336 sector = bio->bi_sector;
337 if (sector + (bio->bi_size >> SECTOR_SHIFT) > 337 if (bio_end_sector(bio) > get_capacity(bdev->bd_disk))
338 get_capacity(bdev->bd_disk))
339 goto out; 338 goto out;
340 339
341 if (unlikely(bio->bi_rw & REQ_DISCARD)) { 340 if (unlikely(bio->bi_rw & REQ_DISCARD)) {
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 2e7de7a59bfc..26938e8e2fc3 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -901,7 +901,7 @@ static void pkt_iosched_process_queue(struct pktcdvd_device *pd)
901 pd->iosched.successive_reads += bio->bi_size >> 10; 901 pd->iosched.successive_reads += bio->bi_size >> 10;
902 else { 902 else {
903 pd->iosched.successive_reads = 0; 903 pd->iosched.successive_reads = 0;
904 pd->iosched.last_write = bio->bi_sector + bio_sectors(bio); 904 pd->iosched.last_write = bio_end_sector(bio);
905 } 905 }
906 if (pd->iosched.successive_reads >= HI_SPEED_SWITCH) { 906 if (pd->iosched.successive_reads >= HI_SPEED_SWITCH) {
907 if (pd->read_speed == pd->write_speed) { 907 if (pd->read_speed == pd->write_speed) {
@@ -2454,7 +2454,7 @@ static void pkt_make_request(struct request_queue *q, struct bio *bio)
2454 zone = ZONE(bio->bi_sector, pd); 2454 zone = ZONE(bio->bi_sector, pd);
2455 VPRINTK("pkt_make_request: start = %6llx stop = %6llx\n", 2455 VPRINTK("pkt_make_request: start = %6llx stop = %6llx\n",
2456 (unsigned long long)bio->bi_sector, 2456 (unsigned long long)bio->bi_sector,
2457 (unsigned long long)(bio->bi_sector + bio_sectors(bio))); 2457 (unsigned long long)bio_end_sector(bio));
2458 2458
2459 /* Check if we have to split the bio */ 2459 /* Check if we have to split the bio */
2460 { 2460 {
@@ -2462,7 +2462,7 @@ static void pkt_make_request(struct request_queue *q, struct bio *bio)
2462 sector_t last_zone; 2462 sector_t last_zone;
2463 int first_sectors; 2463 int first_sectors;
2464 2464
2465 last_zone = ZONE(bio->bi_sector + bio_sectors(bio) - 1, pd); 2465 last_zone = ZONE(bio_end_sector(bio) - 1, pd);
2466 if (last_zone != zone) { 2466 if (last_zone != zone) {
2467 BUG_ON(last_zone != zone + pd->settings.size); 2467 BUG_ON(last_zone != zone + pd->settings.size);
2468 first_sectors = last_zone - bio->bi_sector; 2468 first_sectors = last_zone - bio->bi_sector;
diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
index d8837d313f54..ea5e878a30b9 100644
--- a/drivers/md/dm-stripe.c
+++ b/drivers/md/dm-stripe.c
@@ -258,7 +258,7 @@ static int stripe_map_range(struct stripe_c *sc, struct bio *bio,
258 sector_t begin, end; 258 sector_t begin, end;
259 259
260 stripe_map_range_sector(sc, bio->bi_sector, target_stripe, &begin); 260 stripe_map_range_sector(sc, bio->bi_sector, target_stripe, &begin);
261 stripe_map_range_sector(sc, bio->bi_sector + bio_sectors(bio), 261 stripe_map_range_sector(sc, bio_end_sector(bio),
262 target_stripe, &end); 262 target_stripe, &end);
263 if (begin < end) { 263 if (begin < end) {
264 bio->bi_bdev = sc->stripe[target_stripe].dev->bdev; 264 bio->bi_bdev = sc->stripe[target_stripe].dev->bdev;
diff --git a/drivers/md/dm-verity.c b/drivers/md/dm-verity.c
index 6ad538375c3c..923115d08baa 100644
--- a/drivers/md/dm-verity.c
+++ b/drivers/md/dm-verity.c
@@ -472,7 +472,7 @@ static int verity_map(struct dm_target *ti, struct bio *bio)
472 return -EIO; 472 return -EIO;
473 } 473 }
474 474
475 if ((bio->bi_sector + bio_sectors(bio)) >> 475 if (bio_end_sector(bio) >>
476 (v->data_dev_block_bits - SECTOR_SHIFT) > v->data_blocks) { 476 (v->data_dev_block_bits - SECTOR_SHIFT) > v->data_blocks) {
477 DMERR_LIMIT("io out of range"); 477 DMERR_LIMIT("io out of range");
478 return -EIO; 478 return -EIO;
diff --git a/drivers/md/faulty.c b/drivers/md/faulty.c
index 5e7dc772f5de..3193aefe982b 100644
--- a/drivers/md/faulty.c
+++ b/drivers/md/faulty.c
@@ -185,8 +185,7 @@ static void make_request(struct mddev *mddev, struct bio *bio)
185 return; 185 return;
186 } 186 }
187 187
188 if (check_sector(conf, bio->bi_sector, bio->bi_sector+(bio->bi_size>>9), 188 if (check_sector(conf, bio->bi_sector, bio_end_sector(bio), WRITE))
189 WRITE))
190 failit = 1; 189 failit = 1;
191 if (check_mode(conf, WritePersistent)) { 190 if (check_mode(conf, WritePersistent)) {
192 add_sector(conf, bio->bi_sector, WritePersistent); 191 add_sector(conf, bio->bi_sector, WritePersistent);
@@ -196,8 +195,7 @@ static void make_request(struct mddev *mddev, struct bio *bio)
196 failit = 1; 195 failit = 1;
197 } else { 196 } else {
198 /* read request */ 197 /* read request */
199 if (check_sector(conf, bio->bi_sector, bio->bi_sector + (bio->bi_size>>9), 198 if (check_sector(conf, bio->bi_sector, bio_end_sector(bio), READ))
200 READ))
201 failit = 1; 199 failit = 1;
202 if (check_mode(conf, ReadTransient)) 200 if (check_mode(conf, ReadTransient))
203 failit = 1; 201 failit = 1;
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index 21014836bdbf..f03fabd2b37b 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -317,8 +317,7 @@ static void linear_make_request(struct mddev *mddev, struct bio *bio)
317 bio_io_error(bio); 317 bio_io_error(bio);
318 return; 318 return;
319 } 319 }
320 if (unlikely(bio->bi_sector + (bio->bi_size >> 9) > 320 if (unlikely(bio_end_sector(bio) > tmp_dev->end_sector)) {
321 tmp_dev->end_sector)) {
322 /* This bio crosses a device boundary, so we have to 321 /* This bio crosses a device boundary, so we have to
323 * split it. 322 * split it.
324 */ 323 */
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index fd86b372692d..4d8c2e0a6bad 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1018,7 +1018,7 @@ static void make_request(struct mddev *mddev, struct bio * bio)
1018 md_write_start(mddev, bio); /* wait on superblock update early */ 1018 md_write_start(mddev, bio); /* wait on superblock update early */
1019 1019
1020 if (bio_data_dir(bio) == WRITE && 1020 if (bio_data_dir(bio) == WRITE &&
1021 bio->bi_sector + bio->bi_size/512 > mddev->suspend_lo && 1021 bio_end_sector(bio) > mddev->suspend_lo &&
1022 bio->bi_sector < mddev->suspend_hi) { 1022 bio->bi_sector < mddev->suspend_hi) {
1023 /* As the suspend_* range is controlled by 1023 /* As the suspend_* range is controlled by
1024 * userspace, we want an interruptible 1024 * userspace, we want an interruptible
@@ -1029,7 +1029,7 @@ static void make_request(struct mddev *mddev, struct bio * bio)
1029 flush_signals(current); 1029 flush_signals(current);
1030 prepare_to_wait(&conf->wait_barrier, 1030 prepare_to_wait(&conf->wait_barrier,
1031 &w, TASK_INTERRUPTIBLE); 1031 &w, TASK_INTERRUPTIBLE);
1032 if (bio->bi_sector + bio->bi_size/512 <= mddev->suspend_lo || 1032 if (bio_end_sector(bio) <= mddev->suspend_lo ||
1033 bio->bi_sector >= mddev->suspend_hi) 1033 bio->bi_sector >= mddev->suspend_hi)
1034 break; 1034 break;
1035 schedule(); 1035 schedule();
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 3ee2912889e7..68706970d217 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2384,11 +2384,11 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx, in
2384 } else 2384 } else
2385 bip = &sh->dev[dd_idx].toread; 2385 bip = &sh->dev[dd_idx].toread;
2386 while (*bip && (*bip)->bi_sector < bi->bi_sector) { 2386 while (*bip && (*bip)->bi_sector < bi->bi_sector) {
2387 if ((*bip)->bi_sector + ((*bip)->bi_size >> 9) > bi->bi_sector) 2387 if (bio_end_sector(*bip) > bi->bi_sector)
2388 goto overlap; 2388 goto overlap;
2389 bip = & (*bip)->bi_next; 2389 bip = & (*bip)->bi_next;
2390 } 2390 }
2391 if (*bip && (*bip)->bi_sector < bi->bi_sector + ((bi->bi_size)>>9)) 2391 if (*bip && (*bip)->bi_sector < bio_end_sector(bi))
2392 goto overlap; 2392 goto overlap;
2393 2393
2394 BUG_ON(*bip && bi->bi_next && (*bip) != bi->bi_next); 2394 BUG_ON(*bip && bi->bi_next && (*bip) != bi->bi_next);
@@ -2404,8 +2404,8 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx, in
2404 sector < sh->dev[dd_idx].sector + STRIPE_SECTORS && 2404 sector < sh->dev[dd_idx].sector + STRIPE_SECTORS &&
2405 bi && bi->bi_sector <= sector; 2405 bi && bi->bi_sector <= sector;
2406 bi = r5_next_bio(bi, sh->dev[dd_idx].sector)) { 2406 bi = r5_next_bio(bi, sh->dev[dd_idx].sector)) {
2407 if (bi->bi_sector + (bi->bi_size>>9) >= sector) 2407 if (bio_end_sector(bi) >= sector)
2408 sector = bi->bi_sector + (bi->bi_size>>9); 2408 sector = bio_end_sector(bi);
2409 } 2409 }
2410 if (sector >= sh->dev[dd_idx].sector + STRIPE_SECTORS) 2410 if (sector >= sh->dev[dd_idx].sector + STRIPE_SECTORS)
2411 set_bit(R5_OVERWRITE, &sh->dev[dd_idx].flags); 2411 set_bit(R5_OVERWRITE, &sh->dev[dd_idx].flags);
@@ -3941,7 +3941,7 @@ static int chunk_aligned_read(struct mddev *mddev, struct bio * raid_bio)
3941 0, 3941 0,
3942 &dd_idx, NULL); 3942 &dd_idx, NULL);
3943 3943
3944 end_sector = align_bi->bi_sector + (align_bi->bi_size >> 9); 3944 end_sector = bio_end_sector(align_bi);
3945 rcu_read_lock(); 3945 rcu_read_lock();
3946 rdev = rcu_dereference(conf->disks[dd_idx].replacement); 3946 rdev = rcu_dereference(conf->disks[dd_idx].replacement);
3947 if (!rdev || test_bit(Faulty, &rdev->flags) || 3947 if (!rdev || test_bit(Faulty, &rdev->flags) ||
@@ -4216,7 +4216,7 @@ static void make_request(struct mddev *mddev, struct bio * bi)
4216 } 4216 }
4217 4217
4218 logical_sector = bi->bi_sector & ~((sector_t)STRIPE_SECTORS-1); 4218 logical_sector = bi->bi_sector & ~((sector_t)STRIPE_SECTORS-1);
4219 last_sector = bi->bi_sector + (bi->bi_size>>9); 4219 last_sector = bio_end_sector(bi);
4220 bi->bi_next = NULL; 4220 bi->bi_next = NULL;
4221 bi->bi_phys_segments = 1; /* over-loaded to count active stripes */ 4221 bi->bi_phys_segments = 1; /* over-loaded to count active stripes */
4222 4222
@@ -4679,7 +4679,7 @@ static int retry_aligned_read(struct r5conf *conf, struct bio *raid_bio)
4679 logical_sector = raid_bio->bi_sector & ~((sector_t)STRIPE_SECTORS-1); 4679 logical_sector = raid_bio->bi_sector & ~((sector_t)STRIPE_SECTORS-1);
4680 sector = raid5_compute_sector(conf, logical_sector, 4680 sector = raid5_compute_sector(conf, logical_sector,
4681 0, &dd_idx, NULL); 4681 0, &dd_idx, NULL);
4682 last_sector = raid_bio->bi_sector + (raid_bio->bi_size>>9); 4682 last_sector = bio_end_sector(raid_bio);
4683 4683
4684 for (; logical_sector < last_sector; 4684 for (; logical_sector < last_sector;
4685 logical_sector += STRIPE_SECTORS, 4685 logical_sector += STRIPE_SECTORS,
diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c
index b6ad0de07930..12d08b4529e9 100644
--- a/drivers/s390/block/dcssblk.c
+++ b/drivers/s390/block/dcssblk.c
@@ -826,8 +826,7 @@ dcssblk_make_request(struct request_queue *q, struct bio *bio)
826 if ((bio->bi_sector & 7) != 0 || (bio->bi_size & 4095) != 0) 826 if ((bio->bi_sector & 7) != 0 || (bio->bi_size & 4095) != 0)
827 /* Request is not page-aligned. */ 827 /* Request is not page-aligned. */
828 goto fail; 828 goto fail;
829 if (((bio->bi_size >> 9) + bio->bi_sector) 829 if (bio_end_sector(bio) > get_capacity(bio->bi_bdev->bd_disk)) {
830 > get_capacity(bio->bi_bdev->bd_disk)) {
831 /* Request beyond end of DCSS segment. */ 830 /* Request beyond end of DCSS segment. */
832 goto fail; 831 goto fail;
833 } 832 }
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index f173c5af6461..bed072aa461f 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2527,8 +2527,7 @@ static int submit_extent_page(int rw, struct extent_io_tree *tree,
2527 if (old_compressed) 2527 if (old_compressed)
2528 contig = bio->bi_sector == sector; 2528 contig = bio->bi_sector == sector;
2529 else 2529 else
2530 contig = bio->bi_sector + (bio->bi_size >> 9) == 2530 contig = bio_end_sector(bio) == sector;
2531 sector;
2532 2531
2533 if (prev_bio_flags != bio_flags || !contig || 2532 if (prev_bio_flags != bio_flags || !contig ||
2534 merge_bio(rw, tree, page, offset, page_size, bio, bio_flags) || 2533 merge_bio(rw, tree, page, offset, page_size, bio, bio_flags) ||
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index a5055977a214..5c37ef982390 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -300,7 +300,7 @@ static struct bio *gfs2_log_get_bio(struct gfs2_sbd *sdp, u64 blkno)
300 u64 nblk; 300 u64 nblk;
301 301
302 if (bio) { 302 if (bio) {
303 nblk = bio->bi_sector + bio_sectors(bio); 303 nblk = bio_end_sector(bio);
304 nblk >>= sdp->sd_fsb2bb_shift; 304 nblk >>= sdp->sd_fsb2bb_shift;
305 if (blkno == nblk) 305 if (blkno == nblk)
306 return bio; 306 return bio;
diff --git a/include/linux/bio.h b/include/linux/bio.h
index fcb4dba2d8ea..20507eb7c979 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -67,6 +67,7 @@
67#define bio_offset(bio) bio_iovec((bio))->bv_offset 67#define bio_offset(bio) bio_iovec((bio))->bv_offset
68#define bio_segments(bio) ((bio)->bi_vcnt - (bio)->bi_idx) 68#define bio_segments(bio) ((bio)->bi_vcnt - (bio)->bi_idx)
69#define bio_sectors(bio) ((bio)->bi_size >> 9) 69#define bio_sectors(bio) ((bio)->bi_size >> 9)
70#define bio_end_sector(bio) ((bio)->bi_sector + bio_sectors((bio)))
70 71
71static inline unsigned int bio_cur_bytes(struct bio *bio) 72static inline unsigned int bio_cur_bytes(struct bio *bio)
72{ 73{