diff options
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r-- | fs/btrfs/disk-io.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 898263f56d96..b8ed1d4fe509 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -1658,15 +1658,20 @@ static int cleaner_kthread(void *arg) | |||
1658 | struct btrfs_root *root = arg; | 1658 | struct btrfs_root *root = arg; |
1659 | 1659 | ||
1660 | do { | 1660 | do { |
1661 | int again = 0; | ||
1662 | |||
1661 | if (!(root->fs_info->sb->s_flags & MS_RDONLY) && | 1663 | if (!(root->fs_info->sb->s_flags & MS_RDONLY) && |
1662 | mutex_trylock(&root->fs_info->cleaner_mutex)) { | 1664 | down_read_trylock(&root->fs_info->sb->s_umount)) { |
1663 | btrfs_run_delayed_iputs(root); | 1665 | if (mutex_trylock(&root->fs_info->cleaner_mutex)) { |
1664 | btrfs_clean_old_snapshots(root); | 1666 | btrfs_run_delayed_iputs(root); |
1665 | mutex_unlock(&root->fs_info->cleaner_mutex); | 1667 | again = btrfs_clean_one_deleted_snapshot(root); |
1668 | mutex_unlock(&root->fs_info->cleaner_mutex); | ||
1669 | } | ||
1666 | btrfs_run_defrag_inodes(root->fs_info); | 1670 | btrfs_run_defrag_inodes(root->fs_info); |
1671 | up_read(&root->fs_info->sb->s_umount); | ||
1667 | } | 1672 | } |
1668 | 1673 | ||
1669 | if (!try_to_freeze()) { | 1674 | if (!try_to_freeze() && !again) { |
1670 | set_current_state(TASK_INTERRUPTIBLE); | 1675 | set_current_state(TASK_INTERRUPTIBLE); |
1671 | if (!kthread_should_stop()) | 1676 | if (!kthread_should_stop()) |
1672 | schedule(); | 1677 | schedule(); |
@@ -3358,8 +3363,8 @@ int btrfs_commit_super(struct btrfs_root *root) | |||
3358 | 3363 | ||
3359 | mutex_lock(&root->fs_info->cleaner_mutex); | 3364 | mutex_lock(&root->fs_info->cleaner_mutex); |
3360 | btrfs_run_delayed_iputs(root); | 3365 | btrfs_run_delayed_iputs(root); |
3361 | btrfs_clean_old_snapshots(root); | ||
3362 | mutex_unlock(&root->fs_info->cleaner_mutex); | 3366 | mutex_unlock(&root->fs_info->cleaner_mutex); |
3367 | wake_up_process(root->fs_info->cleaner_kthread); | ||
3363 | 3368 | ||
3364 | /* wait until ongoing cleanup work done */ | 3369 | /* wait until ongoing cleanup work done */ |
3365 | down_write(&root->fs_info->cleanup_work_sem); | 3370 | down_write(&root->fs_info->cleanup_work_sem); |