summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* lvchange: make use of command definitionsdev-dct-cmd-defs45David Teigland2016-11-173-470/+253
| | | | | | Reorganize the lvchange code to take advantage of the command definition, and remove the validation that is done by the command definintion rules.
* commands: new method for defining commandsDavid Teigland2016-11-1726-1832/+7116
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | . 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.
* raid: Remove fixed FIXMEAlasdair G Kergon2016-11-151-1/+0
|
* dbus: also recognize error state for missing service that comes from ↵Peter Rajnoha2016-11-151-2/+4
| | | | original D-Bus
* dbus: only log msg as debug if lvm2-lvmdbusd unit missing for D-Bus notificationPeter Rajnoha2016-11-142-1/+7
| | | | | | | | | Do not emit warning message but only log debug message if lvm2-lvmdbusd.service unit is missing and at the same time we have global/notify_dbus=1 (which is used by default if we configured sources with "--enable-notify-dbus"). We don't want hard dependency between LVM2 and lvmdbusd so it's enough to log only debug message in this case.
* tests: fix checking for pvmove LVZdenek Kabelac2016-11-142-2/+2
| | | | | | Use consitently egrep. TODO: make probably aux func
* cleanup: debug trace and indent changeZdenek Kabelac2016-11-111-2/+2
|
* cleanup: avoid using double __ in extracted image nameZdenek Kabelac2016-11-111-2/+2
|
* cleanup: add dots to debug messagesZdenek Kabelac2016-11-111-2/+2
|
* tests: do not set zero interval in aux lvm.confZdenek Kabelac2016-11-111-1/+1
| | | | | | | | | 0 interval leads as of now to a busy loop with lvmetad and command. Avoid testing this patological case. TODO: Code should possibly translate zero interval into some small sleep. With lvmpolld it's already 1/10s
* tests: avoid using pollingZdenek Kabelac2016-11-111-2/+3
|
* tests: update make targetsZdenek Kabelac2016-11-111-0/+18
| | | | | | | | | | | | | | Add new targets: make check_lvmpolld make check_cluster_lvmpolld make check_lvmetad_lvmpolld make check_all_lvmpolld So check_lvmetad runs only base lvmetad test - to much logic of remaining targets. Previous behavior is available via check_all_lvmpolld.
* conf: support zero for missing_stripe_fillerZdenek Kabelac2016-11-114-10/+21
| | | | | | | | | Make it easier to replace missing segments with 'zero' returning target - otherwise user would have to create some extra target to provide zeros as /dev/zero can't be used (not a block device). Also break code loop when segment is found and make it an INTERNAL_ERROR where it's missing.
* cleanup: skip checking for just assigned stringZdenek Kabelac2016-11-111-2/+1
| | | | | When 'stripe_filler' has been just set to 'error', do not check it again for not being 'error'.
* lvconvert: repair accepts interval and backgroundZdenek Kabelac2016-11-113-0/+8
| | | | | For mirror and raid we expose --interval and --background on command line (instead of using just always using compiled-in defaults).
* lvconvert: Introduce enum to separate cases.Alasdair G Kergon2016-11-111-113/+170
| | | | | Start to separate out the different things that lvconvert does by using an enum to identify 12 distinct cases.
* dmsetup: [v2] return 0 for [--]{version,help}Heinz Mauelshagen2016-11-101-3/+2
| | | | | | | Leverage 0b1c79642061 to cope with "dmsetup SubCommand --{help,version}" and bail out directly when _report_init() fails. Related: rhbz1393692
* dmsetup: return 0 for [--]{version,help}Heinz Mauelshagen2016-11-101-0/+1
| | | | | | | dmsetup regressed returning 1 when properly processing version or help subcommands. Resolves: rhbz1393692
* tests: for repair we need neewer versionZdenek Kabelac2016-11-081-1/+2
| | | | Older cache targets were not able to report write failures.
* tests: test raid0_meta typeZdenek Kabelac2016-11-081-3/+3
| | | | | Enable testing of raid0_meta type. Also slow down devices a bit more.
* raid: faster rmeta clearingZdenek Kabelac2016-11-082-31/+48
| | | | | | | | | | | | Instead of clearing multiple rmeta device with sequential activation process and waiting for udev for every _rmeta device separately, activate all _rmeta devices first and then clear them and deactivate afterwards. Also update some tracing messages. When anyhing goes wrong during clearing process, always try to deactivate as much _rmeta devices as possible before fail.
* post-releaseAlasdair G Kergon2016-11-054-2/+8
|
* pre-releasev2_02_167Alasdair G Kergon2016-11-054-7/+7
|
* tests: Disable 3-leg raid1 pre-sync repair attemptAlasdair G Kergon2016-11-041-1/+2
| | | | Test fails as it doesn't ensure device isn't already in sync.
* lvmdbusd: Remove the periodic timer taskTony Asleson2016-11-032-23/+3
| | | | | | This code is no longer needed because the back ground task has been removed. Will add back if we change the design and end up utilizing multiple worker threads.
* lvmdbusd: Take out background threadTony Asleson2016-11-032-99/+33
| | | | | | | There is no reason to create another background task when the task that created it is going to block waiting for it to finish. Instead we will just execute the logic in the worker thread that is servicing the worker queue.
* dmeventd: provide message contextZdenek Kabelac2016-11-031-9/+11
| | | | | | Show device name with printed message. Also use different level for printing error message and standard informational message.
* cleanup: use WARNING prefix for log_warnZdenek Kabelac2016-11-032-5/+5
| | | | Use capital WARNING prefix for log_warn() messages.
* cleanup: remove gotoZdenek Kabelac2016-11-031-7/+4
| | | | Move goto path into 'if()' branch.
* log_info to log_very_verboseZdenek Kabelac2016-11-034-16/+16
| | | | | | | | Translate log_info() into log_very_verbose() which is macro supposed to be used by our code. log_info() is internal macro with eventually some 'symbolic' meaning in syslogging daemons.
* log_info to log_warnZdenek Kabelac2016-11-031-2/+2
| | | | Switch to log_warn level when we are reporting these message.
* cleanup: log_info to log_errorZdenek Kabelac2016-11-035-4/+6
| | | | Switch to more appropriate logging level.
* libdm: use dm_log_with_errno alwaysZdenek Kabelac2016-11-033-16/+57
| | | | | | | | | | | | | | Instead of compiling 2 log call for 2 different logging functions, and runtime decide which version to use - use only 'newer' function and when user sets his own OLD dm_log logging translate it runtime for old arg list set. The positive part is - we get shorter generated library, on the negative part this translation means, we always have evaluate all args and print the message into local on stack buffer, before we can pass this buffer to the users' logging function with proper expected parameters (and such function may later decide to discard logging based on message level so whole printing was unnecessary).
* tests: check that pvscan cannot activate exported VGDavid Teigland2016-11-031-0/+22
|
* cleanup: add 'static' for local structZdenek Kabelac2016-11-031-1/+1
|
* cleanup: drop unused attributeZdenek Kabelac2016-11-031-2/+1
| | | | | In this function we pass args through so make the function header look the same as with _default_log().
* dmeventd: separate dm and dmeventd loggingZdenek Kabelac2016-11-033-5/+21
| | | | | | | | | | | | | | | Ensure different logging function for dmeventd.c logging and dm and lvm library. We can recognize we want to show every log_info() and log_notice() message from dmeventd.c code while not exposing those from libdm/libdevmapper-event Also switch to use log with errno - it's not changing anything and doesn't bring any more features yet to dmeventd logging but we just properly pass dm_errno_or_class properly through the whole code stack for possible future use (i.e. support of class logging for dmeventd).
* dmeventd: debug only subsystemd with # signZdenek Kabelac2016-11-032-8/+19
| | | | | | | | | | | | | | | | | | | | Reword the logging logic and try to restore previous logging behavior for 'standalone' running daemon while preserving debuggable feautures it has gained. So actual rules: dmeventd without any '-d' option will syslog all messages from dmeventd.c it dmeventd plugins. log_notice()==log_verbose() log_info()==log_very_verbose() But to show also log_debug() used has to give '-ddd'. When user specified '-d, -dd, -ddd, -dddd' it will also enable tracing of messages from libdm & lib executed code - which is mainly useful for testing i.e.: 'dmeventd -fldddd'
* dmeventd: abort on internal errorZdenek Kabelac2016-11-032-0/+11
| | | | | Provide same support for DM_ABORT_ON_INTERNAL_ERRORS we do have with default libdm logging as dmeventd is libdm based tool.
* libdm: report logging with errno as changed defaultZdenek Kabelac2016-11-032-1/+2
| | | | | When user changes logging with 'dm_log_with_errno_init()' also report this as non default dm logging.
* logging: add more log macrosZdenek Kabelac2016-11-035-10/+15
| | | | | | | | | | | | Introduce macros: log_level(), log_stderr(), log_once(), log_bypass_report() For easier and more consisten way how to 'decoder' bits of info from passed 'level'. This patch fixes potential problem when 'level' of message might not have always masked right bits.
* lvmdbusd: Stop using threads for job waitTony Asleson2016-11-022-31/+81
| | | | | | | Instead of creating a thread to handle the case where a client is calling job.Wait, we will utilize a timer. This significantly reduces the number of threads that get created and destroyed while the service is running.
* lvmdbusd: main.py: change debug msg textTony Asleson2016-11-021-1/+1
|
* lvmdbusd: Don't use dbus lib in worker threadTony Asleson2016-11-024-43/+16
| | | | | | | Simplify the code paths so that we don't utilize the dbus library code when we are in worker thread context. ref. https://bugs.freedesktop.org/show_bug.cgi?id=98521
* lvmdbusd: Execute load in main threadTony Asleson2016-11-022-9/+26
| | | | | | | We will fetch the lvm state in non-main thread and only process the new data with the main thread to prevent hanging the main thread event loop. ref. https://bugs.freedesktop.org/show_bug.cgi?id=98521
* lvmdbusd: Return results in main threadTony Asleson2016-11-023-10/+74
| | | | | | | Also introduce some additional new code to execute code other code in main thread too. ref. https://bugs.freedesktop.org/show_bug.cgi?id=98521
* lvmdbusd: Use timer instead of threadTony Asleson2016-11-022-15/+11
| | | | | We had a thread sitting around for cleaning up other processes, changed to a periodic timer task.
* pvscan: fix autoactivation of exported VGDavid Teigland2016-11-021-0/+3
| | | | | | | | pvscan --cache -aay was activating LVs in exported VGs when it should not. It appears that this was a regression from commit 9b640c36841 "pvscan: use process_each_vg for autoactivate".
* blkdeactivate: deactivate dev stack if dev on top already unmountedPeter Rajnoha2016-11-012-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If blkdeactivate finds out that the device on top of device stack is already unmounted, it still proceeds with device stack deactivation underneath now. This situation can happen if blkdeactivate is started and the mount point is unmounted in parallel by chance (so when blkdeactivate gets the the actual umount call, the device is not mounted anymore). Before, the blkdeactivate added such device to skip list which caused all the stack underneath to be skipped too on deactivation. Now, we proceed just as if blkdeactivate did the umount itself. For example, in the example below, the vg-lvol0 is mounted on /mnt/test when blkdeactivate is called, but it gets unmounted in parallel later on when blkdeactivate gets to the actual umount call. Before this patch (vg-lvol0 underneath not deactivated): $ blkdeactivate -u Deactivating block devices: [UMOUNT]: unmounting vg-lvol0 (dm-2) mounted on /mnt/test... skipping With this patch applied (vg-lvol0 underneath still deactivated): $ blkdeactivate -u Deactivating block devices: [UMOUNT]: unmounting vg-lvol0 (dm-2) mounted on /mnt/test... already unmounted [LVM]: deactivating Logical Volume vg/lvol0... done
* test: add raid4 checks to respective testsHeinz Mauelshagen2016-10-287-8/+32
| | | | Add missing checks for valid raid4 mapping to tests.