]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
afs: Wait on PG_fscache before modifying/releasing a page
authorDavid Howells <dhowells@redhat.com>
Thu, 6 Feb 2020 14:22:28 +0000 (14:22 +0000)
committerDavid Howells <dhowells@redhat.com>
Thu, 28 Jan 2021 10:57:12 +0000 (10:57 +0000)
PG_fscache is going to be used to indicate that a page is being written to
the cache, and that the page should not be modified or released until it's
finished.

Make afs_invalidatepage() and afs_releasepage() wait for it.

Signed-off-by: David Howells <dhowells@redhat.com>
fs/afs/file.c
fs/afs/write.c

index f1bab69e99d402aa768f1ef897274c56d23065af..acbc21a8c80e15c1b54f44e5218597ae09521338 100644 (file)
@@ -594,6 +594,7 @@ static void afs_invalidatepage(struct page *page, unsigned int offset,
        if (PagePrivate(page))
                afs_invalidate_dirty(page, offset, length);
 
+       wait_on_page_fscache(page);
        _leave("");
 }
 
@@ -611,6 +612,14 @@ static int afs_releasepage(struct page *page, gfp_t gfp_flags)
 
        /* 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);
index dd4dc1c868b53e2468db31a4e5142f2c1715afa5..e1791de904784b393f0adec08da6351d59c0e9d3 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 (PageWriteback(vmf->page) &&
            wait_on_page_bit_killable(vmf->page, PG_writeback) < 0)
@@ -948,5 +957,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;
 }