[PATCH] CIFS oops

From: Maciej Babinski (maciej@apathy.killer-robot.net)
Date: Mon Jun 09 2003 - 14:23:25 EST


This patch fixes a non-critical oops that occurs when the cifs module is
removed from the kernel. It uses the completion.h mechanism to
ensure that the cifsoplockd kernel thread exits before the module is
unloaded.

                                    -- Maciej Babinski

--- linux-2.5.70.old/fs/cifs/cifsfs.c Mon May 26 20:00:40 2003
+++ linux-2.5.70/fs/cifs/cifsfs.c Mon Jun 9 12:59:31 2003
@@ -62,6 +62,8 @@
 void cifs_proc_init(void);
 void cifs_proc_clean(void);
 
+static DECLARE_COMPLETION(cifsoplock_exited);
+
 static int
 cifs_read_super(struct super_block *sb, void *data,
                 const char *devname, int silent)
@@ -423,7 +425,8 @@
                        "cifs_destroy_mids: error not all structures were freed\n");
         if (kmem_cache_destroy(cifs_oplock_cachep))
                 printk(KERN_WARNING
- "error not all oplock structures were freed\n");}
+ "error not all oplock structures were freed\n");
+}
 
 static int cifs_oplock_thread(void * dummyarg)
 {
@@ -435,10 +438,10 @@
         int rc;
 
         daemonize("cifsoplockd");
- allow_signal(SIGKILL);
+ allow_signal(SIGTERM);
 
         oplockThread = current;
- while (1) {
+ do {
                 set_current_state(TASK_INTERRUPTIBLE);
                 schedule_timeout(100*HZ);
                 /* BB add missing code */
@@ -466,7 +469,9 @@
                 }
                 write_unlock(&GlobalMid_Lock);
                 cFYI(1,("next time through while loop")); /* BB remove */
- }
+ } while (!signal_pending(current));
+
+ complete_and_exit (&cifsoplock_exited, 0);
 }
 
 static int __init
@@ -528,8 +533,10 @@
         cifs_destroy_inodecache();
         cifs_destroy_mids();
         cifs_destroy_request_bufs();
- if(oplockThread)
- send_sig(SIGKILL, oplockThread, 1);
+ if(oplockThread) {
+ send_sig(SIGTERM, oplockThread, 1);
+ wait_for_completion(&cifsoplock_exited);
+ }
 }
 
 MODULE_AUTHOR("Steve French <sfrench@us.ibm.com>");
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Jun 15 2003 - 22:00:21 EST