[Click] [PATCH 3/5] proclikefs: use per_cpu super_block.s_files

Joonwoo Park joonwpark81 at gmail.com
Sun Jan 30 04:20:11 EST 2011


Use per_cpu super_blocks.s_files.
Also use kzalloc to zero initialize newfs.
Recent linux calls file_system_type.mount if it's not null.

Signed-off-by: Joonwoo Park <joonwpark81 at gmail.com>
---
 linuxmodule/proclikefs.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/linuxmodule/proclikefs.c b/linuxmodule/proclikefs.c
index 1cc5585..d7f1e39 100644
--- a/linuxmodule/proclikefs.c
+++ b/linuxmodule/proclikefs.c
@@ -167,7 +167,7 @@ proclikefs_register_filesystem(const char *name, int fs_flags,
     }
 
     if (!newfs) {
-	newfs = kmalloc(sizeof(struct proclikefs_file_system) + strlen(name), GFP_ATOMIC);
+	newfs = kzalloc(sizeof(struct proclikefs_file_system) + strlen(name), GFP_ATOMIC);
 	if (!newfs) {		/* out of memory */
 	    spin_unlock(&fslist_lock);
 	    MOD_DEC_USE_COUNT;
@@ -247,14 +247,23 @@ static void
 proclikefs_kill_super(struct super_block *sb, struct file_operations *dummy)
 {
     struct dentry *dentry_tree;
-    struct list_head *p;
+    struct list_head *p, *list;
+#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)) && (CONFIG_SMP))
+    int cpu;
+#endif
 
     DEBUG("killing files");
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16)
 # if HAVE_LINUX_FILES_LOCK
     file_list_lock();
 # endif
-    list_for_each(p, &sb->s_files) {
+# if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)) && (CONFIG_SMP))
+    cpu = smp_processor_id();
+    list = per_cpu_ptr(sb->s_files, cpu);
+# else
+    list = &sb->s_files;
+# endif
+    list_for_each(p, list) {
 	struct file *filp = list_entry(p, struct file, f_u.fu_list);
 	filp->f_op = dummy;
     }
-- 
1.7.1


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-proclikefs-use-per_cpu-super_block.s_files.patch
Type: text/x-diff
Size: 1852 bytes
Desc: not available
Url : http://amsterdam.lcs.mit.edu/pipermail/click/attachments/20110130/27962137/attachment.patch 


More information about the click mailing list