Home » Mailing lists » Devel » [PATCH 0/59] Cleanup sysctl
[PATCH 56/59] sysctl: factor out sysctl_head_next from do_sysctl [message #17205 is a reply to message #17149] |
Tue, 16 January 2007 16:40   |
ebiederm
Messages: 1354 Registered: February 2006
|
Senior Member |
|
|
From: Eric W. Biederman <ebiederm@xmission.com> - unquoted
The current logic to walk through the list of sysctl table
headers is slightly painful and implement in a way it cannot
be used by code outside sysctl.c
I am in the process of implementing a version of the sysctl
proc support that instead of using the proc generic non-caching
monster, just uses the existing sysctl data structure as
backing store for building the dcache entries and for doing
directory reads. To use the existing data structures however
I need a way to get at them.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
include/linux/sysctl.h | 4 +++
kernel/sysctl.c | 57 +++++++++++++++++++++++++++++++++++------------
2 files changed, 46 insertions(+), 15 deletions(-)
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 6113f3b..81ee9ea 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -923,6 +923,10 @@ enum
#ifdef __KERNEL__
#include <linux/list.h>
+/* For the /proc/sys support */
+extern struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev);
+extern void sysctl_head_finish(struct ctl_table_header *prev);
+
extern void sysctl_init(void);
typedef struct ctl_table ctl_table;
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 5beee1f..ca2831a 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1066,6 +1066,42 @@ static void start_unregistering(struct ctl_table_header *p)
list_del_init(&p->ctl_entry);
}
+void sysctl_head_finish(struct ctl_table_header *head)
+{
+ if (!head)
+ return;
+ spin_lock(&sysctl_lock);
+ unuse_table(head);
+ spin_unlock(&sysctl_lock);
+}
+
+struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
+{
+ struct ctl_table_header *head;
+ struct list_head *tmp;
+ spin_lock(&sysctl_lock);
+ if (prev) {
+ tmp = &prev->ctl_entry;
+ unuse_table(prev);
+ goto next;
+ }
+ tmp = &root_table_header.ctl_entry;
+ for (;;) {
+ head = list_entry(tmp, struct ctl_table_header, ctl_entry);
+
+ if (!use_table(head))
+ goto next;
+ spin_unlock(&sysctl_lock);
+ return head;
+ next:
+ tmp = tmp->next;
+ if (tmp == &root_table_header.ctl_entry)
+ break;
+ }
+ spin_unlock(&sysctl_lock);
+ return NULL;
+}
+
void __init sysctl_init(void)
{
#ifdef CONFIG_PROC_SYSCTL
@@ -1077,6 +1113,7 @@ void __init sysctl_init(void)
int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
void __user *newval, size_t newlen)
{
+ struct ctl_table_header *head;
struct list_head *tmp;
int error = -ENOTDIR;
@@ -1087,26 +1124,16 @@ int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *ol
if (!oldlenp || get_user(old_len, oldlenp))
return -EFAULT;
}
- spin_lock(&sysctl_lock);
- tmp = &root_table_header.ctl_entry;
- do {
- struct ctl_table_header *head =
- list_entry(tmp, struct ctl_table_header, ctl_entry);
- if (!use_table(head))
- continue;
-
- spin_unlock(&sysctl_lock);
+ for (head = sysctl_head_next(NULL); head; head = sysctl_head_next(head)) {
error = parse_table(name, nlen, oldval, oldlenp,
newval, newlen, head->ctl_table);
-
- spin_lock(&sysctl_lock);
- unuse_table(head);
- if (error != -ENOTDIR)
+ if (error != -ENOTDIR) {
+ sysctl_head_finish(head);
break;
- } while ((tmp = tmp->next) != &root_table_header.ctl_entry);
- spin_unlock(&sysctl_lock);
+ }
+ }
return error;
}
--
1.4.4.1.g278f
_______________________________________________
Containers mailing list
Containers@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/containers
|
|
|
 |
|
[PATCH 0/59] Cleanup sysctl
By: ebiederm on Tue, 16 January 2007 16:33
|
 |
|
[PATCH 1/59] sysctl x25: Remove unnecessary insert_at_head from register_sysctl_table.
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 2/59] sysctl: Move CTL_SUNRPC to sysctl.h where it belongs
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 3/59] sysctl: sunrpc Remove unnecessary insert_at_head flag
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 4/59] sysctl: sunrpc Don't unnecessarily set ctl_table->de
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 5/59] sysctl: rose remove unnecessary insert_at_head flag
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
Re: [PATCH 5/59] sysctl: rose remove unnecessary insert_at_head flag
|
 |
