linux-lvm.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Zdenek Kabelac <zkabelac@redhat.com>
To: LVM general discussion and development <linux-lvm@redhat.com>,
	Martin Wilck <mwilck@suse.com>,
	Heming Zhao <heming.zhao@suse.com>
Subject: Re: [linux-lvm] confused with lvm2 filter rules
Date: Tue, 25 Jun 2019 10:56:52 +0200	[thread overview]
Message-ID: <ef7fae62-36c9-02a9-2f72-1378f62a7468@redhat.com> (raw)
In-Reply-To: <891f3b74ead41e1fa86471e1085d6b4a8253da80.camel@suse.com>

Dne 25. 06. 19 v 9:56 Martin Wilck napsal(a):
> Hello Zdenek,
> 
> On Tue, 2019-06-25 at 05:30 +0000, Heming Zhao wrote:
>> Hello Zdenek,
>>
>> I raise this topic again. Lvm should have bug in filter code.
>> Let me show the example.
>>
>> filter = [ "a|^/dev/sd.*|", "r|.*|" ]
>> As document description, above filter rules:
>>    deny all the devices except "/dev/sd.*"
>>
>> issue:
>>    pvcreate executes successfully with "/dev/disk/by-id/xxx", but
>> vgextend doesn't.
>>
>> expect result:
>>    pvcreate should deny the device "/dev/disk/by-id/xxx".
>>
> 
> I disagree with Heming in this point. IMO both pvcreate and vgextend
> should accept the device because of the first "a" rule. In any case,
> it's obviously wrong that the two tools behave differently.
> 
> Note also that this difference occurs only if lvmetad is used. Without
> lvmetad, both commands accept the device. The reason is that in this
> case, lvmcache_label_scan(), which also builds the alias tree, is
> called before applying the filter. With lvmetad OTOH,
> lvmcache_label_scan() is basically a noop.
> 
> IMO this should be fixed by adding a call to
> lvmcache_seed_infos_from_lvmetad() before applying the device filter to
> vgextend. vgcreate() calls it early on, right after
> lvmcache_label_scan(); the same might work for vgextend as well.
> Alternatively, it might be possible to add a call to
> lvmcache_seed_infos_from_lvmetad() to pvcreate_each_device(); in that
> case it might even be possible to remove the early calls in vgcreate().
> I don't understand the initialization sequence of LVM2 commands well
> enough to create a patch myself. Besides vgextend, other LVM2 commands
> that need to apply the filter may be affected, too, as
> lvmcache_seed_infos_from_lvmetad() seems to be used only in a few hand-
> selected code paths.
> 
> I suspect that this problem came to be in David's "label_scan" patch
> series in April 2018. But we haven't verified that yet. I've put David
> on CC.
> 
>>
>> analysis:
>>
>> vgextend log excerpt: the aliases DB is built up _after_ applying
>> the I've put
>> filter, which falsely rejects the device.
>> ```log
>>    lvmcmdline.c:2888    Processing command: vgextend -vvvv -dddddd -t
>> testvg /dev/disk/by-id/scsi-36001405bbbdf17a69ad46ffb287a3340-part3
>>    device/dev-cache.c:723     Found dev 8:35
>> /dev/disk/by-id/scsi-36001405bbbdf17a69ad46ffb287a3340-part3 - new.
>>    filters/filter-regex.c:172
>> /dev/disk/by-id/scsi-36001405bbbdf17a69ad46ffb287a3340-part3:
>> Skipping
>> (regex)
>>    filters/filter-persistent.c:346     filter caching bad
>> /dev/disk/by-id/scsi-36001405bbbdf17a69ad46ffb287a3340-part3
>>    ...
>>    device/dev-cache.c:1212    Creating list of system devices.
>>    device/dev-cache.c:763     Found dev 8:35 /dev/sdc3 - new alias
>>    device/dev-cache.c:763     Found dev 8:35
>> /dev/disk/by-id/iscsi-iqn.2018-06.de.suse.mwilck:sles15u-sp1-
>> 01_i_iface:default-1--iqn.2018-06.de.suse.zeus:01_t_0x1-lun-3-part3
>> - new alias.
>> ```
>>
>> vgcreate: the aliases DB is built up before applying the filter,
>> which
>> works correctly now.
>> ```log
>>    lvmcmdline.c:2888    Processing command: vgcreate -vvvv -dddddd -t
>> tvg1 /dev/disk/by-id/scsi-36001405bbbdf17a69ad46ffb287a3340-part3
>>    device/dev-cache.c:1212    Creating list of system devices.
>>    device/dev-cache.c:723     Found dev 8:35 /dev/sdc3 - new.
>>    device/dev-cache.c:763     Found dev 8:35
>> /dev/disk/by-id/iscsi-iqn.2018-06.de.suse.mwilck:sles15u-sp1-
>> 01_i_iface:default-1--iqn.2018-06.de.suse.zeus:01_t_0x1-lun-3-part3
>> - new alias.
>>    filters/filter-persistent.c:312     /dev/sdc3: filter cache using
>> (cached good)
>> ```
>>
>> pvcreate will convert "/dev/disk/by-id/xxx" into another name
>> "/dev/sdX", which can pass the filter rule.
> 
> A bit more precisely: when running pvcreate (or vgcreate), by the time
> the filter is called, "/dev/sdX" has been added to the list of aliases
> and thus the device is accepted, whereas in a vgextend run, the list of
> aliases has not been built up yet, and contains only a single member
> "/dev/disk/by-id/...", which is rejected.
>


Please open bugzilla with your findings:

https://bugzilla.redhat.com/enter_bug.cgi?product=LVM%20and%20device-mapper

Thanks

Zdenek

  reply	other threads:[~2019-06-25  8:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-03 13:03 [linux-lvm] confused with lvm2 filter rules Heming Zhao
2019-06-05  2:41 ` Heming Zhao
2019-06-05 10:20 ` Zdenek Kabelac
2019-06-06  6:42   ` Heming Zhao
2019-06-06  8:16   ` Heming Zhao
2019-06-06  8:43     ` Zdenek Kabelac
2019-06-06 13:30       ` Heming Zhao
2019-06-06 13:51         ` Zdenek Kabelac
2019-06-10  2:43           ` Heming Zhao
     [not found]             ` <60982841-fabc-71d9-b8b1-6d98b87ba738@suse.com>
2019-06-25  7:56               ` Martin Wilck
2019-06-25  8:56                 ` Zdenek Kabelac [this message]
2019-06-25  9:13                   ` Heming Zhao
2019-06-26  6:49                     ` Heming Zhao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ef7fae62-36c9-02a9-2f72-1378f62a7468@redhat.com \
    --to=zkabelac@redhat.com \
    --cc=heming.zhao@suse.com \
    --cc=linux-lvm@redhat.com \
    --cc=mwilck@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).