The patch titled

     md: use kthread infrastructure in md

has been added to the -mm tree.  Its filename is

     md-use-kthread-infrastructure-in-md.patch

Patches currently in -mm which might be from [EMAIL PROTECTED] are

sunrpc-cache_register-can-use-wrong-module-reference.patch
md-fix-minor-error-in-raid10-read-balancing-calculation.patch
md-fail-io-request-to-md-that-require-a-barrier.patch
md-dont-allow-new-md-bitmap-file-to-be-set-if-one-already-exists.patch
md-improve-handling-of-bitmap-initialisation.patch
md-all-hot-add-and-hot-remove-of-md-intent-logging-bitmaps.patch
md-support-write-mostly-device-in-raid1.patch
md-add-write-behind-support-for-md-raid1.patch
md-support-md-linear-array-with-components-greater-than-2-terabytes.patch
md-raid1_quiesce-is-back-to-front-fix-it.patch
md-make-sure-bitmap_daemon_work-actually-does-work.patch
md-do-not-set-mddev-bitmap-until-bitmap-is-fully-initialised.patch
md-allow-hot-adding-devices-to-arrays-with-non-persistant-superblocks.patch
md-allow-md-to-load-a-superblock-with-feature-bit-1-set.patch
md-fix-bitmap-read_sb_page-so-that-it-handles-errors-properly.patch
md-remove-old-cruft-from-md_kh-header-file.patch
md-limit-size-of-sb-read-written-to-appropriate-amount.patch
md-add-write-intent-bitmap-support-to-raid5.patch
md-write-intent-bitmap-support-for-raid6.patch
md-use-kthread-infrastructure-in-md.patch
md-ensure-bitmap_writeback_daemon-handles-shutdown-properly.patch
md-tidy-up-daemon-stop-start-code-in-md-bitmapc.patch
drivers-md-fix-up-schedule_timeout-usage.patch



From: NeilBrown <[EMAIL PROTECTED]>

Switch MD to use the kthread infrastructure, to simplify the code and get rid
of tasklist_lock abuse in md_unregister_thread.  

Also don't flush signals in md_thread, as the called thread will always do
that.

Signed-off-by: Christoph Hellwig <[EMAIL PROTECTED]>
Signed-off-by: Neil Brown <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/md/md.c |   48 ++++++++++--------------------------------------
 1 files changed, 10 insertions(+), 38 deletions(-)

diff -puN drivers/md/md.c~md-use-kthread-infrastructure-in-md drivers/md/md.c
--- devel/drivers/md/md.c~md-use-kthread-infrastructure-in-md   2005-08-29 
23:44:31.000000000 -0700
+++ devel-akpm/drivers/md/md.c  2005-08-29 23:44:31.000000000 -0700
@@ -34,6 +34,7 @@
 
 #include <linux/module.h>
 #include <linux/config.h>
+#include <linux/kthread.h>
 #include <linux/linkage.h>
 #include <linux/raid/md.h>
 #include <linux/raid/bitmap.h>
@@ -3049,18 +3050,6 @@ static int md_thread(void * arg)
 {
        mdk_thread_t *thread = arg;
 
-       lock_kernel();
-
-       /*
-        * Detach thread
-        */
-
-       daemonize(thread->name, mdname(thread->mddev));
-
-       current->exit_signal = SIGCHLD;
-       allow_signal(SIGKILL);
-       thread->tsk = current;
-
        /*
         * md_thread is a 'system-thread', it's priority should be very
         * high. We avoid resource deadlocks individually in each
@@ -3072,14 +3061,14 @@ static int md_thread(void * arg)
         * bdflush, otherwise bdflush will deadlock if there are too
         * many dirty RAID5 blocks.
         */
-       unlock_kernel();
 
        complete(thread->event);
-       while (thread->run) {
+       while (!kthread_should_stop()) {
                void (*run)(mddev_t *);
 
                wait_event_interruptible_timeout(thread->wqueue,
-                                                test_bit(THREAD_WAKEUP, 
&thread->flags),
+                                                test_bit(THREAD_WAKEUP, 
&thread->flags)
+                                                || kthread_should_stop(),
                                                 thread->timeout);
                try_to_freeze();
 
@@ -3088,11 +3077,8 @@ static int md_thread(void * arg)
                run = thread->run;
                if (run)
                        run(thread->mddev);
-
-               if (signal_pending(current))
-                       flush_signals(current);
        }
-       complete(thread->event);
+
        return 0;
 }
 
@@ -3109,11 +3095,9 @@ mdk_thread_t *md_register_thread(void (*
                                 const char *name)
 {
        mdk_thread_t *thread;
-       int ret;
        struct completion event;
 
-       thread = (mdk_thread_t *) kmalloc
-                               (sizeof(mdk_thread_t), GFP_KERNEL);
+       thread = kmalloc(sizeof(mdk_thread_t), GFP_KERNEL);
        if (!thread)
                return NULL;
 
@@ -3126,8 +3110,8 @@ mdk_thread_t *md_register_thread(void (*
        thread->mddev = mddev;
        thread->name = name;
        thread->timeout = MAX_SCHEDULE_TIMEOUT;
-       ret = kernel_thread(md_thread, thread, 0);
-       if (ret < 0) {
+       thread->tsk = kthread_run(md_thread, thread, mdname(thread->mddev));
+       if (IS_ERR(thread->tsk)) {
                kfree(thread);
                return NULL;
        }
@@ -3137,21 +3121,9 @@ mdk_thread_t *md_register_thread(void (*
 
 void md_unregister_thread(mdk_thread_t *thread)
 {
-       struct completion event;
-
-       init_completion(&event);
-
-       thread->event = &event;
-
-       /* As soon as ->run is set to NULL, the task could disappear,
-        * so we need to hold tasklist_lock until we have sent the signal
-        */
        dprintk("interrupting MD-thread pid %d\n", thread->tsk->pid);
-       read_lock(&tasklist_lock);
-       thread->run = NULL;
-       send_sig(SIGKILL, thread->tsk, 1);
-       read_unlock(&tasklist_lock);
-       wait_for_completion(&event);
+
+       kthread_stop(thread->tsk);
        kfree(thread);
 }
 
_
-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to