summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* commands: new method for defining commandsdev-dct-cmd-defs17David Teigland2016-10-1315-1788/+13382
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | . Define a prototype for every lvm command. . Verify every user command matches one. . 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, --test, --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, --test ID: lvresize_by_pv DESC: Resize an LV by a specified PV. lvresize --poolmetadatasize SizeMB LV_thinpool OO: --alloc Alloc, --autobackup Bool, --force, --nofsck, --nosync, --noudevsync, --reportformat String, --stripes Number, --stripesize SizeKB, --test OP: PV ... ID: lvresize_pool_metadata_by_size DESC: Resize the metadata SubLV of a pool LV. 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" text is also 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[78].name = "lvresize"; commands[78].command_line_id = "lvresize_by_size"; commands[78].command_line_enum = lvresize_by_size_CMD; commands[78].fn = lvresize; commands[78].ro_count = 1; commands[78].rp_count = 1; commands[78].oo_count = 22; commands[78].op_count = 1; commands[78].desc = "DESC: Resize an LV by a specified size."; commands[78].usage = "lvresize --size Number[m|unit] LV" " [ --alloc contiguous|cling|normal|anywhere|inherit, --autobackup y|n, --nofsck, --nosync, --reportformat String, --resizefs, --stripes Number, --stripesize Number[k|unit], --poolmetadatasize Number[m|unit] ]" " [ PV ... ]"; commands[78].usage_common = " [ --commandprofile String, --config String, --debug, --driverloaded y|n, --help, --profile String, --quiet, --verbose, --version, --yes, --force, --test, --noudevsync ]"; commands[78].required_opt_args[0].opt = size_ARG; commands[78].required_opt_args[0].def.val_bits = val_enum_to_bit(sizemb_VAL); commands[78].required_pos_args[0].pos = 1; commands[78].required_pos_args[0].def.val_bits = val_enum_to_bit(lv_VAL); commands[78].optional_opt_args[0].opt = commandprofile_ARG; commands[78].optional_opt_args[0].def.val_bits = val_enum_to_bit(string_VAL); commands[78].optional_opt_args[1].opt = config_ARG; commands[78].optional_opt_args[1].def.val_bits = val_enum_to_bit(string_VAL); commands[78].optional_opt_args[2].opt = debug_ARG; commands[78].optional_opt_args[3].opt = driverloaded_ARG; commands[78].optional_opt_args[3].def.val_bits = val_enum_to_bit(bool_VAL); commands[78].optional_opt_args[4].opt = help_ARG; commands[78].optional_opt_args[5].opt = profile_ARG; commands[78].optional_opt_args[5].def.val_bits = val_enum_to_bit(string_VAL); commands[78].optional_opt_args[6].opt = quiet_ARG; commands[78].optional_opt_args[7].opt = verbose_ARG; commands[78].optional_opt_args[8].opt = version_ARG; commands[78].optional_opt_args[9].opt = yes_ARG; commands[78].optional_opt_args[10].opt = alloc_ARG; commands[78].optional_opt_args[10].def.val_bits = val_enum_to_bit(alloc_VAL); commands[78].optional_opt_args[11].opt = autobackup_ARG; commands[78].optional_opt_args[11].def.val_bits = val_enum_to_bit(bool_VAL); commands[78].optional_opt_args[12].opt = force_ARG; commands[78].optional_opt_args[13].opt = nofsck_ARG; commands[78].optional_opt_args[14].opt = nosync_ARG; commands[78].optional_opt_args[15].opt = noudevsync_ARG; commands[78].optional_opt_args[16].opt = reportformat_ARG; commands[78].optional_opt_args[16].def.val_bits = val_enum_to_bit(string_VAL); commands[78].optional_opt_args[17].opt = resizefs_ARG; commands[78].optional_opt_args[18].opt = stripes_ARG; commands[78].optional_opt_args[18].def.val_bits = val_enum_to_bit(number_VAL); commands[78].optional_opt_args[19].opt = stripesize_ARG; commands[78].optional_opt_args[19].def.val_bits = val_enum_to_bit(sizekb_VAL); commands[78].optional_opt_args[20].opt = test_ARG; commands[78].optional_opt_args[21].opt = poolmetadatasize_ARG; commands[78].optional_opt_args[21].def.val_bits = val_enum_to_bit(sizemb_VAL); commands[78].optional_pos_args[0].pos = 2; commands[78].optional_pos_args[0].def.val_bits = val_enum_to_bit(pv_VAL); commands[78].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, e.g.: $ lvresize --help lvresize - Resize a logical volume Resize an LV by a specified size. lvresize --size Number[m|unit] LV [ --alloc contiguous|cling|normal|anywhere|inherit, --autobackup y|n, --nofsck, --nosync, --reportformat String, --resizefs, --stripes Number, --stripesize Number[k|unit], --poolmetadatasize Number[m|unit] ] [ PV ... ] Resize an LV by a specified PV. lvresize LV PV ... [ --alloc contiguous|cling|normal|anywhere|inherit, --autobackup y|n, --nofsck, --nosync, --reportformat String, --resizefs, --stripes Number, --stripesize Number[k|unit] ] Resize the metadata SubLV of a pool LV. lvresize --poolmetadatasize Number[m|unit] LV_thinpool [ --alloc contiguous|cling|normal|anywhere|inherit, --autobackup y|n, --nofsck, --nosync, --reportformat String, --stripes Number, --stripesize Number[k|unit] ] [ PV ... ] Common options: [ --commandprofile String, --config String, --debug, --driverloaded y|n, --help, --profile String, --quiet, --verbose, --version, --yes, --force, --test, --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 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 implementation. 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.
* man: lvconvert mention required optionDavid Teigland2016-08-171-0/+3
|
* man: lvconvert change location of sentenceDavid Teigland2016-08-171-2/+2
| | | | | The details about each option are explained in the section for that option.
* vgsplit: fix regression processing thin external originsHeinz Mauelshagen2016-08-161-1/+1
| | | | | | | | | a579ba2ac27d fixed a regression causing a segfault if no external origin existed but broke the logic leading to erroneous error messages and creations of split off exported VGs in case the external origin and the pool LVs were allocated on different PVs. - resolves rhbz1367459
* lvcreate: better error message creating RAID LV on < 4 KiB VG extent sizeHeinz Mauelshagen2016-08-161-0/+7
| | | | | | | | | Creating a RaidLV in VGs with very small extent sizes caused late failure in the kernel giving a not very informative error message. Catch the attempt early and display failure message 'Unable to create RAID LV: requires minimum VG extent size 4.00 KiB'. - resoves rhbz1179970
* tools: Suppress some unnecessary --stripesize warnings.Alasdair G Kergon2016-08-152-3/+6
| | | | https://bugzilla.redhat.com/1366745
* pvmove: fix regression introduced with 8e9d5d12ae3ac75852ebd74b64c28e31abb68d0eHeinz Mauelshagen2016-08-152-1/+13
| | | | | | | 'pvmove -n name pv1 pv2' called with the name of a top-level LV failed with mentioned commit. Enhance pvmove-raid-segtypes.sh to test for prohibited RAID SubLV moves.
* pvmove: prohibit non-resilient collocation of RAID SubLVsHeinz Mauelshagen2016-08-154-8/+88
| | | | | | | | | | | | | | | | | | 'pvmove -n name pv1 pv2' allows to collocate multiple RAID SubLVs on pv2 (e.g. results in collocated raidlv_rimage_0 and raidlv_rimage_1), thus causing loss of resilence and/or performance of the RaidLV. Fix this pvmove flaw leading to potential data loss in case of PV failure by preventing any SubLVs from collocation on any PVs of the RaidLV. Still allow to collocate any DataLVs of a RaidLV with their sibling MetaLVs and vice-versa though (e.g. raidlv_rmeta_0 on pv1 may still be moved to pv2 already holding raidlv_rimage_0). Because access to the top-level RaidLV name is needed, promote local _top_level_lv_name() from raid_manip.c to global top_level_lv_name(). - resolves rhbz1202497
* post-releaseAlasdair G Kergon2016-08-154-2/+8
|
* pre-releasev2_02_164Alasdair G Kergon2016-08-154-6/+6
|
* conf: add comment about cfg_runtimePeter Rajnoha2016-08-151-0/+5
|
* raid_manip: pay attention to PVs listed on command line when allocating MetaLVsHeinz Mauelshagen2016-08-131-4/+15
| | | | | Adding MetaLVs to given DataLVs (e.g. raid0 -> raid0_meta takeover) wasn't paying attention to any PVs listed on the lvconvert command line.
* raid_manip: add missing code avoiding MetaLV collocation on the same PVHeinz Mauelshagen2016-08-121-4/+20
| | | | | | | | | Adding MetaLVs to given DataLVs (e.g. raid0 -> raid0_meta takeover), _avoid_pvs_with_other_images_of_lv() was missing code to prohibit allocation when called with a just allocated MetaLV to prohibit collaocation of the next allocated MetaLV on the same PV. - resolves rhbz1366738
* notify: Fix hang with lvm shell & --enable-notify-dbusTony Asleson2016-08-121-1/+1
| | | | | | | | When lvm is compiled with --enable-notify-dbus and a user uses lvm shell, after they issue 200+ commands the lvm shell will hang for ~30 seconds trying to notify the lvm dbus service that a change has occurred. This appears to be caused by resource exhaustion, because the sockets used for dbus communication are not be closed.
* lvcreate/lvconvert: fix validation of maximum mirrors/stripesHeinz Mauelshagen2016-08-126-11/+61
| | | | | | | | | Enforce mirror/raid0/1/10/4/5/6 type specific maximum images when creating LVs or converting them from mirror <-> raid1. Document those maxima in the lvcreate/lvconvert man pages. - resolves rhbz1366060
* raid: Avoid double suffix on rmeta LV name paired with rimage LV.Alasdair G Kergon2016-08-112-4/+20
|
* spec: Add new filesMarian Csontos2016-08-111-0/+2
|
* lvmcmdline: use long int for number returned by strtolPeter Rajnoha2016-08-101-1/+1
|
* post-releaseAlasdair G Kergon2016-08-104-2/+8
|
* pre-releasev2_02_163Alasdair G Kergon2016-08-104-6/+13
|
* man: fix references to names for --configreport arg in pvs, vgs and lvs man pagedev-prajnoha-log-report-extrasPeter Rajnoha2016-08-093-3/+3
|
* man: add lvm fullreport man pagePeter Rajnoha2016-08-093-1/+150
|
* report: add report_reset_cmdlog_seqnum and call it for each new cmd executed ↵Peter Rajnoha2016-08-093-3/+11
| | | | in lvm shell
* conf: mark selected settings with CFG_DISALLOW_INTERACTIVE flagPeter Rajnoha2016-08-091-6/+6
|
* config: add support for CFG_DISALLOW_INTERACTIVE flag to mark settings as ↵Peter Rajnoha2016-08-095-14/+57
| | | | | | | | | | | | | not suitable for override in interactive mode Some settings are not suitable for override in interactive/shell mode because such settings may confuse the code and it may end up with unexpected behaviour. This is because of the fact that once we're in the interactive/shell mode, we have already applied some settings for the shell itself and we can't override them further because we're already using those settings to drive the interactive/shell mode. Such settings would get ignored silently or, in worse case, they would mess up the existing configuration.
* refactor: modify original _check_profile fn and rename to config_force_check ↵Peter Rajnoha2016-08-092-5/+7
| | | | for general use
* conf: add lvmdbusd.profilePeter Rajnoha2016-08-092-1/+52
|
* lvm: shell: honor log/command_log_selection as default and reset to this ↵Peter Rajnoha2016-08-091-1/+13
| | | | value after lastlog
* lvmcmdline: profile: early profile load for lvm shellPeter Rajnoha2016-08-091-0/+8
| | | | | Make it possible to also load profile for lvm shell by honouring LVM_COMMAND_PROFILE environment variable.
* lvm: shell: extend log report to cover whole lvm shell's main loopPeter Rajnoha2016-08-094-37/+71
| | | | | | | When lvm commands are executed in lvm shell, we cover the whole lvm command execution within this shell now. That means, all messages logged and status caught during each command execution is now recorded in the log report, including overall command's return code.
* libdm: report: add dm_report_group_output_and_pop_allPeter Rajnoha2016-08-093-38/+23
| | | | | | | | | | | | The dm_report_group_output_and_pop_all calls dm_report_output and dm_report_group_pop for all the items that are currently in report group. This is just a shortcut that makes it easier to output and pop group's content so the group handle can be reused again without a need to initialize and configure it again. The functionality of dm_report_group_output_and_pop_all is the same as dm_report_destroy but without destroying the report group handle.
* libdm: report: postpone printing of JSON starting '{' character till it's neededPeter Rajnoha2016-08-091-36/+14
| | | | | | | | | | This patch moves printing of starting '{' character for JSON output up untili it's known there's any further output following - either the content or ending '}' character. Also, remove unnecessary switch for different report group types and calling individual functions to handle dm_report_group_create as that code is shared for all existing types at the moment.
* libdm: report: add dm_report_destroy_rowsPeter Rajnoha2016-08-093-0/+11
| | | | | | | | | | | | | Calling dm_report_destroy_rows makes it possible to destroy any report content we have but at the same time it doesn't destroy the report handle itself, thus it's possible to reuse that handle again for new report content. Functionally, this is the same as calling dm_report_output with the report handle but omitting the output iself. This functionality may be useful if we, for whatever reason, need to discard the report content and start a fresh new one but with the same report configuration and initialization and thus we can just reuse the existing handle.
* lvmcmdline: return 0/NULL if cmd->arg_values not set and ↵Peter Rajnoha2016-08-091-3/+3
| | | | | | | | | | | | | | | | | | | | | | | arg_count/grouped_arg_count/arg_value called We may call arg_count/grouped_arg_count/arg_value soon enough that cmd->arg_values is not set yet. Normally, when running a command, we execute lvm_run_command which in turn calls _process_command_line to allocate and parse the command line values and stores them in cmd->arg_values. However, if we run lvm shell, this one doesn't accept any command line options and we parse the command line for each command that is executed within the lvm shell then. If we used any code that tries to access cmd->arg_values through any of the the arg handling functions too early, we could end up with a segfault due to uninitialized (NULL) cmd->arg_values. This patch just saves extra checks in all the code where arg handling may be called too early so that the cmd->arg_values is not set up yet. This does not apply to any of existing code, but subsequent patches will need that.
* refactor: move report grouping and log reporting handles from ↵Peter Rajnoha2016-08-097-79/+61
| | | | | | | | | processing_handle to cmd_context With patches that will follow, this will make it possible to widen log report coverage when commands are executed from lvm shell so the amount of messages that may end up in stderr/stdout instead of log report are minimized.
* shell: also collect last command's return code for subsequent 'lastlog' ↵Peter Rajnoha2016-08-093-2/+43
| | | | | | | | | invocation Add new log_context=shell and with log_object_type=cmd and log_object_name=<command_name> for command log report to collect overall return code from last command (this is reported under log_type=status).
* log: separate output and make it possible to use given FDsPeter Rajnoha2016-08-096-59/+245
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, the output is separated in 3 parts and each part can go into a separate and user-defined file descriptor: - common output (stdout by default, customizable by LVM_OUT_FD environment variable) - error output (stderr by default, customizable by LVM_ERR_FD environment variable) - report output (stdout by default, customizable by LVM_REPORT_FD environment variable) For example, each type of output goes to different output file: [0] fedora/~ # export LVM_REPORT_FD=3 [0] fedora/~ # lvs fedora vg/abc 1>out 2>err 3>report [0] fedora/~ # cat out [0] fedora/~ # cat err Volume group "vg" not found Cannot process volume group vg [0] fedora/~ # cat report LV VG Attr LSize Layout Role CTime root fedora -wi-ao---- 19.00g linear public Wed May 27 2015 08:09:21 swap fedora -wi-ao---- 500.00m linear public Wed May 27 2015 08:09:21 Another example in LVM shell where the report goes to "report" file: [0] fedora/~ # export LVM_REPORT_FD=3 [0] fedora/~ # lvm 3>report (in lvm shell) lvm> vgs (content of "report" file) [1] fedora/~ # cat report VG #PV #LV #SN Attr VSize VFree fedora 1 2 0 wz--n- 19.49g 0 (in lvm shell) lvm> lvs (content of "report" file) [1] fedora/~ # cat report VG #PV #LV #SN Attr VSize VFree fedora 1 2 0 wz--n- 19.49g 0 LV VG Attr LSize Layout Role CTime root fedora -wi-ao---- 19.00g linear public Wed May 27 2015 08:09:21 swap fedora -wi-ao---- 500.00m linear public Wed May 27 2015 08:09:21
* test: fix/enhance lvcreate-large-raid*.shHeinz Mauelshagen2016-08-092-8/+16
| | | | | | Multi-step extend to even larger raid10 LV lvcreate-large-raid.sh. Comment fixes.
* test: fix lvcreate-large-raid.shHeinz Mauelshagen2016-08-091-14/+49
| | | | | | | | | | | RAID6 LVs may not be created with --nosync or data corruption may occur in case of device failures. The underlying MD raid6 personality used to drive the RaidLV performs read-modify-write updates on stripes and thus relies on properly written parity (P and Q Syndromes) during initial synchronization. Once on it, enhance test to create/extend more and larger RaidLVs and check sync/nosync status.
* test: add lvconvert-raid-takeover.shHeinz Mauelshagen2016-08-091-0/+126
| | | | | | | | | | | | Commit 76ef2d15d839106adac4d82005d517be05a657eb introduced raid0 <-> raid4 takeover and full mirror <-> raid1 support. Add tests for these conversions. Tests exposed a kernel semantics change freezing resynchronization on conversions from raid0[_meta] -> raid4 or adding raid1 legs because kernel kept the RAID mapped device in 'frozen' state unless an 'idle' message was sent or the table was reloaded (kernel patch pending).
* lvconvert: Fix repair and replace routing.Alasdair G Kergon2016-08-081-1/+1
|
* man: explain deletion of 1st group member in dmstats.8.inBryn M. Reeves2016-08-081-2/+15
| | | | | | | | Although the use of the first region_id in a group to store the DMS_GROUP=... aux_data tag is an internal implementation detail, it has a user visible consequence in that deleting this region will cause the group to disappear: add an explanation of this to the 'group' command and 'Regions, areas, and groups' section.
* man: minor fixes to dmstats.8.inBryn M. Reeves2016-08-081-1/+1
| | | | Remove obsolete reference to '--target'.
* test: Drop --mirrorlog when not a mirror.Alasdair G Kergon2016-08-082-4/+12
|
* lvconvert: separate type raid to mirrorDavid Teigland2016-08-082-1/+20
| | | | | | By the current division of unique operations, converting type raid to type mirror is distinct from converting type raid to raid.
* WHATS_NEW: reject --nosync option for RAID6 LVs in lvcreateHeinz Mauelshagen2016-08-081-0/+1
|
* lvconvert: Limit --corelog and --mirrorlog to mirrors.Alasdair G Kergon2016-08-082-1/+13
| | | | | It's an error to specify a log when the final result is not of type mirror.
* lvcreate: reject '--nosync' option for RAID6 LVsHeinz Mauelshagen2016-08-083-7/+112
| | | | | | | | | | | | | | | | The MD raid6 personality being used to drive lvm raid6 LVs does read-modify-write updates to any stripes and thus relies on correct P and Q Syndromes being written during initial synchronization or it may fail reconstructing proper user data in case of SubLVs failing. We may not allow the '--nosync' option on creation of raid6 LVs for that reason. Update/fix 'man lvcreate' in that regard. add lvcreate-raid-nosync.sh test script. - Resolves rhbz1358532
* lvmcmdline: do not refresh whole cmd context if profile dropped after ↵Peter Rajnoha2016-08-082-1/+5
| | | | | | | | | | | | | | | | processing LVM cmd We don't need to refresh whole cmd context if we drop profile after processing LVM command - just like we don't refresh cmd context when we're applying the profile. It's because profiles contain only safe subset of settings which do not require complete cmd context refresh. This patch calls process_profilable_config instead of refresh_toolcontext if there was profile applied for the LVM command only, not --config which requires toolcontext refresh. The process_profilable_config just sets proper values based on values of profilable settings, but it does not do complete reinitialization of various parts (e.g. filters, logging etc.).
* lvconvert: Support raid0<->raid4 and mirror<->raid1.Alasdair G Kergon2016-08-073-45/+535
| | | | Only simple takeover cases so far.