unionfs: kthread API related Changes
authorYamini Allu <yamini@louie.fsl.cs.sunysb.edu>
Sat, 16 Feb 2008 06:00:32 +0000 (01:00 -0500)
committerRachita Kothiyal <rachita@dewey.fsl.cs.sunysb.edu>
Thu, 1 May 2008 23:03:35 +0000 (19:03 -0400)
Signed-off-by: Yamini P. Allu <yamini@fsl.cs.sunysb.edu>
fs/unionfs/main.c
fs/unionfs/sioq.c
fs/unionfs/sioq.h
fs/unionfs/union.h

index beda8afe3c335fb8d00fb1a00831ede03243cbf1..c1a9763ff9a1b6d60a70cac7a88f8559753f305e 100644 (file)
@@ -784,10 +784,11 @@ static int unionfs_read_super(struct super_block *sb, void *raw_data,
        unionfs_unlock_dentry(sb->s_root);
        if (!err) {
                /* its now ok to start the cleanup thread */
-               run_sioa(odf->cleanup, __odf_cleanup,
+               err = run_sioa(odf->cleanup, __odf_cleanup,
                         msecs_to_jiffies(odf->cleanup->cleanup.attr->timeout->
                                          val));
-               goto out;
+               if (!err)
+                       goto out;
        }
        /* else fall through */
 
index 5c2c7df03f7dc5eb63ace76af722383b591945f6..d44a899b65577655b81ca4523248a818f6831c7b 100644 (file)
@@ -57,8 +57,7 @@ void run_sioq(work_func_t func, struct sioq_args *args)
 int __run_sioa(void *args)
 {
        struct sioa_args *sioa_args = (struct sioa_args *)args;
-       sioa_args->process = current;
-       while (!sioa_args->complete) {
+       while (!kthread_should_stop()) {
                sioa_args->work(args);
                if (sioa_args->waiting) {
                        complete(&sioa_args->comp_work);
@@ -80,22 +79,27 @@ int __run_sioa(void *args)
 
 /*
  * Creates an asynchronous thread.  Calling process is responsible for
- * calling wait_for_completion.  The thread executes the work function, then
- * sleeps for timeout time.  When it wakes up it runs the done function and
- * terminates if done, otherwise repeats the loop.  The done function should
- * return 0 if not done.
+ * calling kthread_stop.  The function returns 0 upon success.
+ * The thread executes the work function, then sleeps for timeout time.
+ * When it wakes up it runs the done function and terminates if done,
+ * otherwise repeats the loop.  The done function should return 0
+ * if not done.
  */
-void run_sioa(struct sioa_args *args, void (*work) (void *),
+
+int run_sioa(struct sioa_args *args, void (*work) (void *),
              signed long timeout)
 {
+       int err = 0;
        init_completion(&args->comp_thread);
        mutex_init(&args->lock);
-       args->complete = 0;
        args->waiting = 0;
        args->process = NULL;
        args->timeout = timeout;
        args->work = work;
-       kernel_thread(__run_sioa, args, 0);
+       args->process = kernel_run(__run_sioa, args, "kunionfs_odf_cleanup");
+       if (IS_ERR(args->process))
+               err = PTR_ERR(args->process);
+       return err;
 }
 
 /*
@@ -134,14 +138,11 @@ void wake_up_sioa(struct sioa_args *args)
 void complete_sioa(struct sioa_args *args)
 {
        mutex_lock(&args->lock);
-       args->complete = 1;
 
        /* there might be the case that this is called before the */
        /* thread actually runs and process is initialized */
        if (args->process)
-               wake_up_process(args->process);
-       schedule();
-       wait_for_completion(&args->comp_thread);
+               kthread_stop(args->process);
        mutex_unlock(&args->lock);
 }
 
index 46b91c74bf8652913e0b47c232c3cae220eb4a70..1626b9d829a10c28ec4fa815ddd864c66bcbdcea 100644 (file)
@@ -77,7 +77,6 @@ struct sioa_args {
        void (*work) (void *);
        struct mutex lock;      /* synchronize multiple threads */
        int waiting;
-       int complete;
 
        union {
                struct cleanup_args cleanup;
@@ -87,7 +86,7 @@ struct sioa_args {
 extern int __init init_sioq(void);
 extern void stop_sioq(void);
 extern void run_sioq(work_func_t func, struct sioq_args *args);
-extern void run_sioa(struct sioa_args *args, void (*work) (void *),
+extern int run_sioa(struct sioa_args *args, void (*work) (void *),
                     signed long timeout);
 extern void wake_up_and_wait_sioa(struct sioa_args *args);
 extern void wake_up_sioa(struct sioa_args *args);
index cfdb36c7b0f345b4d2b54d11cb751bf56151297f..a35301c9dbadb482d1e0b137902d093c508519af 100644 (file)
@@ -47,6 +47,7 @@
 #include <linux/mman.h>
 #include <linux/backing-dev.h>
 #include <linux/exportfs.h>
+#include <linux/kthread.h>
 
 #include <asm/system.h>