diff mbox series

[v2,2/6] ceph: rework PageFsCache handling

Message ID 20210217125845.10319-3-jlayton@kernel.org
State Superseded
Headers show
Series [v2,1/6] ceph: disable old fscache readpage handling | expand

Commit Message

Jeff Layton Feb. 17, 2021, 12:58 p.m. UTC
With the new fscache API, the PageFsCache bit now indicates that the
page is being written to the cache and shouldn't be modified or released
until it's finished.

Change releasepage and invalidatepage to wait on that bit before
returning.

Also define FSCACHE_USE_NEW_IO_API so that we opt into the new fscache
API.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Cc: ceph-devel@vger.kernel.org
Cc: linux-cachefs@redhat.com
Cc: linux-fsdevel@vger.kernel.org
---
 fs/ceph/addr.c  | 9 ++++++++-
 fs/ceph/super.h | 1 +
 2 files changed, 9 insertions(+), 1 deletion(-)

Comments

Matthew Wilcox Feb. 17, 2021, 2:38 p.m. UTC | #1
On Wed, Feb 17, 2021 at 07:58:41AM -0500, Jeff Layton wrote:
> -static int ceph_releasepage(struct page *page, gfp_t g)
> +static int ceph_releasepage(struct page *page, gfp_t gfp_flags)
>  {
>  	dout("%p releasepage %p idx %lu (%sdirty)\n", page->mapping->host,
>  	     page, page->index, PageDirty(page) ? "" : "not ");
>  
> +	if (PageFsCache(page)) {
> +		if (!(gfp_flags & __GFP_DIRECT_RECLAIM) || !(gfp_flags & __GFP_FS))

If you called it 'gfp' instead of 'gfp_flags', you wouldn't go over 80
columns ;-)

		if (!(gfp & __GFP_DIRECT_RECLAIM) || !(gfp & __GFP_FS))
diff mbox series

Patch

diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 2b17bb36e548..fbfa49db06fd 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -146,6 +146,8 @@  static void ceph_invalidatepage(struct page *page, unsigned int offset,
 	struct ceph_inode_info *ci;
 	struct ceph_snap_context *snapc = page_snap_context(page);
 
+	wait_on_page_fscache(page);
+
 	inode = page->mapping->host;
 	ci = ceph_inode(inode);
 
@@ -168,11 +170,16 @@  static void ceph_invalidatepage(struct page *page, unsigned int offset,
 	ClearPagePrivate(page);
 }
 
-static int ceph_releasepage(struct page *page, gfp_t g)
+static int ceph_releasepage(struct page *page, gfp_t gfp_flags)
 {
 	dout("%p releasepage %p idx %lu (%sdirty)\n", page->mapping->host,
 	     page, page->index, PageDirty(page) ? "" : "not ");
 
+	if (PageFsCache(page)) {
+		if (!(gfp_flags & __GFP_DIRECT_RECLAIM) || !(gfp_flags & __GFP_FS))
+			return 0;
+		wait_on_page_fscache(page);
+	}
 	return !PagePrivate(page);
 }
 
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index b62d8fee3b86..96bd3487d788 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -21,6 +21,7 @@ 
 #include <linux/ceph/libceph.h>
 
 #ifdef CONFIG_CEPH_FSCACHE
+#define FSCACHE_USE_NEW_IO_API
 #include <linux/fscache.h>
 #endif