|
[PATCH 6/59] sysctl: netrom remove unnecessary insert_at_head flag
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 7/59] sysctl: llc remove unnecessary insert_at_head flag
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 8/59] sysctl: ipx remove unnecessary insert_at_head flag
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 9/59] sysctl: decnet remove unnecessary insert_at_head flag
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 10/59] sysctl: dccp remove unnecessary insert_at_head flag
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 11/59] sysctl: ax25 remove unnecessary insert_at_head flag
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 12/59] sysctl: atalk remove unnecessary insert_at_head flag
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 13/59] sysctl: xfs remove unnecessary insert_at_head flag
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 14/59] sysctl: C99 convert xfs ctl_tables
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
Re: [PATCH 14/59] sysctl: C99 convert xfs ctl_tables
By: dev on Wed, 17 January 2007 17:01
|
 |
|
[PATCH 15/59] sysctl: scsi remove unnecessary insert_at_head flag
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 16/59] sysctl: md Remove unnecessary insert_at_head flag
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 17/59] sysctl: mac_hid remove unnecessary insert_at_head flag
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 18/59] sysctl: ipmi remove unnecessary insert_at_head flag
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
Re: [PATCH 18/59] sysctl: ipmi remove unnecessary insert_at_head flag
|
 |
|
[PATCH 19/59] sysctl: cdrom remove unnecessary insert_at_head flag
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 20/59] sysctl: cdrom Don't set de->owner
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
Re: [PATCH 20/59] sysctl: cdrom Don't set de->owner
|
 |
|
[PATCH 21/59] sysctl: Move CTL_PM into sysctl.h where it belongs.
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 22/59] sysctl: frv pm remove unnecessary insert_at_head flag
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 23/59] sysctl: Move CTL_FRV into sysctl.h where it belongs
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 24/59] sysctl: frv remove unnecessary insert_at_head flag
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 25/59] sysctl: C99 convert arch/frv/kernel/pm.c
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
Re: [PATCH 25/59] sysctl: C99 convert arch/frv/kernel/pm.c
By: dev on Wed, 17 January 2007 17:14
|
 |
|
Re: [PATCH 25/59] sysctl: C99 convert arch/frv/kernel/pm.c
|
 |
|
Re: [PATCH 25/59] sysctl: C99 convert arch/frv/kernel/pm.c
|
 |
|
[PATCH 26/59] sysctl: C99 convert arch/frv/kernel/sysctl.c
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 27/59] sysctl: sn Remove sysctl ABI BREAKAGE
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 28/59] sysctl: C99 Convert arch/ia64/sn/kernel/xpc_main.c
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 29/59] sysctl: C99 convert arch/ia64/kernel/perfmon and remove ABI breakage
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 30/59] sysctl: mips/au1000 Remove sys_sysctl support
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 31/59] sysctl: C99 convert the ctl_tables in arch/mips/au1000/common/power.c
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
Re: [PATCH 31/59] sysctl: C99 convert the ctl_tables in arch/mips/au1000/common/power.c
|
 |
|
[PATCH 32/59] sysctl: C99 convert arch/mips/lasat/sysctl.c and remove ABI breakage.
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 33/59] sysctl: s390 move sysctl definitions to sysctl.h
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
Re: [PATCH 33/59] sysctl: s390 move sysctl definitions to sysctl.h
By: dev on Wed, 17 January 2007 17:23
|
 |
|
[PATCH 34/59] sysctl: s390 Remove unnecessary use of insert_at_head
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 35/59] sysctl: C99 convert ctl_tables in arch/powerpc/kernel/idle.c
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
Re: [PATCH 35/59] sysctl: C99 convert ctl_tables in arch/powerpc/kernel/idle.c
|
 |
|
[PATCH 36/59] sysctl: C99 convert ctl_tables entries in arch/ppc/kernel/ppc_htab.c
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
Re: [PATCH 36/59] sysctl: C99 convert ctl_tables entries in arch/ppc/kernel/ppc_htab.c
|
 |
|
[PATCH 37/59] sysctl: C99 convert arch/sh64/kernel/traps.c and remove ABI breakage.
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
Re: [PATCH 37/59] sysctl: C99 convert arch/sh64/kernel/traps.c and remove ABI breakage.
|
 |
