summaryrefslogtreecommitdiff
path: root/tools
Commit message (Collapse)AuthorAgeFilesLines
* select: initialize selection handle for process_each_* fns with initial ↵Peter Rajnoha2015-02-103-7/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | report type This is a followup patch for previous patchset that enables selection in process_each_* fns to fix an issue where field prefixes are not automatically used for fields in selection criteria. Use initial report type that matches the intention of each process_each_* functions: - _process_pvs_in_vg - PVS - process_each_vg - VGS - process_each_lv and process_each_lv_in_vg - LVS This is not normally needed for the selection handle init, BUT we would miss the field prefix matching, e.g. lvchange -ay -S 'name=lvol0' The "name" above would not work if we didn't initialize reporting with the LVS type at its start. If we pass proper init type, reporting code can deduce the prefix automatically ("lv_name" in this case). This report type is then changed further based on what selection criteria we have. When doing pure selection, not report output, the final report type is purely based on combination of this initial report type and report types of the fields used in selection criteria.
* tools: allow -S|--select for vgexport and vgimportPeter Rajnoha2015-02-103-8/+10
|
* tools: allow -S|--select for vgdisplay, lvdisplay and pvdisplay without -CPeter Rajnoha2015-02-104-3/+3
| | | | | | | We already allowed -S|--select with {vg,lv,pv}display -C (which was then equal to {vg,lv,pv}s command. Since we support selection in toolib now, we can support -S also without using -C in *display commands now.
* tools: allow -S|--select for vgremove and lvremovePeter Rajnoha2015-02-104-9/+13
|
* tools: allow -S|--select for vgchange, lvchange and pvchangePeter Rajnoha2015-02-103-12/+15
|
* pvchange: use processing_handle when processing items for pvchangePeter Rajnoha2015-02-101-10/+35
| | | | | | pvchange is an exception that does not use toollib yet for iterating over the list of PVs (process_each_pv) so intialize the processing_handle and use just like it's used in toollib.
* report: implement report_for_selectionPeter Rajnoha2015-02-101-1/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | We have 3 input report types: - LVS (representing "_select_match_lv") - VGS (representing "_select_match_vg") - PVS (representing "_select_match_pv") The input report type is saved in struct selection_handle's "orig_report_type" variable. However, users can use any combination of fields of different report types in selection criteria - the resulting report type can thus differ. The struct selection_handle's "report_type" variable stores this resulting report type. The resulting report_type can end up as one of: - LVS - VGS - PVS - SEGS - PVSEGS This patch adds logic to report_for_selection based on (sensible) combination of orig_report_type and report_type and calls appropriate reporting functions or iterates over multiple items that need reporting to determine the selection result.
* report: add report_for_selection and use it in select_match_{pv,vg,lv}Peter Rajnoha2015-02-102-3/+38
| | | | | | The report_for_selection does the actual "reporting for selection only". The selection status will be saved in struct selection_handle's "selected" variable.
* refactor: report: factor out code to determine final report typePeter Rajnoha2015-02-101-26/+45
| | | | | | | The code to determine final report type based on combination of input report type (determined from fields used for reporting to output and selection) can be reused for pure reporting for selection - factor out this code into _get_final_report_type function.
* toollib: select the whole structure if at least one of its items is selectedPeter Rajnoha2015-02-101-0/+42
| | | | | | | | | | This applies to: - process_each_lv_in_vg - the VG is selected only if at least one of its LVs is selected - process_each_segment_in_lv - the LV is selected only if at least one of its LV segments is selected - process_each_pv_in_vg - the VG is selected only if at least one of its PVs is selected - process_each_segment_in_pv - the PV is selected only if at least one of its PV segments is selected So this patch causes the selection result to be properly propagated up to callers.
* toollib: initialize handles (including reporting for selection) for ↵Peter Rajnoha2015-02-105-52/+113
| | | | | | | | _select_match_* used in process_each_* fns Call _init_processing_handle, _init_selection_handle and _destroy_processing_handle in process_each_* and related functions to set up and destroy handles used while processing items.
* toollib: add init_processing_handle, init_selection_handle and ↵Peter Rajnoha2015-02-102-0/+58
| | | | | | | | | destroy_processing_handle helper functions The init_processing_handle, init_selection_handle and destroy_processing_handle are helper functions that allocate and initialize the handles used when processing items in process_each_* and related functions.
* toollib: pass struct processing_handle to _select_match_* functionsPeter Rajnoha2015-02-102-14/+30
| | | | | | | | | The "struct processing_handle" contains handles to drive the selection/matching so pass it to the _select_match_* functions which are entry points to the selection mechanism used in process_each_* and related functions. This is revised and edited version of former Dave Teigland's patch which provided starting point for all the select support in process_each_* fns.
* report: add report_init_for_selection fn and modify report_object to support ↵Peter Rajnoha2015-02-101-11/+24
| | | | | | | | | | | | | | | | | reporting for selection only The new "report_init_for_selection" is just a wrapper over dm_report_init_with_selection that initializes reporting for selection only. This means we're not going to do the actual reporting to output for display and as such we intialize reporting as if no fields are reported or sorted. The only fields "reported" are taken from the selection criteria string and all such fields are marked as hidden automatically (FLD_HIDDEN flag). These fields are used solely for selection criteria matching. Also, modify existing report_object function that was used for reporting to output for display. Now, it can either cause reporting to output or reporting for selection only. The selection result is stored in struct selection_handle's "selected" variable which can be handled further by any report_object caller.
* toollib: replace void *handle with struct processing_handle for use in ↵Peter Rajnoha2015-02-1021-105/+189
| | | | | | | | | | | | | | | | | | processing functions (process_each_*/process_single_* and related) This patch replaces "void *handle" with "struct processing_handle *handle" in process_each_*, process_single_* and related functions. The struct processing_handle consists of two handles inside now: - the "struct selection_handle *selection_handle" used for applying selection criteria while processing process_each_*, process_single_* and related functions (patches using this logic will follow) - the "void* custom_handle" (this is actually the original handle used before this patch - a pointer to custom data passed into process_each_*, process_single_* and related functions).
* cleanup: make report type condition consistent with the rest of the codePeter Rajnoha2015-02-101-3/+2
| | | | | | It's just more readable this way (each condition resulting in a certain report type is always on one line), just like it's used elsewhere in the code.
* toollib: prepare select_match_{pv,vg,lv} hooksDavid Teigland2015-02-102-6/+59
| | | | | These hooks will check currently processed PV/VG/LV with current selection criteria and the processing continues only if there's a match.
* lvm: recognize LVM_COMMAND_PROFILE env var for default command profile to ↵Peter Rajnoha2015-02-091-8/+45
| | | | | | | | | use in LVM commands Once LVM_COMMAND_PROFILE environment variable is specified, the profile referenced is used just like it was specified using "<lvm command> --commandprofile". If both --commandprofile cmd line option and LVM_COMMAND_PROFILE env var is used, the --commandprofile cmd line option gets preference.
* reporter: properly check for _do_info_and_status return value and free the ↵Peter Rajnoha2015-02-091-10/+6
| | | | mempool if created within the fn
* thin: report proper status for thin poolZdenek Kabelac2015-01-301-2/+6
| | | | | | | | | | | After commit 158e9988768be344c0c97acdf52d1c020ab8c83e where we may start to readlv_attr with a 'shared' ioctl call for a single lvs line we where obtaing single status for thin pools. However this is not properly reflecting lvm2 reality. Correcting this by reading lv status from layered thin pool, but lv info from non-layered (linear) mapped device which is maintained for proper cluster locking.
* thin: preserve chunksize with lvconvertZdenek Kabelac2015-01-281-0/+1
| | | | | | When repairing thin pool or swapping thin pool metadata, preserve chunk_size property and avoid to be automatically changed later in the code to better match thin pool metadata size.
* report: add separate LVSINFOSTATUS field type for info+status combined fieldsPeter Rajnoha2015-01-201-5/+7
| | | | | | | | | | | | | | | | | | | | Add separate LVSINFOSTATUS field type for fields which display both dm info-like and dm status-like information. The internal interface is there with the introduction of LVSSTATUS field type which can cope with the combination of LVSSTATUS and LVSINFO field types (several fields). However, till now, we considered that *single* field can display either LVSINFO or LVSSTATUS, but not both at the same time. Till now, we haven't had single field which needs both - hence add LVSINFOSTATUS field type for such fields as we currently need this for the lv_attr field which requires combination of info and status. This patch just adds interface for an ability to register such fields (the code that copes with this is already in).
* thin: support errorwhenfull with thin creationZdenek Kabelac2015-01-201-1/+2
| | | | | When thinpool and thinvolume are created at the same time, still support usage of --errorwhenfull.
* report: update report_object APIZdenek Kabelac2015-01-201-15/+17
| | | | Internal API change - pass single struct for both info & seg_status.
* report: reporting unknown statusZdenek Kabelac2015-01-201-12/+8
| | | | | Add SEG_STATUS_UNKNOWN when status cannot be parsed. Also add 'info_ok' variable when info was correctly obtained.
* thin: lvchange support for errorwhenfullZdenek Kabelac2015-01-202-1/+39
| | | | Support lvchange --errorwhenfull y|n for thin pools.
* libdm-report: Fix order of NULL dm_report check.Alasdair G Kergon2015-01-171-1/+0
|
* toollib: search for duplicate PVs only when neededDavid Teigland2015-01-141-3/+1
| | | | | | | | A full search for duplicate PVs in the case of pvs -a is only necessary when duplicates have previously been detected in lvmcache. Use a global variable from lvmcache to indicate that duplicate PVs exist, so we can skip the search for duplicates when none exist.
* toollib: pvs -a should display VG name for each duplicate PVDavid Teigland2015-01-141-7/+38
| | | | | | | | | Previously, 'pvs -a' displayed the VG name for only the device associated with the cached PV (pv->dev), and other duplicate devices would have a blank VG name. This commit displays the VG name for each of the duplicate devices. The cost of doing this is not small: for each PV processed, the list of all devices must be searched for duplicates.
* toollib: override the PV device with duplicatesDavid Teigland2015-01-141-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When multiple duplicate devices are specified on the command line, the PV is processed once for each of them, but pv->dev is the device used each time. This overrides the PV device to reflect the duplicate device that was specified on the command line. This is done by hacking the lvmcache to replace pv->dev with the device of the duplicate being processed. (It would be preferable to override pv->dev without munging the content of the cache, and without sprinkling special cases throughout the code.) This override only applies when multiple duplicate devices are specified on the command line. When only a single duplicate device of pv->dev is specified, the priority is to display the cached pv->dev, so pv->dev is not overridden by the named duplicate device. In the examples below, loop3 is the cached device referenced by pv->dev, and is given priority for processing. Only after loop3 is processed/displayed, will other duplicate devices loop0/loop1 appear (when requested on the command line.) With two duplicate devices, loop0 and loop3: # pvs Found duplicate PV XhLbpVo0hmuwrMQLjfxuAvPFUFZqD4vr: using /dev/loop3 not /dev/loop0 PV VG Fmt Attr PSize PFree /dev/loop3 loopa lvm2 a-- 12.00m 12.00m # pvs /dev/loop3 Found duplicate PV XhLbpVo0hmuwrMQLjfxuAvPFUFZqD4vr: using /dev/loop3 not /dev/loop0 PV VG Fmt Attr PSize PFree /dev/loop3 loopa lvm2 a-- 12.00m 12.00m # pvs /dev/loop0 Found duplicate PV XhLbpVo0hmuwrMQLjfxuAvPFUFZqD4vr: using /dev/loop3 not /dev/loop0 PV VG Fmt Attr PSize PFree /dev/loop3 loopa lvm2 a-- 12.00m 12.00m # pvs -o+dev_size /dev/loop0 /dev/loop3 Found duplicate PV XhLbpVo0hmuwrMQLjfxuAvPFUFZqD4vr: using /dev/loop3 not /dev/loop0 PV VG Fmt Attr PSize PFree DevSize /dev/loop0 loopa lvm2 a-- 12.00m 12.00m 16.00m /dev/loop3 loopa lvm2 a-- 12.00m 12.00m 32.00m With three duplicate devices, loop0, loop1, loop3: # pvs -o+dev_size Found duplicate PV XhLbpVo0hmuwrMQLjfxuAvPFUFZqD4vr: using /dev/loop1 not /dev/loop0 Found duplicate PV XhLbpVo0hmuwrMQLjfxuAvPFUFZqD4vr: using /dev/loop3 not /dev/loop1 PV VG Fmt Attr PSize PFree DevSize /dev/loop3 loopa lvm2 a-- 12.00m 12.00m 32.00m # pvs -o+dev_size /dev/loop3 Found duplicate PV XhLbpVo0hmuwrMQLjfxuAvPFUFZqD4vr: using /dev/loop1 not /dev/loop0 Found duplicate PV XhLbpVo0hmuwrMQLjfxuAvPFUFZqD4vr: using /dev/loop3 not /dev/loop1 PV VG Fmt Attr PSize PFree DevSize /dev/loop3 loopa lvm2 a-- 12.00m 12.00m 32.00m # pvs -o+dev_size /dev/loop0 Found duplicate PV XhLbpVo0hmuwrMQLjfxuAvPFUFZqD4vr: using /dev/loop1 not /dev/loop0 Found duplicate PV XhLbpVo0hmuwrMQLjfxuAvPFUFZqD4vr: using /dev/loop3 not /dev/loop1 PV VG Fmt Attr PSize PFree DevSize /dev/loop3 loopa lvm2 a-- 12.00m 12.00m 32.00m # pvs -o+dev_size /dev/loop1 Found duplicate PV XhLbpVo0hmuwrMQLjfxuAvPFUFZqD4vr: using /dev/loop1 not /dev/loop0 Found duplicate PV XhLbpVo0hmuwrMQLjfxuAvPFUFZqD4vr: using /dev/loop3 not /dev/loop1 PV VG Fmt Attr PSize PFree DevSize /dev/loop3 loopa lvm2 a-- 12.00m 12.00m 32.00m # pvs -o+dev_size /dev/loop3 /dev/loop0 Found duplicate PV XhLbpVo0hmuwrMQLjfxuAvPFUFZqD4vr: using /dev/loop1 not /dev/loop0 Found duplicate PV XhLbpVo0hmuwrMQLjfxuAvPFUFZqD4vr: using /dev/loop3 not /dev/loop1 PV VG Fmt Attr PSize PFree DevSize /dev/loop0 loopa lvm2 a-- 12.00m 12.00m 16.00m /dev/loop3 loopa lvm2 a-- 12.00m 12.00m 32.00m # pvs -o+dev_size /dev/loop3 /dev/loop1 Found duplicate PV XhLbpVo0hmuwrMQLjfxuAvPFUFZqD4vr: using /dev/loop1 not /dev/loop0 Found duplicate PV XhLbpVo0hmuwrMQLjfxuAvPFUFZqD4vr: using /dev/loop3 not /dev/loop1 PV VG Fmt Attr PSize PFree DevSize /dev/loop1 loopa lvm2 a-- 12.00m 12.00m 32.00m /dev/loop3 loopa lvm2 a-- 12.00m 12.00m 32.00m # pvs -o+dev_size /dev/loop0 /dev/loop1 Found duplicate PV XhLbpVo0hmuwrMQLjfxuAvPFUFZqD4vr: using /dev/loop1 not /dev/loop0 Found duplicate PV XhLbpVo0hmuwrMQLjfxuAvPFUFZqD4vr: using /dev/loop3 not /dev/loop1 PV VG Fmt Attr PSize PFree DevSize /dev/loop1 loopa lvm2 a-- 12.00m 12.00m 32.00m /dev/loop3 loopa lvm2 a-- 12.00m 12.00m 32.00m # pvs -o+dev_size /dev/loop0 /dev/loop1 /dev/loop3 Found duplicate PV XhLbpVo0hmuwrMQLjfxuAvPFUFZqD4vr: using /dev/loop1 not /dev/loop0 Found duplicate PV XhLbpVo0hmuwrMQLjfxuAvPFUFZqD4vr: using /dev/loop3 not /dev/loop1 PV VG Fmt Attr PSize PFree DevSize /dev/loop0 loopa lvm2 a-- 12.00m 12.00m 16.00m /dev/loop1 loopa lvm2 a-- 12.00m 12.00m 32.00m /dev/loop3 loopa lvm2 a-- 12.00m 12.00m 32.00m
* toollib: handle duplicate pvs in process_in_pvDavid Teigland2015-01-141-39/+100
| | | | | | | | | | | | | | | | | | | | | | | | Processes a PV once for each time a device with its PV ID exists on the command line. This fixes a regression in the case where: . devices /dev/sdA and /dev/sdB where clones (same PV ID) . the cached VG references /dev/sdA . before the regression, the command: pvs /dev/sdB would display the cached device clone /dev/sdA . after the regression, pvs /dev/sdB would display nothing, causing vgimportclone /dev/sdB to fail. . with this fix, pvs /dev/sdB displays /dev/sdA Also, pvs /dev/sdA /dev/sdB will report two lines, one for each device on the command line, but /dev/sdA is displayed for each. This only works without lvmetad.
* thin: errrorwhenfull supportZdenek Kabelac2015-01-143-1/+18
| | | | | | | Support error_if_no_space feature for thin pools. Report more info about thinpool status: (out_of_data (D), metadata_read_only (M), failed (F) also as health attribute.)
* cleanup: update API for segment reportingZdenek Kabelac2015-01-141-51/+59
| | | | | | | | | API for seg reporting is breaking internal lvm coding - it cannot use vgmem mem pool for allocation of reported value. So use separate pool instead of 'vgmem' for non vg related allocations Add consts for many function params - but still many other are left for now as non-const - needs deeper level of change even on libdm side.
* pvscan: notify lvmetad about device that is gone and pvscan is run with ↵Peter Rajnoha2015-01-121-2/+11
| | | | | | | | | | | | | | | | | | | | | | device path instead of major:minor pair If pvscan is run with device path instead of major:minor pair and this device still exists in the system and the device is not visible anymore (due to a filter that is applied), notify lvmetad properly about this. This makes it more consistent with respect to existing pvscan with major:minor which already notifies lvmetad about device that is gone due to filters. However, if the device is not in the system anymore, we're not able to translate the original device path into major:minor pair which lvmetad needs for its action (lvmetad_pv_gone fn). So in this case, we still need to use major:minor pair only, not device path. But at least make "pvscan --cache DevicePath" as near as possible to "pvscan --cahce <major>:<minor>" functionality. Also add a note to pvscan man page about this difference when using pvscan --cache with DevicePath and major:minor pair.
* toollib: process_each_pv should match by deviceDavid Teigland2015-01-091-24/+72
| | | | | | | | | | | | | | | When processing PVs specified on the command line, the arg name was being matched against pv_dev_name, which will not always work: - The PV specified on the command line could be an alias, e.g. /dev/disk/by-id/... - The PV specified on the command line could be any random path to the device, e.g. /dev/../dev/sdb To fix this, first resolve the named PV args to struct device's, then iterate through the devices for processing.
* pvremove: Avoid metadata re-reads & related error messages.Petr Rockai2015-01-061-7/+8
|
* tools, man: --binary option is available with -C for {pv,vg,lv}displayPeter Rajnoha2014-12-114-9/+17
| | | | | | The {pv,vg,lv}display *do* use reporting in case "-C|--columns" is used. The man page was correct, the recognition for the --binary was missing in the code though!
* config: add report/compact_output lvm.conf setting to enable or isable field ↵Peter Rajnoha2014-12-051-0/+5
| | | | | | | | | | | | | | | | | | | | | | compacting $ lvm dumpconfig report/compact_output compact_output=0 $ lvs vg LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert lvol0 vg owi-a-s--- 4.00m lvol1 vg -wi-a----- 4.00m lvol2 vg swi-a-s--- 4.00m lvol0 0.00 $ lvm dumpconfig report/compact_output compact_output=1 $ lvs vg LV VG Attr LSize Origin Data% lvol0 vg owi-a-s--- 4.00m lvol1 vg -wi-a----- 4.00m lvol2 vg swi-a-s--- 4.00m lvol0 0.00
* lvcreate: Implement --cachepolicy/--cachesettings.Petr Rockai2014-11-272-2/+20
|
* toollib: Fix uninitialised config value type in get_cachepolicy_params.Petr Rockai2014-11-271-0/+1
|
* toollib: fix regression in parsing /dev/mapper/vg-lvZdenek Kabelac2014-11-261-2/+2
| | | | | Commit b0dde9e8f026ddd679 introduced regression in parsing /dev/mapper prefix - and tried to check for '/' one char behind.
* coverity: fix possible NULL dereferencePeter Rajnoha2014-11-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | The call to dm_config_destroy can derefence result->mem while result is still NULL: struct dm_config_tree *get_cachepolicy_params(struct cmd_context *cmd) { ... int ok = 0; ... if (!(result = dm_config_flatten(current))) goto_out; ... ok = 1; out: if (!ok) { dm_config_destroy(result) ... } ... }
* cache: comment out unsupported pooldatasizeZdenek Kabelac2014-11-241-3/+4
| | | | | Support for pooldatasize is not yet finished, so keep it commented out for now.
* lvconvert: earlier detection of conflicting namesZdenek Kabelac2014-11-241-0/+25
| | | | | Detect same LV names for lvconvert prior opening VG. i.e. lvconvert --thinpool vg/lvol0 -T lvol0
* cleanup: add missing error path checkZdenek Kabelac2014-11-231-1/+2
| | | | New code misses error path check.
* pool: prevent pool conversion with same nameZdenek Kabelac2014-11-231-4/+11
| | | | | When same name is given for converted volume and pool volume, stop further command processing.
* cleanup: drop unused varsZdenek Kabelac2014-11-201-1/+1
|
* toollib: Split --cachesettings from --cachepolicy.Petr Rockai2014-11-204-29/+32
|
* lvchange: Accept --cachepolicy.Petr Rockai2014-11-202-1/+34
|
* toollib: Add --cachepolicy and implement get_cachepolicy_params.Petr Rockai2014-11-203-0/+72
|