[BUG][PATCH] mm: Fix dirty page accounting per backing_dev

From: Tomoki Sekiyama
Date: Wed Feb 07 2007 - 05:09:25 EST


Hello Andrew,

I found a suspicious bug of I/O accounting in 2.6.20-rc6-mm3.
The number of dirty pages per backing_dev available from
/sys/block/<dev>/queue/nr_dirty keeps growing when a file is
rapidly overwritten several times.

For example:
% cat /sys/block/sda/queue/nr_dirty
104
% for i in 1 2; do dd if=/dev/zero of=dummy bs=4096 count=1; done; sync
% cat /sys/block/sda/queue/nr_dirty
105
% for i in 1 2 3; do dd if=/dev/zero of=dummy bs=4096 count=1; done; sync
% cat /sys/block/sda/queue/nr_dirty
107

This patch fixes it.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama.qu@xxxxxxxxxxx>
---
mm/truncate.c | 1 +
1 file changed, 1 insertion(+)

Index: linux-2.6.20-rc6-mm3/mm/truncate.c
===================================================================
--- linux-2.6.20-rc6-mm3.orig/mm/truncate.c
+++ linux-2.6.20-rc6-mm3/mm/truncate.c
@@ -70,6 +70,7 @@ void cancel_dirty_page(struct page *page
if (TestClearPageDirty(page)) {
struct address_space *mapping = page->mapping;
if (mapping && mapping_cap_account_dirty(mapping)) {
+ atomic_long_dec(&mapping->backing_dev_info->nr_dirty);
dec_zone_page_state(page, NR_FILE_DIRTY);
if (account_size)
task_io_account_cancelled_write(account_size);
-
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/