Re: [RFC] [PATCH] A clean approach to writeout throttling

From: Jens Axboe
Date: Mon Dec 10 2007 - 05:51:10 EST


On Wed, Dec 05 2007, Daniel Phillips wrote:
> --- 2.6.24-rc3-mm.clean/block/ll_rw_blk.c 2007-12-04 14:45:25.000000000 -0800
> +++ 2.6.24-rc3-mm/block/ll_rw_blk.c 2007-12-04 14:01:18.000000000 -0800
> @@ -3210,7 +3210,7 @@ static inline int bio_check_eod(struct b
> */
> static inline void __generic_make_request(struct bio *bio)
> {
> - struct request_queue *q;
> + request_queue_t *q = bdev_get_queue(bio->bi_bdev);
> sector_t old_sector;
> int ret, nr_sectors = bio_sectors(bio);
> dev_t old_dev;
> @@ -3221,6 +3221,13 @@ static inline void __generic_make_reques
> if (bio_check_eod(bio, nr_sectors))
> goto end_io;
>
> + if (q && q->metric && !bio->bi_queue) {
> + int need = bio->bi_throttle = q->metric(bio);
> + bio->bi_queue = q;
> + /* FIXME: potential race if atomic_sub is called in the middle of condition check */
> + wait_event_interruptible(q->throttle_wait, atomic_read(&q->available) >= need);
> + atomic_sub(need, &q->available);
> + }
> /*
> * Resolve the mapping until finished. (drivers are
> * still free to implement/resolve their own stacking
> @@ -3234,7 +3241,6 @@ static inline void __generic_make_reques
> do {
> char b[BDEVNAME_SIZE];
>
> - q = bdev_get_queue(bio->bi_bdev);
> if (!q) {
> printk(KERN_ERR
> "generic_make_request: Trying to access "

Ehm, this patch is so broken it's not even funny - did you even compile?
You would have noticed the warning on request_queue_t, surely. The big
problem is the last hunk here though, how would that work on stacked
devices? Clue: ->bi_bdev is not const, it can change after a call to
->make_request_fn().

--
Jens Axboe

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/