mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-19 14:04:17 +03:00
b77497cbd8
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.