]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
jbd2: replace __get_free_pages() with kmalloc()
authorMike Rapoport (Microsoft) <rppt@kernel.org>
Sat, 23 May 2026 17:54:22 +0000 (20:54 +0300)
committerChristian Brauner <brauner@kernel.org>
Wed, 27 May 2026 13:12:24 +0000 (15:12 +0200)
jbd2_alloc() falls back from kmem_cache_alloc() to __get_free_pages() for
allocations larger than PAGE_SIZE.
But kmalloc() can handle such cases with essentially the same fallback.

Replace use of __get_free_pages() with kmalloc() and simplify
jbd2_free() as both kmem_cache_alloc() and kmalloc() allocations can be
freed with kfree().

Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Link: https://patch.msgid.link/20260523-b4-fs-v1-10-275e36a83f0e@kernel.org
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
fs/jbd2/journal.c

index 4f397fcdb13c51494added4bdd6026546b7ed5d5..1137b471e4907f89e9e2c4f1c29d7a129a7318db 100644 (file)
@@ -2784,7 +2784,7 @@ void *jbd2_alloc(size_t size, gfp_t flags)
        if (size < PAGE_SIZE)
                ptr = kmem_cache_alloc(get_slab(size), flags);
        else
-               ptr = (void *)__get_free_pages(flags, get_order(size));
+               ptr = kmalloc(size, flags);
 
        /* Check alignment; SLUB has gotten this wrong in the past,
         * and this can lead to user data corruption! */
@@ -2795,10 +2795,7 @@ void *jbd2_alloc(size_t size, gfp_t flags)
 
 void jbd2_free(void *ptr, size_t size)
 {
-       if (size < PAGE_SIZE)
-               kmem_cache_free(get_slab(size), ptr);
-       else
-               free_pages((unsigned long)ptr, get_order(size));
+       kfree(ptr);
 };
 
 /*