public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den@openvz.org>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, "Denis V. Lunev" <den@openvz.org>
Subject: [PATCH 26/29] kernel: use non-racy method for proc entries creation
Date: Tue,  8 Apr 2008 15:19:33 +0400	[thread overview]
Message-ID: <1207653576-12640-26-git-send-email-den@openvz.org> (raw)
In-Reply-To: <1207653508.7171.18.camel@iris.sw.ru>

Use proc_create()/proc_create_data() to make sure that ->proc_fops and
->data be setup before gluing PDE to main tree.

Signed-off-by: Denis V. Lunev <den@openvz.org>
---
 kernel/configs.c          |    4 ++--
 kernel/dma.c              |    7 +------
 kernel/kallsyms.c         |    6 +-----
 kernel/latencytop.c       |    9 +--------
 kernel/lockdep_proc.c     |   16 ++++------------
 kernel/profile.c          |    4 ++--
 kernel/resource.c         |   10 ++--------
 kernel/sched_debug.c      |    5 +----
 kernel/time/timer_list.c  |    5 +----
 kernel/time/timer_stats.c |    5 +----
 10 files changed, 16 insertions(+), 55 deletions(-)

diff --git a/kernel/configs.c b/kernel/configs.c
index d3a4b82..4c34521 100644
--- a/kernel/configs.c
+++ b/kernel/configs.c
@@ -79,11 +79,11 @@ static int __init ikconfig_init(void)
 	struct proc_dir_entry *entry;
 
 	/* create the current config file */
-	entry = create_proc_entry("config.gz", S_IFREG | S_IRUGO, NULL);
+	entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
+			    &ikconfig_file_ops);
 	if (!entry)
 		return -ENOMEM;
 
-	entry->proc_fops = &ikconfig_file_ops;
 	entry->size = kernel_config_data_size;
 
 	return 0;
