aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r--fs/btrfs/super.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index d366dd4664d0..c389c13f0f38 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -69,7 +69,7 @@ static struct file_system_type btrfs_fs_type;
69 69
70static int btrfs_remount(struct super_block *sb, int *flags, char *data); 70static int btrfs_remount(struct super_block *sb, int *flags, char *data);
71 71
72static const char *btrfs_decode_error(int errno) 72const char *btrfs_decode_error(int errno)
73{ 73{
74 char *errstr = "unknown"; 74 char *errstr = "unknown";
75 75
@@ -1651,6 +1651,17 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
1651 1651
1652 sb->s_flags |= MS_RDONLY; 1652 sb->s_flags |= MS_RDONLY;
1653 1653
1654 /*
1655 * Setting MS_RDONLY will put the cleaner thread to
1656 * sleep at the next loop if it's already active.
1657 * If it's already asleep, we'll leave unused block
1658 * groups on disk until we're mounted read-write again
1659 * unless we clean them up here.
1660 */
1661 mutex_lock(&root->fs_info->cleaner_mutex);
1662 btrfs_delete_unused_bgs(fs_info);
1663 mutex_unlock(&root->fs_info->cleaner_mutex);
1664
1654 btrfs_dev_replace_suspend_for_unmount(fs_info); 1665 btrfs_dev_replace_suspend_for_unmount(fs_info);
1655 btrfs_scrub_cancel(fs_info); 1666 btrfs_scrub_cancel(fs_info);
1656 btrfs_pause_balance(fs_info); 1667 btrfs_pause_balance(fs_info);