summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* commands: new method for defining commandsdev-dct-cmd-defs41David Teigland2016-11-1021-1829/+7041
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | . 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. Example of the corresponding generated structure in command-lines.h for the first lvresize prototype (these structures are never edited directly): commands[83].name = "lvresize"; commands[83].command_line_id = "lvresize_by_size"; commands[83].command_line_enum = lvresize_by_size_CMD; commands[83].fn = lvresize; commands[83].ro_count = 1; commands[83].rp_count = 1; commands[83].oo_count = 22; commands[83].op_count = 1; commands[83].cmd_flags = 0; commands[83].desc = "DESC: Resize an LV by a specified size."; commands[83].usage = "lvresize --size Number[m|unit] LV" " [ --resizefs, --poolmetadatasize Number[m|unit], COMMON_OPTIONS ]" " [ PV ... ]"; commands[83].usage_common = " [ --alloc contiguous|cling|cling_by_tags|normal|anywhere|inherit, --nosync, --reportformat String, --autobackup y|n, --stripes Number, --stripesize Number[k|unit], --nofsck, --commandprofile String, --config String, --debug, --driverloaded y|n, --help, --profile String, --quiet, --verbose, --version, --yes, --test, --force, --noudevsync ]"; commands[83].required_opt_args[0].opt = size_ARG; commands[83].required_opt_args[0].def.val_bits = val_enum_to_bit(sizemb_VAL); commands[83].required_pos_args[0].pos = 1; commands[83].required_pos_args[0].def.val_bits = val_enum_to_bit(lv_VAL); commands[83].optional_opt_args[0].opt = commandprofile_ARG; commands[83].optional_opt_args[0].def.val_bits = val_enum_to_bit(string_VAL); commands[83].optional_opt_args[1].opt = config_ARG; commands[83].optional_opt_args[1].def.val_bits = val_enum_to_bit(string_VAL); commands[83].optional_opt_args[2].opt = debug_ARG; commands[83].optional_opt_args[3].opt = driverloaded_ARG; commands[83].optional_opt_args[3].def.val_bits = val_enum_to_bit(bool_VAL); commands[83].optional_opt_args[4].opt = help_ARG; commands[83].optional_opt_args[5].opt = profile_ARG; commands[83].optional_opt_args[5].def.val_bits = val_enum_to_bit(string_VAL); commands[83].optional_opt_args[6].opt = quiet_ARG; commands[83].optional_opt_args[7].opt = verbose_ARG; commands[83].optional_opt_args[8].opt = version_ARG; commands[83].optional_opt_args[9].opt = yes_ARG; commands[83].optional_opt_args[10].opt = test_ARG; commands[83].optional_opt_args[11].opt = alloc_ARG; commands[83].optional_opt_args[11].def.val_bits = val_enum_to_bit(alloc_VAL); commands[83].optional_opt_args[12].opt = autobackup_ARG; commands[83].optional_opt_args[12].def.val_bits = val_enum_to_bit(bool_VAL); commands[83].optional_opt_args[13].opt = force_ARG; commands[83].optional_opt_args[14].opt = nofsck_ARG; commands[83].optional_opt_args[15].opt = nosync_ARG; commands[83].optional_opt_args[16].opt = noudevsync_ARG; commands[83].optional_opt_args[17].opt = reportformat_ARG; commands[83].optional_opt_args[17].def.val_bits = val_enum_to_bit(string_VAL); commands[83].optional_opt_args[18].opt = resizefs_ARG; commands[83].optional_opt_args[19].opt = stripes_ARG; commands[83].optional_opt_args[19].def.val_bits = val_enum_to_bit(number_VAL); commands[83].optional_opt_args[20].opt = stripesize_ARG; commands[83].optional_opt_args[20].def.val_bits = val_enum_to_bit(sizekb_VAL); commands[83].optional_opt_args[21].opt = poolmetadatasize_ARG; commands[83].optional_opt_args[21].def.val_bits = val_enum_to_bit(sizemb_VAL); commands[83].optional_pos_args[0].pos = 2; commands[83].optional_pos_args[0].def.val_bits = val_enum_to_bit(pv_VAL); commands[83].optional_pos_args[0].def.flags = ARG_DEF_FLAG_MAY_REPEAT; 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> ] $ lvresize --help lvresize - Resize a logical volume Resize an LV by a specified size. lvresize --size Number[m|unit] LV [ --resizefs, --poolmetadatasize Number[m|unit], COMMON_OPTIONS ] [ PV ... ] Resize a pool metadata SubLV by a specified size. lvresize --poolmetadatasize Number[m|unit] LV_thinpool [ COMMON_OPTIONS ] [ PV ... ] Common options: [ --alloc contiguous|cling|cling_by_tags|normal|anywhere|inherit, --nosync, --reportformat String, --autobackup y|n, --stripes Number, --stripesize Number[k|unit], --nofsck, --commandprofile String, --config String, --debug, --driverloaded y|n, --help, --profile String, --quiet, --verbose, --version, --yes, --test, --force, --noudevsync ] (Use --help --help for usage notes.) $ lvresize --poolmetadatasize 4 Failed to find a matching command definition. Closest command usage is: lvresize --poolmetadatasize Number[m|unit] LV_thinpool 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. So, this first phase validates every user-entered command against the set of command prototypes, then calls the existing implementation. The second phase can associate an implementation function with each definition, and take further advantage of the known operation to avoid the complicated option analysis.
* spec: move dmeventd -R from post to posttrans script for device-mapper-event ↵Peter Rajnoha2016-10-121-3/+5
| | | | | | package See also https://bugzilla.redhat.com/show_bug.cgi?id=1382688.
* lvconvert: still use strcmp for nowZdenek Kabelac2016-10-121-6/+6
| | | | | | | | Keep for now function logic making its decision on string content. We need bigger patch converting all things to bit-checks later. This needs however bigger refactoring. So this commit reverts some changes from: c8b6c130158e1cc1a639afc21f5fd6306286fdb3
* lvconvert: fix RAID SubLV --splitmirror regressionHeinz Mauelshagen2016-10-121-24/+25
| | | | | | | | | | | | | Commit 088b3d036a73a7d947f6e9b12e8fad8a9f40d97f allowed repair on cache origin RAID LVs and restricted lvconvert actions on RAID SubLVs to change number of mirrors, repair, replace and type changes in order to avoid unsuitable coversions on them. This introduced a regression prohibiting --splitmirrors on any RAID SubLVs (e.g. of cache or thin LVs; lvconvert-{cache,thin}-raid.sh tests failing). Fix allows split mirrors again. Fix some indenting whilst on it.
* lvmdbustest.py: ws fixesTony Asleson2016-10-112-90/+101
|
* lvmdbustest.py: Add $PREFIX supportTony Asleson2016-10-111-19/+33
| | | | Use the env variable PREFIX for vg & lv names
* lvmdbustest.py: Use more compatible syntaxTony Asleson2016-10-111-2/+3
|
* lvmdbusd: Remove log ouput when ec=0 & stderr != 0 bytesTony Asleson2016-10-111-6/+0
| | | | | lvm likes to log to stderr virtually all the time, this isn't helpful.
* lvmdbusd: Disable lvm abort on too much log outputTony Asleson2016-10-112-4/+4
| | | | | | | | | The commit: https://git.fedorahosted.org/cgit/lvm2.git/commit/?id=34c55d98eefd88f85476c0f62f0649c706bde6f0 introduced an abort if lvm logs too much. In the case of utilizing lvm shell this is a pretty normal occurance, so we will disable when we use lvm shell.
* tests: notify dbus only for dbus testZdenek Kabelac2016-10-111-1/+5
|
* cleanup: indentZdenek Kabelac2016-10-111-6/+4
|
* cleanup: lvconvert drop unused variableZdenek Kabelac2016-10-111-4/+1
|
* cleanup: use already set valuesZdenek Kabelac2016-10-111-32/+27
| | | | | | When we have already decoded arg_is_set into a local var or already set segment type - already use these values instead of repeating calls and string checks.
* cleanup: reorder codeZdenek Kabelac2016-10-111-30/+33
| | | | | Move some arg test into a single place with sort of alphabetic order when possible to make reading easier.
* lvconvert: use _read_conversion_typeZdenek Kabelac2016-10-111-5/+8
| | | | | Code reodering and using same pattern for reading and validating arg (--type in this case).
* lvconvert: fix error valueZdenek Kabelac2016-10-112-8/+5
| | | | | | Seems some error path where not converted to 'new' ECMD return value. Fix them to always 'goto out'. Also drop unneeded 'ret = 0' when ret already is 0.
* lvmdbustest.py: Add profile and path for lvm binaryTony Asleson2016-10-101-0/+14
|
* lvmdbustest.py: Skip test_job_handling_timer on loopbackTony Asleson2016-10-101-0/+5
| | | | | | | | This test never passes on loop back, so we will skip unless the pv devices are real devices which contain `/dev/sd`. We always fail because we need lvm to run slow to get a timer to pop, and loopback are too fast.
* lvmdbustest.py: Denote failure if set_execution failsTony Asleson2016-10-101-0/+5
|
* lvmdbustest.py: Print to stderrTony Asleson2016-10-101-9/+13
| | | | | | It's easier to follow if we print to stderr, so that our print messages are in the lvm error log in the correct position to other printed messages.
* lvmdbustest.py: Ensure we exit non-zero on failTony Asleson2016-10-101-5/+24
| | | | | | | If you run multiple runs of unittest.main, unless you don't pass exit=true the test case always ends with a 0 exit code. Add ability to store the result of each invocation of the test and exit with a non-zero exit code if anyone of them fail.
* lvmdbusd: Ensure tmp dir gets cleaned upTony Asleson2016-10-101-14/+18
| | | | | Regardless of the outcome of starting up the lvm shell process, lets ensure we clean up the temp directory and pipe.
* lvmdbusd: Ensure lvm shell still existsTony Asleson2016-10-101-1/+12
|
* lvconvert: certain repair of cache raid volumes fails "Cannot convert ↵Heinz Mauelshagen2016-10-101-42/+71
| | | | | | | | | | | | | | internal LV" In case a RAID orig LV is being cached and fails, repair is impossible because "lvconvert --repair" gets rejected. Fix by allowing repair on cache orig RAID LVs and "lvconvert --replace/--mirrors/--type {raid*|mirror|striped|linear}" as well. Allow the same lvconvert actions on any cache pool and metadata RAID SubLVs. Resolves: rhbz1380532
* lvmdbusd: Add LvCommon.DataPercentTony Asleson2016-10-051-0/+1
|
* lvmdbusd: Add LvCommon.MovePvTony Asleson2016-10-052-4/+24
| | | | Needed for feature parity for lvm2app.
* lvmdbusd: Add properties to LvCommonTony Asleson2016-10-052-5/+21
| | | | | | | | | | | | The following LvCommon properties were added so that the API would have the same functionality as lvm2app has. LvCommon.MetaDataSizeBytes LvCommon.Attr LvCommon.MetaDataPercent LvCommon.CopyPercent LvCommon.SnapPercent LvCommon.SyncPercent
* toollib: clean up coverity issueDavid Teigland2016-10-041-3/+6
| | | | in processing duplicate pvs.
* Revert "cleanup: simplier assign of cmd vars"Alasdair G Kergon2016-10-031-2/+6
| | | | | | | This reverts commit cea441f4d1e19f170d9161203ef843c59f3fbf70. cmd->default_values is configurable and this code should not make any assumptions about values it holds.
* tests: proper wait usageZdenek Kabelac2016-10-031-1/+10
| | | | | | | | | | Fix missing wait so we have paired waiting. Also 'wait' for precise PID to get 'exit' code. Test for 'error' replacing only with newer snapshot targets. The old one will wait for resume. Note: 'wait -n' is not always available so can't be used..
* cleanup :drop unneeded header fileZdenek Kabelac2016-10-031-1/+0
| | | | Not needed (Coverity).
* cleanup: drop test for NULLZdenek Kabelac2016-10-031-1/+2
| | | | | Since lp->segtype has been already checked for not-being NULL, drop this test so Coverity is not later confused it 'can be a NULL'.
* cleanup: drop assign before useZdenek Kabelac2016-10-034-4/+4
| | | | | Drop unneeded assigns singe vars are set later in code before their first use (Coverity).
* cleanup: simplier assign of cmd varsZdenek Kabelac2016-10-031-6/+2
| | | | | Directly assign queried args as they provide matching values for a setting.
* dmeventd: pthread_sigmask in single functionZdenek Kabelac2016-10-032-15/+11
| | | | | | Integrate back _unblock_sigalrm() and check for error code of pthread_sigmask() function so we do not use uninitialized sigmask_t on error path (Coverity).
* libdm: check for mem when _canonicalize_field_idsZdenek Kabelac2016-10-032-1/+5
| | | | Add missing check for dm_pool_strdup() call (Coverity).
* raid: dmeventd plugin use 64bit arithmeticZdenek Kabelac2016-10-032-2/+3
| | | | | Coverity suggested to used 64bit unsigned ints instead of signed 32b int. Assuming there is no user of >31legs raid array.
* libdm: convert FIEMAP buffer allocation from stack to dm_zallocBryn M. Reeves2016-10-031-6/+21
|
* lvmlockd: fix segfault in error pathDavid Teigland2016-09-281-1/+2
| | | | The log_debug statement was ignoring the NULL vg error case.
* lvmdbusd: Use 'pv_missing' column instead of '[unknown]'Tony Asleson2016-09-283-5/+14
| | | | | Previously using '[unknown]' for PV device path comparison which is incorrect as it's not always true.
* lvmdbusd: Remove extraneous parameterTony Asleson2016-09-283-23/+22
| | | | Remove 'gen_new' parameter as it's not needed, correct documentation.
* lvmdbusd: Add diagnostic validate for look upsTony Asleson2016-09-272-2/+32
| | | | | Make sure that the lookup tables don't have extranoues stuff in them.
* lvmdbustest.py: Make sure to test for hidden lookupsTony Asleson2016-09-271-1/+9
| | | | Test both vgname/[hidden] and vgname/hidden forms
* lvmdbusd: Allow PV device names to be '[unknown]'Tony Asleson2016-09-271-8/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a PV device is missing lvm will return '[unknown]' for the device path. The object manager keeps a hash table lookup for uuid and for PV's device name. When we had multiple PVs with the same device path we we only had 1 key in the table for the lvm id (device path). This caused a problem when the PV device transitioned from '[unknown]' to known as any subsequent transitions would cause an exception: Traceback (most recent call last): File "/usr/lib/python3.5/site-packages/lvmdbusd/request.py", line 66, in run_cmd result = self.method(*self.arguments) File "/usr/lib/python3.5/site-packages/lvmdbusd/manager.py", line 205, in _pv_scan cfg.load() File "/usr/lib/python3.5/site-packages/lvmdbusd/fetch.py", line 24, in load cache_refresh=False)[1] File "/usr/lib/python3.5/site-packages/lvmdbusd/pv.py", line 48, in load_pvs emit_signal, cache_refresh) File "/usr/lib/python3.5/site-packages/lvmdbusd/loader.py", line 80, in common cfg.om.remove_object(cfg.om.get_object_by_path(k), True) File "/usr/lib/python3.5/site-packages/lvmdbusd/objectmanager.py", line 153, in remove_object self._lookup_remove(path) File "/usr/lib/python3.5/site-packages/lvmdbusd/objectmanager.py", line 97, in _lookup_remove del self._id_to_object_path[lvm_id] KeyError: '[unknown]' when trying to delete a key that wasn't present. In this case we don't add a lookup key for the device path and the PV can only be located by UUID. Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1379357
* lvmdbusd: Clean up objectmanager.get_object_path_by_uuid_lvm_idTony Asleson2016-09-271-44/+62
| | | | | This method grew crufty with a number of stuble bugs. Refactor and simplify.
* lvmdbustest.py: Make env variable workTony Asleson2016-09-271-1/+2
|
* lvconvert: Disable thin pool raid conversion while active.Alasdair G Kergon2016-09-272-0/+6
| | | | | | | | | Works if the pool is inactive. Activation code doesn't notice a new raid dependency in on-disk metadata when a thin LV is already active. https://bugzilla.redhat.com/1365286
* libdm: fix dm_stats_delete_region() backwards compatBryn M. Reeves2016-09-272-9/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The dm_stats_delete_region() call removes a region from the bound device, and, if the region is grouped, from the group leader group descriptor stored in aux_data. To do this requires a listed handle: previous versions of the library do not since no dependencies exist between regions without grouping. This leads to strange behaviour when a command built against an old version of the library is used with one supporting groups. Deleting a region with dmstats succeeds, but logs errors: # dmstats list Name RgID RgSta RgSiz #Areas ArSize ProgID vg_hex-root 0 0 1.00g 1 1.00g dmstats vg_hex-root 1 1.00g 1.00g 1 1.00g dmstats vg_hex-root 2 2.00g 1.00g 1 1.00g dmstats # dmstats delete --regionid 2 vg_hex/root Region ID 2 does not exist Could not delete statistics region. Command failed # dmstats list Name RgID RgSta RgSiz #Areas ArSize ProgID vg_hex-root 0 0 1.00g 1 1.00g dmstats vg_hex-root 1 1.00g 1.00g 1 1.00g dmstats This happens because the call to dm_stats_delete_region() is inside a dm_stats_walk_*() iterator: upon entry to the call, the iterator is at its end conditions and about to terminate. Due to the call to dm_stats_list() inside the function, it returns with an iterator at the beginning of a walk and performs a further iteration before exiting. This final loop makes a further attempt to delete the (already deleted) region, leading to the confusing error messages.
* libdm: fix stats walk compatibility with older dmsetupBryn M. Reeves2016-09-272-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | The current dmsetup.c handles DR_STATS and DR_STATS_META reports separately in _display_info_cols(), meaning that the stats walk functions are never called for these report types. Versions before v2.02.159 have a loop using dm_stats_walk_do() and dm_stats_walk_while(), that executes once for non-stats reports, and once per region, or area, for DR_STATS/DR_STATS_META reports. This older behaviour relies on the documented behaviour that the walk functions will accept a NULL pointer as the struct dm_stats* argument. This was broken by commit f1f2df7b: the NULL test on dms and dms->regions were incorrectly moved from the dm_stats_walk_end() wrapper to the internal '_stats_walk_end()' helper. Since the pointer is dereferenced in between these points, using an older dmsetup with current libdm results in a segfault when running a non-stats report: # dmsetup info -c vg00/lvol0 Segmentation fault (core dumped) Restore the NULL checks to the wrapper function as intended.
* systemd: disable service start rate limiting for lvm2-pvscan@.servicePeter Rajnoha2016-09-272-0/+2
| | | | | | | We shouldn't be losing pvscans just because of the fact that the underlying device (PV) appears and disappears quickly in the system, otherwise lvmetad may not see the device if it appears again (or it may still keep the device in cache even it's already gone).