diff options
author | Jan Kara <jack@suse.cz> | 2012-03-12 11:05:50 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2012-03-22 06:53:11 -0400 |
commit | 914b20070b413ca10f832c45a58b2894990f065f (patch) | |
tree | 1c1f6af7f0f1243e9585a4b726065d579eebc3e9 /fs/btrfs/disk-io.c | |
parent | 79787eaab46121d4713ed03c8fc63b9ec3eaec76 (diff) |
btrfs: Fix busyloop in transaction_kthread()
When a filesystem got aborted due do error, transaction_kthread() will
busyloop. Fix it by going to sleep in that case as well. Maybe we should
just stop transaction_kthread() when filesystem is aborted but that would be
more complex.
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r-- | fs/btrfs/disk-io.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 16a0cada26c2..438993e3d832 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -1640,8 +1640,10 @@ static int transaction_kthread(void *arg) | |||
1640 | u64 transid; | 1640 | u64 transid; |
1641 | unsigned long now; | 1641 | unsigned long now; |
1642 | unsigned long delay; | 1642 | unsigned long delay; |
1643 | bool cannot_commit; | ||
1643 | 1644 | ||
1644 | do { | 1645 | do { |
1646 | cannot_commit = false; | ||
1645 | delay = HZ * 30; | 1647 | delay = HZ * 30; |
1646 | vfs_check_frozen(root->fs_info->sb, SB_FREEZE_WRITE); | 1648 | vfs_check_frozen(root->fs_info->sb, SB_FREEZE_WRITE); |
1647 | mutex_lock(&root->fs_info->transaction_kthread_mutex); | 1649 | mutex_lock(&root->fs_info->transaction_kthread_mutex); |
@@ -1665,8 +1667,10 @@ static int transaction_kthread(void *arg) | |||
1665 | 1667 | ||
1666 | /* If the file system is aborted, this will always fail. */ | 1668 | /* If the file system is aborted, this will always fail. */ |
1667 | trans = btrfs_join_transaction(root); | 1669 | trans = btrfs_join_transaction(root); |
1668 | if (IS_ERR(trans)) | 1670 | if (IS_ERR(trans)) { |
1671 | cannot_commit = true; | ||
1669 | goto sleep; | 1672 | goto sleep; |
1673 | } | ||
1670 | if (transid == trans->transid) { | 1674 | if (transid == trans->transid) { |
1671 | btrfs_commit_transaction(trans, root); | 1675 | btrfs_commit_transaction(trans, root); |
1672 | } else { | 1676 | } else { |
@@ -1679,7 +1683,8 @@ sleep: | |||
1679 | if (!try_to_freeze()) { | 1683 | if (!try_to_freeze()) { |
1680 | set_current_state(TASK_INTERRUPTIBLE); | 1684 | set_current_state(TASK_INTERRUPTIBLE); |
1681 | if (!kthread_should_stop() && | 1685 | if (!kthread_should_stop() && |
1682 | !btrfs_transaction_blocked(root->fs_info)) | 1686 | (!btrfs_transaction_blocked(root->fs_info) || |
1687 | cannot_commit)) | ||
1683 | schedule_timeout(delay); | 1688 | schedule_timeout(delay); |
1684 | __set_current_state(TASK_RUNNING); | 1689 | __set_current_state(TASK_RUNNING); |
1685 | } | 1690 | } |