Skip to content

Commit 27942c9

Browse files
committed
btrfs: fix messages after changing compression level by remount
Reported by Forza on IRC that remounting with compression options does not reflect the change in level, or at least it does not appear to do so according to the messages: mount -o compress=zstd:1 /dev/sda /mnt mount -o remount,compress=zstd:15 /mnt does not print the change to the level to syslog: [ 41.366060] BTRFS info (device vda): use zstd compression, level 1 [ 41.368254] BTRFS info (device vda): disk space caching is enabled [ 41.390429] BTRFS info (device vda): disk space caching is enabled What really happens is that the message is lost but the level is actualy changed. There's another weird output, if compression is reset to 'no': [ 45.413776] BTRFS info (device vda): use no compression, level 4 To fix that, save the previous compression level and print the message in that case too and use separate message for 'no' compression. CC: [email protected] # 4.19+ Signed-off-by: David Sterba <[email protected]>
1 parent bf53d46 commit 27942c9

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

fs/btrfs/super.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
517517
char *compress_type;
518518
bool compress_force = false;
519519
enum btrfs_compression_type saved_compress_type;
520+
int saved_compress_level;
520521
bool saved_compress_force;
521522
int no_compress = 0;
522523

@@ -598,6 +599,7 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
598599
info->compress_type : BTRFS_COMPRESS_NONE;
599600
saved_compress_force =
600601
btrfs_test_opt(info, FORCE_COMPRESS);
602+
saved_compress_level = info->compress_level;
601603
if (token == Opt_compress ||
602604
token == Opt_compress_force ||
603605
strncmp(args[0].from, "zlib", 4) == 0) {
@@ -642,6 +644,8 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
642644
no_compress = 0;
643645
} else if (strncmp(args[0].from, "no", 2) == 0) {
644646
compress_type = "no";
647+
info->compress_level = 0;
648+
info->compress_type = 0;
645649
btrfs_clear_opt(info->mount_opt, COMPRESS);
646650
btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS);
647651
compress_force = false;
@@ -662,11 +666,11 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
662666
*/
663667
btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS);
664668
}
665-
if ((btrfs_test_opt(info, COMPRESS) &&
666-
(info->compress_type != saved_compress_type ||
667-
compress_force != saved_compress_force)) ||
668-
(!btrfs_test_opt(info, COMPRESS) &&
669-
no_compress == 1)) {
669+
if (no_compress == 1) {
670+
btrfs_info(info, "use no compression");
671+
} else if ((info->compress_type != saved_compress_type) ||
672+
(compress_force != saved_compress_force) ||
673+
(info->compress_level != saved_compress_level)) {
670674
btrfs_info(info, "%s %s compression, level %d",
671675
(compress_force) ? "force" : "use",
672676
compress_type, info->compress_level);

0 commit comments

Comments
 (0)