aboutsummaryrefslogtreecommitdiffstats
path: root/block/ll_rw_blk.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/ll_rw_blk.c')
-rw-r--r--block/ll_rw_blk.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index 136066583c68..c7b1dac8bee9 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -2999,6 +2999,7 @@ void generic_make_request(struct bio *bio)
2999{ 2999{
3000 request_queue_t *q; 3000 request_queue_t *q;
3001 sector_t maxsector; 3001 sector_t maxsector;
3002 sector_t old_sector;
3002 int ret, nr_sectors = bio_sectors(bio); 3003 int ret, nr_sectors = bio_sectors(bio);
3003 dev_t old_dev; 3004 dev_t old_dev;
3004 3005
@@ -3027,7 +3028,7 @@ void generic_make_request(struct bio *bio)
3027 * NOTE: we don't repeat the blk_size check for each new device. 3028 * NOTE: we don't repeat the blk_size check for each new device.
3028 * Stacking drivers are expected to know what they are doing. 3029 * Stacking drivers are expected to know what they are doing.
3029 */ 3030 */
3030 maxsector = -1; 3031 old_sector = -1;
3031 old_dev = 0; 3032 old_dev = 0;
3032 do { 3033 do {
3033 char b[BDEVNAME_SIZE]; 3034 char b[BDEVNAME_SIZE];
@@ -3061,15 +3062,30 @@ end_io:
3061 */ 3062 */
3062 blk_partition_remap(bio); 3063 blk_partition_remap(bio);
3063 3064
3064 if (maxsector != -1) 3065 if (old_sector != -1)
3065 blk_add_trace_remap(q, bio, old_dev, bio->bi_sector, 3066 blk_add_trace_remap(q, bio, old_dev, bio->bi_sector,
3066 maxsector); 3067 old_sector);
3067 3068
3068 blk_add_trace_bio(q, bio, BLK_TA_QUEUE); 3069 blk_add_trace_bio(q, bio, BLK_TA_QUEUE);
3069 3070
3070 maxsector = bio->bi_sector; 3071 old_sector = bio->bi_sector;
3071 old_dev = bio->bi_bdev->bd_dev; 3072 old_dev = bio->bi_bdev->bd_dev;
3072 3073
3074 maxsector = bio->bi_bdev->bd_inode->i_size >> 9;
3075 if (maxsector) {
3076 sector_t sector = bio->bi_sector;
3077
3078 if (maxsector < nr_sectors || maxsector - nr_sectors < sector) {
3079 /*
3080 * This may well happen - partitions are not checked
3081 * to make sure they are within the size of the
3082 * whole device.
3083 */
3084 handle_bad_sector(bio);
3085 goto end_io;
3086 }
3087 }
3088
3073 ret = q->make_request_fn(q, bio); 3089 ret = q->make_request_fn(q, bio);
3074 } while (ret); 3090 } while (ret);
3075} 3091}