SUNRPC: Convert the scratch page into a scratch folio
Subsystems (3)
Anna Schumaker
maintainercover SUNRPC: Convert the scratch page into a scratch folio
From: Anna Schumaker <[email protected]>
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(-)
Signature · 1 line
2.51.0
Anna Schumaker
maintainerPATCH 1/9 sunrpc: Introduce xdr_set_scratch_folio()
From: Anna Schumaker <[email protected]>
This will replace xdr_set_scratch_page() when we switch pages to folios.
--- include/linux/sunrpc/xdr.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)
include/linux/sunrpc/xdr.h +13 -0
@@ -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
Signature · 1 line
2.51.0
Anna Schumaker
maintainerPATCH 1/9 SUNRPC: Introduce xdr_set_scratch_folio()
In reply to Anna SchumakerFrom: Anna Schumaker <[email protected]>
This will replace xdr_set_scratch_page() when we switch pages to folios.
--- include/linux/sunrpc/xdr.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)
include/linux/sunrpc/xdr.h +13 -0
@@ -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
Signature · 1 line
2.51.0
Anna Schumaker
maintainerPATCH 2/9 NFS: Update readdir to use a scratch folio
In reply to Anna SchumakerFrom: Anna Schumaker <[email protected]>
--- fs/nfs/dir.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/nfs/dir.c +4 -4
@@ -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; }
Signature · 1 line
2.51.0
Anna Schumaker
maintainerPATCH 3/9 NFS: Update getacl to use xdr_set_scratch_folio()
In reply to Anna SchumakerFrom: Anna Schumaker <[email protected]>
--- fs/nfs/nfs4proc.c | 4 ++-- fs/nfs/nfs4xdr.c | 2 +- include/linux/nfs_xdr.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
fs/nfs/nfs4proc.c +2 -2
@@ -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; }
fs/nfs/nfs4xdr.c +1 -1
@@ -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;
include/linux/nfs_xdr.h +1 -1
@@ -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 {
Signature · 1 line
2.51.0
Anna Schumaker
maintainerPATCH 4/9 NFS: Update listxattr to use xdr_set_scratch_folio()
In reply to Anna SchumakerFrom: Anna Schumaker <[email protected]>
--- fs/nfs/nfs42proc.c | 4 ++-- fs/nfs/nfs42xdr.c | 2 +- include/linux/nfs_xdr.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
fs/nfs/nfs42proc.c +2 -2
@@ -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;
fs/nfs/nfs42xdr.c +1 -1
@@ -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)
include/linux/nfs_xdr.h +1 -1
@@ -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;
Signature · 1 line
2.51.0
Anna Schumaker
maintainerPATCH 5/9 NFS: Update the blocklayout to use xdr_set_scratch_folio()
In reply to Anna SchumakerFrom: Anna Schumaker <[email protected]>
--- fs/nfs/blocklayout/blocklayout.c | 8 ++++---- fs/nfs/blocklayout/dev.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-)
fs/nfs/blocklayout/blocklayout.c +4 -4
@@ -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) {
fs/nfs/blocklayout/dev.c +4 -4
@@ -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; }
Signature · 1 line
2.51.0
Anna Schumaker
maintainerPATCH 6/9 NFS: Update the filelayout to use xdr_set_scratch_folio()
In reply to Anna SchumakerFrom: Anna Schumaker <[email protected]>
--- fs/nfs/filelayout/filelayout.c | 10 +++++----- fs/nfs/filelayout/filelayoutdev.c | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-)
fs/nfs/filelayout/filelayout.c +5 -5
@@ -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 ; }
fs/nfs/filelayout/filelayoutdev.c +5 -5
@@ -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 ;
Signature · 1 line
2.51.0
Anna Schumaker
maintainerPATCH 7/9 NFS: Update the flexfilelayout driver to use xdr_set_scratch_folio()
In reply to Anna SchumakerFrom: Anna Schumaker <[email protected]>
--- fs/nfs/flexfilelayout/flexfilelayout.c | 8 ++++---- fs/nfs/flexfilelayout/flexfilelayoutdev.c | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-)
fs/nfs/flexfilelayout/flexfilelayout.c +4 -4
@@ -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);
fs/nfs/flexfilelayout/flexfilelayoutdev.c +5 -5
@@ -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);
Signature · 1 line
2.51.0
Anna Schumaker
maintainerPATCH 8/9 SUNRPC: Update svcxdr_init_decode() to call xdr_set_scratch_folio()
In reply to Anna SchumakerFrom: Anna Schumaker <[email protected]>
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.
--- include/linux/sunrpc/svc.h | 4 ++-- net/sunrpc/svc.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-)
include/linux/sunrpc/svc.h +2 -2
@@ -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); }/**
net/sunrpc/svc.c +5 -5
@@ -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);
Signature · 1 line
2.51.0
Anna Schumaker
maintainerPATCH 9/9 SUNRPC: Update gssx_accept_sec_context() to use xdr_set_scratch_folio()
In reply to Anna SchumakerFrom: Anna Schumaker <[email protected]>
This was the last caller of xdr_set_scratch_page(), so I remove this function while I'm at it.
--- include/linux/sunrpc/xdr.h | 13 ------------- net/sunrpc/auth_gss/gss_rpc_xdr.c | 8 ++++---- 2 files changed, 4 insertions(+), 17 deletions(-)
include/linux/sunrpc/xdr.h +0 -13
@@ -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
net/sunrpc/auth_gss/gss_rpc_xdr.c +4 -4
@@ -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; }
Signature · 1 line
2.51.0