mm: count writeback pages per BDI
authorPeter Zijlstra <a.p.zijlstra@chello.nl>
Wed, 17 Oct 2007 06:25:48 +0000 (23:25 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Wed, 17 Oct 2007 15:42:45 +0000 (08:42 -0700)
Count per BDI writeback pages.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/backing-dev.h
mm/page-writeback.c

index bfae09d2a1eb21d411a8adafba705d9d0d322748..4d9222c2f222c3130ec64b866b6892c862e0c517 100644 (file)
@@ -28,6 +28,7 @@ typedef int (congested_fn)(void *, int);
 
 enum bdi_stat_item {
        BDI_RECLAIMABLE,
+       BDI_WRITEBACK,
        NR_BDI_STAT_ITEMS
 };
 
index 9b3c4ee62abfcb9c865be14e8113f52568f29907..f1d201fdcf9cab46711dd98c6dec6d2c9dbd5d43 100644 (file)
@@ -979,14 +979,18 @@ int test_clear_page_writeback(struct page *page)
        int ret;
 
        if (mapping) {
+               struct backing_dev_info *bdi = mapping->backing_dev_info;
                unsigned long flags;
 
                write_lock_irqsave(&mapping->tree_lock, flags);
                ret = TestClearPageWriteback(page);
-               if (ret)
+               if (ret) {
                        radix_tree_tag_clear(&mapping->page_tree,
                                                page_index(page),
                                                PAGECACHE_TAG_WRITEBACK);
+                       if (bdi_cap_writeback_dirty(bdi))
+                               __dec_bdi_stat(bdi, BDI_WRITEBACK);
+               }
                write_unlock_irqrestore(&mapping->tree_lock, flags);
        } else {
                ret = TestClearPageWriteback(page);
@@ -1002,14 +1006,18 @@ int test_set_page_writeback(struct page *page)
        int ret;
 
        if (mapping) {
+               struct backing_dev_info *bdi = mapping->backing_dev_info;
                unsigned long flags;
 
                write_lock_irqsave(&mapping->tree_lock, flags);
                ret = TestSetPageWriteback(page);
-               if (!ret)
+               if (!ret) {
                        radix_tree_tag_set(&mapping->page_tree,
                                                page_index(page),
                                                PAGECACHE_TAG_WRITEBACK);
+                       if (bdi_cap_writeback_dirty(bdi))
+                               __inc_bdi_stat(bdi, BDI_WRITEBACK);
+               }
                if (!PageDirty(page))
                        radix_tree_tag_clear(&mapping->page_tree,
                                                page_index(page),