[PATCH] block: factor out bio_check_eod()
End of device check is done twice in __generic_make_request() and it's fully inlined each time. Factor out bio_check_eod(). This is taken from Jens' zero-length barrier patch. Signed-off-by: Tejun Heo [EMAIL PROTECTED] Cc: Jens Axboe [EMAIL PROTECTED] --- block/ll_rw_blk.c | 63 -- 1 file changed, 33 insertions(+), 30 deletions(-) Index: work/block/ll_rw_blk.c === --- work.orig/block/ll_rw_blk.c +++ work/block/ll_rw_blk.c @@ -3094,6 +3094,35 @@ static inline int should_fail_request(st #endif /* CONFIG_FAIL_MAKE_REQUEST */ +/* + * Check whether this bio extends beyond the end of the device. + */ +static int bio_check_eod(struct bio *bio, unsigned int nr_sectors) +{ + sector_t maxsector; + + if (!nr_sectors) + return 0; + + /* Test device or partition size, when known. */ + maxsector = bio-bi_bdev-bd_inode-i_size 9; + if (maxsector) { + sector_t sector = bio-bi_sector; + + if (maxsector nr_sectors || maxsector - nr_sectors sector) { + /* +* This may well happen - the kernel calls bread() +* without checking the size of the device, e.g., when +* mounting a device. +*/ + handle_bad_sector(bio); + return 1; + } + } + + return 0; +} + /** * generic_make_request: hand a buffer to its device driver for I/O * @bio: The bio describing the location in memory and on the device. @@ -3121,27 +3150,14 @@ static inline int should_fail_request(st static inline void __generic_make_request(struct bio *bio) { request_queue_t *q; - sector_t maxsector; sector_t old_sector; int ret, nr_sectors = bio_sectors(bio); dev_t old_dev; might_sleep(); - /* Test device or partition size, when known. */ - maxsector = bio-bi_bdev-bd_inode-i_size 9; - if (maxsector) { - sector_t sector = bio-bi_sector; - if (maxsector nr_sectors || maxsector - nr_sectors sector) { - /* -* This may well happen - the kernel calls bread() -* without checking the size of the device, e.g., when -* mounting a device. -*/ - handle_bad_sector(bio); - goto end_io; - } - } + if (bio_check_eod(bio, nr_sectors)) + goto end_io; /* * Resolve the mapping until finished. (drivers are @@ -3197,21 +3213,8 @@ end_io: old_sector = bio-bi_sector; old_dev = bio-bi_bdev-bd_dev; - maxsector = bio-bi_bdev-bd_inode-i_size 9; - if (maxsector) { - sector_t sector = bio-bi_sector; - - if (maxsector nr_sectors || - maxsector - nr_sectors sector) { - /* -* This may well happen - partitions are not -* checked to make sure they are within the size -* of the whole device. -*/ - handle_bad_sector(bio); - goto end_io; - } - } + if (bio_check_eod(bio, nr_sectors)) + goto end_io; ret = q-make_request_fn(q, bio); } while (ret); - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] block: factor out bio_check_eod()
On Wed, Jul 18 2007, Tejun Heo wrote: End of device check is done twice in __generic_make_request() and it's fully inlined each time. Factor out bio_check_eod(). Tejun, yeah I should seperate the cleanups and put them in the upstream branch. Will do so and add your signed-off to both of them. -- Jens Axboe - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] block: factor out bio_check_eod()
Jens Axboe wrote: On Wed, Jul 18 2007, Tejun Heo wrote: End of device check is done twice in __generic_make_request() and it's fully inlined each time. Factor out bio_check_eod(). Tejun, yeah I should seperate the cleanups and put them in the upstream branch. Will do so and add your signed-off to both of them. Would they be different from the one I just posted? No big deal either way. I'm just basing the zero-length barrier on top of these patches. Oh well, the changes are trivial anyway. -- tejun - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] block: factor out bio_check_eod()
On Wed, Jul 18 2007, Tejun Heo wrote: Jens Axboe wrote: On Wed, Jul 18 2007, Tejun Heo wrote: End of device check is done twice in __generic_make_request() and it's fully inlined each time. Factor out bio_check_eod(). Tejun, yeah I should seperate the cleanups and put them in the upstream branch. Will do so and add your signed-off to both of them. Would they be different from the one I just posted? No big deal either way. I'm just basing the zero-length barrier on top of these patches. Oh well, the changes are trivial anyway. This one ended up being the same, but in the first one you missed some of the cleanups. I ended up splitting the patch some more though, see the series: http://git.kernel.dk/?p=linux-2.6-block.git;a=shortlog;h=barrier -- Jens Axboe - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] block: factor out bio_check_eod()
Jens Axboe wrote: On Wed, Jul 18 2007, Tejun Heo wrote: Jens Axboe wrote: On Wed, Jul 18 2007, Tejun Heo wrote: End of device check is done twice in __generic_make_request() and it's fully inlined each time. Factor out bio_check_eod(). Tejun, yeah I should seperate the cleanups and put them in the upstream branch. Will do so and add your signed-off to both of them. Would they be different from the one I just posted? No big deal either way. I'm just basing the zero-length barrier on top of these patches. Oh well, the changes are trivial anyway. This one ended up being the same, but in the first one you missed some of the cleanups. I ended up splitting the patch some more though, see the series: http://git.kernel.dk/?p=linux-2.6-block.git;a=shortlog;h=barrier Alright, will base on 662d5c5e6afb79d05db5563205b809c0de530286. Thanks. -- tejun - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] block: factor out bio_check_eod()
Jens Axboe wrote: On Wed, Jul 18 2007, Tejun Heo wrote: Jens Axboe wrote: On Wed, Jul 18 2007, Tejun Heo wrote: Jens Axboe wrote: On Wed, Jul 18 2007, Tejun Heo wrote: End of device check is done twice in __generic_make_request() and it's fully inlined each time. Factor out bio_check_eod(). Tejun, yeah I should seperate the cleanups and put them in the upstream branch. Will do so and add your signed-off to both of them. Would they be different from the one I just posted? No big deal either way. I'm just basing the zero-length barrier on top of these patches. Oh well, the changes are trivial anyway. This one ended up being the same, but in the first one you missed some of the cleanups. I ended up splitting the patch some more though, see the series: http://git.kernel.dk/?p=linux-2.6-block.git;a=shortlog;h=barrier Alright, will base on 662d5c5e6afb79d05db5563205b809c0de530286. Thanks. 1781c6a39fb6e31836557618c4505f5f7bc61605, no? Unless you want to rewrite it completely :-) I think I'll start from 662d5c5e and steal most parts from 1781c6a3. I like stealing, you know. :-) I think 1781c6a3 also can use splitting - zero length barrier implementation and issue_flush conversion. Anyways, how do I pull from git.kernel.dk? git://git.kernel.dk/linux-2.6-block.git gives me connection reset by server. Thanks. -- tejun - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] block: factor out bio_check_eod()
On Wed, Jul 18 2007, Tejun Heo wrote: Jens Axboe wrote: On Wed, Jul 18 2007, Tejun Heo wrote: Jens Axboe wrote: On Wed, Jul 18 2007, Tejun Heo wrote: Jens Axboe wrote: On Wed, Jul 18 2007, Tejun Heo wrote: End of device check is done twice in __generic_make_request() and it's fully inlined each time. Factor out bio_check_eod(). Tejun, yeah I should seperate the cleanups and put them in the upstream branch. Will do so and add your signed-off to both of them. Would they be different from the one I just posted? No big deal either way. I'm just basing the zero-length barrier on top of these patches. Oh well, the changes are trivial anyway. This one ended up being the same, but in the first one you missed some of the cleanups. I ended up splitting the patch some more though, see the series: http://git.kernel.dk/?p=linux-2.6-block.git;a=shortlog;h=barrier Alright, will base on 662d5c5e6afb79d05db5563205b809c0de530286. Thanks. 1781c6a39fb6e31836557618c4505f5f7bc61605, no? Unless you want to rewrite it completely :-) I think I'll start from 662d5c5e and steal most parts from 1781c6a3. I like stealing, you know. :-) I think 1781c6a3 also can use splitting - zero length barrier implementation and issue_flush conversion. Yes that's true, I could split that in two as well. Will do so! Anyways, how do I pull from git.kernel.dk? git://git.kernel.dk/linux-2.6-block.git gives me connection reset by server. git://git.kernel.dk/data/git/linux-2.6-block.git somewhat annoying, I'll see if I can prefix it with git-daemon in the future. -- Jens Axboe - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] block: factor out bio_check_eod()
On Wed, Jul 18 2007, Jens Axboe wrote: On Wed, Jul 18 2007, Tejun Heo wrote: Jens Axboe wrote: On Wed, Jul 18 2007, Tejun Heo wrote: Jens Axboe wrote: On Wed, Jul 18 2007, Tejun Heo wrote: Jens Axboe wrote: On Wed, Jul 18 2007, Tejun Heo wrote: End of device check is done twice in __generic_make_request() and it's fully inlined each time. Factor out bio_check_eod(). Tejun, yeah I should seperate the cleanups and put them in the upstream branch. Will do so and add your signed-off to both of them. Would they be different from the one I just posted? No big deal either way. I'm just basing the zero-length barrier on top of these patches. Oh well, the changes are trivial anyway. This one ended up being the same, but in the first one you missed some of the cleanups. I ended up splitting the patch some more though, see the series: http://git.kernel.dk/?p=linux-2.6-block.git;a=shortlog;h=barrier Alright, will base on 662d5c5e6afb79d05db5563205b809c0de530286. Thanks. 1781c6a39fb6e31836557618c4505f5f7bc61605, no? Unless you want to rewrite it completely :-) I think I'll start from 662d5c5e and steal most parts from 1781c6a3. I like stealing, you know. :-) I think 1781c6a3 also can use splitting - zero length barrier implementation and issue_flush conversion. Yes that's true, I could split that in two as well. Will do so! Anyways, how do I pull from git.kernel.dk? git://git.kernel.dk/linux-2.6-block.git gives me connection reset by server. git://git.kernel.dk/data/git/linux-2.6-block.git somewhat annoying, I'll see if I can prefix it with git-daemon in the future. OK, now skip the /data/git/ stuff and just use git://git.kernel.dk/linux-2.6-block.git :-) -- Jens Axboe - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] block: factor out bio_check_eod()
On Wed, Jul 18 2007, Jens Axboe wrote: On Wed, Jul 18 2007, Tejun Heo wrote: Jens Axboe wrote: On Wed, Jul 18 2007, Tejun Heo wrote: Jens Axboe wrote: On Wed, Jul 18 2007, Tejun Heo wrote: Jens Axboe wrote: On Wed, Jul 18 2007, Tejun Heo wrote: End of device check is done twice in __generic_make_request() and it's fully inlined each time. Factor out bio_check_eod(). Tejun, yeah I should seperate the cleanups and put them in the upstream branch. Will do so and add your signed-off to both of them. Would they be different from the one I just posted? No big deal either way. I'm just basing the zero-length barrier on top of these patches. Oh well, the changes are trivial anyway. This one ended up being the same, but in the first one you missed some of the cleanups. I ended up splitting the patch some more though, see the series: http://git.kernel.dk/?p=linux-2.6-block.git;a=shortlog;h=barrier Alright, will base on 662d5c5e6afb79d05db5563205b809c0de530286. Thanks. 1781c6a39fb6e31836557618c4505f5f7bc61605, no? Unless you want to rewrite it completely :-) I think I'll start from 662d5c5e and steal most parts from 1781c6a3. I like stealing, you know. :-) I think 1781c6a3 also can use splitting - zero length barrier implementation and issue_flush conversion. Yes that's true, I could split that in two as well. Will do so! Done, result in the same location. -- Jens Axboe - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] block: factor out bio_check_eod()
Jens Axboe wrote: somewhat annoying, I'll see if I can prefix it with git-daemon in the future. OK, now skip the /data/git/ stuff and just use git://git.kernel.dk/linux-2.6-block.git Alright, it works like a charm now. Thanks. -- tejun - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html