Skip to contentSkip to conversation

quota: check for register_sysctl() failure when has CONFIG_SYSCTL

PATCH In review Yangtao Li 2 participants 2 messages Mar 20, 2023 – Mar 22, 2023 Diskquota

lore
Share & tools
lore

Yangtao Li

author
#0 lore raw

PATCH 1/1 quota: check for register_sysctl() failure when has CONFIG_SYSCTL

Print a message that sysctl registration failed if CONFIG_SYSCTL is enabled, and wrap the fs_dqstats_table array with CONFIG_SYSCTL.

---
 fs/quota/dquot.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
fs/quota/dquot.c +6 -1
index 90cb70c82012..a16ddda02612 100644
@@ -2879,6 +2879,7 @@ static int do_proc_dqstats(struct ctl_table *table, int write,
 	return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
 }
 
+#ifdef CONFIG_SYSCTL
 static struct ctl_table fs_dqstats_table[] = {
 	{
 		.procname	= "lookups",
@@ -2947,6 +2948,7 @@ static struct ctl_table fs_dqstats_table[] = {
 #endif
 	{ },
 };
+#endif
 
 static int __init dquot_init(void)
 {
@@ -2955,7 +2957,10 @@ static int __init dquot_init(void)
 
 	printk(KERN_NOTICE "VFS: Disk quotas %s\n", __DQUOT_VERSION__);
 
-	register_sysctl("fs/quota", fs_dqstats_table);
+#ifdef CONFIG_SYSCTL
+	if (!register_sysctl("fs/quota", fs_dqstats_table))
+		pr_notice("quota sysctl registration failed!\n");
+#endif
 
 	dquot_cachep = kmem_cache_create("dquot",
 			sizeof(struct dquot), sizeof(unsigned long) * 4,
Signature · 1 line
2.35.1
#1 lore raw
Quoted 4 lines · Yangtao Li

Print a message that sysctl registration failed if CONFIG_SYSCTL is enabled, and wrap the fs_dqstats_table array with CONFIG_SYSCTL.

Thanks! I've added the patch to my tree.

Honza

Quoted 39 lines
---
 fs/quota/dquot.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
fs/quota/dquot.c +6 -1
index 90cb70c82012..a16ddda02612 100644
@@ -2879,6 +2879,7 @@ static int do_proc_dqstats(struct ctl_table *table, int write,
 	return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
 }
 
+#ifdef CONFIG_SYSCTL
 static struct ctl_table fs_dqstats_table[] = {
 	{
 		.procname	= "lookups",
@@ -2947,6 +2948,7 @@ static struct ctl_table fs_dqstats_table[] = {
 #endif
 	{ },
 };
+#endif
 
 static int __init dquot_init(void)
 {
@@ -2955,7 +2957,10 @@ static int __init dquot_init(void)
 
 	printk(KERN_NOTICE "VFS: Disk quotas %s\n", __DQUOT_VERSION__);
 
-	register_sysctl("fs/quota", fs_dqstats_table);
+#ifdef CONFIG_SYSCTL
+	if (!register_sysctl("fs/quota", fs_dqstats_table))
+		pr_notice("quota sysctl registration failed!\n");
+#endif
 
 	dquot_cachep = kmem_cache_create("dquot",
 			sizeof(struct dquot), sizeof(unsigned long) * 4,
Signature · 1 line
2.35.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR