Re: [PATCH 07/17] NFSD: replace __get_free_page() with kmalloc() in nfsd_buffered_readdir()

From: Jeff Layton

Date: Sat May 23 2026 - 14:46:18 EST


On Sat, 2026-05-23 at 20:54 +0300, Mike Rapoport (Microsoft) wrote:
> nfsd_buffered_readdir() allocates a staging buffer with __get_free_page().
>
> kmalloc() is a better API for such use and it also provides better
> scalability and more debugging possibilities.
>
> Replace use of __get_free_page() with kmalloc().
>
> Signed-off-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
> ---
> fs/nfsd/vfs.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> index eafdf7b7890f..c99e54b23cd9 100644
> --- a/fs/nfsd/vfs.c
> +++ b/fs/nfsd/vfs.c
> @@ -2407,7 +2407,7 @@ static __be32 nfsd_buffered_readdir(struct file *file, struct svc_fh *fhp,
> loff_t offset;
> struct readdir_data buf = {
> .ctx.actor = nfsd_buffered_filldir,
> - .dirent = (void *)__get_free_page(GFP_KERNEL)
> + .dirent = kmalloc(PAGE_SIZE, GFP_KERNEL)
> };
>
> if (!buf.dirent)
> @@ -2458,7 +2458,7 @@ static __be32 nfsd_buffered_readdir(struct file *file, struct svc_fh *fhp,
> offset = vfs_llseek(file, 0, SEEK_CUR);
> }
>
> - free_page((unsigned long)(buf.dirent));
> + kfree((buf.dirent));

nit: Don't need double parenthesis here

>
> if (host_err)
> return nfserrno(host_err);

The rest seems ok though.

Acked-by: Jeff Layton <jlayton@xxxxxxxxxx>