[PATCH] __set_page_dirty_nobuffers mappings

From: Hugh Dickins
Date: Sun Sep 05 2004 - 18:07:56 EST


Marcelo noticed that the BUG_ON in __set_page_dirty_nobuffers doesn't
make much sense: it lost its way in 2.6.7, amidst so many page_mappings!

It's supposed to be checking that, although page->mapping may suddenly
go NULL from truncation, and although tmpfs swizzles page_mapping(page)
between tmpfs inode address_space and swapper_space, there's sufficient
stabilization while here in __set_page_dirty_nobuffers that the mapping
after we locked mapping->tree_lock is the same as the mapping before we
locked mapping->tree_lock i.e. the lock we hold is the right one.

Signed-off-by: Hugh Dickins <hugh@xxxxxxxxxxx>
---

mm/page-writeback.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)

--- 2.6.9-rc1-bk12/mm/page-writeback.c 2004-09-05 12:58:41.000000000 +0100
+++ linux/mm/page-writeback.c 2004-09-05 17:07:14.513083224 +0100
@@ -582,12 +582,13 @@ int __set_page_dirty_nobuffers(struct pa

if (!TestSetPageDirty(page)) {
struct address_space *mapping = page_mapping(page);
+ struct address_space *mapping2;

if (mapping) {
spin_lock_irq(&mapping->tree_lock);
- mapping = page_mapping(page);
- if (page_mapping(page)) { /* Race with truncate? */
- BUG_ON(page_mapping(page) != mapping);
+ mapping2 = page_mapping(page);
+ if (mapping2) { /* Race with truncate? */
+ BUG_ON(mapping2 != mapping);
if (!mapping->backing_dev_info->memory_backed)
inc_page_state(nr_dirty);
radix_tree_tag_set(&mapping->page_tree,

-
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/