[PATCH] [SRU][TRUSTY] Btrfs: clear compress-force when remounting with compress option

Colin King colin.king at canonical.com
Thu Mar 19 17:37:14 UTC 2015

From: Colin Ian King <colin.king at canonical.com>

BugLink: http://bugs.launchpad.net/bugs/1434183

Steps to reproduce:
 # mkfs.btrfs -f /dev/sdb
 # mount /dev/sdb /mnt -o compress-force=lzo
 # mount /dev/sdb /mnt -o remount,compress=zlib
 # cat /proc/mounts

Remounting from compress-force to compress could not clear compress-force
option. The problem is there is no way for users to clear compress-force
option separately.

Fix this problem by clearing @FORCE_COMPRESS flag when remounting to

Suggested-by: Tsutomu Itoh <t-itoh at jp.fujitsu.com>
Signed-off-by: Wang Shilong <wangsl.fnst at cn.fujitsu.com>
Reviewed-by: David Sterba <dsterba at suse.cz>
Reviewed-by: Satoru Takeuchi <takeuchi_satoru at jp.fujitsu.com>
Tested-by: Satoru Takeuchi <takeuchi_satoru at jp.fujitsu.com>
Signed-off-by: Chris Mason <clm at fb.com>
(backport from upstream commit 4027e0f4c4b2df28d564560a3c65c179bebae4c8)
Signed-off-by: Colin Ian King <colin.king at canonical.com>
 fs/btrfs/super.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index d71a11d..53d1cac 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -475,6 +475,13 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
 			} else if (btrfs_test_opt(root, COMPRESS)) {
 				pr_info("btrfs: use %s compression\n",
+				/*
+				 * If we remount from compress-force=xxx to
+				 * compress=xxx, we need clear FORCE_COMPRESS
+				 * flag, otherwise, there is no way for users
+				 * to disable forcible compression separately.
+				 */
+				btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS);
 		case Opt_ssd:

More information about the kernel-team mailing list