summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* man lvm: remove optionsdev-dct-cmd-defs70David Teigland2017-01-121-255/+3
| | | | all options are now included in commands
* Makefile: clean up create-command partsDavid Teigland2017-01-121-6/+12
|
* fix lvmcmdline warningDavid Teigland2017-01-121-20/+20
| | | | declaration of ‘usage’ shadows a globa
* args: add man page descriptionsDavid Teigland2017-01-124-268/+1611
|
* args: use uint32 arg for maxphysicalvolumesDavid Teigland2017-01-044-4/+6
|
* lvconvert: remove unused codeDavid Teigland2017-01-041-1731/+325
|
* lvconvert: use command defs for raid/mirror typesDavid Teigland2017-01-044-797/+323
| | | | | | | | | | 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.
* tests: use swapmetadataDavid Teigland2017-01-045-33/+33
| | | | and some other pool/cache/thin related changes
* lvconvert: use command defs for mergemirrorsDavid Teigland2017-01-045-40/+111
| | | | | and route the generic --merge to one of the specific merge functions
* toollib: find VG name in option values when neededDavid Teigland2017-01-044-2/+162
|
* lvconvert: use command defs for thin/cache/pool creationDavid Teigland2017-01-0410-74/+1394
| | | | Everything related to thin and cache.
* lvconvert: add startpoll command using command defDavid Teigland2017-01-046-18/+86
| | | | | | 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.
* lvconvert: snapshot: use command definitionsDavid Teigland2017-01-0410-140/+277
| | | | | | | 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.
* lvconvert: remove unused calls for repair and replaceDavid Teigland2017-01-041-227/+10
| | | | | repair and replace are no longer called from the monolithic lvconvert code, so remove the unused code.
* lvconvert: repair and replace: use command definitionsDavid Teigland2017-01-044-18/+330
| | | | | | | 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.
* lvchange: make use of command definitionsDavid Teigland2017-01-044-452/+430
| | | | | | Reorganize the lvchange code to take advantage of the command definition, and remove the validation that is done by the command definintion rules.
* process_each_lv: add check_single_lv functionDavid Teigland2017-01-0411-15/+38
| | | | | | | | | | | | | | | | | 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.
* commands: new method for defining commandsDavid Teigland2017-01-0428-1836/+7312
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | . 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.
* lvmlockd: test mode doesn't workDavid Teigland2017-01-031-0/+5
| | | | | | The --test option is not yet compatible with shared VGs because changes are made in lvmlockd that cannot be reversed or faked.
* cleanup: more use of lvseg_nameZdenek Kabelac2017-01-037-16/+7
| | | | Use existing function lvseg_name().
* cleanup: use macrosZdenek Kabelac2017-01-031-2/+2
|
* cleanup: definesZdenek Kabelac2017-01-031-5/+11
|
* cleanup: reuse existing codeZdenek Kabelac2017-01-031-20/+14
|
* cache: add missing udev waitZdenek Kabelac2017-01-032-1/+14
| | | | | | | | | | | | | | | | | | | When we need to clear dirty cache content of cached LV, there is table reload which usually is shortly followed by next metadata change. However udev can't (as of now) process udev event while device is 'suspended'. So whenever sequence of 'suspend/resume/suspend' is needed, we need to wait first for finishing of 'resume' processing before starting next 'suspend'. Otherwise there is 'race' danger of triggering unwantend umount by systemd as such event will trigger SYSTEMD_READY=0 state for a moment for such changed device. Such race is pretty ugly to trace so we may need to review more sequencies for missing 'sync'. (Other option is to enhnace 'udev' rules processing to avoid such dramatic actions to be happening for suspended devices).
* vgchange: max_pv limited to uint32Zdenek Kabelac2017-01-033-1/+9
| | | | | | | | | | | | | | | Solves: https://bugzilla.redhat.com/1280496 The only reasonable behaviour here is to error on any number out of accepted range (i.e. now numbers wrapping around with some hidden logic). As this is plain bug there is no support for backward compatibility since noone should set numbers >UINT32_MAX and expect 0 or error depending on how big number was used.... TODO: more fields might need to be converted.
* lvmcmdline: support uint32Zdenek Kabelac2017-01-032-0/+9
| | | | | | | | Add simple function to wrap usage for only uint32 numbers. Unlike 'int_arg' which accepts full range of 64bit number this function will error on numbers out of this range: <0, UINT32_MAX>
* man: fix name of 'write_time' field in dmstats.8.inBryn M. Reeves2016-12-251-1/+1
|
* tests: update testZdenek Kabelac2016-12-231-3/+12
| | | | | lvm2 now correctly reports thin_id after action of merged thin, but before physical metadata update as we know the merge has happened.
* validation: temporarily let pass linear with chunk_sizeZdenek Kabelac2016-12-231-0/+2
| | | | | Old pool format seems to be setting chunk_size. For now let validation pass with this.
* lvchange: allow a transiently failed RaidLV to be refreshedHeinz Mauelshagen2016-12-235-28/+171
| | | | | | | | | | | | | | | | | | | | | | Add to commits 87117c2b2546 and 0b8bf73a63d8 to avoid refreshing two times altogether, thus avoiding issues related to clustered, remotely activated RaidLV. Avoid need to repeat "lvchange --refresh RaidLV" two times as a workaround to refresh a RaidLV. Fix handles removal of temporary *-missing-* devices created for any missing segments in RAID SubLVs during activation. Because the kernel dm-raid target isn't able to handle transiently failing devices properly we need "[dm-devel][PATCH] dm raid: fix transient device failure processing" as well. test: add lvchange-raid-transient-failures.sh and enhance lvconvert-raid.sh Resolves: rhbz1025322 Related: rhbz1265191 Related: rhbz1399844 Related: rhbz1404425
* tests: use hold_device_openZdenek Kabelac2016-12-223-20/+5
|
* tests: add device holding functionZdenek Kabelac2016-12-221-0/+21
| | | | | Hold device open with sleep and wait till sleep really opens given devices.
* tests: workaround failure on fc23Zdenek Kabelac2016-12-221-0/+6
|
* thin: refresh status when error processing failsZdenek Kabelac2016-12-222-0/+27
| | | | | | | When thin-pool processes event and 'lvextend --use-policies' fails rather capture up-to-date new info as the fullness percentage may have jumped noticable. This way we could use 'more' correct numbers when checking for thresholds.
* report: show proper info for merging originZdenek Kabelac2016-12-222-0/+59
| | | | | | | | | | | | When there is 'merging' of an origin in progress, but metadata stil do provide both origin and snapshot, we should show data from merged snapshot. This is important mainly for thin case, where there was a window, where i.e. 'lvs -o+device_id' would report information about 'already gone' origin thin LV. This race window is usually hard to trigger but can be ocasionally hit. Usually shortly after activation, but before polling process manages to update metadata after merge.
* snapshot: validate merge has startedZdenek Kabelac2016-12-222-2/+8
| | | | | | | | | Before starting polling process, validate the merge has actually started so there is not pointless invoke of lvmpolld. This also fixes reported message from command, so user has correct info whether merging has already started or if it's delayed for next activation.
* lv: more exact check for merging originZdenek Kabelac2016-12-222-1/+2
| | | | Merging origin has 'MERGE_LV' and should also have its merging snapshot.
* validation: rework segment validationZdenek Kabelac2016-12-222-295/+233
| | | | | | | | | | | | Move individual segment validation to a separate function executed for 'complete_vg'. Move some 'extra' validation bits from 'raid' validation to global segtype validation (so extending existing normal validation) TODO: still some test are left to be moved. Reduce some duplication in validation process - there are still some left thought so still room for improving overal speed.
* lvmdbustest: Print messages if timeout value > 10%Tony Asleson2016-12-201-3/+22
| | | | | We will dump some informational messages if the time to return when we specify a timeout exceeds 10% of requested.
* lvmdbusd: Use timeout_add insteadTony Asleson2016-12-201-6/+9
| | | | | | | The function timeout_add_seconds has quite a bit of variability. Using timeout_add which specifies the timeout in ms instead of seconds. Testing shows that this is much more consistent which should improve clients that are using shorter timeouts for the API and the connection.
* lvmdbusd: Use cfg.reload() instead of dbo.refreshTony Asleson2016-12-202-4/+4
| | | | | We want to update the data and send out any signals as needed, not just update the in memory database.
* lvmdbusd: Remove un-needed main thread executionTony Asleson2016-12-201-2/+5
|
* tests: usage of cached volume for snapshotZdenek Kabelac2016-12-193-1/+126
|
* cache: support cached origin for snapshotZdenek Kabelac2016-12-194-3/+18
| | | | | | | | | Enable 'lvcreate/lvconvert -s' for cached LV. and supported operations: Create a snapshot of cached LV Split/Join snapshot LV to cached origin LV.
* lvconvert: fix shown lv name for snapshot splitZdenek Kabelac2016-12-192-5/+6
| | | | | | | | We can't keep 'display_lvname' for too long - it's using ringbuffer and keeps limited number of names. So it's safe only per few simple tests, but can't be used anymore after some function calls.. (Fixes 00e641ef37a977129acc503f3fa1b67f556ac5eb)
* libdm: add dm_stats_bind_from_fd()Bryn M. Reeves2016-12-185-19/+32
| | | | | dmsetup already has a version of this function, and dmfilemapd will need it too: move it to libdevmapper to avoid copying it around.
* libdm: clear region table in dm_stats_list()Bryn M. Reeves2016-12-181-0/+3
| | | | | | | Call _stats_regions_destroy() from dm_stats_list() if dms->regions is non-NULL. This avoids leaking any pool allocations and ensures the handle is in a known state: if an error occurs during the list, dms->regions will be NULL and the handle will appear empty.
* tests: using cached LV for external originZdenek Kabelac2016-12-181-0/+107
|
* debug: add debug message showing new lvZdenek Kabelac2016-12-181-0/+2
| | | | Make trace easier to follow knowing which LV was added to dtree.
* activate: further _info API refinementZdenek Kabelac2016-12-181-47/+41
| | | | | | Another cleanup of internal _info() API simplifying code. Also make sure 'error' on _info() call is properly passed upward (return 0 is error path).