Skip to content

Commit 063849e

Browse files
arndChris Mason
authored andcommitted
Btrfs: allow mount -o remount,compress=no
Btrfs allows to turn on compression on a mounted and used filesystem by issuing mount -o remount,compress=lzo. This patch allows to turn compression off again while the filesystem is mounted. As suggested by David Sterba if the compress-force option was set, it is implicitly cleared if compression is turned off. Tested-by: David Sterba <[email protected]> Signed-off-by: Arnd Hannemann <[email protected]>
1 parent c5c3c5f commit 063849e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

fs/btrfs/super.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,15 +396,22 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
396396
strcmp(args[0].from, "zlib") == 0) {
397397
compress_type = "zlib";
398398
info->compress_type = BTRFS_COMPRESS_ZLIB;
399+
btrfs_set_opt(info->mount_opt, COMPRESS);
399400
} else if (strcmp(args[0].from, "lzo") == 0) {
400401
compress_type = "lzo";
401402
info->compress_type = BTRFS_COMPRESS_LZO;
403+
btrfs_set_opt(info->mount_opt, COMPRESS);
404+
} else if (strncmp(args[0].from, "no", 2) == 0) {
405+
compress_type = "no";
406+
info->compress_type = BTRFS_COMPRESS_NONE;
407+
btrfs_clear_opt(info->mount_opt, COMPRESS);
408+
btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS);
409+
compress_force = false;
402410
} else {
403411
ret = -EINVAL;
404412
goto out;
405413
}
406414

407-
btrfs_set_opt(info->mount_opt, COMPRESS);
408415
if (compress_force) {
409416
btrfs_set_opt(info->mount_opt, FORCE_COMPRESS);
410417
pr_info("btrfs: force %s compression\n",

0 commit comments

Comments
 (0)