diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2021-03-18 13:19:45 +0100 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2021-03-18 18:56:49 +0100 |
commit | 7a9efc5fae713a09cc1d1238a19a1cac555fb364 (patch) | |
tree | 2a7338f16e8e140b7aa24e6ac611a02c6a62313d /tools/lvresize.c | |
parent | b35ef9d67cabd23f65e2ee2113af46bea095138c (diff) | |
download | lvm2-7a9efc5fae713a09cc1d1238a19a1cac555fb364.tar.gz |
lvresize: allow mixing striped with errors or zero
Enabled extension/mixing of stripes/linears, error and zero
segtype LVs with stripes/linear, error and zero segtypes.
It is not very useful in practice, as the user cannot store any real
data on error or zero segtypes, but it may get some uses in
some scenarios where i.e. some portion of the device should not be
readable. Mixing of types happens on 'extent_size' level:
lvcreate -L1 -n lv vg
lvextend --type error -L+1 vg/lv
lvextend --type zero -L+1 vg/lv
lvextend --type linear -L+1 vg/lv
lvextend --type striped -L+1 vg/lv
lvs -o+segtype,seg_size vg
Note: when the type is not specified, the last segment type is
automatically selected.
It's also a small 'can of worms' since we can't tell LVs if
the LV is linear/error/zero or their mixtures. So the meaning behind
them may need some updates.
We already have this types of LV created i.e by:
vgreduce --removemissing --force
where missing LV segments have been replaced by either
error or zero segtype (lvm.conf).
TODO: it might be worth adding a message while such device is activated.
Diffstat (limited to 'tools/lvresize.c')
-rw-r--r-- | tools/lvresize.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/tools/lvresize.c b/tools/lvresize.c index a3c17a744..f39f03a40 100644 --- a/tools/lvresize.c +++ b/tools/lvresize.c @@ -20,9 +20,17 @@ static int _lvresize_params(struct cmd_context *cmd, int argc, char **argv, { const char *cmd_name = command_name(cmd); const char *type_str = arg_str_value(cmd, type_ARG, NULL); + int only_linear = 0; - if (type_str && !(lp->segtype = get_segtype_from_string(cmd, type_str))) - return_0; + if (type_str) { + if (!strcmp(type_str, "linear")) { + type_str = "striped"; + only_linear = 1; /* User requested linear only target */ + } + + if (!(lp->segtype = get_segtype_from_string(cmd, type_str))) + return_0; + } if (!strcmp(cmd_name, "lvreduce")) lp->resize = LV_REDUCE; @@ -137,6 +145,11 @@ static int _lvresize_params(struct cmd_context *cmd, int argc, char **argv, return 0; } + if (only_linear && lp->stripes > 1) { + log_error("Cannot use stripes with linear type."); + return 0; + } + if ((lp->stripe_size = arg_uint64_value(cmd, stripesize_ARG, 0)) && (arg_sign_value(cmd, stripesize_ARG, SIGN_NONE) == SIGN_MINUS)) { log_error("Stripesize may not be negative."); |