]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
jfs: replace __get_free_page() with kmalloc()
authorMike Rapoport (Microsoft) <rppt@kernel.org>
Sat, 23 May 2026 17:54:21 +0000 (20:54 +0300)
committerChristian Brauner <brauner@kernel.org>
Wed, 27 May 2026 13:12:23 +0000 (15:12 +0200)
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>
fs/jfs/jfs_dtree.c

index ac0f79fafaca04828256f2d5d8478e672083a940..8ce6e4458cc256a88c596748f5b0dc611a85a184 100644 (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 @@ skip_one:
                /* 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 @@ skip_one:
 
                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;
 }