Skip to content

Commit e3a4167

Browse files
committed
btrfs: add error messages to all unrecognized mount options
Almost none of the errors stemming from a valid mount option but wrong value prints a descriptive message which would help to identify why mount failed. Like in the linked report: $ uname -r v4.19 $ mount -o compress=zstd /dev/sdb /mnt mount: /mnt: wrong fs type, bad option, bad superblock on /dev/sdb, missing codepage or helper program, or other error. $ dmesg ... BTRFS error (device sdb): open_ctree failed Errors caused by memory allocation failures are left out as it's not a user error so reporting that would be confusing. Link: https://lore.kernel.org/linux-btrfs/[email protected]/ CC: [email protected] # 4.9+ Reviewed-by: Qu Wenruo <[email protected]> Reviewed-by: Nikolay Borisov <[email protected]> Reviewed-by: Anand Jain <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 0591f04 commit e3a4167

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

fs/btrfs/super.c

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,8 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
763763
compress_force = false;
764764
no_compress++;
765765
} else {
766+
btrfs_err(info, "unrecognized compression value %s",
767+
args[0].from);
766768
ret = -EINVAL;
767769
goto out;
768770
}
@@ -821,8 +823,11 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
821823
case Opt_thread_pool:
822824
ret = match_int(&args[0], &intarg);
823825
if (ret) {
826+
btrfs_err(info, "unrecognized thread_pool value %s",
827+
args[0].from);
824828
goto out;
825829
} else if (intarg == 0) {
830+
btrfs_err(info, "invalid value 0 for thread_pool");
826831
ret = -EINVAL;
827832
goto out;
828833
}
@@ -883,8 +888,11 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
883888
break;
884889
case Opt_ratio:
885890
ret = match_int(&args[0], &intarg);
886-
if (ret)
891+
if (ret) {
892+
btrfs_err(info, "unrecognized metadata_ratio value %s",
893+
args[0].from);
887894
goto out;
895+
}
888896
info->metadata_ratio = intarg;
889897
btrfs_info(info, "metadata ratio %u",
890898
info->metadata_ratio);
@@ -901,6 +909,8 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
901909
btrfs_set_and_info(info, DISCARD_ASYNC,
902910
"turning on async discard");
903911
} else {
912+
btrfs_err(info, "unrecognized discard mode value %s",
913+
args[0].from);
904914
ret = -EINVAL;
905915
goto out;
906916
}
@@ -933,6 +943,8 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
933943
btrfs_set_and_info(info, FREE_SPACE_TREE,
934944
"enabling free space tree");
935945
} else {
946+
btrfs_err(info, "unrecognized space_cache value %s",
947+
args[0].from);
936948
ret = -EINVAL;
937949
goto out;
938950
}
@@ -1014,8 +1026,12 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
10141026
break;
10151027
case Opt_check_integrity_print_mask:
10161028
ret = match_int(&args[0], &intarg);
1017-
if (ret)
1029+
if (ret) {
1030+
btrfs_err(info,
1031+
"unrecognized check_integrity_print_mask value %s",
1032+
args[0].from);
10181033
goto out;
1034+
}
10191035
info->check_integrity_print_mask = intarg;
10201036
btrfs_info(info, "check_integrity_print_mask 0x%x",
10211037
info->check_integrity_print_mask);
@@ -1030,22 +1046,28 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
10301046
goto out;
10311047
#endif
10321048
case Opt_fatal_errors:
1033-
if (strcmp(args[0].from, "panic") == 0)
1049+
if (strcmp(args[0].from, "panic") == 0) {
10341050
btrfs_set_opt(info->mount_opt,
10351051
PANIC_ON_FATAL_ERROR);
1036-
else if (strcmp(args[0].from, "bug") == 0)
1052+
} else if (strcmp(args[0].from, "bug") == 0) {
10371053
btrfs_clear_opt(info->mount_opt,
10381054
PANIC_ON_FATAL_ERROR);
1039-
else {
1055+
} else {
1056+
btrfs_err(info, "unrecognized fatal_errors value %s",
1057+
args[0].from);
10401058
ret = -EINVAL;
10411059
goto out;
10421060
}
10431061
break;
10441062
case Opt_commit_interval:
10451063
intarg = 0;
10461064
ret = match_int(&args[0], &intarg);
1047-
if (ret)
1065+
if (ret) {
1066+
btrfs_err(info, "unrecognized commit_interval value %s",
1067+
args[0].from);
1068+
ret = -EINVAL;
10481069
goto out;
1070+
}
10491071
if (intarg == 0) {
10501072
btrfs_info(info,
10511073
"using default commit interval %us",
@@ -1059,8 +1081,11 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
10591081
break;
10601082
case Opt_rescue:
10611083
ret = parse_rescue_options(info, args[0].from);
1062-
if (ret < 0)
1084+
if (ret < 0) {
1085+
btrfs_err(info, "unrecognized rescue value %s",
1086+
args[0].from);
10631087
goto out;
1088+
}
10641089
break;
10651090
#ifdef CONFIG_BTRFS_DEBUG
10661091
case Opt_fragment_all:

0 commit comments

Comments
 (0)