Add force option to zero-metadata

Force option is used to enforce metadata erasure despite
dirty data, metadata mistmatch and/or dirty shutdown.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
Adam Rutkowski
2021-01-21 15:30:26 -06:00
parent 68b68db9c0
commit 4c98949cac
3 changed files with 43 additions and 5 deletions

View File

@@ -1832,12 +1832,15 @@ static int handle_help();
struct {
const char *device;
bool force;
} static zero_params = {
.device = ""
.device = "",
.force = false
};
static cli_option zero_options[] = {
{'d', "device", "Path to device on which metadata would be cleared", 1, "DEVICE", CLI_OPTION_REQUIRED},
{'f', "force", "Ignore potential dirty data on cache device"},
{0}
};
@@ -1848,7 +1851,8 @@ int zero_handle_option(char *opt, const char **arg)
if(validate_device_name(arg[0]) == FAILURE)
return FAILURE;
zero_params.device = arg[0];
} else if (!strcmp(opt, "force")){
zero_params.force = 1;
} else {
return FAILURE;
}
@@ -1872,7 +1876,7 @@ int handle_zero()
return FAILURE;
}
return zero_md(zero_params.device);
return zero_md(zero_params.device, zero_params.force);
}
static cli_command cas_commands[] = {