Linux NFS development
 help / color / mirror / Atom feed
* [PATCH v1 0/9] SUNRPC: Convert the scratch page into a scratch folio
@ 2025-09-12 21:14 Anna Schumaker
  2025-09-12 21:14 ` [PATCH v1 1/9] sunrpc: Introduce xdr_set_scratch_folio() Anna Schumaker
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Anna Schumaker @ 2025-09-12 21:14 UTC (permalink / raw)
  To: linux-nfs, trond.myklebust; +Cc: anna

From: Anna Schumaker <anna.schumaker@oracle.com>

This is the first of a handful of patchsets I've been working on to
convert our usage of 'struct page's into 'struct folio's. I figured I
would start things off easy with converting the scratch page set to the
xdr_buf before I dive into converting over the page array.

What do you all think?
Anna


Anna Schumaker (9):
  SUNRPC: Introduce xdr_set_scratch_folio()
  NFS: Update readdir to use a scratch folio
  NFS: Update getacl to use xdr_set_scratch_folio()
  NFS: Update listxattr to use xdr_set_scratch_folio()
  NFS: Update the blocklayout to use xdr_set_scratch_folio()
  NFS: Update the filelayout to use xdr_set_scratch_folio()
  NFS: Update the flexfilelayout driver to use xdr_set_scratch_folio()
  SUNRPC: Update svcxdr_init_decode() to call xdr_set_scratch_folio()
  SUNRPC: Update gssx_accept_sec_context() to use
    xdr_set_scratch_folio()

 fs/nfs/blocklayout/blocklayout.c          |  8 ++++----
 fs/nfs/blocklayout/dev.c                  |  8 ++++----
 fs/nfs/dir.c                              |  8 ++++----
 fs/nfs/filelayout/filelayout.c            | 10 +++++-----
 fs/nfs/filelayout/filelayoutdev.c         | 10 +++++-----
 fs/nfs/flexfilelayout/flexfilelayout.c    |  8 ++++----
 fs/nfs/flexfilelayout/flexfilelayoutdev.c | 10 +++++-----
 fs/nfs/nfs42proc.c                        |  4 ++--
 fs/nfs/nfs42xdr.c                         |  2 +-
 fs/nfs/nfs4proc.c                         |  4 ++--
 fs/nfs/nfs4xdr.c                          |  2 +-
 include/linux/nfs_xdr.h                   |  4 ++--
 include/linux/sunrpc/svc.h                |  4 ++--
 include/linux/sunrpc/xdr.h                |  8 ++++----
 net/sunrpc/auth_gss/gss_rpc_xdr.c         |  8 ++++----
 net/sunrpc/svc.c                          | 10 +++++-----
 16 files changed, 54 insertions(+), 54 deletions(-)

-- 
2.51.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v1 1/9] sunrpc: Introduce xdr_set_scratch_folio()
  2025-09-12 21:14 [PATCH v1 0/9] SUNRPC: Convert the scratch page into a scratch folio Anna Schumaker
@ 2025-09-12 21:14 ` Anna Schumaker
  2025-09-12 21:14 ` [PATCH v1 1/9] SUNRPC: " Anna Schumaker
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Anna Schumaker @ 2025-09-12 21:14 UTC (permalink / raw)
  To: linux-nfs, trond.myklebust; +Cc: anna

From: Anna Schumaker <anna.schumaker@oracle.com>

This will replace xdr_set_scratch_page() when we switch pages to folios.

Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
 include/linux/sunrpc/xdr.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h
index 8a9ec617cf66..3ce17321689a 100644
--- a/include/linux/sunrpc/xdr.h
+++ b/include/linux/sunrpc/xdr.h
@@ -300,6 +300,19 @@ xdr_set_scratch_page(struct xdr_stream *xdr, struct page *page)
 	xdr_set_scratch_buffer(xdr, page_address(page), PAGE_SIZE);
 }
 
+/**
+ * xdr_set_scratch_folio - Attach a scratch buffer for decoding data
+ * @xdr: pointer to xdr_stream struct
+ * @page: an anonymous folio
+ *
+ * See xdr_set_scratch_buffer().
+ */
+static inline void
+xdr_set_scratch_folio(struct xdr_stream *xdr, struct folio *folio)
+{
+	xdr_set_scratch_buffer(xdr, folio_address(folio), folio_size(folio));
+}
+
 /**
  * xdr_reset_scratch_buffer - Clear scratch buffer information
  * @xdr: pointer to xdr_stream struct
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v1 1/9] SUNRPC: Introduce xdr_set_scratch_folio()
  2025-09-12 21:14 [PATCH v1 0/9] SUNRPC: Convert the scratch page into a scratch folio Anna Schumaker
  2025-09-12 21:14 ` [PATCH v1 1/9] sunrpc: Introduce xdr_set_scratch_folio() Anna Schumaker
