David Teigland [Tue, 21 Feb 2017 20:32:54 +0000 (14:32 -0600)]
man/help: use separate common option lists
There are two kinds of common options:
1. options common to all variants of a given command name
2. options common to all lvm commands
Previously, both kinds of common options were listed together
under "Common options". Now the first are printed under
"Common options for command" (when needed), and the second
are printed under "Common options for lvm" (always).
David Teigland [Tue, 21 Feb 2017 17:40:51 +0000 (11:40 -0600)]
commands: adjust default help output
Remove the "usage notes" which should just
live in the man pages.
When there are 3 or more variants of a command,
print all the options produces a lot of output,
so require --longhelp to print all the options
in these cases.
David Teigland [Mon, 20 Feb 2017 17:23:46 +0000 (11:23 -0600)]
lvresize/lvextend: accept type option
The --type option has previously been accepted for
lvresize/lvextend. Using it did not affect the operation
of the command. The value was simply verified as matching
the current seg type of the LV.
David Teigland [Fri, 17 Feb 2017 17:45:13 +0000 (11:45 -0600)]
lvconvert: include swap behavior in generic pool syntax
For this syntax:
lvconvert --thinpool LV1 --poolmetadata LV2
lvconvert --cachepool LV1 --poolmetadata LV2
Restore the metadata swapping behavior in addition to
the pool creation behavior. When LV1 is already a pool,
the metadata LV will be swapped with LV2.
When LV1 is not a pool, it will be converted to a
pool using the specified LV for metadata.
This syntax is no longer advertised because of the
ambiguous behavior. The primary syntaxes for pool
creation and metadata swapping will be the advertised
methods.
Zdenek Kabelac [Fri, 17 Feb 2017 09:00:43 +0000 (10:00 +0100)]
commands: optimize binary search
Since there is a lot of options and lot of searches,
use binary search to keep strcmp at minimum.
The interesting part is - alphabetically sorted array contains
duplicates and some of them are not the 'right anwer', so
after we find matching string but not matching long_ARG,
we may need to check if the surrouding strings are the right matching
one.
The single loops is used also for strictly define --foo_long
(i.e. --stripes) and just differs at final part.
TODO1: replace strstr call with some flag (just like short_opt).
TODO2: drop '--' from being stored and tests by strcmp.
David Teigland [Thu, 16 Feb 2017 21:26:42 +0000 (15:26 -0600)]
commands: track errors in command def parsing
When parsing command defs, track and report all
errors that are found. Add an error return case
from define_commands so the standard error exit
path is used.
David Teigland [Wed, 15 Feb 2017 18:40:35 +0000 (12:40 -0600)]
lvconvert: handle old arg quirk when combining snapshot
The old ad hoc arg parsing when combining a split snapshot
allowed the first lv to have a vgname, but not the second.
Since lvconvert now uses the standard arg parsing in
process_each_lv(), the old one-off behavior requires a
work around.
These alternate forms for swapping metadata cannot be
distinguished from the command for creating a pool.
If we were to add these alternate forms for swapping
metadata, we would need to overload the pool creation
command defs, making those definitions ambiguous.
David Teigland [Fri, 13 Jan 2017 21:08:51 +0000 (15:08 -0600)]
command struct: remove command name refs
Change run time access to the command_name struct
cmd->cname instead of indirectly through
cmd->command->cname. This removes the two run time
fields from struct command.
David Teigland [Mon, 19 Dec 2016 21:53:21 +0000 (15:53 -0600)]
lvconvert: use command defs for raid/mirror types
All lvconvert functionality has been moved out of the
previous monolithic lvconvert code, except conversions
related to raid/mirror/striped/linear. This switches
that remaining code to be based on command defs, and
standard process_each_lv arg processing. This final
switch results in quite a bit of dead code that is
also removed.
David Teigland [Mon, 19 Dec 2016 21:38:03 +0000 (15:38 -0600)]
lvconvert: add startpoll command using command def
This is a new explicit version of 'lvconvert LV'
which has been an obscure way of triggering polling
to be restarted on an LV that was previously converted.
David Teigland [Fri, 18 Nov 2016 19:16:04 +0000 (13:16 -0600)]
lvconvert: snapshot: use command definitions
Lift all the snapshot utilities (merge, split, combine)
out of the monolithic lvconvert implementation, using
the command definitions. The old code associated with
these commands is now unused and will be removed separately.