diff options
author | Tsutomu Itoh <t-itoh@jp.fujitsu.com> | 2016-01-06 03:03:40 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-01-15 13:25:36 -0500 |
commit | b7c47bbb2d1856330f71ba04c8eb03b39aca87cd (patch) | |
tree | 511803ab4a7175e6d14d5b57c5f7c158178c7327 /fs | |
parent | f32e48e925964c4f8ab917850788a87e1cef3bad (diff) |
Btrfs: fix output of compression message in btrfs_parse_options()
The compression message might not be correctly output.
Fix it.
[[before fix]]
# mount -o compress /dev/sdb3 /test3
[ 996.874264] BTRFS info (device sdb3): disk space caching is enabled
[ 996.874268] BTRFS: has skinny extents
# mount | grep /test3
/dev/sdb3 on /test3 type btrfs (rw,relatime,compress=zlib,space_cache,subvolid=5,subvol=/)
# mount -o remount,compress-force /dev/sdb3 /test3
[ 1035.075017] BTRFS info (device sdb3): force zlib compression
[ 1035.075021] BTRFS info (device sdb3): disk space caching is enabled
# mount | grep /test3
/dev/sdb3 on /test3 type btrfs (rw,relatime,compress-force=zlib,space_cache,subvolid=5,subvol=/)
# mount -o remount,compress /dev/sdb3 /test3
[ 1053.679092] BTRFS info (device sdb3): disk space caching is enabled
# mount | grep /test3
/dev/sdb3 on /test3 type btrfs (rw,relatime,compress=zlib,space_cache,subvolid=5,subvol=/)
[[after fix]]
# mount -o compress /dev/sdb3 /test3
[ 401.021753] BTRFS info (device sdb3): use zlib compression
[ 401.021758] BTRFS info (device sdb3): disk space caching is enabled
[ 401.021760] BTRFS: has skinny extents
# mount | grep /test3
/dev/sdb3 on /test3 type btrfs (rw,relatime,compress=zlib,space_cache,subvolid=5,subvol=/)
# mount -o remount,compress-force /dev/sdb3 /test3
[ 439.824624] BTRFS info (device sdb3): force zlib compression
[ 439.824629] BTRFS info (device sdb3): disk space caching is enabled
# mount | grep /test3
/dev/sdb3 on /test3 type btrfs (rw,relatime,compress-force=zlib,space_cache,subvolid=5,subvol=/)
# mount -o remount,compress /dev/sdb3 /test3
[ 459.918430] BTRFS info (device sdb3): use zlib compression
[ 459.918434] BTRFS info (device sdb3): disk space caching is enabled
# mount | grep /test3
/dev/sdb3 on /test3 type btrfs (rw,relatime,compress=zlib,space_cache,subvolid=5,subvol=/)
Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/super.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 5099e4633e50..3225ac365408 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -381,6 +381,9 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) | |||
381 | int ret = 0; | 381 | int ret = 0; |
382 | char *compress_type; | 382 | char *compress_type; |
383 | bool compress_force = false; | 383 | bool compress_force = false; |
384 | enum btrfs_compression_type saved_compress_type; | ||
385 | bool saved_compress_force; | ||
386 | int no_compress = 0; | ||
384 | 387 | ||
385 | cache_gen = btrfs_super_cache_generation(root->fs_info->super_copy); | 388 | cache_gen = btrfs_super_cache_generation(root->fs_info->super_copy); |
386 | if (cache_gen) | 389 | if (cache_gen) |
@@ -458,6 +461,10 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) | |||
458 | /* Fallthrough */ | 461 | /* Fallthrough */ |
459 | case Opt_compress: | 462 | case Opt_compress: |
460 | case Opt_compress_type: | 463 | case Opt_compress_type: |
464 | saved_compress_type = btrfs_test_opt(root, COMPRESS) ? | ||
465 | info->compress_type : BTRFS_COMPRESS_NONE; | ||
466 | saved_compress_force = | ||
467 | btrfs_test_opt(root, FORCE_COMPRESS); | ||
461 | if (token == Opt_compress || | 468 | if (token == Opt_compress || |
462 | token == Opt_compress_force || | 469 | token == Opt_compress_force || |
463 | strcmp(args[0].from, "zlib") == 0) { | 470 | strcmp(args[0].from, "zlib") == 0) { |
@@ -466,6 +473,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) | |||
466 | btrfs_set_opt(info->mount_opt, COMPRESS); | 473 | btrfs_set_opt(info->mount_opt, COMPRESS); |
467 | btrfs_clear_opt(info->mount_opt, NODATACOW); | 474 | btrfs_clear_opt(info->mount_opt, NODATACOW); |
468 | btrfs_clear_opt(info->mount_opt, NODATASUM); | 475 | btrfs_clear_opt(info->mount_opt, NODATASUM); |
476 | no_compress = 0; | ||
469 | } else if (strcmp(args[0].from, "lzo") == 0) { | 477 | } else if (strcmp(args[0].from, "lzo") == 0) { |
470 | compress_type = "lzo"; | 478 | compress_type = "lzo"; |
471 | info->compress_type = BTRFS_COMPRESS_LZO; | 479 | info->compress_type = BTRFS_COMPRESS_LZO; |
@@ -473,25 +481,21 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) | |||
473 | btrfs_clear_opt(info->mount_opt, NODATACOW); | 481 | btrfs_clear_opt(info->mount_opt, NODATACOW); |
474 | btrfs_clear_opt(info->mount_opt, NODATASUM); | 482 | btrfs_clear_opt(info->mount_opt, NODATASUM); |
475 | btrfs_set_fs_incompat(info, COMPRESS_LZO); | 483 | btrfs_set_fs_incompat(info, COMPRESS_LZO); |
484 | no_compress = 0; | ||
476 | } else if (strncmp(args[0].from, "no", 2) == 0) { | 485 | } else if (strncmp(args[0].from, "no", 2) == 0) { |
477 | compress_type = "no"; | 486 | compress_type = "no"; |
478 | btrfs_clear_opt(info->mount_opt, COMPRESS); | 487 | btrfs_clear_opt(info->mount_opt, COMPRESS); |
479 | btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS); | 488 | btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS); |
480 | compress_force = false; | 489 | compress_force = false; |
490 | no_compress++; | ||
481 | } else { | 491 | } else { |
482 | ret = -EINVAL; | 492 | ret = -EINVAL; |
483 | goto out; | 493 | goto out; |
484 | } | 494 | } |
485 | 495 | ||
486 | if (compress_force) { | 496 | if (compress_force) { |
487 | btrfs_set_and_info(root, FORCE_COMPRESS, | 497 | btrfs_set_opt(info->mount_opt, FORCE_COMPRESS); |
488 | "force %s compression", | ||
489 | compress_type); | ||
490 | } else { | 498 | } else { |
491 | if (!btrfs_test_opt(root, COMPRESS)) | ||
492 | btrfs_info(root->fs_info, | ||
493 | "btrfs: use %s compression", | ||
494 | compress_type); | ||
495 | /* | 499 | /* |
496 | * If we remount from compress-force=xxx to | 500 | * If we remount from compress-force=xxx to |
497 | * compress=xxx, we need clear FORCE_COMPRESS | 501 | * compress=xxx, we need clear FORCE_COMPRESS |
@@ -500,6 +504,17 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) | |||
500 | */ | 504 | */ |
501 | btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS); | 505 | btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS); |
502 | } | 506 | } |
507 | if ((btrfs_test_opt(root, COMPRESS) && | ||
508 | (info->compress_type != saved_compress_type || | ||
509 | compress_force != saved_compress_force)) || | ||
510 | (!btrfs_test_opt(root, COMPRESS) && | ||
511 | no_compress == 1)) { | ||
512 | btrfs_info(root->fs_info, | ||
513 | "%s %s compression", | ||
514 | (compress_force) ? "force" : "use", | ||
515 | compress_type); | ||
516 | } | ||
517 | compress_force = false; | ||
503 | break; | 518 | break; |
504 | case Opt_ssd: | 519 | case Opt_ssd: |
505 | btrfs_set_and_info(root, SSD, | 520 | btrfs_set_and_info(root, SSD, |