diff options
author | Christoph Hellwig <hch@lst.de> | 2006-02-15 13:49:04 -0500 |
---|---|---|
committer | Dave Kleikamp <shaggy@austin.ibm.com> | 2006-02-15 13:49:04 -0500 |
commit | 91dbb4deb30e817efc8d6bed89b1190a489ca776 (patch) | |
tree | d3742a35be49da1ab785ac398459d7a71a64a765 /fs/jfs/super.c | |
parent | 4837c672fd4d43c519d6b53308ee68d45b91b872 (diff) |
JFS: Use the kthread_ API
Use the kthread_ API instead of opencoding lots of hairy code for kernel
thread creation and teardown.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Kleikamp <shaggy@austin.ibm.com>
Diffstat (limited to 'fs/jfs/super.c')
-rw-r--r-- | fs/jfs/super.c | 55 |
1 files changed, 22 insertions, 33 deletions
diff --git a/fs/jfs/super.c b/fs/jfs/super.c index 1639d2cd371f..bd6720d807a6 100644 --- a/fs/jfs/super.c +++ b/fs/jfs/super.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/vfs.h> | 25 | #include <linux/vfs.h> |
26 | #include <linux/mount.h> | 26 | #include <linux/mount.h> |
27 | #include <linux/moduleparam.h> | 27 | #include <linux/moduleparam.h> |
28 | #include <linux/kthread.h> | ||
28 | #include <linux/posix_acl.h> | 29 | #include <linux/posix_acl.h> |
29 | #include <asm/uaccess.h> | 30 | #include <asm/uaccess.h> |
30 | #include <linux/seq_file.h> | 31 | #include <linux/seq_file.h> |
@@ -54,11 +55,9 @@ static int commit_threads = 0; | |||
54 | module_param(commit_threads, int, 0); | 55 | module_param(commit_threads, int, 0); |
55 | MODULE_PARM_DESC(commit_threads, "Number of commit threads"); | 56 | MODULE_PARM_DESC(commit_threads, "Number of commit threads"); |
56 | 57 | ||
57 | int jfs_stop_threads; | 58 | static struct task_struct *jfsCommitThread[MAX_COMMIT_THREADS]; |
58 | static pid_t jfsIOthread; | 59 | struct task_struct *jfsIOthread; |
59 | static pid_t jfsCommitThread[MAX_COMMIT_THREADS]; | 60 | struct task_struct *jfsSyncThread; |
60 | static pid_t jfsSyncThread; | ||
61 | DECLARE_COMPLETION(jfsIOwait); | ||
62 | 61 | ||
63 | #ifdef CONFIG_JFS_DEBUG | 62 | #ifdef CONFIG_JFS_DEBUG |
64 | int jfsloglevel = JFS_LOGLEVEL_WARN; | 63 | int jfsloglevel = JFS_LOGLEVEL_WARN; |
@@ -661,12 +660,12 @@ static int __init init_jfs_fs(void) | |||
661 | /* | 660 | /* |
662 | * I/O completion thread (endio) | 661 | * I/O completion thread (endio) |
663 | */ | 662 | */ |
664 | jfsIOthread = kernel_thread(jfsIOWait, NULL, CLONE_KERNEL); | 663 | jfsIOthread = kthread_run(jfsIOWait, NULL, "jfsIO"); |
665 | if (jfsIOthread < 0) { | 664 | if (IS_ERR(jfsIOthread)) { |
666 | jfs_err("init_jfs_fs: fork failed w/rc = %d", jfsIOthread); | 665 | rc = PTR_ERR(jfsIOthread); |
666 | jfs_err("init_jfs_fs: fork failed w/rc = %d", rc); | ||
667 | goto end_txmngr; | 667 | goto end_txmngr; |
668 | } | 668 | } |
669 | wait_for_completion(&jfsIOwait); /* Wait until thread starts */ | ||
670 | 669 | ||
671 | if (commit_threads < 1) | 670 | if (commit_threads < 1) |
672 | commit_threads = num_online_cpus(); | 671 | commit_threads = num_online_cpus(); |
@@ -674,24 +673,21 @@ static int __init init_jfs_fs(void) | |||
674 | commit_threads = MAX_COMMIT_THREADS; | 673 | commit_threads = MAX_COMMIT_THREADS; |
675 | 674 | ||
676 | for (i = 0; i < commit_threads; i++) { | 675 | for (i = 0; i < commit_threads; i++) { |
677 | jfsCommitThread[i] = kernel_thread(jfs_lazycommit, NULL, | 676 | jfsCommitThread[i] = kthread_run(jfs_lazycommit, NULL, "jfsCommit"); |
678 | CLONE_KERNEL); | 677 | if (IS_ERR(jfsCommitThread[i])) { |
679 | if (jfsCommitThread[i] < 0) { | 678 | rc = PTR_ERR(jfsCommitThread[i]); |
680 | jfs_err("init_jfs_fs: fork failed w/rc = %d", | 679 | jfs_err("init_jfs_fs: fork failed w/rc = %d", rc); |
681 | jfsCommitThread[i]); | ||
682 | commit_threads = i; | 680 | commit_threads = i; |
683 | goto kill_committask; | 681 | goto kill_committask; |
684 | } | 682 | } |
685 | /* Wait until thread starts */ | ||
686 | wait_for_completion(&jfsIOwait); | ||
687 | } | 683 | } |
688 | 684 | ||
689 | jfsSyncThread = kernel_thread(jfs_sync, NULL, CLONE_KERNEL); | 685 | jfsSyncThread = kthread_run(jfs_sync, NULL, "jfsSync"); |
690 | if (jfsSyncThread < 0) { | 686 | if (IS_ERR(jfsSyncThread)) { |
691 | jfs_err("init_jfs_fs: fork failed w/rc = %d", jfsSyncThread); | 687 | rc = PTR_ERR(jfsSyncThread); |
688 | jfs_err("init_jfs_fs: fork failed w/rc = %d", rc); | ||
692 | goto kill_committask; | 689 | goto kill_committask; |
693 | } | 690 | } |
694 | wait_for_completion(&jfsIOwait); /* Wait until thread starts */ | ||
695 | 691 | ||
696 | #ifdef PROC_FS_JFS | 692 | #ifdef PROC_FS_JFS |
697 | jfs_proc_init(); | 693 | jfs_proc_init(); |
@@ -700,13 +696,9 @@ static int __init init_jfs_fs(void) | |||
700 | return register_filesystem(&jfs_fs_type); | 696 | return register_filesystem(&jfs_fs_type); |
701 | 697 | ||
702 | kill_committask: | 698 | kill_committask: |
703 | jfs_stop_threads = 1; | ||
704 | wake_up_all(&jfs_commit_thread_wait); | ||
705 | for (i = 0; i < commit_threads; i++) | 699 | for (i = 0; i < commit_threads; i++) |
706 | wait_for_completion(&jfsIOwait); | 700 | kthread_stop(jfsCommitThread[i]); |
707 | 701 | kthread_stop(jfsIOthread); | |
708 | wake_up(&jfs_IO_thread_wait); | ||
709 | wait_for_completion(&jfsIOwait); /* Wait for thread exit */ | ||
710 | end_txmngr: | 702 | end_txmngr: |
711 | txExit(); | 703 | txExit(); |
712 | free_metapage: | 704 | free_metapage: |
@@ -722,16 +714,13 @@ static void __exit exit_jfs_fs(void) | |||
722 | 714 | ||
723 | jfs_info("exit_jfs_fs called"); | 715 | jfs_info("exit_jfs_fs called"); |
724 | 716 | ||
725 | jfs_stop_threads = 1; | ||
726 | txExit(); | 717 | txExit(); |
727 | metapage_exit(); | 718 | metapage_exit(); |
728 | wake_up(&jfs_IO_thread_wait); | 719 | |
729 | wait_for_completion(&jfsIOwait); /* Wait until IO thread exits */ | 720 | kthread_stop(jfsIOthread); |
730 | wake_up_all(&jfs_commit_thread_wait); | ||
731 | for (i = 0; i < commit_threads; i++) | 721 | for (i = 0; i < commit_threads; i++) |
732 | wait_for_completion(&jfsIOwait); | 722 | kthread_stop(jfsCommitThread[i]); |
733 | wake_up(&jfs_sync_thread_wait); | 723 | kthread_stop(jfsSyncThread); |
734 | wait_for_completion(&jfsIOwait); /* Wait until Sync thread exits */ | ||
735 | #ifdef PROC_FS_JFS | 724 | #ifdef PROC_FS_JFS |
736 | jfs_proc_clean(); | 725 | jfs_proc_clean(); |
737 | #endif | 726 | #endif |