jfs: replace __get_free_page() with kmalloc()

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>
Link: https://patch.msgid.link/20260523-b4-fs-v1-9-275e36a83f0e@kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
This commit is contained in:
Mike Rapoport (Microsoft) 2026-05-23 20:54:21 +03:00 committed by Christian Brauner
parent 02d7d892d2
commit de9f4f0b2c
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2

View File

@ -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;
}