diff options
author | Tejun Heo <tj@kernel.org> | 2011-11-21 15:32:22 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2011-11-21 15:32:22 -0500 |
commit | a0acae0e886d44bd5ce6d2f173c1ace0fcf0d9f6 (patch) | |
tree | 0b763388360a5a9043986e1f2201e43df74ebc46 /fs | |
parent | 3a7cbd50f74907580eb47a8d08e1f29741b81abf (diff) |
freezer: unexport refrigerator() and update try_to_freeze() slightly
There is no reason to export two functions for entering the
refrigerator. Calling refrigerator() instead of try_to_freeze()
doesn't save anything noticeable or removes any race condition.
* Rename refrigerator() to __refrigerator() and make it return bool
indicating whether it scheduled out for freezing.
* Update try_to_freeze() to return bool and relay the return value of
__refrigerator() if freezing().
* Convert all refrigerator() users to try_to_freeze().
* Update documentation accordingly.
* While at it, add might_sleep() to try_to_freeze().
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Samuel Ortiz <samuel@sortiz.org>
Cc: Chris Mason <chris.mason@oracle.com>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jan Kara <jack@suse.cz>
Cc: KONISHI Ryusuke <konishi.ryusuke@lab.ntt.co.jp>
Cc: Christoph Hellwig <hch@infradead.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/async-thread.c | 2 | ||||
-rw-r--r-- | fs/btrfs/disk-io.c | 8 | ||||
-rw-r--r-- | fs/ext4/super.c | 3 | ||||
-rw-r--r-- | fs/gfs2/log.c | 4 | ||||
-rw-r--r-- | fs/gfs2/quota.c | 4 | ||||
-rw-r--r-- | fs/jbd/journal.c | 2 | ||||
-rw-r--r-- | fs/jbd2/journal.c | 2 | ||||
-rw-r--r-- | fs/jfs/jfs_logmgr.c | 2 | ||||
-rw-r--r-- | fs/jfs/jfs_txnmgr.c | 4 | ||||
-rw-r--r-- | fs/nilfs2/segment.c | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_buf.c | 2 |
11 files changed, 15 insertions, 20 deletions
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c index 7ec14097fef1..98ab240072e5 100644 --- a/fs/btrfs/async-thread.c +++ b/fs/btrfs/async-thread.c | |||
@@ -340,7 +340,7 @@ again: | |||
340 | if (freezing(current)) { | 340 | if (freezing(current)) { |
341 | worker->working = 0; | 341 | worker->working = 0; |
342 | spin_unlock_irq(&worker->lock); | 342 | spin_unlock_irq(&worker->lock); |
343 | refrigerator(); | 343 | try_to_freeze(); |
344 | } else { | 344 | } else { |
345 | spin_unlock_irq(&worker->lock); | 345 | spin_unlock_irq(&worker->lock); |
346 | if (!kthread_should_stop()) { | 346 | if (!kthread_should_stop()) { |
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 62afe5c5694e..622654fe051f 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -1579,9 +1579,7 @@ static int cleaner_kthread(void *arg) | |||
1579 | btrfs_run_defrag_inodes(root->fs_info); | 1579 | btrfs_run_defrag_inodes(root->fs_info); |
1580 | } | 1580 | } |
1581 | 1581 | ||
1582 | if (freezing(current)) { | 1582 | if (!try_to_freeze()) { |
1583 | refrigerator(); | ||
1584 | } else { | ||
1585 | set_current_state(TASK_INTERRUPTIBLE); | 1583 | set_current_state(TASK_INTERRUPTIBLE); |
1586 | if (!kthread_should_stop()) | 1584 | if (!kthread_should_stop()) |
1587 | schedule(); | 1585 | schedule(); |
@@ -1635,9 +1633,7 @@ sleep: | |||
1635 | wake_up_process(root->fs_info->cleaner_kthread); | 1633 | wake_up_process(root->fs_info->cleaner_kthread); |
1636 | mutex_unlock(&root->fs_info->transaction_kthread_mutex); | 1634 | mutex_unlock(&root->fs_info->transaction_kthread_mutex); |
1637 | 1635 | ||
1638 | if (freezing(current)) { | 1636 | if (!try_to_freeze()) { |
1639 | refrigerator(); | ||
1640 | } else { | ||
1641 | set_current_state(TASK_INTERRUPTIBLE); | 1637 | set_current_state(TASK_INTERRUPTIBLE); |
1642 | if (!kthread_should_stop() && | 1638 | if (!kthread_should_stop() && |
1643 | !btrfs_transaction_blocked(root->fs_info)) | 1639 | !btrfs_transaction_blocked(root->fs_info)) |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 9953d80145ad..877350ef0253 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -2882,8 +2882,7 @@ cont_thread: | |||
2882 | } | 2882 | } |
2883 | mutex_unlock(&eli->li_list_mtx); | 2883 | mutex_unlock(&eli->li_list_mtx); |
2884 | 2884 | ||
2885 | if (freezing(current)) | 2885 | try_to_freeze(); |
2886 | refrigerator(); | ||
2887 | 2886 | ||
2888 | cur = jiffies; | 2887 | cur = jiffies; |
2889 | if ((time_after_eq(cur, next_wakeup)) || | 2888 | if ((time_after_eq(cur, next_wakeup)) || |
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c index 598646434362..8154d42e4647 100644 --- a/fs/gfs2/log.c +++ b/fs/gfs2/log.c | |||
@@ -951,8 +951,8 @@ int gfs2_logd(void *data) | |||
951 | wake_up(&sdp->sd_log_waitq); | 951 | wake_up(&sdp->sd_log_waitq); |
952 | 952 | ||
953 | t = gfs2_tune_get(sdp, gt_logd_secs) * HZ; | 953 | t = gfs2_tune_get(sdp, gt_logd_secs) * HZ; |
954 | if (freezing(current)) | 954 | |
955 | refrigerator(); | 955 | try_to_freeze(); |
956 | 956 | ||
957 | do { | 957 | do { |
958 | prepare_to_wait(&sdp->sd_logd_waitq, &wait, | 958 | prepare_to_wait(&sdp->sd_logd_waitq, &wait, |
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index 7e528dc14f85..d49669e92652 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c | |||
@@ -1427,8 +1427,8 @@ int gfs2_quotad(void *data) | |||
1427 | /* Check for & recover partially truncated inodes */ | 1427 | /* Check for & recover partially truncated inodes */ |
1428 | quotad_check_trunc_list(sdp); | 1428 | quotad_check_trunc_list(sdp); |
1429 | 1429 | ||
1430 | if (freezing(current)) | 1430 | try_to_freeze(); |
1431 | refrigerator(); | 1431 | |
1432 | t = min(quotad_timeo, statfs_timeo); | 1432 | t = min(quotad_timeo, statfs_timeo); |
1433 | 1433 | ||
1434 | prepare_to_wait(&sdp->sd_quota_wait, &wait, TASK_INTERRUPTIBLE); | 1434 | prepare_to_wait(&sdp->sd_quota_wait, &wait, TASK_INTERRUPTIBLE); |
diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c index fea8dd661d2b..a96cff0c5f1d 100644 --- a/fs/jbd/journal.c +++ b/fs/jbd/journal.c | |||
@@ -166,7 +166,7 @@ loop: | |||
166 | */ | 166 | */ |
167 | jbd_debug(1, "Now suspending kjournald\n"); | 167 | jbd_debug(1, "Now suspending kjournald\n"); |
168 | spin_unlock(&journal->j_state_lock); | 168 | spin_unlock(&journal->j_state_lock); |
169 | refrigerator(); | 169 | try_to_freeze(); |
170 | spin_lock(&journal->j_state_lock); | 170 | spin_lock(&journal->j_state_lock); |
171 | } else { | 171 | } else { |
172 | /* | 172 | /* |
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 0fa0123151d3..c0a5f9f1b127 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c | |||
@@ -173,7 +173,7 @@ loop: | |||
173 | */ | 173 | */ |
174 | jbd_debug(1, "Now suspending kjournald2\n"); | 174 | jbd_debug(1, "Now suspending kjournald2\n"); |
175 | write_unlock(&journal->j_state_lock); | 175 | write_unlock(&journal->j_state_lock); |
176 | refrigerator(); | 176 | try_to_freeze(); |
177 | write_lock(&journal->j_state_lock); | 177 | write_lock(&journal->j_state_lock); |
178 | } else { | 178 | } else { |
179 | /* | 179 | /* |
diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c index cc5f811ed383..2eb952c41a69 100644 --- a/fs/jfs/jfs_logmgr.c +++ b/fs/jfs/jfs_logmgr.c | |||
@@ -2349,7 +2349,7 @@ int jfsIOWait(void *arg) | |||
2349 | 2349 | ||
2350 | if (freezing(current)) { | 2350 | if (freezing(current)) { |
2351 | spin_unlock_irq(&log_redrive_lock); | 2351 | spin_unlock_irq(&log_redrive_lock); |
2352 | refrigerator(); | 2352 | try_to_freeze(); |
2353 | } else { | 2353 | } else { |
2354 | set_current_state(TASK_INTERRUPTIBLE); | 2354 | set_current_state(TASK_INTERRUPTIBLE); |
2355 | spin_unlock_irq(&log_redrive_lock); | 2355 | spin_unlock_irq(&log_redrive_lock); |
diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c index af9606057dde..bb8b661bcc50 100644 --- a/fs/jfs/jfs_txnmgr.c +++ b/fs/jfs/jfs_txnmgr.c | |||
@@ -2800,7 +2800,7 @@ int jfs_lazycommit(void *arg) | |||
2800 | 2800 | ||
2801 | if (freezing(current)) { | 2801 | if (freezing(current)) { |
2802 | LAZY_UNLOCK(flags); | 2802 | LAZY_UNLOCK(flags); |
2803 | refrigerator(); | 2803 | try_to_freeze(); |
2804 | } else { | 2804 | } else { |
2805 | DECLARE_WAITQUEUE(wq, current); | 2805 | DECLARE_WAITQUEUE(wq, current); |
2806 | 2806 | ||
@@ -2994,7 +2994,7 @@ int jfs_sync(void *arg) | |||
2994 | 2994 | ||
2995 | if (freezing(current)) { | 2995 | if (freezing(current)) { |
2996 | TXN_UNLOCK(); | 2996 | TXN_UNLOCK(); |
2997 | refrigerator(); | 2997 | try_to_freeze(); |
2998 | } else { | 2998 | } else { |
2999 | set_current_state(TASK_INTERRUPTIBLE); | 2999 | set_current_state(TASK_INTERRUPTIBLE); |
3000 | TXN_UNLOCK(); | 3000 | TXN_UNLOCK(); |
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index bb24ab6c282f..0e72ad6f22aa 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c | |||
@@ -2470,7 +2470,7 @@ static int nilfs_segctor_thread(void *arg) | |||
2470 | 2470 | ||
2471 | if (freezing(current)) { | 2471 | if (freezing(current)) { |
2472 | spin_unlock(&sci->sc_state_lock); | 2472 | spin_unlock(&sci->sc_state_lock); |
2473 | refrigerator(); | 2473 | try_to_freeze(); |
2474 | spin_lock(&sci->sc_state_lock); | 2474 | spin_lock(&sci->sc_state_lock); |
2475 | } else { | 2475 | } else { |
2476 | DEFINE_WAIT(wait); | 2476 | DEFINE_WAIT(wait); |
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index cf0ac056815f..018829936d6d 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c | |||
@@ -1703,7 +1703,7 @@ xfsbufd( | |||
1703 | 1703 | ||
1704 | if (unlikely(freezing(current))) { | 1704 | if (unlikely(freezing(current))) { |
1705 | set_bit(XBT_FORCE_SLEEP, &target->bt_flags); | 1705 | set_bit(XBT_FORCE_SLEEP, &target->bt_flags); |
1706 | refrigerator(); | 1706 | try_to_freeze(); |
1707 | } else { | 1707 | } else { |
1708 | clear_bit(XBT_FORCE_SLEEP, &target->bt_flags); | 1708 | clear_bit(XBT_FORCE_SLEEP, &target->bt_flags); |
1709 | } | 1709 | } |