afs: Wait on PG_fscache before modifying/releasing a page
[linux-block.git] / fs / afs / write.c
index 6e41b982c71b9ff3146dc67ae1a35a2ecd8db3f1..1b8cabf5ac92f32e135ae2d58800c18a4ce0b60b 100644 (file)
@@ -117,6 +117,10 @@ int afs_write_begin(struct file *file, struct address_space *mapping,
                SetPageUptodate(page);
        }
 
+#ifdef CONFIG_AFS_FSCACHE
+       wait_on_page_fscache(page);
+#endif
+
 try_again:
        /* See if this page is already partially written in a way that we can
         * merge the new write with.
@@ -857,6 +861,11 @@ vm_fault_t afs_page_mkwrite(struct vm_fault *vmf)
        /* Wait for the page to be written to the cache before we allow it to
         * be modified.  We then assume the entire page will need writing back.
         */
+#ifdef CONFIG_AFS_FSCACHE
+       if (PageFsCache(vmf->page) &&
+           wait_on_page_bit_killable(vmf->page, PG_fscache) < 0)
+               return VM_FAULT_RETRY;
+#endif
 
        if (wait_on_page_writeback_killable(vmf->page))
                return VM_FAULT_RETRY;
@@ -947,5 +956,6 @@ int afs_launder_page(struct page *page)
 
        detach_page_private(page);
        trace_afs_page_dirty(vnode, tracepoint_string("laundered"), page);
+       wait_on_page_fscache(page);
        return ret;
 }