@ 2025-09-12 21:14 ` Anna Schumaker
  2025-09-12 21:14 ` [PATCH v1 2/9] NFS: Update readdir to use a scratch folio Anna Schumaker
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Anna Schumaker @ 2025-09-12 21:14 UTC (permalink / raw)
  To: linux-nfs, trond.myklebust; +Cc: anna

From: Anna Schumaker <anna.schumaker@oracle.com>

This will replace xdr_set_scratch_page() when we switch pages to folios.

Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
 include/linux/sunrpc/xdr.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h
index 8a9ec617cf66..3ce17321689a 100644
--- a/include/linux/sunrpc/xdr.h
+++ b/include/linux/sunrpc/xdr.h
@@ -300,6 +300,19 @@ xdr_set_scratch_page(struct xdr_stream *xdr, struct page *page)
 	xdr_set_scratch_buffer(xdr, page_address(page), PAGE_SIZE);
 }
 
+/**
+ * xdr_set_scratch_folio - Attach a scratch buffer for decoding data
+ * @xdr: pointer to xdr_stream struct
+ * @page: an anonymous folio
+ *
+ * See xdr_set_scratch_buffer().
+ */
+static inline void
+xdr_set_scratch_folio(struct xdr_stream *xdr, struct folio *folio)
+{
+	xdr_set_scratch_buffer(xdr, folio_address(folio), folio_size(folio));
+}
+
 /**
  * xdr_reset_scratch_buffer - Clear scratch buffer information
  * @xdr: pointer to xdr_stream struct
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v1 2/9] NFS: Update readdir to use a scratch folio
  2025-09-12 21:14 [PATCH v1 0/9] SUNRPC: Convert the scratch page into a scratch folio Anna Schumaker
  2025-09-12 21:14 ` [PATCH v1 1/9] sunrpc: Introduce xdr_set_scratch_folio() Anna Schumaker
  2025-09-12 21:14 ` [PATCH v1 1/9] SUNRPC: " Anna Schumaker
@ 2025-09-12 21:14 ` Anna Schumaker
  2025-09-12 21:14 ` [PATCH v1 3/9] NFS: Update getacl to use xdr_set_scratch_folio() Anna Schumaker
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Anna Schumaker @ 2025-09-12 21:14 UTC (permalink / raw)
  To: linux-nfs, trond.myklebust; +Cc: anna

From: Anna Schumaker <anna.schumaker@oracle.com>

Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
 fs/nfs/dir.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index d81217923936..263aae15eb68 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -829,17 +829,17 @@ static int nfs_readdir_folio_filler(struct nfs_readdir_descriptor *desc,
 	struct address_space *mapping = desc->file->f_mapping;
 	struct folio *new, *folio = *arrays;
 	struct xdr_stream stream;
-	struct page *scratch;
+	struct folio *scratch;
 	struct xdr_buf buf;
 	u64 cookie;
 	int status;
 
-	scratch = alloc_page(GFP_KERNEL);
+	scratch = folio_alloc(GFP_KERNEL, 0);
 	if (scratch == NULL)
 		return -ENOMEM;
 
 	xdr_init_decode_pages(&stream, &buf, xdr_pages, buflen);
-	xdr_set_scratch_page(&stream, scratch);
+	xdr_set_scratch_folio(&stream, scratch);
 
 	do {
 		status = nfs_readdir_entry_decode(desc, entry, &stream);
@@ -891,7 +891,7 @@ static int nfs_readdir_folio_filler(struct nfs_readdir_descriptor *desc,
 	if (folio != *arrays)
 		nfs_readdir_folio_unlock_and_put(folio);
 
-	put_page(scratch);
+	folio_put(scratch);
 	return status;
 }
 
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v1 3/9] NFS: Update getacl to use xdr_set_scratch_folio()
  2025-09-12 21:14 [PATCH v1 0/9] SUNRPC: Convert the scratch page into a scratch folio Anna Schumaker
                   ` (2 preceding siblings ...)
  2025-09-12 21:14 ` [PATCH v1 2/9] NFS: Update readdir to use a scratch folio Anna Schumaker
@ 2025-09-12 21:14 ` Anna Schumaker
  2025-09-12 21:14 ` [PATCH v1 4/9] NFS: Update listxattr " Anna Schumaker
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Anna Schumaker @ 2025-09-12 21:14 UTC (permalink / raw)
  To: linux-nfs, trond.myklebust; +Cc: anna

From: Anna Schumaker <anna.schumaker@oracle.com>

Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
 fs/nfs/nfs4proc.c       | 4 ++--
 fs/nfs/nfs4xdr.c        | 2 +-
 include/linux/nfs_xdr.h | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 4de3e4bd724b..a5085820ec0a 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -6160,7 +6160,7 @@ static ssize_t __nfs4_get_acl_uncached(struct inode *inode, void *buf,
 	}
 
 	/* for decoding across pages */
