From: Miquel van Smoorenburg This implements the queue congestion callout for DM stacks. To make bdi_read/write_congested() return correct information. --- drivers/md/dm-table.c | 14 ++++++++++++++ drivers/md/dm.c | 14 ++++++++++++++ drivers/md/dm.h | 1 + 3 files changed, 29 insertions(+) diff -puN drivers/md/dm.c~queue-congestion-dm-implementation drivers/md/dm.c --- 25/drivers/md/dm.c~queue-congestion-dm-implementation 2004-03-07 15:54:54.000000000 -0800 +++ 25-akpm/drivers/md/dm.c 2004-03-07 15:54:54.000000000 -0800 @@ -559,6 +559,18 @@ static int dm_request(request_queue_t *q return 0; } +static int dm_any_congested(void *congested_data, int bdi_bits) +{ + int r; + struct mapped_device *md = congested_data; + + down_read(&md->lock); + r = dm_table_any_congested(md->map, bdi_bits); + up_read(&md->lock); + + return r; +} + /*----------------------------------------------------------------- * A bitset is used to keep track of allocated minor numbers. *---------------------------------------------------------------*/ @@ -637,6 +649,8 @@ static struct mapped_device *alloc_dev(u goto bad1; md->queue->queuedata = md; + md->queue->backing_dev_info.congested_fn = dm_any_congested; + md->queue->backing_dev_info.congested_data = md; blk_queue_make_request(md->queue, dm_request); md->io_pool = mempool_create(MIN_IOS, mempool_alloc_slab, diff -puN drivers/md/dm.h~queue-congestion-dm-implementation drivers/md/dm.h --- 25/drivers/md/dm.h~queue-congestion-dm-implementation 2004-03-07 15:54:54.000000000 -0800 +++ 25-akpm/drivers/md/dm.h 2004-03-07 15:54:54.000000000 -0800 @@ -115,6 +115,7 @@ struct list_head *dm_table_get_devices(s int dm_table_get_mode(struct dm_table *t); void dm_table_suspend_targets(struct dm_table *t); void dm_table_resume_targets(struct dm_table *t); +int dm_table_any_congested(struct dm_table *t, int bdi_bits); /*----------------------------------------------------------------- * A registry of target types. diff -puN drivers/md/dm-table.c~queue-congestion-dm-implementation drivers/md/dm-table.c --- 25/drivers/md/dm-table.c~queue-congestion-dm-implementation 2004-03-07 15:54:54.000000000 -0800 +++ 25-akpm/drivers/md/dm-table.c 2004-03-07 15:54:54.000000000 -0800 @@ -867,6 +867,20 @@ void dm_table_resume_targets(struct dm_t } } +int dm_table_any_congested(struct dm_table *t, int bdi_bits) +{ + struct list_head *d, *devices; + int r = 0; + + devices = dm_table_get_devices(t); + for (d = devices->next; d != devices; d = d->next) { + struct dm_dev *dd = list_entry(d, struct dm_dev, list); + request_queue_t *q = bdev_get_queue(dd->bdev); + r |= bdi_congested(&q->backing_dev_info, bdi_bits); + } + + return r; +} EXPORT_SYMBOL(dm_vcalloc); EXPORT_SYMBOL(dm_get_device); _