Btrfs: clear compress-force when remounting with compress option
authorWang Shilong <wangsl.fnst@cn.fujitsu.com>
Mon, 30 Jun 2014 02:51:25 +0000 (10:51 +0800)
committerChris Mason <clm@fb.com>
Wed, 17 Sep 2014 20:37:19 +0000 (13:37 -0700)
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
compress=xxx.

Suggested-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Reviewed-by: David Sterba <dsterba@suse.cz>
Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Tested-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/super.c

index 568ddc16119f2f8560e747b41563a66245d68539..d66fbd57f1b5084df93e8263f86e1b41a7dfcd82 100644 (file)
@@ -507,6 +507,13 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
                                        btrfs_info(root->fs_info,
                                                   "btrfs: use %s compression",
                                                   compress_type);
+                               /*
+                                * 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);
                        }
                        break;
                case Opt_ssd: