btrfs: introduce mount option rescue=all
authorJosef Bacik <josef@toxicpanda.com>
Fri, 16 Oct 2020 15:29:20 +0000 (11:29 -0400)
committerDavid Sterba <dsterba@suse.com>
Tue, 8 Dec 2020 14:53:42 +0000 (15:53 +0100)
Now that we have the building blocks for some better recovery options
with corrupted file systems, add a rescue=all option to enable all of
the relevant rescue options.  This will allow distros to simply default
to rescue=all for the "oh dear lord the world's on fire" recovery
without needing to know all the different options that we have and may
add in the future.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/super.c
fs/btrfs/sysfs.c

index 6bbd4f04b28df5f9c65e32e7a9de98b23abc8ee8..1ffa50bae1dd75956085de028d966649c3d25064 100644 (file)
@@ -362,6 +362,7 @@ enum {
        Opt_nologreplay,
        Opt_ignorebadroots,
        Opt_ignoredatacsums,
+       Opt_rescue_all,
 
        /* Deprecated options */
        Opt_recovery,
@@ -461,6 +462,7 @@ static const match_table_t rescue_tokens = {
        {Opt_ignorebadroots, "ibadroots"},
        {Opt_ignoredatacsums, "ignoredatacsums"},
        {Opt_ignoredatacsums, "idatacsums"},
+       {Opt_rescue_all, "all"},
        {Opt_err, NULL},
 };
 
@@ -512,6 +514,15 @@ static int parse_rescue_options(struct btrfs_fs_info *info, const char *options)
                        btrfs_set_and_info(info, IGNOREDATACSUMS,
                                           "ignoring data csums");
                        break;
+               case Opt_rescue_all:
+                       btrfs_info(info, "enabling all of the rescue options");
+                       btrfs_set_and_info(info, IGNOREDATACSUMS,
+                                          "ignoring data csums");
+                       btrfs_set_and_info(info, IGNOREBADROOTS,
+                                          "ignoring bad roots");
+                       btrfs_set_and_info(info, NOLOGREPLAY,
+                                          "disabling log replay at mount time");
+                       break;
                case Opt_err:
                        btrfs_info(info, "unrecognized rescue option '%s'", p);
                        ret = -EINVAL;
index 86f70a60447b2a907ef4c2976b6f3e3e063ec7db..fcd6c7a9bbd19d7c9685f2a193815a369b7cd3d5 100644 (file)
@@ -334,6 +334,7 @@ static const char *rescue_opts[] = {
        "nologreplay",
        "ignorebadroots",
        "ignoredatacsums",
+       "all",
 };
 
 static ssize_t supported_rescue_options_show(struct kobject *kobj,