[PATCH] io-accounting: write-cancel accounting

Account for the number of byte writes which this process caused to not happen
after all.

Cc: Jay Lan <jlan@sgi.com>
Cc: Shailabh Nagar <nagar@watson.ibm.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: Chris Sturtivant <csturtiv@sgi.com>
Cc: Tony Ernst <tee@sgi.com>
Cc: Guillaume Thouvenin <guillaume.thouvenin@bull.net>
Cc: David Wright <daw@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Andrew Morton 2006-12-10 02:19:31 -08:00 committed by Linus Torvalds
parent 55e829af06
commit e08748ce01
2 changed files with 9 additions and 2 deletions

View File

@ -2853,8 +2853,13 @@ int try_to_free_buffers(struct page *page)
* could encounter a non-uptodate page, which is unresolvable. * could encounter a non-uptodate page, which is unresolvable.
* This only applies in the rare case where try_to_free_buffers * This only applies in the rare case where try_to_free_buffers
* succeeds but the page is not freed. * succeeds but the page is not freed.
*
* Also, during truncate, discard_buffer will have marked all
* the page's buffers clean. We discover that here and clean
* the page also.
*/ */
clear_page_dirty(page); if (test_clear_page_dirty(page))
task_io_account_cancelled_write(PAGE_CACHE_SIZE);
} }
out: out:
if (buffers_to_free) { if (buffers_to_free) {

View File

@ -13,6 +13,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <linux/pagevec.h> #include <linux/pagevec.h>
#include <linux/task_io_accounting_ops.h>
#include <linux/buffer_head.h> /* grr. try_to_release_page, #include <linux/buffer_head.h> /* grr. try_to_release_page,
do_invalidatepage */ do_invalidatepage */
@ -69,7 +70,8 @@ truncate_complete_page(struct address_space *mapping, struct page *page)
if (PagePrivate(page)) if (PagePrivate(page))
do_invalidatepage(page, 0); do_invalidatepage(page, 0);
clear_page_dirty(page); if (test_clear_page_dirty(page))
task_io_account_cancelled_write(PAGE_CACHE_SIZE);
ClearPageUptodate(page); ClearPageUptodate(page);
ClearPageMappedToDisk(page); ClearPageMappedToDisk(page);
remove_from_page_cache(page); remove_from_page_cache(page);