]> sourceware.org Git - lvm2.git/commit
filters: make sure regex filter is evaluated before any filter that needs disk access
authorPeter Rajnoha <prajnoha@redhat.com>
Tue, 8 Sep 2015 13:03:15 +0000 (15:03 +0200)
committerPeter Rajnoha <prajnoha@redhat.com>
Tue, 8 Sep 2015 13:28:10 +0000 (15:28 +0200)
commitb77497cbd86a854add3ffa4ce09a35f165c0d2ba
treeaa25e8718861cfe724ea6d32fa16e92bbe6974e6
parent596ec5c74b604de42f105032b7e13065ea67d281
filters: make sure regex filter is evaluated before any filter that needs disk access

The regex filter (controlled by devices/filter lvm.conf setting) was
evaluated as the very last filter. However, this is not optimal when
it comes to restricting disk access - users define devices/filter
as well as devices/global_filter to avoid this.

The devices/global_filter is already positioned at the beginning of the
filter chain. We need to do the same for devices/filter.

Filter chains before this patch:

  A: when lvmetad is not used:
       persistent_filter -> sysfs_filter -> global_regex_filter ->
       type_filter -> usable->filter -> mpath_component_filter ->
       partition_filter -> md_component_filter -> fw_raid_filter ->
       regex_filter

  B: when lvmetad is used:

    B1: to update lvmetad:
      sysfs_filter -> global_regex_filter -> type_filter ->
      usable_filter -> mpath_component_filter -> partition_filter ->
      md_component_filter -> fw_raid_filter

    B2: to retrieve info from lvmetad:
      persistent_filter -> usable_filter -> regex_filter

From the chain list above we can see that particularly in case when
lvmetad is not used, the regex filter is the very last one that is
processed. If lvmetad is used, it doesn't matter much as there's
the global_regex_filter which is used instead when updating lvmetad
and when retrieving info from lvmetad, putting regex_filter in front
of usable_filter wouldn't change much since usabled_filter is not
reading disks directly.

This patch puts the regex filter to the front even in case lvmetad
is not used, hence reinstating the state as it was before commit
a7be3b12dfe7388d1648595e6cc4c7a1379bb8a7 (which moved the regex_filter
position in the chain). Still, the arguments for the commit
a7be3b12dfe7388d1648595e6cc4c7a1379bb8a7 still apply and they're
still satisfied since component filters (MD, mpath...) are evaluated
first just before updating lvmetad.

So with this patch, we end up with:

  A: when lvmetad is not used:
       persistent_filter -> sysfs_filter -> global_regex_filter ->
       regex_filter -> type_filter -> usable->filter ->
       mpath_component_filter -> partition_filter ->
       md_component_filter -> fw_raid_filter

  B: when lvmetad is used:

    B1: to update lvmetad:
      sysfs_filter -> global_regex_filter -> type_filter ->
      usable_filter -> mpath_component_filter -> partition_filter ->
      md_component_filter -> fw_raid_filter

    B2: to retrieve info from lvmetad:
      persistent_filter -> regex_filter -> usable_filter

This way, specifying the regex_filter in non-lvmetad case causes
the devices to be filtered based on regex first before processing
any other filters which can access disks (like md_component_filter).

This patch also streamlines the code for better readability.
lib/commands/toolcontext.c
This page took 0.037973 seconds and 5 git commands to generate.