if (PagePrivate(page))
                afs_invalidate_dirty(page, offset, length);
 
+       wait_on_page_fscache(page);
        _leave("");
 }
 
 
        /* deny if page is being written to the cache and the caller hasn't
         * elected to wait */
+#ifdef CONFIG_AFS_FSCACHE
+       if (PageFsCache(page)) {
+               if (!(gfp_flags & __GFP_DIRECT_RECLAIM) || !(gfp_flags & __GFP_FS))
+                       return false;
+               wait_on_page_fscache(page);
+       }
+#endif
+
        if (PagePrivate(page)) {
                detach_page_private(page);
                trace_afs_page_dirty(vnode, tracepoint_string("rel"), page);
 
                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.
        /* 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;
 
        detach_page_private(page);
        trace_afs_page_dirty(vnode, tracepoint_string("laundered"), page);
+       wait_on_page_fscache(page);
        return ret;
 }