Enforce IO throttling policy to asynchronous IO writes at the time tasks
write pages in the page cache.
Signed-off-by: Andrea Righi <redacted>
---
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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>