-	res.acl_scratch = alloc_page(GFP_KERNEL);
+	res.acl_scratch = folio_alloc(GFP_KERNEL, 0);
 	if (!res.acl_scratch)
 		goto out_free;
 
@@ -6196,7 +6196,7 @@ static ssize_t __nfs4_get_acl_uncached(struct inode *inode, void *buf,
 	while (--i >= 0)
 		__free_page(pages[i]);
 	if (res.acl_scratch)
-		__free_page(res.acl_scratch);
+		folio_put(res.acl_scratch);
 	kfree(pages);
 	return ret;
 }
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 4ee88a4c1daa..1d0e6c10f921 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -6585,7 +6585,7 @@ nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
 	int status;
 
 	if (res->acl_scratch != NULL)
-		xdr_set_scratch_page(xdr, res->acl_scratch);
+		xdr_set_scratch_folio(xdr, res->acl_scratch);
 	status = decode_compound_hdr(xdr, &hdr);
 	if (status)
 		goto out;
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index ac4bff6e9913..7823d4574e29 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -862,7 +862,7 @@ struct nfs_getaclres {
 	size_t				acl_len;
 	size_t				acl_data_offset;
 	int				acl_flags;
-	struct page *			acl_scratch;
+	struct folio *			acl_scratch;
 };
 
 struct nfs_setattrres {
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v1 4/9] NFS: Update listxattr to use xdr_set_scratch_folio()
  2025-09-12 21:14 [PATCH v1 0/9] SUNRPC: Convert the scratch page into a scratch folio Anna Schumaker
                   ` (3 preceding siblings ...)
  2025-09-12 21:14 ` [PATCH v1 3/9] NFS: Update getacl to use xdr_set_scratch_folio() Anna Schumaker
@ 2025-09-12 21:14 ` Anna Schumaker
  2025-09-12 21:14 ` [PATCH v1 5/9] NFS: Update the blocklayout " Anna Schumaker
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Anna Schumaker @ 2025-09-12 21:14 UTC (permalink / raw)
  To: linux-nfs, trond.myklebust; +Cc: anna

From: Anna Schumaker <anna.schumaker@oracle.com>

Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
 fs/nfs/nfs42proc.c      | 4 ++--
 fs/nfs/nfs42xdr.c       | 2 +-
 include/linux/nfs_xdr.h | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
