From: Hirokazu Takahashi Hi, Cleanup of P12-mmigrate-pre_writeback.patch. The patch is against 2.6.10-rc1-mm2-mhp1 . need_writeback() is introduced to check whether writeback is required. Signed-off-by: Hirokazu Takahashi Signed-off-by: Dave Hansen --- memhotplug-dave/mm/mmigrate.c | 21 ++++++++++++--------- 1 files changed, 12 insertions(+), 9 deletions(-) diff -puN mm/mmigrate.c~AA-PM-12.2-mmigrate-pre_writeback-cleanup mm/mmigrate.c --- memhotplug/mm/mmigrate.c~AA-PM-12.2-mmigrate-pre_writeback-cleanup 2005-07-28 13:50:43.000000000 -0700 +++ memhotplug-dave/mm/mmigrate.c 2005-07-28 13:50:43.000000000 -0700 @@ -388,6 +388,12 @@ migrate_onepage(struct page *page) return newpage; } +static inline int +need_writeback(struct page *page) +{ + return PageDirty(page) && PagePrivate(page) && !PageWriteback(page); +} + /* * This is the main entry point to migrate pages in a specific region. * If a page is inactive, the page may be just released instead of @@ -407,15 +413,12 @@ int try_to_migrate_pages(struct list_hea /* * Start writeback I/O if it's a dirty page with buffers */ - if (PageDirty(page) && PagePrivate(page)) { - if (!TestSetPageLocked(page)) { - mapping = page_mapping(page); - if (!mapping || - !PageDirty(page) || !PagePrivate(page) || - PageWriteback(page) || - pageout(page, mapping) != PAGE_SUCCESS) { - unlock_page(page); - } + if (need_writeback(page) && !TestSetPageLocked(page)) { + mapping = page_mapping(page); + if (!mapping || mapping->a_ops->migrate_page || + !need_writeback(page) || + pageout(page, mapping) != PAGE_SUCCESS) { + unlock_page(page); } } list_del(&page->lru); _