Skip to content

Commit 7c1ddfc

Browse files
kdavegregkh
authored andcommitted
btrfs: fix messages after changing compression level by remount
commit 27942c9 upstream. 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: stable@vger.kernel.org # 4.19+ Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 35b4a28 commit 7c1ddfc

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

fs/btrfs/super.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
432432
char *compress_type;
433433
bool compress_force = false;
434434
enum btrfs_compression_type saved_compress_type;
435+
int saved_compress_level;
435436
bool saved_compress_force;
436437
int no_compress = 0;
437438

@@ -514,6 +515,7 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
514515
info->compress_type : BTRFS_COMPRESS_NONE;
515516
saved_compress_force =
516517
btrfs_test_opt(info, FORCE_COMPRESS);
518+
saved_compress_level = info->compress_level;
517519
if (token == Opt_compress ||
518520
token == Opt_compress_force ||
519521
strncmp(args[0].from, "zlib", 4) == 0) {
@@ -552,6 +554,8 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
552554
no_compress = 0;
553555
} else if (strncmp(args[0].from, "no", 2) == 0) {
554556
compress_type = "no";
557+
info->compress_level = 0;
558+
info->compress_type = 0;
555559
btrfs_clear_opt(info->mount_opt, COMPRESS);
556560
btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS);
557561
compress_force = false;
@@ -572,11 +576,11 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
572576
*/
573577
btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS);
574578
}
575-
if ((btrfs_test_opt(info, COMPRESS) &&
576-
(info->compress_type != saved_compress_type ||
577-
compress_force != saved_compress_force)) ||
578-
(!btrfs_test_opt(info, COMPRESS) &&
579-
no_compress == 1)) {
579+
if (no_compress == 1) {
580+
btrfs_info(info, "use no compression");
581+
} else if ((info->compress_type != saved_compress_type) ||
582+
(compress_force != saved_compress_force) ||
583+
(info->compress_level != saved_compress_level)) {
580584
btrfs_info(info, "%s %s compression, level %d",
581585
(compress_force) ? "force" : "use",
582586
compress_type, info->compress_level);

0 commit comments

Comments
 (0)