]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
quota: allocate dquot_hash with kmalloc()
authorMike Rapoport (Microsoft) <rppt@kernel.org>
Sat, 23 May 2026 17:54:13 +0000 (20:54 +0300)
committerJan Kara <jack@suse.cz>
Mon, 25 May 2026 16:09:40 +0000 (18:09 +0200)
dquot_init() allocates a single page for dquot_hash with
__get_free_pages().

kmalloc() is a better API for such use and it also provides better
scalability and more debugging possibilities.

Replace use of __get_free_pages() with kmalloc() and get rid of the order
variable that remained 0 for more than 20 years.

Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Link: https://patch.msgid.link/20260523-b4-fs-v1-1-275e36a83f0e@kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
fs/quota/dquot.c

index 64cf42721496544e431878551c6c0e9daa2ca43c..9850de3955d313df9c8cad4dbd276e59576ea722 100644 (file)
@@ -3022,7 +3022,7 @@ static const struct ctl_table fs_dqstats_table[] = {
 static int __init dquot_init(void)
 {
        int i, ret;
-       unsigned long nr_hash, order;
+       unsigned long nr_hash;
        struct shrinker *dqcache_shrinker;
 
        printk(KERN_NOTICE "VFS: Disk quotas %s\n", __DQUOT_VERSION__);
@@ -3035,8 +3035,7 @@ static int __init dquot_init(void)
                                SLAB_PANIC),
                        NULL);
 
-       order = 0;
-       dquot_hash = (struct hlist_head *)__get_free_pages(GFP_KERNEL, order);
+       dquot_hash = kmalloc(PAGE_SIZE, GFP_KERNEL);
        if (!dquot_hash)
                panic("Cannot create dquot hash table");
 
@@ -3046,7 +3045,7 @@ static int __init dquot_init(void)
                panic("Cannot create dquot stat counters");
 
        /* Find power-of-two hlist_heads which can fit into allocation */
-       nr_hash = (1UL << order) * PAGE_SIZE / sizeof(struct hlist_head);
+       nr_hash = PAGE_SIZE / sizeof(struct hlist_head);
        dq_hash_bits = ilog2(nr_hash);
 
        nr_hash = 1UL << dq_hash_bits;
@@ -3054,8 +3053,8 @@ static int __init dquot_init(void)
        for (i = 0; i < nr_hash; i++)
                INIT_HLIST_HEAD(dquot_hash + i);
 
-       pr_info("VFS: Dquot-cache hash table entries: %ld (order %ld,"
-               " %ld bytes)\n", nr_hash, order, (PAGE_SIZE << order));
+       pr_info("VFS: Dquot-cache hash table entries: %ld (%ld bytes)\n",
+               nr_hash, PAGE_SIZE);
 
        dqcache_shrinker = shrinker_alloc(0, "dquota-cache");
        if (!dqcache_shrinker)