mm: count reclaimable pages per BDI
authorPeter Zijlstra <a.p.zijlstra@chello.nl>
Wed, 17 Oct 2007 06:25:47 +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 reclaimable pages; nr_reclaimable = nr_dirty + nr_unstable.

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>
fs/buffer.c
fs/nfs/write.c
include/linux/backing-dev.h
mm/page-writeback.c
mm/truncate.c

index faceb5eecca96d5fd8d879640c510e2edb944a85..86e58b1dcd9cbbe5184289c69d5e1186a88303d4 100644 (file)
@@ -710,6 +710,8 @@ static int __set_page_dirty(struct page *page,
 
                if (mapping_cap_account_dirty(mapping)) {
                        __inc_zone_page_state(page, NR_FILE_DIRTY);
+                       __inc_bdi_stat(mapping->backing_dev_info,
+                                       BDI_RECLAIMABLE);
                        task_io_account_write(PAGE_CACHE_SIZE);
                }
                radix_tree_tag_set(&mapping->page_tree,
index 82d7ee98c675da31aec4161512711f2ec5b9e5b3..0cf9d1cd9bd256c1f1ff4928f523fb48788b3b41 100644 (file)
@@ -447,6 +447,7 @@ nfs_mark_request_commit(struct nfs_page *req)
                        NFS_PAGE_TAG_COMMIT);
        spin_unlock(&inode->i_lock);
        inc_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
+       inc_bdi_stat(req->wb_page->mapping->backing_dev_info, BDI_RECLAIMABLE);
        __mark_inode_dirty(inode, I_DIRTY_DATASYNC);
 }
 
@@ -533,6 +534,8 @@ static void nfs_cancel_commit_list(struct list_head *head)
        while(!list_empty(head)) {
                req = nfs_list_entry(head->next);
                dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
+               dec_bdi_stat(req->wb_page->mapping->backing_dev_info,
+                               BDI_RECLAIMABLE);
                nfs_list_remove_request(req);
                clear_bit(PG_NEED_COMMIT, &(req)->wb_flags);
                nfs_inode_remove_request(req);
@@ -1193,6 +1196,8 @@ nfs_commit_list(struct inode *inode, struct list_head *head, int how)
                nfs_list_remove_request(req);
                nfs_mark_request_commit(req);
                dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
+               dec_bdi_stat(req->wb_page->mapping->backing_dev_info,
+                               BDI_RECLAIMABLE);
                nfs_clear_page_tag_locked(req);
        }
        return -ENOMEM;
@@ -1218,6 +1223,8 @@ static void nfs_commit_done(struct rpc_task *task, void *calldata)
                nfs_list_remove_request(req);
                clear_bit(PG_NEED_COMMIT, &(req)->wb_flags);
                dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
+               dec_bdi_stat(req->wb_page->mapping->backing_dev_info,
+                               BDI_RECLAIMABLE);
 
                dprintk("NFS: commit (%s/%Ld %d@%Ld)",
                        req->wb_context->path.dentry->d_inode->i_sb->s_id,
index f7677ff80cc52a6a45e62850cb7edf05eff3e19c..bfae09d2a1eb21d411a8adafba705d9d0d322748 100644 (file)
@@ -27,6 +27,7 @@ enum bdi_state {
 typedef int (congested_fn)(void *, int);
 
 enum bdi_stat_item {
+       BDI_RECLAIMABLE,
        NR_BDI_STAT_ITEMS
 };
 
index d821321326e3f6fcff609d7f87ecb5c0890213c9..9b3c4ee62abfcb9c865be14e8113f52568f29907 100644 (file)
@@ -827,6 +827,8 @@ int __set_page_dirty_nobuffers(struct page *page)
                        WARN_ON_ONCE(!PagePrivate(page) && !PageUptodate(page));
                        if (mapping_cap_account_dirty(mapping)) {
                                __inc_zone_page_state(page, NR_FILE_DIRTY);
+                               __inc_bdi_stat(mapping->backing_dev_info,
+                                               BDI_RECLAIMABLE);
                                task_io_account_write(PAGE_CACHE_SIZE);
                        }
                        radix_tree_tag_set(&mapping->page_tree,
@@ -961,6 +963,8 @@ int clear_page_dirty_for_io(struct page *page)
                 */
                if (TestClearPageDirty(page)) {
                        dec_zone_page_state(page, NR_FILE_DIRTY);
+                       dec_bdi_stat(mapping->backing_dev_info,
+                                       BDI_RECLAIMABLE);
                        return 1;
                }
                return 0;
index 5cdfbc1a59fdce4e1a1346ef8c9ddf97f159777d..ff78505453d42ac45c5e3fd563ff05606a9d3786 100644 (file)
@@ -72,6 +72,8 @@ void cancel_dirty_page(struct page *page, unsigned int account_size)
                struct address_space *mapping = page->mapping;
                if (mapping && mapping_cap_account_dirty(mapping)) {
                        dec_zone_page_state(page, NR_FILE_DIRTY);
+                       dec_bdi_stat(mapping->backing_dev_info,
+                                       BDI_RECLAIMABLE);
                        if (account_size)
                                task_io_account_cancelled_write(account_size);
                }