[PATCH] splice: page stealing needs to wait_on_page_writeback()
[linux-2.6-block.git] / fs / splice.c
index 7c2abd4504d702fea0fe514abe6bcbcfdbf0adbf..b5fb2f3e3ac6c3525c6567f56288ea4553e2568d 100644 (file)
@@ -52,6 +52,15 @@ static int page_cache_pipe_buf_steal(struct pipe_inode_info *info,
        WARN_ON(!PageLocked(page));
        WARN_ON(!PageUptodate(page));
 
+       /*
+        * At least for ext2 with nobh option, we need to wait on writeback
+        * completing on this page, since we'll remove it from the pagecache.
+        * Otherwise truncate wont wait on the page, allowing the disk
+        * blocks to be reused by someone else before we actually wrote our
+        * data to them. fs corruption ensues.
+        */
+       wait_on_page_writeback(page);
+
        if (PagePrivate(page))
                try_to_release_page(page, mapping_gfp_mask(mapping));