mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
To: Jan Kara <jack@suse.com>, Mark Fasheh <mark@fasheh.com>,
	 Joel Becker <jlbec@evilplan.org>,
	Joseph Qi <joseph.qi@linux.alibaba.com>,
	 Ryusuke Konishi <konishi.ryusuke@gmail.com>,
	 Viacheslav Dubeyko <slava@dubeyko.com>,
	 Trond Myklebust <trondmy@kernel.org>,
	Anna Schumaker <anna@kernel.org>,
	 Chuck Lever <chuck.lever@oracle.com>,
	Jeff Layton <jlayton@kernel.org>,  NeilBrown <neil@brown.name>,
	Olga Kornievskaia <okorniev@redhat.com>,
	 Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
	 Alexander Viro <viro@zeniv.linux.org.uk>,
	 Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
	 Dave Kleikamp <shaggy@kernel.org>, Theodore Ts'o <tytso@mit.edu>,
	 Miklos Szeredi <miklos@szeredi.hu>,
	 Andreas Hindborg <a.hindborg@kernel.org>,
	Breno Leitao <leitao@debian.org>,  Kees Cook <kees@kernel.org>,
	 "Tigran A. Aivazian" <aivazian.tigran@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	 ocfs2-devel@lists.linux.dev, linux-nilfs@vger.kernel.org,
	 linux-nfs@vger.kernel.org, jfs-discussion@lists.sourceforge.net,
	 linux-ext4@vger.kernel.org, linux-mm@kvack.org,
	 "Mike Rapoport (Microsoft)" <rppt@kernel.org>
Subject: [PATCH 09/17] jfs: replace __get_free_page() with kmalloc()
Date: Sat, 23 May 2026 20:54:21 +0300	[thread overview]
Message-ID: <20260523-b4-fs-v1-9-275e36a83f0e@kernel.org> (raw)
In-Reply-To: <20260523-b4-fs-v1-0-275e36a83f0e@kernel.org>

jfs_readdir() allocates dirent_buf 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@kernel.org>
---
 fs/jfs/jfs_dtree.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
index ac0f79fafaca..8ce6e4458cc2 100644
--- a/fs/jfs/jfs_dtree.c
+++ b/fs/jfs/jfs_dtree.c
@@ -2729,7 +2729,7 @@ int jfs_readdir(struct file *file, struct dir_context *ctx)
 	struct ldtentry *d;
 	struct dtslot *t;
 	int d_namleft, len, outlen;
-	unsigned long dirent_buf;
+	void *dirent_buf;
 	char *name_ptr;
 	u32 dir_index;
 	int do_index = 0;
@@ -2884,7 +2884,7 @@ int jfs_readdir(struct file *file, struct dir_context *ctx)
 		}
 	}
 