|
[PATCH 38/59] sysctl: x86_64 Remove unnecessary use of insert_at_head
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 39/59] sysctl: C99 convert ctl_tables in arch/x86_64/ia32/ia32_binfmt.c
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 40/59] sysctl: C99 convert ctl_tables in arch/x86_64/kernel/vsyscall.c
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 41/59] sysctl: C99 convert ctl_tables in arch/x86_64/mm/init.c
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 42/59] sysctl: Remove sys_sysctl support from the hpet timer driver.
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 43/59] sysctl: Remove sys_sysctl support from drivers/char/rtc.c
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 44/59] sysctl: Register the sysctl number used by the arlan driver.
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 45/59] sysctl: C99 convert ctl_tables in drivers/parport/procfs.c
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
Re: [PATCH 45/59] sysctl: C99 convert ctl_tables in drivers/parport/procfs.c
By: ebiederm on Tue, 16 January 2007 23:00
|
 |
|
Re: [PATCH 45/59] sysctl: C99 convert ctl_tables in drivers/parport/procfs.c
|
 |
|
[PATCH 46/59] sysctl: C99 convert coda ctl_tables and remove binary sysctls.
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 47/59] sysctl: C99 convert ctl_tables in NTFS and remove sys_sysctl support
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 48/59] sysctl: Register the ocfs2 sysctl numbers
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
Re: [PATCH 48/59] sysctl: Register the ocfs2 sysctl numbers
|
 |
|
[PATCH 49/59] sysctl: Move init_irq_proc into init/main where it belongs
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
Re: [PATCH 49/59] sysctl: Move init_irq_proc into init/main where it belongs
|
 |
|
[PATCH 50/59] sysctl: Move utsname sysctls to their own file
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
Re: [PATCH 50/59] sysctl: Move utsname sysctls to their own file
By: ebiederm on Wed, 17 January 2007 19:31
|
 |
|
Re: [PATCH 50/59] sysctl: Move utsname sysctls to their own file
|
 |
|
Re: [PATCH 50/59] sysctl: Move utsname sysctls to their own file
By: dev on Wed, 17 January 2007 17:41
|
 |
|
[PATCH 51/59] sysctl: Move SYSV IPC sysctls to their own file
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
Re: [PATCH 51/59] sysctl: Move SYSV IPC sysctls to their own file
By: dev on Wed, 17 January 2007 17:44
|
 |
|
[PATCH 52/59] sysctl: Create sys/fs/binfmt_misc as an ordinary sysctl entry
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 53/59] sysctl: Remove support for CTL_ANY
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 54/59] sysctl: Remove support for directory strategy routines.
By: ebiederm on Tue, 16 January 2007 16:39
|
 |
|
[PATCH 55/59] sysctl: Remove insert_at_head from register_sysctl
By: ebiederm on Tue, 16 January 2007 16:40
|
 |
|
[PATCH 56/59] sysctl: factor out sysctl_head_next from do_sysctl
By: ebiederm on Tue, 16 January 2007 16:40
|
 |
|
[PATCH 57/59] sysctl: allow sysctl_perm to be called from outside of sysctl.c
By: ebiederm on Tue, 16 January 2007 16:40
|
 |
|
[PATCH 58/59] sysctl: Reimplement the sysctl proc support
By: ebiederm on Tue, 16 January 2007 16:40
|
 |
|
[PATCH 59/59] sysctl: Remove the proc_dir_entry member for the sysctl tables.
By: ebiederm on Tue, 16 January 2007 16:40
|
 |
|
Re: [PATCH 0/59] Cleanup sysctl
By: hpa on Tue, 16 January 2007 18:35
|
 |
|
Re: [PATCH 0/59] Cleanup sysctl
By: ebiederm on Tue, 16 January 2007 18:54
|
 |
|
Re: [PATCH 0/59] Cleanup sysctl
By: hpa on Tue, 16 January 2007 18:58
|
 |
|
Re: [PATCH 0/59] Cleanup sysctl
By: ebiederm on Tue, 16 January 2007 19:03
|
 |
|
Re: [PATCH 0/59] Cleanup sysctl
By: hpa on Tue, 16 January 2007 19:15
|
 |
|
Re: [PATCH 0/59] Cleanup sysctl
By: ebiederm on Tue, 16 January 2007 19:30
|
 |
|
Re: [PATCH 0/59] Cleanup sysctl
|
 |
|
Re: [PATCH 0/59] Cleanup sysctl
By: ebiederm on Wed, 17 January 2007 19:02
|
 |
|
Re: [PATCH 0/59] Cleanup sysctl
|
 |
|
Re: [PATCH 0/59] Cleanup sysctl
|
 |
|
Re: [PATCH 0/59] Cleanup sysctl
By: dev on Wed, 17 January 2007 18:10
|
Goto Forum:
Current Time: Thu Sep 18 22:16:19 GMT 2025
Total time taken to generate the page: 0.06650 seconds
|