index 6a0b5871ba3b..d537fb0c230e 100644
--- a/fs/nfs/nfs42proc.c
+++ b/fs/nfs/nfs42proc.c
@@ -1514,7 +1514,7 @@ static ssize_t _nfs42_proc_listxattrs(struct inode *inode, void *buf,
 
 
 	ret = -ENOMEM;
-	res.scratch = alloc_page(GFP_KERNEL);
+	res.scratch = folio_alloc(GFP_KERNEL, 0);
 	if (!res.scratch)
 		goto out;
 
@@ -1552,7 +1552,7 @@ static ssize_t _nfs42_proc_listxattrs(struct inode *inode, void *buf,
 	}
 	kfree(pages);
 out_free_scratch:
-	__free_page(res.scratch);
+	folio_put(res.scratch);
 out:
 	return ret;
 
diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c
index 4cc915d5741d..e10d83ba835e 100644
--- a/fs/nfs/nfs42xdr.c
+++ b/fs/nfs/nfs42xdr.c
@@ -1781,7 +1781,7 @@ static int nfs4_xdr_dec_listxattrs(struct rpc_rqst *rqstp,
 	struct compound_hdr hdr;
 	int status;
 
-	xdr_set_scratch_page(xdr, res->scratch);
+	xdr_set_scratch_folio(xdr, res->scratch);
 
 	status = decode_compound_hdr(xdr, &hdr);
 	if (status)
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index 7823d4574e29..d56583572c98 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -1596,7 +1596,7 @@ struct nfs42_listxattrsargs {
 
 struct nfs42_listxattrsres {
 	struct nfs4_sequence_res	seq_res;
-	struct page			*scratch;
+	struct folio			*scratch;
 	void				*xattr_buf;
 	size_t				xattr_len;
 	u64				cookie;
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v1 5/9] NFS: Update the blocklayout to use xdr_set_scratch_folio()
  2025-09-12 21:14 [PATCH v1 0/9] SUNRPC: Convert the scratch page into a scratch folio Anna Schumaker
                   ` (4 preceding siblings ...)
  2025-09-12 21:14 ` [PATCH v1 4/9] NFS: Update listxattr " Anna Schumaker
@ 2025-09-12 21:14 ` Anna Schumaker
  2025-09-12 21:14 ` [PATCH v1 6/9] NFS: Update the filelayout " Anna Schumaker
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Anna Schumaker @ 2025-09-12 21:14 UTC (permalink / raw)
  To: linux-nfs, trond.myklebust; +Cc: anna

From: Anna Schumaker <anna.schumaker@oracle.com>

Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
 fs/nfs/blocklayout/blocklayout.c | 8 ++++----
 fs/nfs/blocklayout/dev.c         | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c
index 5d6edafbed20..0e4c67373e4f 100644
--- a/fs/nfs/blocklayout/blocklayout.c
+++ b/fs/nfs/blocklayout/blocklayout.c
@@ -676,7 +676,7 @@ bl_alloc_lseg(struct pnfs_layout_hdr *lo, struct nfs4_layoutget_res *lgr,
 	struct pnfs_layout_segment *lseg;
 	struct xdr_buf buf;
 	struct xdr_stream xdr;
-	struct page *scratch;
+	struct folio *scratch;
 	int status, i;
 	uint32_t count;
 	__be32 *p;
@@ -689,13 +689,13 @@ bl_alloc_lseg(struct pnfs_layout_hdr *lo, struct nfs4_layoutget_res *lgr,
 		return ERR_PTR(-ENOMEM);
 
 	status = -ENOMEM;
-	scratch = alloc_page(gfp_mask);
+	scratch = folio_alloc(gfp_mask, 0);
 	if (!scratch)
 		goto out;
 
 	xdr_init_decode_pages(&xdr, &buf,
 			lgr->layoutp->pages, lgr->layoutp->len);
-	xdr_set_scratch_page(&xdr, scratch);
+	xdr_set_scratch_folio(&xdr, scratch);
 
 	status = -EIO;
 	p = xdr_inline_decode(&xdr, 4);
@@ -744,7 +744,7 @@ bl_alloc_lseg(struct pnfs_layout_hdr *lo, struct nfs4_layoutget_res *lgr,
 	}
 
 out_free_scratch:
-	__free_page(scratch);
+	folio_put(scratch);
 out:
 	dprintk("%s returns %d\n", __func__, status);
 	switch (status) {
diff --git a/fs/nfs/blocklayout/dev.c b/fs/nfs/blocklayout/dev.c
index 44306ac22353..ab76120705e2 100644
--- a/fs/nfs/blocklayout/dev.c
+++ b/fs/nfs/blocklayout/dev.c
@@ -541,16 +541,16 @@ bl_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
 	struct pnfs_block_dev *top;
 	struct xdr_stream xdr;
 	struct xdr_buf buf;
-	struct page *scratch;
+	struct folio *scratch;
 	int nr_volumes, ret, i;
 	__be32 *p;
 
-	scratch = alloc_page(gfp_mask);
+	scratch = folio_alloc(gfp_mask, 0);
 	if (!scratch)
 		goto out;
 
 	xdr_init_decode_pages(&xdr, &buf, pdev->pages, pdev->pglen);
-	xdr_set_scratch_page(&xdr, scratch);
+	xdr_set_scratch_folio(&xdr, scratch);
 
 	p = xdr_inline_decode(&xdr, sizeof(__be32));
 	if (!p)
@@ -582,7 +582,7 @@ bl_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
 out_free_volumes:
 	kfree(volumes);
 out_free_scratch:
-	__free_page(scratch);
+	folio_put(scratch);
 out:
 	return node;
 }
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v1 6/9] NFS: Update the filelayout to use xdr_set_scratch_folio()
  2025-09-12 21:14 [PATCH v1 0/9] SUNRPC: Convert the scratch page into a scratch folio Anna Schumaker
                   ` (5 preceding siblings ...)
  2025-09-12 21:14 ` [PATCH v1 5/9] NFS: Update the blocklayout " Anna Schumaker
@ 2025-09-12 21:14 ` Anna Schumaker
  2025-09-12 21:14 ` [PATCH v1 7/9] NFS: Update the flexfilelayout driver " Anna Schumaker
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Anna Schumaker @ 2025-09-12 21:14 UTC (permalink / raw)
  To: linux-nfs, trond.myklebust; +Cc: anna

From: Anna Schumaker <anna.schumaker@oracle.com>

Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
 fs/nfs/filelayout/filelayout.c    | 10 +++++-----
 fs/nfs/filelayout/filelayoutdev.c | 10 +++++-----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/fs/nfs/filelayout/filelayout.c b/fs/nfs/filelayout/filelayout.c
index d39a1f58e18d..5c4551117c58 100644
--- a/fs/nfs/filelayout/filelayout.c
+++ b/fs/nfs/filelayout/filelayout.c
@@ -646,19 +646,19 @@ filelayout_decode_layout(struct pnfs_layout_hdr *flo,
 {
 	struct xdr_stream stream;
 	struct xdr_buf buf;
-	struct page *scratch;
+	struct folio *scratch;
 	__be32 *p;
 	uint32_t nfl_util;
 	int i;
 
 	dprintk("%s: set_layout_map Begin\n", __func__);
 
-	scratch = alloc_page(gfp_flags);
+	scratch = folio_alloc(gfp_flags, 0);
 	if (!scratch)
 		return -ENOMEM;
 
 	xdr_init_decode_pages(&stream, &buf, lgr->layoutp->pages, lgr->layoutp->len);
-	xdr_set_scratch_page(&stream, scratch);
+	xdr_set_scratch_folio(&stream, scratch);
 
 	/* 20 = ufl_util (4), first_stripe_index (4), pattern_offset (8),
 	 * num_fh (4) */
@@ -724,11 +724,11 @@ filelayout_decode_layout(struct pnfs_layout_hdr *flo,
 			fl->fh_array[i]->size);
 	}
 
-	__free_page(scratch);
+	folio_put(scratch);
 	return 0;
 
 out_err:
-	__free_page(scratch);
+	folio_put(scratch);
 	return -EIO;
 }
 
diff --git a/fs/nfs/filelayout/filelayoutdev.c b/fs/nfs/filelayout/filelayoutdev.c
index 29d9234d5c08..df79aeb68db4 100644
--- a/fs/nfs/filelayout/filelayoutdev.c
+++ b/fs/nfs/filelayout/filelayoutdev.c
@@ -73,18 +73,18 @@ nfs4_fl_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
 	struct nfs4_file_layout_dsaddr *dsaddr = NULL;
 	struct xdr_stream stream;
 	struct xdr_buf buf;
-	struct page *scratch;
+	struct folio *scratch;
 	struct list_head dsaddrs;
 	struct nfs4_pnfs_ds_addr *da;
 	struct net *net = server->nfs_client->cl_net;
 
 	/* set up xdr stream */
-	scratch = alloc_page(gfp_flags);
+	scratch = folio_alloc(gfp_flags, 0);
 	if (!scratch)
 		goto out_err;
 
 	xdr_init_decode_pages(&stream, &buf, pdev->pages, pdev->pglen);
-	xdr_set_scratch_page(&stream, scratch);
+	xdr_set_scratch_folio(&stream, scratch);
 
 	/* Get the stripe count (number of stripe index) */
 	p = xdr_inline_decode(&stream, 4);
@@ -186,7 +186,7 @@ nfs4_fl_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
 		}
 	}
 
-	__free_page(scratch);
+	folio_put(scratch);
 	return dsaddr;
 
 out_err_drain_dsaddrs:
@@ -204,7 +204,7 @@ nfs4_fl_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
 out_err_free_stripe_indices:
 	kfree(stripe_indices);
 out_err_free_scratch:
-	__free_page(scratch);
+	folio_put(scratch);
 out_err:
 	dprintk("%s ERROR: returning NULL\n", __func__);
 	return NULL;
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v1 7/9] NFS: Update the flexfilelayout driver to use xdr_set_scratch_folio()
  2025-09-12 21:14 [PATCH v1 0/9] SUNRPC: Convert the scratch page into a scratch folio Anna Schumaker
                   ` (6 preceding siblings ...)
  2025-09-12 21:14 ` [PATCH v1 6/9] NFS: Update the filelayout " Anna Schumaker
@ 2025-09-12 21:14 ` Anna Schumaker
  2025-09-12 21:14 ` [PATCH v1 8/9] SUNRPC: Update svcxdr_init_decode() to call xdr_set_scratch_folio() Anna Schumaker
  2025-09-12 21:14 ` [PATCH v1 9/9] SUNRPC: Update gssx_accept_sec_context() to use xdr_set_scratch_folio() Anna Schumaker
  9 siblings, 0 replies; 11+ messages in thread
From: Anna Schumaker @ 2025-09-12 21:14 UTC (permalink / raw)
  To: linux-nfs, trond.myklebust; +Cc: anna

From: Anna Schumaker <anna.schumaker@oracle.com>

Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
 fs/nfs/flexfilelayout/flexfilelayout.c    |  8 ++++----
 fs/nfs/flexfilelayout/flexfilelayoutdev.c | 10 +++++-----
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index 04a6dded8a13..d29d2a2dfc2a 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -439,7 +439,7 @@ ff_layout_alloc_lseg(struct pnfs_layout_hdr *lh,
 	struct nfs4_ff_layout_segment *fls = NULL;
 	struct xdr_stream stream;
 	struct xdr_buf buf;
-	struct page *scratch;
+	struct folio *scratch;
 	u64 stripe_unit;
 	u32 mirror_array_cnt;
 	__be32 *p;
@@ -447,13 +447,13 @@ ff_layout_alloc_lseg(struct pnfs_layout_hdr *lh,
 	struct nfs4_ff_layout_ds_stripe *dss_info;
 
 	dprintk("--> %s\n", __func__);
-	scratch = alloc_page(gfp_flags);
+	scratch = folio_alloc(gfp_flags, 0);
 	if (!scratch)
 		return ERR_PTR(-ENOMEM);
 
 	xdr_init_decode_pages(&stream, &buf, lgr->layoutp->pages,
 			      lgr->layoutp->len);
-	xdr_set_scratch_page(&stream, scratch);
+	xdr_set_scratch_folio(&stream, scratch);
 
 	/* stripe unit and mirror_array_cnt */
 	rc = -EIO;
@@ -639,7 +639,7 @@ ff_layout_alloc_lseg(struct pnfs_layout_hdr *lh,
 	ret = &fls->generic_hdr;
 	dprintk("<-- %s (success)\n", __func__);
 out_free_page:
-	__free_page(scratch);
+	folio_put(scratch);
 	return ret;
 out_err_free:
 	_ff_layout_free_lseg(fls);
diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
index 9ab1555b45c8..d06a3f619fa7 100644
--- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c
+++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
@@ -44,7 +44,7 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
 {
 	struct xdr_stream stream;
 	struct xdr_buf buf;
-	struct page *scratch;
+	struct folio *scratch;
 	struct list_head dsaddrs;
 	struct nfs4_pnfs_ds_addr *da;
 	struct nfs4_ff_layout_ds *new_ds = NULL;
@@ -56,7 +56,7 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
 	int i, ret = -ENOMEM;
 
 	/* set up xdr stream */
-	scratch = alloc_page(gfp_flags);
+	scratch = folio_alloc(gfp_flags, 0);
 	if (!scratch)
 		goto out_err;
 
@@ -70,7 +70,7 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
 	INIT_LIST_HEAD(&dsaddrs);
 
 	xdr_init_decode_pages(&stream, &buf, pdev->pages, pdev->pglen);
-	xdr_set_scratch_page(&stream, scratch);
+	xdr_set_scratch_folio(&stream, scratch);
 
 	/* multipath count */
 	p = xdr_inline_decode(&stream, 4);
@@ -163,7 +163,7 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
 		kfree(da);
 	}
 
-	__free_page(scratch);
+	folio_put(scratch);
 	return new_ds;
 
 out_err_drain_dsaddrs:
@@ -177,7 +177,7 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
 
 	kfree(ds_versions);
 out_scratch:
-	__free_page(scratch);
+	folio_put(scratch);
 out_err:
 	kfree(new_ds);
 
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v1 8/9] SUNRPC: Update svcxdr_init_decode() to call xdr_set_scratch_folio()
  2025-09-12 21:14 [PATCH v1 0/9] SUNRPC: Convert the scratch page into a scratch folio Anna Schumaker
                   ` (7 preceding siblings ...)
  2025-09-12 21:14 ` [PATCH v1 7/9] NFS: Update the flexfilelayout driver " Anna Schumaker
@ 2025-09-12 21:14 ` Anna Schumaker
  2025-09-12 21:14 ` [PATCH v1 9/9] SUNRPC: Update gssx_accept_sec_context() to use xdr_set_scratch_folio() Anna Schumaker
  9 siblings, 0 replies; 11+ messages in thread
From: Anna Schumaker @ 2025-09-12 21:14 UTC (permalink / raw)
  To: linux-nfs, trond.myklebust; +Cc: anna

From: Anna Schumaker <anna.schumaker@oracle.com>

The only snag here is that __folio_alloc_node() doesn't handle
NUMA_NO_NODE, so I also need to update svc_pool_map_get_node() to return
numa_mem_id() instead. I arrived at this approach by  looking at what
other users of __folio_alloc_node() do for this case.

Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
 include/linux/sunrpc/svc.h |  4 ++--
 net/sunrpc/svc.c           | 10 +++++-----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
index 40cbe81360ed..5506d20857c3 100644
--- a/include/linux/sunrpc/svc.h
+++ b/include/linux/sunrpc/svc.h
@@ -196,7 +196,7 @@ struct svc_rqst {
 	struct xdr_buf		rq_arg;
 	struct xdr_stream	rq_arg_stream;
 	struct xdr_stream	rq_res_stream;
-	struct page		*rq_scratch_page;
+	struct folio		*rq_scratch_folio;
 	struct xdr_buf		rq_res;
 	unsigned long		rq_maxpages;	/* num of entries in rq_pages */
 	struct page *		*rq_pages;
@@ -503,7 +503,7 @@ static inline void svcxdr_init_decode(struct svc_rqst *rqstp)
 	buf->len = buf->head->iov_len + buf->page_len + buf->tail->iov_len;
 
 	xdr_init_decode(xdr, buf, argv->iov_base, NULL);
-	xdr_set_scratch_page(xdr, rqstp->rq_scratch_page);
+	xdr_set_scratch_folio(xdr, rqstp->rq_scratch_folio);
 }
 
 /**
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index 9c7245d811eb..de05ef637bdc 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -352,7 +352,7 @@ static int svc_pool_map_get_node(unsigned int pidx)
 		if (m->mode == SVC_POOL_PERNODE)
 			return m->pool_to[pidx];
 	}
-	return NUMA_NO_NODE;
+	return numa_mem_id();
 }
 /*
  * Set the given thread's cpus_allowed mask so that it
@@ -669,8 +669,8 @@ svc_rqst_free(struct svc_rqst *rqstp)
 	folio_batch_release(&rqstp->rq_fbatch);
 	kfree(rqstp->rq_bvec);
 	svc_release_buffer(rqstp);
-	if (rqstp->rq_scratch_page)
-		put_page(rqstp->rq_scratch_page);
+	if (rqstp->rq_scratch_folio)
+		folio_put(rqstp->rq_scratch_folio);
 	kfree(rqstp->rq_resp);
 	kfree(rqstp->rq_argp);
 	kfree(rqstp->rq_auth_data);
@@ -691,8 +691,8 @@ svc_prepare_thread(struct svc_serv *serv, struct svc_pool *pool, int node)
 	rqstp->rq_server = serv;
 	rqstp->rq_pool = pool;
 
-	rqstp->rq_scratch_page = alloc_pages_node(node, GFP_KERNEL, 0);
-	if (!rqstp->rq_scratch_page)
+	rqstp->rq_scratch_folio = __folio_alloc_node(GFP_KERNEL, 0, node);
+	if (!rqstp->rq_scratch_folio)
 		goto out_enomem;
 
 	rqstp->rq_argp = kmalloc_node(serv->sv_xdrsize, GFP_KERNEL, node);
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v1 9/9] SUNRPC: Update gssx_accept_sec_context() to use xdr_set_scratch_folio()
  2025-09-12 21:14 [PATCH v1 0/9] SUNRPC: Convert the scratch page into a scratch folio Anna Schumaker
                   ` (8 preceding siblings ...)
  2025-09-12 21:14 ` [PATCH v1 8/9] SUNRPC: Update svcxdr_init_decode() to call xdr_set_scratch_folio() Anna Schumaker
@ 2025-09-12 21:14 ` Anna Schumaker
  9 siblings, 0 replies; 11+ messages in thread
From: Anna Schumaker @ 2025-09-12 21:14 UTC (permalink / raw)
  To: linux-nfs, trond.myklebust; +Cc: anna

From: Anna Schumaker <anna.schumaker@oracle.com>

This was the last caller of xdr_set_scratch_page(), so I remove this
function while I'm at it.

Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
 include/linux/sunrpc/xdr.h        | 13 -------------
 net/sunrpc/auth_gss/gss_rpc_xdr.c |  8 ++++----
 2 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h
index 3ce17321689a..49278749ad0c 100644
--- a/include/linux/sunrpc/xdr.h
+++ b/include/linux/sunrpc/xdr.h
@@ -287,19 +287,6 @@ xdr_set_scratch_buffer(struct xdr_stream *xdr, void *buf, size_t buflen)
 	xdr->scratch.iov_len = buflen;
 }
 
