diff options
Diffstat (limited to 'fs/jfs/jfs_txnmgr.c')
-rw-r--r-- | fs/jfs/jfs_txnmgr.c | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c index 2ddb6b892bcf..ac3d66948e8c 100644 --- a/fs/jfs/jfs_txnmgr.c +++ b/fs/jfs/jfs_txnmgr.c | |||
@@ -49,6 +49,7 @@ | |||
49 | #include <linux/suspend.h> | 49 | #include <linux/suspend.h> |
50 | #include <linux/module.h> | 50 | #include <linux/module.h> |
51 | #include <linux/moduleparam.h> | 51 | #include <linux/moduleparam.h> |
52 | #include <linux/kthread.h> | ||
52 | #include "jfs_incore.h" | 53 | #include "jfs_incore.h" |
53 | #include "jfs_inode.h" | 54 | #include "jfs_inode.h" |
54 | #include "jfs_filsys.h" | 55 | #include "jfs_filsys.h" |
@@ -121,8 +122,7 @@ static DEFINE_SPINLOCK(jfsTxnLock); | |||
121 | #define LAZY_LOCK(flags) spin_lock_irqsave(&TxAnchor.LazyLock, flags) | 122 | #define LAZY_LOCK(flags) spin_lock_irqsave(&TxAnchor.LazyLock, flags) |
122 | #define LAZY_UNLOCK(flags) spin_unlock_irqrestore(&TxAnchor.LazyLock, flags) | 123 | #define LAZY_UNLOCK(flags) spin_unlock_irqrestore(&TxAnchor.LazyLock, flags) |
123 | 124 | ||
124 | DECLARE_WAIT_QUEUE_HEAD(jfs_sync_thread_wait); | 125 | static DECLARE_WAIT_QUEUE_HEAD(jfs_commit_thread_wait); |
125 | DECLARE_WAIT_QUEUE_HEAD(jfs_commit_thread_wait); | ||
126 | static int jfs_commit_thread_waking; | 126 | static int jfs_commit_thread_waking; |
127 | 127 | ||
128 | /* | 128 | /* |
@@ -207,7 +207,7 @@ static lid_t txLockAlloc(void) | |||
207 | if ((++TxAnchor.tlocksInUse > TxLockHWM) && (jfs_tlocks_low == 0)) { | 207 | if ((++TxAnchor.tlocksInUse > TxLockHWM) && (jfs_tlocks_low == 0)) { |
208 | jfs_info("txLockAlloc tlocks low"); | 208 | jfs_info("txLockAlloc tlocks low"); |
209 | jfs_tlocks_low = 1; | 209 | jfs_tlocks_low = 1; |
210 | wake_up(&jfs_sync_thread_wait); | 210 | wake_up_process(jfsSyncThread); |
211 | } | 211 | } |
212 | 212 | ||
213 | return lid; | 213 | return lid; |
@@ -2743,10 +2743,6 @@ int jfs_lazycommit(void *arg) | |||
2743 | unsigned long flags; | 2743 | unsigned long flags; |
2744 | struct jfs_sb_info *sbi; | 2744 | struct jfs_sb_info *sbi; |
2745 | 2745 | ||
2746 | daemonize("jfsCommit"); | ||
2747 | |||
2748 | complete(&jfsIOwait); | ||
2749 | |||
2750 | do { | 2746 | do { |
2751 | LAZY_LOCK(flags); | 2747 | LAZY_LOCK(flags); |
2752 | jfs_commit_thread_waking = 0; /* OK to wake another thread */ | 2748 | jfs_commit_thread_waking = 0; /* OK to wake another thread */ |
@@ -2806,13 +2802,13 @@ int jfs_lazycommit(void *arg) | |||
2806 | current->state = TASK_RUNNING; | 2802 | current->state = TASK_RUNNING; |
2807 | remove_wait_queue(&jfs_commit_thread_wait, &wq); | 2803 | remove_wait_queue(&jfs_commit_thread_wait, &wq); |
2808 | } | 2804 | } |
2809 | } while (!jfs_stop_threads); | 2805 | } while (!kthread_should_stop()); |
2810 | 2806 | ||
2811 | if (!list_empty(&TxAnchor.unlock_queue)) | 2807 | if (!list_empty(&TxAnchor.unlock_queue)) |
2812 | jfs_err("jfs_lazycommit being killed w/pending transactions!"); | 2808 | jfs_err("jfs_lazycommit being killed w/pending transactions!"); |
2813 | else | 2809 | else |
2814 | jfs_info("jfs_lazycommit being killed\n"); | 2810 | jfs_info("jfs_lazycommit being killed\n"); |
2815 | complete_and_exit(&jfsIOwait, 0); | 2811 | return 0; |
2816 | } | 2812 | } |
2817 | 2813 | ||
2818 | void txLazyUnlock(struct tblock * tblk) | 2814 | void txLazyUnlock(struct tblock * tblk) |
@@ -2876,10 +2872,10 @@ restart: | |||
2876 | */ | 2872 | */ |
2877 | TXN_UNLOCK(); | 2873 | TXN_UNLOCK(); |
2878 | tid = txBegin(ip->i_sb, COMMIT_INODE | COMMIT_FORCE); | 2874 | tid = txBegin(ip->i_sb, COMMIT_INODE | COMMIT_FORCE); |
2879 | down(&jfs_ip->commit_sem); | 2875 | mutex_lock(&jfs_ip->commit_mutex); |
2880 | txCommit(tid, 1, &ip, 0); | 2876 | txCommit(tid, 1, &ip, 0); |
2881 | txEnd(tid); | 2877 | txEnd(tid); |
2882 | up(&jfs_ip->commit_sem); | 2878 | mutex_unlock(&jfs_ip->commit_mutex); |
2883 | /* | 2879 | /* |
2884 | * Just to be safe. I don't know how | 2880 | * Just to be safe. I don't know how |
2885 | * long we can run without blocking | 2881 | * long we can run without blocking |
@@ -2932,10 +2928,6 @@ int jfs_sync(void *arg) | |||
2932 | int rc; | 2928 | int rc; |
2933 | tid_t tid; | 2929 | tid_t tid; |
2934 | 2930 | ||
2935 | daemonize("jfsSync"); | ||
2936 | |||
2937 | complete(&jfsIOwait); | ||
2938 | |||
2939 | do { | 2931 | do { |
2940 | /* | 2932 | /* |
2941 | * write each inode on the anonymous inode list | 2933 | * write each inode on the anonymous inode list |
@@ -2952,7 +2944,7 @@ int jfs_sync(void *arg) | |||
2952 | * Inode is being freed | 2944 | * Inode is being freed |
2953 | */ | 2945 | */ |
2954 | list_del_init(&jfs_ip->anon_inode_list); | 2946 | list_del_init(&jfs_ip->anon_inode_list); |
2955 | } else if (! down_trylock(&jfs_ip->commit_sem)) { | 2947 | } else if (! !mutex_trylock(&jfs_ip->commit_mutex)) { |
2956 | /* | 2948 | /* |
2957 | * inode will be removed from anonymous list | 2949 | * inode will be removed from anonymous list |
2958 | * when it is committed | 2950 | * when it is committed |
@@ -2961,7 +2953,7 @@ int jfs_sync(void *arg) | |||
2961 | tid = txBegin(ip->i_sb, COMMIT_INODE); | 2953 | tid = txBegin(ip->i_sb, COMMIT_INODE); |
2962 | rc = txCommit(tid, 1, &ip, 0); | 2954 | rc = txCommit(tid, 1, &ip, 0); |
2963 | txEnd(tid); | 2955 | txEnd(tid); |
2964 | up(&jfs_ip->commit_sem); | 2956 | mutex_unlock(&jfs_ip->commit_mutex); |
2965 | 2957 | ||
2966 | iput(ip); | 2958 | iput(ip); |
2967 | /* | 2959 | /* |
@@ -2971,7 +2963,7 @@ int jfs_sync(void *arg) | |||
2971 | cond_resched(); | 2963 | cond_resched(); |
2972 | TXN_LOCK(); | 2964 | TXN_LOCK(); |
2973 | } else { | 2965 | } else { |
2974 | /* We can't get the commit semaphore. It may | 2966 | /* We can't get the commit mutex. It may |
2975 | * be held by a thread waiting for tlock's | 2967 | * be held by a thread waiting for tlock's |
2976 | * so let's not block here. Save it to | 2968 | * so let's not block here. Save it to |
2977 | * put back on the anon_list. | 2969 | * put back on the anon_list. |
@@ -2996,19 +2988,15 @@ int jfs_sync(void *arg) | |||
2996 | TXN_UNLOCK(); | 2988 | TXN_UNLOCK(); |
2997 | refrigerator(); | 2989 | refrigerator(); |
2998 | } else { | 2990 | } else { |
2999 | DECLARE_WAITQUEUE(wq, current); | ||
3000 | |||
3001 | add_wait_queue(&jfs_sync_thread_wait, &wq); | ||
3002 | set_current_state(TASK_INTERRUPTIBLE); | 2991 | set_current_state(TASK_INTERRUPTIBLE); |
3003 | TXN_UNLOCK(); | 2992 | TXN_UNLOCK(); |
3004 | schedule(); | 2993 | schedule(); |
3005 | current->state = TASK_RUNNING; | 2994 | current->state = TASK_RUNNING; |
3006 | remove_wait_queue(&jfs_sync_thread_wait, &wq); | ||
3007 | } | 2995 | } |
3008 | } while (!jfs_stop_threads); | 2996 | } while (!kthread_should_stop()); |
3009 | 2997 | ||
3010 | jfs_info("jfs_sync being killed"); | 2998 | jfs_info("jfs_sync being killed"); |
3011 | complete_and_exit(&jfsIOwait, 0); | 2999 | return 0; |
3012 | } | 3000 | } |
3013 | 3001 | ||
3014 | #if defined(CONFIG_PROC_FS) && defined(CONFIG_JFS_DEBUG) | 3002 | #if defined(CONFIG_PROC_FS) && defined(CONFIG_JFS_DEBUG) |