summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@fb.com>2016-04-14 11:42:31 -0600
committerJens Axboe <axboe@fb.com>2016-04-17 20:16:44 -0500
commitd92e99b7642c3d53dce6e6f742bd04494639267d (patch)
tree22271ebfb0084efd00207b9cc8bcbf47ede28687
parentcaf7006a2350dfafce00d3bc4bbfb0200c85fd93 (diff)
writeback: increment page wait count when waiting
If we end up waiting on a page that is dirty or marked writeback, then increment the corresponding bdi_writeback counter. Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--mm/filemap.c42
1 files changed, 39 insertions, 3 deletions
diff --git a/mm/filemap.c b/mm/filemap.c
index f2479af09da9..a8854a083b71 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -764,37 +764,73 @@ wait_queue_head_t *page_waitqueue(struct page *page)
}
EXPORT_SYMBOL(page_waitqueue);
+static bool inc_dirty_wait(struct page *page)
+{
+ if (!page->mapping || !PageDirty(page) || !PageWriteback(page))
+ return false;
+ else {
+ struct bdi_writeback *wb = inode_to_wb(page->mapping->host);
+
+ atomic_inc(&wb->dirty_sleeping);
+ return true;
+ }
+}
+
+static void dec_dirty_wait(struct page *page)
+{
+ struct bdi_writeback *wb = inode_to_wb(page->mapping->host);
+
+ atomic_dec(&wb->dirty_sleeping);
+}
+
void wait_on_page_bit(struct page *page, int bit_nr)
{
DEFINE_WAIT_BIT(wait, &page->flags, bit_nr);
- if (test_bit(bit_nr, &page->flags))
+ if (test_bit(bit_nr, &page->flags)) {
+ bool did_inc = inc_dirty_wait(page);
__wait_on_bit(page_waitqueue(page), &wait, bit_wait_io,
TASK_UNINTERRUPTIBLE);
+ if (did_inc)
+ dec_dirty_wait(page);
+ }
}
EXPORT_SYMBOL(wait_on_page_bit);
int wait_on_page_bit_killable(struct page *page, int bit_nr)
{
DEFINE_WAIT_BIT(wait, &page->flags, bit_nr);
+ bool did_inc;
+ int ret;
if (!test_bit(bit_nr, &page->flags))
return 0;
- return __wait_on_bit(page_waitqueue(page), &wait,
+ did_inc = inc_dirty_wait(page);
+ ret = __wait_on_bit(page_waitqueue(page), &wait,
bit_wait_io, TASK_KILLABLE);
+ if (did_inc)
+ dec_dirty_wait(page);
+ return ret;
}
int wait_on_page_bit_killable_timeout(struct page *page,
int bit_nr, unsigned long timeout)
{
DEFINE_WAIT_BIT(wait, &page->flags, bit_nr);
+ bool did_inc;
+ int ret;
wait.key.timeout = jiffies + timeout;
if (!test_bit(bit_nr, &page->flags))
return 0;
- return __wait_on_bit(page_waitqueue(page), &wait,
+
+ did_inc = inc_dirty_wait(page);
+ ret = __wait_on_bit(page_waitqueue(page), &wait,
bit_wait_io_timeout, TASK_KILLABLE);
+ if (did_inc)
+ dec_dirty_wait(page);
+ return ret;
}
EXPORT_SYMBOL_GPL(wait_on_page_bit_killable_timeout);