1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-27 01:55:10 +03:00
Commit Graph

13875 Commits

Author SHA1 Message Date
David Teigland
23a1ced439 help: accept positional args
lvm help <commandname> ...
2017-02-13 08:20:10 -06:00
David Teigland
3642deb4f3 fix lvmcmdline warning
declaration of ‘usage’ shadows a globa
2017-02-13 08:20:10 -06:00
David Teigland
4d2c3502e7 man lvm: remove options
all options are now included in commands
2017-02-13 08:20:10 -06:00
David Teigland
5c779b3231 args: add man page descriptions 2017-02-13 08:20:10 -06:00
David Teigland
db26a82f2f args: use uint32 arg for maxphysicalvolumes 2017-02-13 08:20:10 -06:00
David Teigland
041c2fef88 lvconvert: remove unused code 2017-02-13 08:20:10 -06:00
David Teigland
46b2599d5c 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.
2017-02-13 08:20:10 -06:00
David Teigland
a801b92b2c tests: use swapmetadata
and some other pool/cache/thin related changes
2017-02-13 08:20:10 -06:00
David Teigland
86d8ab493b lvconvert: use command defs for mergemirrors
and route the generic --merge to one of the
specific merge functions
2017-02-13 08:20:10 -06:00
David Teigland
95e38607ec toollib: find VG name in option values when needed 2017-02-13 08:20:10 -06:00
David Teigland
0e3e611a13 lvconvert: use command defs for thin/cache/pool creation
Everything related to thin and cache.
2017-02-13 08:20:10 -06:00
David Teigland
d71aaca07b 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.
2017-02-13 08:20:10 -06:00
David Teigland
fa2a728a39 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.
2017-02-13 08:20:10 -06:00
David Teigland
254bffb95d lvconvert: remove unused calls for repair and replace
repair and replace are no longer called from the
monolithic lvconvert code, so remove the unused code.
2017-02-13 08:20:10 -06:00
David Teigland
35b9d4d6e9 lvconvert: repair and replace: use command definitions
This lifts the lvconvert --repair and --replace commands
out of the monolithic lvconvert implementation.  The
previous calls into repair/replace can no longer be
reached and will be removed in a separate commit.
2017-02-13 08:20:10 -06:00
David Teigland
52c60b7e7b lvchange: make use of command definitions
Reorganize the lvchange code to take advantage of
the command definition, and remove the validation
that is done by the command definintion rules.
2017-02-13 08:20:10 -06:00
David Teigland
9c6c55c314 process_each_lv: add check_single_lv function
The new check_single_lv() function is called prior to the
existing process_single_lv().  If the check function returns 0,
the LV will not be processed.

The check_single_lv function is meant to be a standard method
to validate the combination of specific command + specific LV,
and decide if the combination is allowed.  The check_single
function can be used by anything that calls process_each_lv.

As commands are migrated to take advantage of command
definitions, each command definition gets its own entry
point which calls process_each for itself, passing a
pair of check_single/process_single functions which can
be specific to the narrowly defined command def.
2017-02-13 08:20:10 -06:00
David Teigland
1e2420bca8 commands: new method for defining commands
. Define a prototype for every lvm command.
. Match every user command with one definition.
. Generate help text and man pages from them.

The new file command-lines.in defines a prototype for every
unique lvm command.  A unique lvm command is a unique
combination of: command name + required option args +
required positional args.  Each of these prototypes also
includes the optional option args and optional positional
args that the command will accept, a description, and a
unique string ID for the definition.  Any valid command
will match one of the prototypes.

Here's an example of the lvresize command definitions from
command-lines.in, there are three unique lvresize commands:

lvresize --size SizeMB LV
OO: --alloc Alloc, --autobackup Bool, --force,
--nofsck, --nosync, --noudevsync, --reportformat String, --resizefs,
--stripes Number, --stripesize SizeKB, --poolmetadatasize SizeMB
OP: PV ...
ID: lvresize_by_size
DESC: Resize an LV by a specified size.

lvresize LV PV ...
OO: --alloc Alloc, --autobackup Bool, --force,
--nofsck, --nosync, --noudevsync,
--reportformat String, --resizefs, --stripes Number, --stripesize SizeKB
ID: lvresize_by_pv
DESC: Resize an LV by specified PV extents.
FLAGS: SECONDARY_SYNTAX

lvresize --poolmetadatasize SizeMB LV_thinpool
OO: --alloc Alloc, --autobackup Bool, --force,
--nofsck, --nosync, --noudevsync,
--reportformat String, --stripes Number, --stripesize SizeKB
OP: PV ...
ID: lvresize_pool_metadata_by_size
DESC: Resize a pool metadata SubLV by a specified size.

The three commands have separate definitions because they have
different required parameters.  Required parameters are specified
on the first line of the definition.  Optional options are
listed after OO, and optional positional args are listed after OP.

This data is used to generate corresponding command definition
structures for lvm in command-lines.h.  usage/help output is also
auto generated, so it is always in sync with the definitions.