-	dirent_buf = __get_free_page(GFP_KERNEL);
+	dirent_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
 	if (dirent_buf == 0) {
 		DT_PUTPAGE(mp);
 		jfs_warn("jfs_readdir: __get_free_page failed!");
@@ -2893,7 +2893,7 @@ int jfs_readdir(struct file *file, struct dir_context *ctx)
 	}
 
 	while (1) {
-		jfs_dirent = (struct jfs_dirent *) dirent_buf;
+		jfs_dirent = dirent_buf;
 		jfs_dirents = 0;
 		overflow = fix_page = 0;
 
@@ -2903,7 +2903,7 @@ int jfs_readdir(struct file *file, struct dir_context *ctx)
 			if (stbl[i] < 0) {
 				jfs_err("JFS: Invalid stbl[%d] = %d for inode %ld, block = %lld",
 					i, stbl[i], (long)ip->i_ino, (long long)bn);
-				free_page(dirent_buf);
+				kfree(dirent_buf);
 				DT_PUTPAGE(mp);
 				return -EIO;
 			}
@@ -2911,7 +2911,7 @@ int jfs_readdir(struct file *file, struct dir_context *ctx)
 			d = (struct ldtentry *) & p->slot[stbl[i]];
 
 			if (((long) jfs_dirent + d->namlen + 1) >
-			    (dirent_buf + PAGE_SIZE)) {
+			    ((long)dirent_buf + PAGE_SIZE)) {
 				/* DBCS codepages could overrun dirent_buf */
 				index = i;
 				overflow = 1;
@@ -3014,7 +3014,7 @@ int jfs_readdir(struct file *file, struct dir_context *ctx)
 		/* unpin previous leaf page */
 		DT_PUTPAGE(mp);
 
-		jfs_dirent = (struct jfs_dirent *) dirent_buf;
+		jfs_dirent = dirent_buf;
 		while (jfs_dirents--) {
 			ctx->pos = jfs_dirent->position;
 			if (!dir_emit(ctx, jfs_dirent->name,
@@ -3037,13 +3037,13 @@ int jfs_readdir(struct file *file, struct dir_context *ctx)
 
 		DT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
 		if (rc) {
-			free_page(dirent_buf);
+			kfree(dirent_buf);
 			return rc;
 		}
 	}
 
       out:
-	free_page(dirent_buf);
+	kfree(dirent_buf);
 
 	return rc;
 }

-- 
2.53.0


  parent reply	other threads:[~2026-05-23 17:55 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-23 17:54 [PATCH 00/17] fs: replace __get_free_pages() call " Mike Rapoport (Microsoft)
2026-05-23 17:54 ` [PATCH 01/17] quota: allocate dquot_hash " Mike Rapoport (Microsoft)
2026-05-25 16:10   ` Jan Kara
2026-05-23 17:54 ` [PATCH 02/17] proc: replace __get_free_page() " Mike Rapoport (Microsoft)
2026-05-25 16:11   ` Jan Kara
2026-05-23 17:54 ` [PATCH 03/17] ocfs2/dlm: " Mike Rapoport (Microsoft)
2026-05-25  2:50   ` Joseph Qi
2026-05-25 16:13   ` Jan Kara
2026-05-23 17:54 ` [PATCH 04/17] nilfs2: replace get_zeroed_page() with kzalloc() Mike Rapoport (Microsoft)
2026-05-25 17:07   ` Viacheslav Dubeyko
2026-05-27 16:02     ` Ryusuke Konishi
2026-05-23 17:54 ` [PATCH 05/17] NFS: replace __get_free_page() with kmalloc() in nfs_show_devname() Mike Rapoport (Microsoft)
2026-05-23 17:54 ` [PATCH 06/17] NFS: remove unused page and page2 in nfs4_replace_transport() Mike Rapoport (Microsoft)
2026-05-23 17:54 ` [PATCH 07/17] NFSD: replace __get_free_page() with kmalloc() in nfsd_buffered_readdir() Mike Rapoport (Microsoft)
2026-05-23 18:45   ` Jeff Layton
2026-05-23 17:54 ` [PATCH 08/17] libfs: simple_transaction_get(): replace get_zeroed_page() with kzalloc() Mike Rapoport (Microsoft)
2026-05-23 17:54 ` Mike Rapoport (Microsoft) [this message]
2026-05-23 17:54 ` [PATCH 10/17] jbd2: replace __get_free_pages() with kmalloc() Mike Rapoport (Microsoft)
2026-05-25 16:17   ` Jan Kara
2026-05-25 17:21     ` David Laight
2026-05-25 17:55       ` Matthew Wilcox
2026-05-26  9:35         ` David Laight
2026-06-03 13:50   ` Theodore Tso
2026-06-04  6:14     ` Mike Rapoport
2026-06-04 14:05       ` Theodore Tso
2026-06-04 14:46         ` Matthew Wilcox
2026-06-05  8:33         ` David Laight
2026-06-05  9:50           ` Uladzislau Rezki
2026-06-05 20:54           ` Matthew Wilcox
2026-05-23 17:54 ` [PATCH 11/17] isofs: replace __get_free_page() " Mike Rapoport (Microsoft)
2026-05-25 16:17   ` Jan Kara
2026-05-23 17:54 ` [PATCH 12/17] fuse: " Mike Rapoport (Microsoft)
2026-05-26 15:00   ` Miklos Szeredi
2026-05-23 17:54 ` [PATCH 13/17] fs/select: " Mike Rapoport (Microsoft)
2026-05-25 16:19   ` Jan Kara
2026-05-23 17:54 ` [PATCH 14/17] fs/namespace: use __getname() to allocate mntpath buffer Mike Rapoport (Microsoft)
2026-05-25 16:22   ` Jan Kara
2026-05-26  9:06     ` Mike Rapoport
2026-05-28 11:54       ` Christian Brauner
2026-05-23 17:54 ` [PATCH 15/17] configfs: replace __get_free_pages() with kzalloc() Mike Rapoport (Microsoft)
2026-05-25 16:22   ` Jan Kara
2026-05-23 17:54 ` [PATCH 16/17] binfmt_misc: replace __get_free_page() with kmalloc() Mike Rapoport (Microsoft)
2026-05-23 17:54 ` [PATCH 17/17] bfs: replace get_zeroed_page() with kzalloc() Mike Rapoport (Microsoft)
2026-05-27 12:05 ` [PATCH 00/17] fs: replace __get_free_pages() call with kmalloc() Christian Brauner
2026-06-05 20:00 ` [PATCH 00/17] " Zi Yan
2026-06-11  9:09   ` Mike Rapoport

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260523-b4-fs-v1-9-275e36a83f0e@kernel.org \
    --to=rppt@kernel.org \
    --cc=Dai.Ngo@oracle.com \
    --cc=a.hindborg@kernel.org \
    --cc=aivazian.tigran@gmail.com \
    --cc=anna@kernel.org \
    --cc=brauner@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=jack@suse.com \
    --cc=jack@suse.cz \
    --cc=jfs-discussion@lists.sourceforge.net \
    --cc=jlayton@kernel.org \
    --cc=jlbec@evilplan.org \
    --cc=joseph.qi@linux.alibaba.com \
    --cc=kees@kernel.org \
    --cc=konishi.ryusuke@gmail.com \
    --cc=leitao@debian.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-nilfs@vger.kernel.org \
    --cc=mark@fasheh.com \
    --cc=miklos@szeredi.hu \
    --cc=neil@brown.name \
    --cc=ocfs2-devel@lists.linux.dev \
    --cc=okorniev@redhat.com \
    --cc=shaggy@kernel.org \
    --cc=slava@dubeyko.com \
    --cc=tom@talpey.com \
    --cc=trondmy@kernel.org \
    --cc=tytso@mit.edu \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®