]> git.baikalelectronics.ru Git - kernel.git/commit
page_writeback: clean up mess around cancel_dirty_page()
authorKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
Tue, 14 Apr 2015 22:45:27 +0000 (15:45 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 14 Apr 2015 23:49:01 +0000 (16:49 -0700)
commitd88d64b46d7fdd27b59b47814a5dec60397489a8
treee8ab83d71a0bea5330d38e77e948170c0054d2a3
parentd4a7c68a3f616cf2c0f79ebc12bdb71434f11881
page_writeback: clean up mess around cancel_dirty_page()

This patch replaces cancel_dirty_page() with a helper function
account_page_cleaned() which only updates counters.  It's called from
truncate_complete_page() and from try_to_free_buffers() (hack for ext3).
Page is locked in both cases, page-lock protects against concurrent
dirtiers: see commit 73d25e724be0 ("mm: protect set_page_dirty() from
ongoing truncation").

Delete_from_page_cache() shouldn't be called for dirty pages, they must
be handled by caller (either written or truncated).  This patch treats
final dirty accounting fixup at the end of __delete_from_page_cache() as
a debug check and adds WARN_ON_ONCE() around it.  If something removes
dirty pages without proper handling that might be a bug and unwritten
data might be lost.

Hugetlbfs has no dirty pages accounting, ClearPageDirty() is enough
here.

cancel_dirty_page() in nfs_wb_page_cancel() is redundant.  This is
helper for nfs_invalidate_page() and it's called only in case complete
invalidation.

The mess was started in v2.6.20 after commits 34442d1009b8 ("Clean up
and make try_to_free_buffers() not race with dirty pages") and
78ef3dfc9002 ("truncate: clear page dirtiness before running
try_to_free_buffers()") first was reverted right in v2.6.20 in commit
aaed24b50147 ("Resurrect 'try_to_free_buffers()' VM hackery"), second in
v2.6.25 commit cc5efbd21752 ("Fix dirty page accounting leak with ext3
data=journal").

Custom fixes were introduced between these points.  NFS in v2.6.23, commit
b3cef2898106 ("NFS: Fix a write request leak in nfs_invalidate_page()").
Kludge in __delete_from_page_cache() in v2.6.24, commit b37964378c81 ("Do
dirty page accounting when removing a page from the page cache").  Since
v2.6.25 all of them are redundant.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Cc: Tejun Heo <tj@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h
fs/buffer.c
fs/hugetlbfs/inode.c
fs/nfs/write.c
include/linux/mm.h
include/linux/page-flags.h
mm/filemap.c
mm/page-writeback.c
mm/truncate.c