summaryrefslogtreecommitdiff
path: root/fs/btrfs/super.c
diff options
context:
space:
mode:
authorChris Mason <clm@fb.com>2015-08-09 07:35:33 -0700
committerChris Mason <clm@fb.com>2015-08-09 07:35:33 -0700
commit46cd28555ffaa40162290dba203daad0ff6f7abd (patch)
treea10fd81b6c7ff5ea7642b1e2462e529971e8713a /fs/btrfs/super.c
parentda2f0f74cf7d074e5a8918c8efdf6aba4a989b4a (diff)
parente33e17ee1098d8d751552ac11c111e1c1a3db014 (diff)
Merge branch 'jeffm-discard-4.3' into for-linus-4.3
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;
static int btrfs_remount(struct super_block *sb, int *flags, char *data);
-static const char *btrfs_decode_error(int errno)
+const char *btrfs_decode_error(int errno)
{
char *errstr = "unknown";
@@ -1651,6 +1651,17 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
sb->s_flags |= MS_RDONLY;
+ /*
+ * Setting MS_RDONLY will put the cleaner thread to
+ * sleep at the next loop if it's already active.
+ * If it's already asleep, we'll leave unused block
+ * groups on disk until we're mounted read-write again
+ * unless we clean them up here.
+ */
+ mutex_lock(&root->fs_info->cleaner_mutex);
+ btrfs_delete_unused_bgs(fs_info);
+ mutex_unlock(&root->fs_info->cleaner_mutex);
+
btrfs_dev_replace_suspend_for_unmount(fs_info);
btrfs_scrub_cancel(fs_info);
btrfs_pause_balance(fs_info);