mm: Wait for writeback when grabbing pages to begin a write
authorDarrick J. Wong <djwong@us.ibm.com>
Fri, 27 May 2011 19:23:34 +0000 (12:23 -0700)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 28 May 2011 05:03:21 +0000 (01:03 -0400)
When grabbing a page for a buffered IO write, the mm should wait for writeback
on the page to complete so that the page does not become writable during the IO
operation.  This change is needed to provide page stability during writes for
all filesystems.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
mm/filemap.c

index bcdc393..dac95a2 100644 (file)
@@ -2327,7 +2327,7 @@ struct page *grab_cache_page_write_begin(struct address_space *mapping,
 repeat:
        page = find_lock_page(mapping, index);
        if (page)
-               return page;
+               goto found;
 
        page = __page_cache_alloc(mapping_gfp_mask(mapping) & ~gfp_notmask);
        if (!page)
@@ -2340,6 +2340,8 @@ repeat:
                        goto repeat;
                return NULL;
        }
+found:
+       wait_on_page_writeback(page);
        return page;
 }
 EXPORT_SYMBOL(grab_cache_page_write_begin);