Every user-entered command is compared against the set of
command structures, and matched with one.  An error is
reported if an entered command does not have the required
parameters for any definition.  The closest match is printed
as a suggestion, and running lvresize --help will display
the usage for each possible lvresize command.

The prototype syntax used for help/man output includes
required --option and positional args on the first line,
and optional --option and positional args enclosed in [ ]
on subsequent lines.

  command_name <required_opt_args> <required_pos_args>
          [ <optional_opt_args> ]
          [ <optional_pos_args> ]

Command definitions that are not to be advertised/suggested
have the flag SECONDARY_SYNTAX.  These commands will not be
printed in the normal help output.

Man page prototypes are also generated from the same original
command definitions, and are always in sync with the code
and help text.

Very early in command execution, a matching command definition
is found.  lvm then knows the operation being done, and that
the provided args conform to the definition.  This will allow
lots of ad hoc checking/validation to be removed throughout
the code.

Each command definition can also be routed to a specific
function to implement it.  The function is associated with
an enum value for the command definition (generated from
the ID string.)  These per-command-definition implementation
functions have not yet been created, so all commands
currently fall back to the existing per-command-name
implementation functions.

Using per-command-definition functions will allow lots of
code to be removed which tries to figure out what the
command is meant to do.  This is currently based on ad hoc
and complicated option analysis.  When using the new
functions, what the command is doing is already known
from the associated command definition.
2017-02-13 08:20:10 -06:00
David Teigland
19267fa6aa lvmlockd: test mode doesn't work
The --test option is not yet compatible with shared VGs
because changes are made in lvmlockd that cannot be
reversed or faked.
2017-02-13 08:20:10 -06:00
Zdenek Kabelac
2923d9e47d tests: update 2017-02-13 10:06:19 +01:00
Zdenek Kabelac
c3b1f1a07a tests: fix dev path
Use proper device path for test devices.
Use mkfs.ext4 and drop  'echo y|' to it.
Use smaller device size to consume less memory and CPU time.
2017-02-13 10:06:19 +01:00
Zdenek Kabelac
a3579aafc5 cleanup: use matching signed number comparation 2017-02-13 10:06:19 +01:00
Zdenek Kabelac
7cbee8f31a cleanup: use matching const type 2017-02-13 10:06:18 +01:00
Zdenek Kabelac
b6301aa977 cleanup: use fall through
gcc gets 'selective' on having commented fall through case.
2017-02-13 10:06:18 +01:00
Zdenek Kabelac
a39c828c01 cleanup: fix warning about shadowed declaration
Avoid shadowing lv_size as lv_size() is already defined function in lv.h
2017-02-13 10:06:18 +01:00
Zdenek Kabelac
717d0c6b94 cleanup: use proper printf specifier 2017-02-13 10:06:18 +01:00
Zdenek Kabelac
b185a3e333 config: update doc 2017-02-13 10:06:07 +01:00
Zdenek Kabelac
aa0c735e2c dmeventd: limit thin_command usage
Require usable command string to begining with '/'
So 'thin_command = "/some/path/command"' is the only supported variant
to internal 'lvm' command.
2017-02-13 09:43:53 +01:00
Zdenek Kabelac
416f951283 coverity: fix double free
Do not try to free hist_arg twice.
2017-02-12 17:28:44 +01:00
Zdenek Kabelac
a7d2ee4bc2 coverity: fix mem leak on error path in dm stats
Free allocated resouces on error path.
2017-02-12 17:28:13 +01:00
Zdenek Kabelac
0844b20f98 coverity: remove unneeded header files 2017-02-11 21:17:27 +01:00
Zdenek Kabelac
375e38709c cleanup: drop double const specifier
Remove duplicated 'const' specifier.
Reindent.
2017-02-11 20:30:16 +01:00
Zdenek Kabelac
2a9eda1229 mem: add extra mem pages for pthread stack
Some archs can use even 64K pages and then lvm2 runs into trouble if
the stack is 'too small' to fit extra page capturing stack overwrite.

So when lvm2 limits stack - add extra mem page - be it 4K or 64K.

Relates to ppc64le bug: https://bugzilla.redhat.com/1387279
2017-02-11 18:23:15 +01:00
Heinz Mauelshagen
8296b99a89 lvconvert: remove test code
Remove allocate_pvs from raid_manip.c:_region_size_change_request() API
and lv_extend() using it added for temporary test purpose.

Related: rhbz1366296
2017-02-10 23:44:27 +01:00
Heinz Mauelshagen
28ea66d46d lvconvert: add region size checks
Add:
- region size checks to raid_manip.c types array and supporting functions
- tests to lvconvert-raid-takeover.sh to check bogus
  "lvconvert --type  --regionsize N " requests

Related: rhbz1366296
2017-02-10 23:37:08 +01:00
Heinz Mauelshagen
caa2094e33 test: lvresize-raid.sh missing conditional
Test missed to check for raid0 present in the kernel.

