[PATCH 3/3] blkio-throttle: async write io instrumentation

From: Andrea Righi
Date: Mon Feb 28 2011 - 05:17:33 EST


Enforce IO throttling policy to asynchronous IO writes at the time tasks
write pages in the page cache.

Signed-off-by: Andrea Righi <arighi@xxxxxxxxxxx>
---
mm/page-writeback.c | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 2cb01f6..e3f5f4f 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -607,6 +607,19 @@ void set_page_dirty_balance(struct page *page, int page_mkwrite)
}
}

+/*
+ * Get a request_queue of the underlying superblock device from an
+ * address_space.
+ */
+static struct request_queue *as_to_rq(struct address_space *mapping)
+{
+ struct block_device *bdev;
+
+ bdev = (mapping->host && mapping->host->i_sb->s_bdev) ?
+ mapping->host->i_sb->s_bdev : NULL;
+ return bdev ? bdev_get_queue(bdev) : NULL;
+}
+
static DEFINE_PER_CPU(unsigned long, bdp_ratelimits) = 0;

/**
@@ -628,6 +641,7 @@ void balance_dirty_pages_ratelimited_nr(struct address_space *mapping,
{
unsigned long ratelimit;
unsigned long *p;
+ struct request_queue *q;

ratelimit = ratelimit_pages;
if (mapping->backing_dev_info->dirty_exceeded)
@@ -644,6 +658,9 @@ void balance_dirty_pages_ratelimited_nr(struct address_space *mapping,
ratelimit = sync_writeback_pages(*p);
*p = 0;
preempt_enable();
+ q = as_to_rq(mapping);
+ if (q)
+ blk_throtl_async(q, ratelimit << PAGE_SHIFT);
balance_dirty_pages(mapping, ratelimit);
return;
}
--
1.7.1

--
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/