-/**
- * xdr_set_scratch_page - Attach a scratch buffer for decoding data
- * @xdr: pointer to xdr_stream struct
- * @page: an anonymous page
- *
- * See xdr_set_scratch_buffer().
- */
-static inline void
-xdr_set_scratch_page(struct xdr_stream *xdr, struct page *page)
-{
-	xdr_set_scratch_buffer(xdr, page_address(page), PAGE_SIZE);
-}
-
 /**
  * xdr_set_scratch_folio - Attach a scratch buffer for decoding data
  * @xdr: pointer to xdr_stream struct
diff --git a/net/sunrpc/auth_gss/gss_rpc_xdr.c b/net/sunrpc/auth_gss/gss_rpc_xdr.c
index cb32ab9a8395..7d2cdc2bd374 100644
--- a/net/sunrpc/auth_gss/gss_rpc_xdr.c
+++ b/net/sunrpc/auth_gss/gss_rpc_xdr.c
@@ -794,12 +794,12 @@ int gssx_dec_accept_sec_context(struct rpc_rqst *rqstp,
 	struct gssx_res_accept_sec_context *res = data;
 	u32 value_follows;
 	int err;
-	struct page *scratch;
+	struct folio *scratch;
 
-	scratch = alloc_page(GFP_KERNEL);
+	scratch = folio_alloc(GFP_KERNEL, 0);
 	if (!scratch)
 		return -ENOMEM;
-	xdr_set_scratch_page(xdr, scratch);
+	xdr_set_scratch_folio(xdr, scratch);
 
 	/* res->status */
 	err = gssx_dec_status(xdr, &res->status);
