jfs: use kthread_ API
PATCH 1/1 jfs: use kthread_ API
Use the kthread_ API instead of opencoding lots of hairy code for kernel thread creation and teardown.
Signed-off-by Christoph Hellwig <[email protected]>
fs/jfs/jfs_logmgr.c +6 -14
@@ -64,6 +64,7 @@#include <linux/interrupt.h> #include <linux/smp_lock.h> #include <linux/completion.h> +#include <linux/kthread.h> #include <linux/buffer_head.h> /* for sync_blockdev() */ #include <linux/bio.h> #include <linux/suspend.h>
@@ -81,7 +82,6 @@*/ static struct lbuf *log_redrive_list;static DEFINE_SPINLOCK (log_redrive_lock); -DECLARE_WAIT_QUEUE_HEAD (jfs_IO_thread_wait);/*
@@ -1980,7 +1980,7 @@ log_redrive_list = bp;spin_unlock_irqrestore (&log_redrive_lock, flags); -wake_up (&jfs_IO_thread_wait); +wake_up_process (jfsIOthread); }
@@ -2347,13 +2347,7 @@ {struct lbuf *bp; -daemonize ("jfsIO" ); - -complete (&jfsIOwait); - do { - DECLARE_WAITQUEUE(wq, current); - spin_lock_irq(&log_redrive_lock); while ((bp = log_redrive_list) != 0) { log_redrive_list = bp->l_redrive_next;
@@ -2362,21 +2356,19 @@lbmStartIO (bp);spin_lock_irq (&log_redrive_lock); } +spin_unlock_irq (&log_redrive_lock); +if (freezing (current)) { -spin_unlock_irq (&log_redrive_lock);refrigerator (); }else { -add_wait_queue (&jfs_IO_thread_wait, &wq);set_current_state (TASK_INTERRUPTIBLE ); -spin_unlock_irq (&log_redrive_lock);schedule (); current->state =TASK_RUNNING ; -remove_wait_queue (&jfs_IO_thread_wait, &wq); } - }while (!jfs_stop_threads); + }while (!kthread_should_stop ());jfs_info ("jfsIOWait being killed!" ); -complete_and_exit (&jfsIOwait,0 ); +return 0 ; }/*
fs/jfs/jfs_superblock.h +3 -6
@@ -113,12 +113,9 @@extern int jfs_mount_rw (struct super_block *,int );extern int jfs_umount (struct super_block *);extern int jfs_umount_rw (struct super_block *); - -extern int jfs_stop_threads; -extern struct completion jfsIOwait; -extern wait_queue_head_t jfs_IO_thread_wait; -extern wait_queue_head_t jfs_commit_thread_wait; -extern wait_queue_head_t jfs_sync_thread_wait;extern int jfs_extendfs (struct super_block *,s64 ,int ); +extern struct task_struct *jfsIOthread; +extern struct task_struct *jfsSyncThread; +#endif /*_H_JFS_SUPERBLOCK */
fs/jfs/jfs_txnmgr.c +7 -19
@@ -49,6 +49,7 @@#include <linux/suspend.h> #include <linux/module.h> #include <linux/moduleparam.h> +#include <linux/kthread.h> #include "jfs_incore.h" #include "jfs_inode.h" #include "jfs_filsys.h"
@@ -121,8 +122,7 @@#define LAZY_LOCK (flags) spin_lock_irqsave(&TxAnchor.LazyLock, flags)#define LAZY_UNLOCK (flags) spin_unlock_irqrestore(&TxAnchor.LazyLock, flags) -DECLARE_WAIT_QUEUE_HEAD (jfs_sync_thread_wait); -DECLARE_WAIT_QUEUE_HEAD (jfs_commit_thread_wait); +static DECLARE_WAIT_QUEUE_HEAD (jfs_commit_thread_wait);static int jfs_commit_thread_waking;/*
@@ -207,7 +207,7 @@if ((++TxAnchor.tlocksInUse > TxLockHWM) && (jfs_tlocks_low ==0 )) {jfs_info ("txLockAlloc tlocks low" ); jfs_tlocks_low =1 ; -wake_up (&jfs_sync_thread_wait); +wake_up_process (jfsSyncThread); }return lid;
@@ -2743,10 +2743,6 @@unsigned long flags;struct jfs_sb_info *sbi; -daemonize ("jfsCommit" ); - -complete (&jfsIOwait); - do { LAZY_LOCK(flags); jfs_commit_thread_waking = 0; /* OK to wake another thread */
@@ -2806,13 +2802,13 @@ current->state =TASK_RUNNING ;remove_wait_queue (&jfs_commit_thread_wait, &wq); } - }while (!jfs_stop_threads); + }while (!kthread_should_stop ());if (!list_empty (&TxAnchor.unlock_queue))jfs_err ("jfs_lazycommit being killed w/pending transactions!" );else jfs_info ("jfs_lazycommit being killed\n" ); -complete_and_exit (&jfsIOwait,0 ); +return 0 ; }void txLazyUnlock (struct tblock * tblk)
@@ -2932,10 +2928,6 @@int rc;tid_t tid; -daemonize ("jfsSync" ); - -complete (&jfsIOwait); - do { /* * write each inode on the anonymous inode list
@@ -2996,19 +2988,15 @@TXN_UNLOCK ();refrigerator (); }else { -DECLARE_WAITQUEUE (wq, current); - -add_wait_queue (&jfs_sync_thread_wait, &wq);set_current_state (TASK_INTERRUPTIBLE );TXN_UNLOCK ();schedule (); current->state =TASK_RUNNING ; -remove_wait_queue (&jfs_sync_thread_wait, &wq); } - }while (!jfs_stop_threads); + }while (!kthread_should_stop ());jfs_info ("jfs_sync being killed" ); -complete_and_exit (&jfsIOwait,0 ); +return 0 ; }#if defined(CONFIG_PROC_FS ) && defined(CONFIG_JFS_DEBUG )
fs/jfs/super.c +22 -33
104 lines not on this page · raw message
Quoted 5 lines · Christoph Hellwig
Use the
kthread_API instead of opencoding lots of hairy code for kernel thread creation and teardown.Signed-off-by Christoph Hellwig <[email protected]>
This looks good. I'll take a closer look and probably push it to -mm as soon as I can get to it.
Thanks,
Shaggy
Signature · 2 lines
David Kleikamp IBM Linux Technology Center