diff --git a/kernel/dma.c b/kernel/dma.c
index 6a82bb7..d2c60a8 100644
--- a/kernel/dma.c
+++ b/kernel/dma.c
@@ -149,12 +149,7 @@ static const struct file_operations proc_dma_operations = {
 
 static int __init proc_dma_init(void)
 {
-	struct proc_dir_entry *e;
-
-	e = create_proc_entry("dma", 0, NULL);
-	if (e)
-		e->proc_fops = &proc_dma_operations;
-
+	proc_create("dma", 0, NULL, &proc_dma_operations);
 	return 0;
 }
 
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index f091d13..6fc0040 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -472,11 +472,7 @@ static const struct file_operations kallsyms_operations = {
 
 static int __init kallsyms_init(void)
 {
-	struct proc_dir_entry *entry;
-
-	entry = create_proc_entry("kallsyms", 0444, NULL);
-	if (entry)
-		entry->proc_fops = &kallsyms_operations;
+	proc_create("kallsyms", 0444, NULL, &kallsyms_operations);
 	return 0;
 }
 __initcall(kallsyms_init);
diff --git a/kernel/latencytop.c b/kernel/latencytop.c
index 7c74dab..5e7b45c 100644
--- a/kernel/latencytop.c
+++ b/kernel/latencytop.c
@@ -233,14 +233,7 @@ static struct file_operations lstats_fops = {
 
 static int __init init_lstats_procfs(void)
 {
-	struct proc_dir_entry *pe;
-
-	pe = create_proc_entry("latency_stats", 0644, NULL);
-	if (!pe)
-		return -ENOMEM;
-
-	pe->proc_fops = &lstats_fops;
-
+	proc_create("latency_stats", 0644, NULL, &lstats_fops);
 	return 0;
 }
 __initcall(init_lstats_procfs);
diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
index 8a135bd..dc5d296 100644
--- a/kernel/lockdep_proc.c
+++ b/kernel/lockdep_proc.c
@@ -660,20 +660,12 @@ static const struct file_operations proc_lock_stat_operations = {
 
 static int __init lockdep_proc_init(void)
 {
-	struct proc_dir_entry *entry;
-
-	entry = create_proc_entry("lockdep", S_IRUSR, NULL);
-	if (entry)
-		entry->proc_fops = &proc_lockdep_operations;
-
-	entry = create_proc_entry("lockdep_stats", S_IRUSR, NULL);
-	if (entry)
-		entry->proc_fops = &proc_lockdep_stats_operations;
+	proc_create("lockdep", S_IRUSR, NULL, &proc_lockdep_operations);
+	proc_create("lockdep_stats", S_IRUSR, NULL,
+		    &proc_lockdep_stats_operations);
 
 #ifdef CONFIG_LOCK_STAT
-	entry = create_proc_entry("lock_stat", S_IRUSR, NULL);
-	if (entry)
-		entry->proc_fops = &proc_lock_stat_operations;
+	proc_create("lock_stat", S_IRUSR, NULL, &proc_lock_stat_operations);
 #endif
 
 	return 0;
diff --git a/kernel/profile.c b/kernel/profile.c
index 3b7a1b0..1a21762 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -588,10 +588,10 @@ static int __init create_proc_profile(void)
 		return 0;
 	if (create_hash_tables())
 		return -1;
-	entry = create_proc_entry("profile", S_IWUSR | S_IRUGO, NULL);
+	entry = proc_create("profile", S_IWUSR | S_IRUGO,
+			    NULL, &proc_profile_operations);
 	if (!entry)
 		return 0;
-	entry->proc_fops = &proc_profile_operations;
 	entry->size = (1+prof_len) * sizeof(atomic_t);
 	hotcpu_notifier(profile_cpu_callback, 0);
 	return 0;
diff --git a/kernel/resource.c b/kernel/resource.c
index 46ad4f4..da8ee1b 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -131,14 +131,8 @@ static const struct file_operations proc_iomem_operations = {
 
 static int __init ioresources_init(void)
 {
-	struct proc_dir_entry *entry;
-
-	entry = create_proc_entry("ioports", 0, NULL);
-	if (entry)
-		entry->proc_fops = &proc_ioports_operations;
-	entry = create_proc_entry("iomem", 0, NULL);
-	if (entry)
-		entry->proc_fops = &proc_iomem_operations;
+	proc_create("ioports", 0, NULL, &proc_ioports_operations);
+	proc_create("iomem", 0, NULL, &proc_iomem_operations);
 	return 0;
 }
 __initcall(ioresources_init);
diff --git a/kernel/sched_debug.c b/kernel/sched_debug.c
index 475b5ad..08dddd7 100644
--- a/kernel/sched_debug.c
+++ b/kernel/sched_debug.c
@@ -248,12 +248,9 @@ static int __init init_sched_debug_procfs(void)
 {
 	struct proc_dir_entry *pe;
 
-	pe = create_proc_entry("sched_debug", 0644, NULL);
+	pe = proc_create("sched_debug", 0644, NULL, &sched_debug_fops);
 	if (!pe)
 		return -ENOMEM;
-
-	pe->proc_fops = &sched_debug_fops;
-
 	return 0;
 }
 
diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
index 67fe8fc..a40e20f 100644
--- a/kernel/time/timer_list.c
+++ b/kernel/time/timer_list.c
@@ -278,12 +278,9 @@ static int __init init_timer_list_procfs(void)
 {
 	struct proc_dir_entry *pe;
 
-	pe = create_proc_entry("timer_list", 0644, NULL);
+	pe = proc_create("timer_list", 0644, NULL, &timer_list_fops);
 	if (!pe)
 		return -ENOMEM;
-
-	pe->proc_fops = &timer_list_fops;
-
 	return 0;
 }
 __initcall(init_timer_list_procfs);
diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
index 417da8c..c994530 100644
--- a/kernel/time/timer_stats.c
+++ b/kernel/time/timer_stats.c
@@ -415,12 +415,9 @@ static int __init init_tstats_procfs(void)
 {
 	struct proc_dir_entry *pe;
 
-	pe = create_proc_entry("timer_stats", 0644, NULL);
+	pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
 	if (!pe)
 		return -ENOMEM;
-
-	pe->proc_fops = &tstats_fops;
-
 	return 0;
 }
 __initcall(init_tstats_procfs);
-- 
1.5.3.rc5


  parent reply	other threads:[~2008-04-08 11:25 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-08 11:18 [PATCH 0/29] proc entries creation race Denis V. Lunev
2008-04-08 11:19 ` [PATCH 1/29] proc: introduce proc_create_data to setup de->data Denis V. Lunev
2008-04-08 11:19 ` [PATCH 2/29] nfsd: use proc_create to setup de->proc_fops Denis V. Lunev
2008-04-08 11:19 ` [PATCH 3/29] nfs: " Denis V. Lunev
2008-04-08 11:19 ` [PATCH 4/29] afs: use non-racy method for proc entries creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 5/29] ext4: " Denis V. Lunev
2008-04-08 11:19 ` [PATCH 6/29] reiserfs: " Denis V. Lunev
2008-04-08 11:19 ` [PATCH 7/29] jbd2: " Denis V. Lunev
2008-04-08 11:19 ` [PATCH 8/29] proc: use non-racy method for /proc/page_owner creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 9/29] sysvipc: use non-racy method for proc entries creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 10/29] mm: use non-racy method for /proc/swaps creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 11/29] sound: use non-racy method for /proc/driver/snd-page-alloc creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 12/29] zorro: use non-racy method for proc entries creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 13/29] samples: use non-racy method for /proc/marker-example creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 14/29] scsi: use non-racy method for proc entries creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 15/29] usb: " Denis V. Lunev
2008-04-08 11:19 ` [PATCH 16/29] s390: " Denis V. Lunev
2008-04-08 11:19 ` [PATCH 17/29] arm: use non-racy method for /proc/davinci_clocks creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 18/29] avr32: proc: use non-racy method for /proc/tlb creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 19/29] cris: use non-racy method for /proc/system_profile creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 20/29] ia64: use non-racy method for proc entries creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 21/29] parisc: use non-racy method for /proc/pcxl_dma creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 22/29] powerpc: use non-racy method for proc entries creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 23/29] acpi: " Denis V. Lunev
2008-04-08 11:19 ` [PATCH 24/29] net: " Denis V. Lunev
2008-04-08 11:19 ` [PATCH 25/29] isdn: " Denis V. Lunev
2008-04-30 17:57   ` [patch, -git] isdn: hysdn_procconf.c build fix Ingo Molnar
2008-04-30 18:10     ` Andrew Morton
2008-04-30 18:30       ` Ingo Molnar
2008-04-30 18:47         ` Andrew Morton
2008-04-30 19:03           ` Denis V. Lunev
2008-04-30 19:14             ` Andrew Morton
2008-04-30 19:24               ` Harvey Harrison
2008-04-30 21:21                 ` Alexey Dobriyan
2008-04-08 11:19 ` Denis V. Lunev [this message]
2008-04-08 11:19 ` [PATCH 27/29] parisc: use non-racy method for proc entries creation Denis V. Lunev
2008-04-08 11:19 ` [PATCH 28/29] drivers: " Denis V. Lunev
2008-04-08 11:19 ` [PATCH 29/29] " Denis V. Lunev
2008-04-17 17:13   ` Dmitry Torokhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1207653576-12640-26-git-send-email-den@openvz.org \
    --to=den@openvz.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox