Skip to content

Commit 6d06b04

Browse files
rpptjankara
authored andcommitted
quota: allocate dquot_hash with kmalloc()
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>
1 parent 5f04194 commit 6d06b04

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

fs/quota/dquot.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3022,7 +3022,7 @@ static const struct ctl_table fs_dqstats_table[] = {
30223022
static int __init dquot_init(void)
30233023
{
30243024
int i, ret;
3025-
unsigned long nr_hash, order;
3025+
unsigned long nr_hash;
30263026
struct shrinker *dqcache_shrinker;
30273027

30283028
printk(KERN_NOTICE "VFS: Disk quotas %s\n", __DQUOT_VERSION__);
@@ -3035,8 +3035,7 @@ static int __init dquot_init(void)
30353035
SLAB_PANIC),
30363036
NULL);
30373037

3038-
order = 0;
3039-
dquot_hash = (struct hlist_head *)__get_free_pages(GFP_KERNEL, order);
3038+
dquot_hash = kmalloc(PAGE_SIZE, GFP_KERNEL);
30403039
if (!dquot_hash)
30413040
panic("Cannot create dquot hash table");
30423041

@@ -3046,16 +3045,16 @@ static int __init dquot_init(void)
30463045
panic("Cannot create dquot stat counters");
30473046

30483047
/* Find power-of-two hlist_heads which can fit into allocation */
3049-
nr_hash = (1UL << order) * PAGE_SIZE / sizeof(struct hlist_head);
3048+
nr_hash = PAGE_SIZE / sizeof(struct hlist_head);
30503049
dq_hash_bits = ilog2(nr_hash);
30513050

30523051
nr_hash = 1UL << dq_hash_bits;
30533052
dq_hash_mask = nr_hash - 1;
30543053
for (i = 0; i < nr_hash; i++)
30553054
INIT_HLIST_HEAD(dquot_hash + i);
30563055

3057-
pr_info("VFS: Dquot-cache hash table entries: %ld (order %ld,"
3058-
" %ld bytes)\n", nr_hash, order, (PAGE_SIZE << order));
3056+
pr_info("VFS: Dquot-cache hash table entries: %ld (%ld bytes)\n",
3057+
nr_hash, PAGE_SIZE);
30593058

30603059
dqcache_shrinker = shrinker_alloc(0, "dquota-cache");
30613060
if (!dqcache_shrinker)

0 commit comments

Comments
 (0)