Related: rhbz1366296
2017-02-10 21:22:38 +01:00
Zdenek Kabelac
c908a8b131 libdm: avoid resume if preloaded device is smaller
When we preload device with smaller size, we avoid its resume,
so later suspend/resume of full device tree my process all
existing in flight bios.

Also update comment and avoid using confusing opposite meaning.
2017-02-10 20:29:11 +01:00
Ondrej Kozina
035c614c19 dmsetup: do not suppress kernel key descriptions in tables
Kernel 4.10 (dm-crypt v1.15.0) and later supports loading device
tables with crypt segment having key in kernel keyring retention
service.

dmsetup hid key section of tables output. With this patch dmsetup
no longer hides key section if it detects kernel key description
instead of hex byte representation of key itself.
2017-02-10 19:18:49 +01:00
Heinz Mauelshagen
baba3f8e2a lvconvert: add conversion from/to raid10
Add:
- conversion support from striped/raid0/raid0_meta to/from raid10;
  raid10 goes by the near format (same as used in creation of
  raid10 LVs), which groups data copies together with their original
  blocks (e.g. 3-way striped, 2 data copies resulting in 112233 in the
  first stripe followed by 445566 in the second etc.) and is limited
  to even numbers of legs for now
- related tests to lvconvert-raid-takeover.sh
- typo

Related: rhbz1366296
2017-02-10 19:13:02 +01:00
Bryn M. Reeves
68ec6940e6 man: mention dmstats in lvmsar and lvmsadc man pages 2017-02-10 17:09:17 +00:00
Heinz Mauelshagen
55eaabd118 lvreduce/lvresize: add ability to reduce the size of a RaidLV
- support shrinking of raid0/1/4/5/6/10 LVs
- enhance lvresize-raid.sh tests: add raid0* and raid10
- fix have_raid4 in aux.sh to allow lv_resize-raid.sh
  and other scripts to test raid4

Resolves: rhbz1394048
2017-02-09 22:42:03 +01:00
Heinz Mauelshagen
79f31008fa lvconvert: add support to change RAID region size (fixup)
Commit cfb6ef654d introduced
support to change RAID region size.

Fix:
- don't change region_size until after prompting the user
- use log_print_unless_silent() instead of log_warn()
- avoid superfluous sigint() calls which are already
  covered in yes_no_prompt()
- typo

Related: rhbz1392947
2017-02-07 19:05:01 +01:00
Heinz Mauelshagen
69fe8729f3 lvconvert: avoid setting segment flag
Fix:
- don't set SEG_RAID in _convert_mirror_to_raid1() errounously

Related: rhbz1366296
2017-02-07 17:48:17 +01:00
Heinz Mauelshagen
46a772fbc4 lvconvert: add support to change RAID region size (fixup)
Commit cfb6ef654d introduced
support to change RAID region size.

Add:
- missing conditions to support any types to function with
  it in lv_raid_convert();  temporary workaround used until
  cli validation patches get merged
- tests requesting "-R " to lvconvert-raid-takeover.sh
  involving a cleanup of the script

Related: rhbz1392947
2017-02-07 16:52:04 +01:00
Heinz Mauelshagen
91c4bd14d0 lvconvert: add segtype raid5_n and conversions to/from it (cleanup)
Cleanups as of Jons review:
- enhance comment about mandatory raid4 <-> raid5_n activation w/o metadata SubLVs
- remove bogus segment flag setting
- fix to sync related comments on conversions to raid0/striped and amongst raid4/5
- add missing error message for non-synced conversion to raid0/striped

Related: rhbz1366296
2017-02-07 12:25:26 +01:00
Heinz Mauelshagen
cfb6ef654d lvconvert: add support to change RAID region size
Add:
- support to change region size of existing RaidLVs
  (all RAID LV types but raid0/raid0_meta)
- lvconvert-raid-regionsize.sh with test variations
  for different RAID types and region sizes

Resolves: rhbz1392947
2017-02-07 01:01:19 +01:00
Zdenek Kabelac
51d03acb1c tests: drop zeroing
Well waiting for zeroing may take enough time to finish 'raid' sync.
So make the test running faster without zeroing and better avoid race
to have chance to happen (i.e. lvcreate is finished after array
gets already in sync).
2017-02-06 13:15:39 +01:00
Zdenek Kabelac
48abbdf452 tests: drop /tmp polution
Drop forgotten extra metadata debug.
2017-02-06 11:43:07 +01:00
Zdenek Kabelac
811d137d3f cleanup: hide gcc warning
Gcc is not clever enough to see these vars are actually initialize in
given code path so let's just make sure it has a value.
2017-02-06 11:43:07 +01:00
Zdenek Kabelac
9fe8c2da36 debug: add space before uuid
With commit 8853462528 we added
uuid right after device name. Add space between them.
(Also fix some indenting)
2017-02-05 17:55:37 +01:00