Bug 642575

Summary: LVM filter regex causes lvm commands to fail
Product: Red Hat Enterprise Linux 6 Reporter: Saggi Mizrahi <smizrahi>
Component: lvm2Assignee: Alasdair Kergon <agk>
Status: CLOSED ERRATA QA Contact: Corey Marthaler <cmarthal>
Severity: medium Docs Contact:
Priority: urgent    
Version: 6.0CC: abaron, agk, antillon.maurizio, bazulay, coughlan, cpelland, danken, dwysocha, hateya, heinzm, iheim, jbrassow, joe.thornber, mbroz, mgoldboi, plyons, prajnoha, prockai, smizrahi, ykaul
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: lvm2-2.02.82-1.el6 Doc Type: Bug Fix
Doc Text:
Filtering with regular expressions (for example when using lvm commands to filter devices) could have failed. This was due to an error in removing a common suffix. With this update, the optimization for common suffixes works correctly.
Story Points: ---
Clone Of:
: 651349 (view as bug list) Environment:
Last Closed: 2011-05-19 14:26:51 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 651349, 652185    

Description Saggi Mizrahi 2010-10-13 11:35:15 UTC
Description of problem:

Some filters filter devices wrongly.

The original cmd:
/sbin/pvs --config " devices { preferred_names = [\"^/dev/mapper/\"] write_cache_state=0 filter = [ \"a%/dev/mapper/36000402004ec06f56089aa1400000000|/dev/mapper/36000402004ec06f56089ab3a00000000|/dev/mapper/36000402004ec06f5608a865500000000%\", \"r%.*%\" ] } "

This is an irc log excerpt that shows agk trying to narrow down the issue.

[Tuesday 12 October 2010] [19:03:01] <agk> so it's do with pulling the suffix out
[Tuesday 12 October 2010] [19:03:12] <agk> /sbin/pvs --config " devices { write_cache_state=0 filter = [ \"a%8(9aa140000000|9ab3a0000000|a86550)%\", \"r%.*%\" ] } "
[Tuesday 12 October 2010] [19:03:15] <agk> vs
[Tuesday 12 October 2010] [19:03:26] <agk> /sbin/pvs --config " devices { write_cache_state=0 filter = [ \"a%8(9aa140000000|9ab3a0000000|a8655)%\", \"r%.*%\" ] } "
[Tuesday 12 October 2010] [19:03:44] <agk> removing that last '0' it starts to work again
[Tuesday 12 October 2010] [19:04:51] <agk> So the simplest case so far:
[Tuesday 12 October 2010] [19:04:56] <agk> "a%8(9aa140|9ab3a0|a86550)%\ fails
[Tuesday 12 October 2010] [19:05:11] <agk> a%8(9aa140|9ab3a|a86550)%\
[Tuesday 12 October 2010] [19:05:12] <agk> works
[Tuesday 12 October 2010] [19:05:36] <agk> so it must be going wrong when it sees a common suffix (0) and pulls it out of the expression
[Tuesday 12 October 2010] [19:06:30] <agk> but if there are only 2 things instead of 3 between the |s it works ok
[Tuesday 12 October 2010] [19:10:48] <agk> So: /tmp/bothcmd2 is my simplest test case so far
[Tuesday 12 October 2010] [19:10:55] <agk> bothcmds2
[Tuesday 12 October 2010] [19:11:07] <agk> it runs two supposedly identical cmds but gets different output

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 6 Alasdair Kergon 2010-10-22 21:03:21 UTC
Well the conclusion from irc was that removing a common suffix was broken.

But other parts of this code were changed since that was added, so we might find rather than fixing that, removing it no longer makes any noticeable performance difference.

So (1) try removing that optimisation and see how much it slows things down;
or (2) try to fix the optimisation.

Comment 7 Alasdair Kergon 2010-11-02 20:02:06 UTC
Patch added upstream for 2.02.76.

The optimiser was ignoring '| d e' and factoring out 'a' to convert
   a b | (a c | d e)
into
   a (b | c | d e).

Comment 14 Ayal Baron 2010-11-30 20:24:34 UTC
*** Bug 653138 has been marked as a duplicate of this bug. ***

Comment 15 Eva Kopalova 2010-12-14 15:20:30 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Filtering with regular expressions (for example when using lvm commands to filter devices) could have failed. This was due to an error in removing a common suffix. With this update, the optimization for common suffixes works correctly.

Comment 17 Corey Marthaler 2011-03-08 21:17:02 UTC
Fix verified in the latest rpms.

2.6.32-114.0.1.el6.x86_64

lvm2-2.02.83-2.el6    BUILT: Tue Feb  8 10:10:57 CST 2011
lvm2-libs-2.02.83-2.el6    BUILT: Tue Feb  8 10:10:57 CST 2011
lvm2-cluster-2.02.83-2.el6    BUILT: Tue Feb  8 10:10:57 CST 2011
udev-147-2.33.el6    BUILT: Wed Feb  9 09:56:24 CST 2011
device-mapper-1.02.62-2.el6    BUILT: Tue Feb  8 10:10:57 CST 2011
device-mapper-libs-1.02.62-2.el6    BUILT: Tue Feb  8 10:10:57 CST 2011
device-mapper-event-1.02.62-2.el6    BUILT: Tue Feb  8 10:10:57 CST 2011
device-mapper-event-libs-1.02.62-2.el6    BUILT: Tue Feb  8 10:10:57 CST 2011
cmirror-2.02.83-2.el6    BUILT: Tue Feb  8 10:10:57 CST 2011


Scan with a regex filter:

     filter = [ "r|hda|hdc|sdc|" ]

[root@grant-01 bin]# pvscan
  WARNING: Ignoring duplicate config node: filter (seeking filter)
  PV /dev/sdb1   VG vg1          lvm2 [204.34 GiB / 204.34 GiB free]
  PV /dev/sdc1   VG vg1          lvm2 [272.46 GiB / 272.46 GiB free]
  PV /dev/sda2   VG vg_grant01   lvm2 [74.01 GiB / 0    free]
  Total: 3 [550.82 GiB] / in use: 3 [550.82 GiB] / in no VG: 0 [0   ]
[root@grant-01 bin]# echo $?
0

Comment 18 errata-xmlrpc 2011-05-19 14:26:51 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-0772.html