Bug 1112544

Summary: Provide criteria-based LVM processing
Product: [Fedora] Fedora Reporter: Peter Rajnoha <prajnoha>
Component: lvm2Assignee: Peter Rajnoha <prajnoha>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: rawhideCC: agk, bmarzins, bmr, dwysocha, heinzm, jonathan, lvm-team, mcsontos, msnitzer, prajnoha, prockai, zkabelac
Target Milestone: ---Keywords: FutureFeature
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: lvm2-2.02.118-1.fc23 Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-05-05 12:15:18 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Peter Rajnoha 2014-06-24 07:37:40 UTC
This is continuation of bz #867376 which should cover criteria-based LVM processing. Similarly as in bz #867376 where the selection criteria are applied for reporting, let's reuse the same logic for LVM processing too - we should be able to execute a non-reporting LVM command to process only volumes that match selection criteria.

A few examples:

  lvchange -ay --select 'lv_size > 1g'
  (activate LVs where the size is more than 1g)

  vgchange --metadatacopies 4 --select '(pv_count > 30) && (pv_count < 50)'
  (keep 4 metadata copies managed in VGs with PV count more than 30 and less than 50)

   pvchange --allocatable n 'pv_size < 10g'
   (disable allocation on PVs less than 10g)

   ...and so on and similarly including other possible fields. Inspect which fields may be causing problems - one issue that could be hit is that the selection is actually done on fields which we normally report - there must be a mapping between these fields and internal PV/VG/LV structures where we keep this information. The comparison logic must be adapted to this. Currently, it compares selection fields with reporting fields - we should be able to replace the reporting field with the PV/VG/LV structure and make it possible to do direct comparisons with values stored in these structures...

(We probably don't need this for dmsetup.)

Comment 1 Peter Rajnoha 2014-12-02 13:45:13 UTC
Current development branch:
  https://git.fedorahosted.org/cgit/lvm2.git/log/?h=dev-prajnoha-tool-select

(not adequate for review yet - it's still work in progress)

More patches will follow, this is an early version of the code supporting this feature. The --select is not yet recognized in LVM processing tools, I haven't done any testing yet... I'll be updating this branch progressively.

Comment 2 Marian Csontos 2015-05-05 11:55:01 UTC
Is not this merged?

Comment 3 Peter Rajnoha 2015-05-05 12:15:18 UTC
Yes, this code is merged already since lvm2 v 2.02.117 (the nearest released rawhide package is lvm2-2.02.118-1.fc23).

We've added support for selection in these LVM processing commands:
  pvchange, vgchange, lvchange
  vgremove, lvremove
  vgimport, vgexport

Also these reporting commands (but not using libdevmapper's reporting infrastructure):

  pvdisplay, vgdisplay, lvdisplay if used without -C

(With -C option, it uses libdevmapper's reporting infra and hence it already supported selection even before.)