
From: Hirokazu Takahashi <taka@valinux.co.jp>

Hi Dave,

I found a bug. Would you apply the following patch, please.
The patch is against 2.6.11-rc1-mm1-mhp1 and should be applied
right after AA-PM-10.3-rename_rewind_page_to_unwind_page.patch .

> Well, here it is, the grand new nonlinear implementation.  The fun part
> is, it's only half of nonlinear for now.  What Andy Whitcroft did was
> split nonlinear up into two pieces:
> 
> http://sr71.net/patches/2.6.11/2.6.11-rc1-mm1-mhp1/
> http://sr71.net/patches/2.6.11/2.6.11-rc1-mm1-mhp1/patch-2.6.11-rc1-mm1-mhp1.gz
> 
> the one config that I know compiles:
> http://sr71.net/patches/2.6.11/2.6.11-rc1-mm1-mhp1/configs/config-i386-sparse-hotplug

unwind() may cause Oops if the inode which the target page belongs is
just removing and the page is under writeback, as end_page_writeback()
tries to refer the inode via newpage->mapping which may not exit anymore.

newpage->mapping should be set NULL before calling end_page_writeback().

Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
---

 memhotplug-dave/mm/mmigrate.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)

diff -puN mm/mmigrate.c~AA-PM-32-unwind_may_cause_Oops_against_removing_pages mm/mmigrate.c
--- memhotplug/mm/mmigrate.c~AA-PM-32-unwind_may_cause_Oops_against_removing_pages	2005-03-28 16:38:17.000000000 -0800
+++ memhotplug-dave/mm/mmigrate.c	2005-03-28 16:38:17.000000000 -0800
@@ -195,9 +195,9 @@ unwind_page(struct page *page, struct pa
 	/* no page_cache_get(page); needed */
 	read_unlock_irq(&mapping->tree_lock);
 out:
+	newpage->mapping = NULL;
 	if (PageWriteback(newpage))
 		end_page_writeback(newpage);	/* XXX */
-	newpage->mapping = NULL;
 	newpage->private = 0;
 	ClearPageSwapCache(newpage);
 	/* XXX unmap needed?  No, it shouldn't.  Handled by fault handlers. */
_
