FAILED: patch "[PATCH] quota: initialize dquot cache before mounting rootfs" failed to apply to 6.6-stable tree
Subsystems (3)
Sasha Levin
maintainerThe patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x e21a6f39aa6d0336ffbf5f34e5fa20ff8de36773
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 6.6.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From e21a6f39aa6d0336ffbf5f34e5fa20ff8de36773 Mon Sep 17 00:00:00 2001
From: YouYou Yu <[email protected]>
Date: Wed, 21 Oct 2026 18:12:17 +0000
Subject: [PATCH] quota: initialize dquot cache before mounting rootfs
On some systems, a tmpfs backed rootfs is extensively used throughout system's lifecycle. tmpfs quotas are needed to limit per user rootfs usage. However, booting with CONFIG_TMPFS_QUOTA=y, an initramfs, no root= and "initramfs_options=usrquota" panics at boot:
BUG: kernel NULL pointer dereference, address: 0000000000000000 RIP: 0010:dqget+0x1ac/0x490 Call Trace: __dquot_initialize dquot_initialize shmem_get_inode shmem_fill_super ... mnt_init vfs_caches_init start_kernel
The rootfs is mounted from mnt_init(), but the dquot hash table and cache are only set up later by dquot_init(), an fs_initcall. Creating the root inode of a quota enabled rootfs thus dereferences the NULL dquot_hash in dqget().
Rename dquot_init() to dquot_cache_init() and call it from vfs_caches_init() before mnt_init(). The slab, percpu and early workqueue code it relies on is available there, and the workqueue rescuer and shrinker debugfs entries are set up later by their own subsystems. Keep the sysctl registration in an fs_initcall, as done for the dcache, inode and mount sysctls. This only moves existing allocations earlier in boot.
--- fs/dcache.c | 2 ++ fs/quota/dquot.c | 10 ++++++---- include/linux/quotaops.h | 5 +++++ 3 files changed, 13 insertions(+), 4 deletions(-)
fs/dcache.c +2 -0
@@ -33,6 +33,7 @@#include <linux/rculist_bl.h> #include <linux/list_lru.h> #include <linux/namei.h> +#include <linux/quotaops.h> #include "internal.h" #include "mount.h"
@@ -3683,6 +3684,7 @@ void __init vfs_caches_init(void)inode_init ();files_init ();files_maxfiles_init (); +dquot_cache_init ();mnt_init ();bdev_cache_init ();chrdev_init ();
fs/quota/dquot.c +6 -4
@@ -2958,7 +2958,7 @@ static const struct ctl_table fs_dqstats_table[] = { }, }; -static int __init dquot_init (void ) +void __init dquot_cache_init (void ) {int i, ret;unsigned long nr_hash;
@@ -2966,8 +2966,6 @@ static int __init dquot_init(void)printk (KERN_NOTICE "VFS: Disk quotas %s\n" , __DQUOT_VERSION__); -register_sysctl_init ("fs/quota" , fs_dqstats_table); - dquot_cachep = kmem_cache_create("dquot", sizeof(struct dquot), sizeof(unsigned long) * 4, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
@@ -3008,7 +3006,11 @@ static int __init dquot_init(void) WQ_UNBOUND | WQ_MEM_RECLAIM, WQ_MAX_ACTIVE);if (!quota_unbound_wq)panic ("Cannot create quota_unbound_wq\n" ); +} +static int __init init_fs_dquot_sysctls (void ) +{ +register_sysctl_init ("fs/quota" , fs_dqstats_table);return 0 ; } -fs_initcall (dquot_init); +fs_initcall (init_fs_dquot_sysctls);
include/linux/quotaops.h +5 -0
@@ -40,6 +40,7 @@ void __quota_error(struct super_block *sb, const char *func,/* * declaration of quota_function calls in kernel. */ +void dquot_cache_init (void );int dquot_initialize (struct inode *inode);bool dquot_initialize_needed (struct inode *inode);void dquot_drop (struct inode *inode);
@@ -206,6 +207,10 @@ static inline int sb_has_quota_active(struct super_block *sb, int type)return 0 ; } +static inline void dquot_cache_init (void ) +{ +} +static inline int dquot_initialize (struct inode *inode) {return 0 ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 quota: initialize dquot cache before mounting rootfs
From: YouYou Yu <[email protected]>
[ Upstream commit e21a6f39aa6d0336ffbf5f34e5fa20ff8de36773 ]
On some systems, a tmpfs backed rootfs is extensively used throughout system's lifecycle. tmpfs quotas are needed to limit per user rootfs usage. However, booting with CONFIG_TMPFS_QUOTA=y, an initramfs, no root= and "initramfs_options=usrquota" panics at boot:
BUG: kernel NULL pointer dereference, address: 0000000000000000 RIP: 0010:dqget+0x1ac/0x490 Call Trace: __dquot_initialize dquot_initialize shmem_get_inode shmem_fill_super ... mnt_init vfs_caches_init start_kernel
The rootfs is mounted from mnt_init(), but the dquot hash table and cache are only set up later by dquot_init(), an fs_initcall. Creating the root inode of a quota enabled rootfs thus dereferences the NULL dquot_hash in dqget().
Rename dquot_init() to dquot_cache_init() and call it from vfs_caches_init() before mnt_init(). The slab, percpu and early workqueue code it relies on is available there, and the workqueue rescuer and shrinker debugfs entries are set up later by their own subsystems. Keep the sysctl registration in an fs_initcall, as done for the dcache, inode and mount sysctls. This only moves existing allocations earlier in boot.
--- fs/dcache.c | 2 ++ fs/quota/dquot.c | 10 ++++++---- include/linux/quotaops.h | 5 +++++ 3 files changed, 13 insertions(+), 4 deletions(-)
fs/dcache.c +2 -0
@@ -32,6 +32,7 @@#include <linux/bit_spinlock.h> #include <linux/rculist_bl.h> #include <linux/list_lru.h> +#include <linux/quotaops.h> #include "internal.h" #include "mount.h"
@@ -3357,6 +3358,7 @@ void __init vfs_caches_init(void)inode_init ();files_init ();files_maxfiles_init (); +dquot_cache_init ();mnt_init ();bdev_cache_init ();chrdev_init ();
fs/quota/dquot.c +6 -4
@@ -3030,15 +3030,13 @@ static struct ctl_table fs_dqstats_table[] = { { }, }; -static int __init dquot_init (void ) +void __init dquot_cache_init (void ) {int i, ret;unsigned long nr_hash, order;printk (KERN_NOTICE "VFS: Disk quotas %s\n" , __DQUOT_VERSION__); -register_sysctl_init ("fs/quota" , fs_dqstats_table); - dquot_cachep = kmem_cache_create("dquot", sizeof(struct dquot), sizeof(unsigned long) * 4, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
@@ -3075,7 +3073,11 @@ static int __init dquot_init(void) WQ_UNBOUND | WQ_MEM_RECLAIM, WQ_MAX_ACTIVE);if (!quota_unbound_wq)panic ("Cannot create quota_unbound_wq\n" ); +} +static int __init init_fs_dquot_sysctls (void ) +{ +register_sysctl_init ("fs/quota" , fs_dqstats_table);return 0 ; } -fs_initcall (dquot_init); +fs_initcall (init_fs_dquot_sysctls);
include/linux/quotaops.h +5 -0
@@ -40,6 +40,7 @@ void __quota_error(struct super_block *sb, const char *func,/* * declaration of quota_function calls in kernel. */ +void dquot_cache_init (void );int dquot_initialize (struct inode *inode);bool dquot_initialize_needed (struct inode *inode);void dquot_drop (struct inode *inode);
@@ -206,6 +207,10 @@ static inline int sb_has_quota_active(struct super_block *sb, int type)return 0 ; } +static inline void dquot_cache_init (void ) +{ +} +static inline int dquot_initialize (struct inode *inode) {return 0 ;
Signature · 1 line
2.53.0