@@ -844,6 +844,6 @@ int gssx_dec_accept_sec_context(struct rpc_rqst *rqstp,
 	err = gssx_dec_option_array(xdr, &res->options);
 
 out_free:
-	__free_page(scratch);
+	folio_put(scratch);
 	return err;
 }
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-09-12 21:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-12 21:14 [PATCH v1 0/9] SUNRPC: Convert the scratch page into a scratch folio Anna Schumaker
2025-09-12 21:14 ` [PATCH v1 1/9] sunrpc: Introduce xdr_set_scratch_folio() Anna Schumaker
2025-09-12 21:14 ` [PATCH v1 1/9] SUNRPC: " Anna Schumaker
2025-09-12 21:14 ` [PATCH v1 2/9] NFS: Update readdir to use a scratch folio Anna Schumaker
2025-09-12 21:14 ` [PATCH v1 3/9] NFS: Update getacl to use xdr_set_scratch_folio() Anna Schumaker
2025-09-12 21:14 ` [PATCH v1 4/9] NFS: Update listxattr " Anna Schumaker
2025-09-12 21:14 ` [PATCH v1 5/9] NFS: Update the blocklayout " Anna Schumaker
2025-09-12 21:14 ` [PATCH v1 6/9] NFS: Update the filelayout " Anna Schumaker
2025-09-12 21:14 ` [PATCH v1 7/9] NFS: Update the flexfilelayout driver " Anna Schumaker
2025-09-12 21:14 ` [PATCH v1 8/9] SUNRPC: Update svcxdr_init_decode() to call xdr_set_scratch_folio() Anna Schumaker
2025-09-12 21:14 ` [PATCH v1 9/9] SUNRPC: Update gssx_accept_sec_context() to use xdr_set_scratch_folio() Anna Schumaker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox