master - scan: use full md filter when md 1.0 devices are present
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3fd75d1bcd714b02fb2b843d1928b2a875402f37 Commit: 3fd75d1bcd714b02fb2b843d1928b2a875402f37 Parent: 8eab37593eccbbb8c6d03a9bae2f6852c17a00a5 Author: David Teigland <[email protected]> AuthorDate: Fri Jun 15 11:42:10 2018 -0500 Committer: David Teigland <[email protected]> CommitterDate: Fri Jun 15 12:21:25 2018 -0500
scan: use full md filter when md 1.0 devices are present
The md filter can operate in two native modes:
- normal: reads only the start of each device
- full: reads both the start and end of each device
md 1.0 devices place the superblock at the end of the device, so components of this version will only be identified and excluded when lvm uses the full md filter.
Previously, the full md filter was only used in commands that could write to the device. Now, the full md filter is also applied when there is an md 1.0 device present on the system. This means the 'pvs' command can avoid displaying md 1.0 components (at the cost of doubling the i/o to every device on the system.)
(The md filter can operate in a third mode, using udev, but this is disabled by default because there have been problems with reliability of the info returned from udev.)
--- lib/cache/lvmcache.c | 2 +- lib/device/dev-md.c | 27 +++++++++--- lib/device/dev-type.h | 1 + lib/filters/filter-md.c | 81 ++++++++++++++++------------------- lib/label/label.c | 14 ++++++ test/shell/pvcreate-md-fake-hdr.sh | 3 +- 6 files changed, 75 insertions(+), 53 deletions(-)
lib/cache/lvmcache.c +1 -1
@@ -452,7 +452,7 @@ int lvmcache_dev_is_unchosen_duplicate(struct device *dev)* unused_duplicate_devs list, and restrict what we allow done with it. * * In the case of md components, we usually filter these out in filter-md, -* but in the special case of md superblocks <= 1.0 where the superblock +* but in the special case of md superblock version 1.0 where the superblock * is@the end of the device, filter-md doesn't always eliminate them * first, so we eliminate them here. *
lib/device/dev-md.c +20 -7
@@ -142,13 +142,6 @@ static int _native_dev_is_md(struct device *dev, uint64_t *offset_found, int ful* command if it should do a full check (cmd->use_full_md_check), * and set it for commands that could possibly write to an md dev * (pvcreate/vgcreate/vgextend). -* -* For old md versions with magic numbers at the end of devices, -* the md dev components won't be filtered out here when full is 0, -* so they will be scanned, and appear as duplicate PVs in lvmcache. -* The md device itself will be chosen as the primary duplicate, -* and the components are dropped from the list of duplicates in, -* i.e. a kind of post-scan filtering. */ if (!full) { sb_offset =0 ;
@@ -414,6 +407,26 @@ unsigned long dev_md_stripe_width(struct dev_types *dt, struct device *dev)return stripe_width_sectors; } +int dev_is_md_with_end_superblock (struct dev_types *dt,struct device *dev) +{ +char version_string[MD_MAX_SYSFS_SIZE ]; +const char *attribute ="metadata_version" ; + +if (MAJOR (dev->dev) != dt->md_major) +return 0 ; + +if (_md_sysfs_attribute_scanf (dt, dev, attribute, +"%s" , &version_string) !=1 ) +return -1 ; + +log_very_verbose ("Device %s %s is %s." , +dev_name (dev), attribute, version_string); + +if (!strcmp (version_string,"1.0" )) +return 1 ; +return 0 ; +} +#else int dev_is_md(struct device *dev __attribute__((unused)),
lib/device/dev-type.h +1 -0
@@ -76,6 +76,7 @@ int wipe_known_signatures(struct cmd_context *cmd, struct device *dev, const cha/* Type-specific device properties */ unsigned long dev_md_stripe_width (struct dev_types *dt,struct device *dev); +int dev_is_md_with_end_superblock (struct dev_types *dt,struct device *dev);/* Partitioning */ int major_max_partitions (struct dev_types *dt,int major);
lib/filters/filter-md.c +37 -44
87 lines not on this page · raw message
lib/label/label.c +14 -0
@@ -847,6 +847,20 @@ int label_scan(struct cmd_context *cmd)bcache_invalidate_fd (scan_bcache, dev->bcache_fd);_scan_dev_close (dev); } + +/* +* When md devices exist that use the old superblock at the +* end of the device, then in order to detect and filter out +* the component devices of those md devs, we need to enable +* the full md filter which scans both the start and the end +* of every device. This doubles the amount of scanning i/o, +* which we want to avoid. FIXME: it may not be worth the +* cost of double i/o just to avoid displaying md component +* devs in 'pvs', which is a pretty harmless effect from a +* pretty uncommon situation. +*/ +if (dev_is_md_with_end_superblock (cmd->dev_types, dev)) + cmd->use_full_md_check =1 ; };dev_iter_destroy (iter);
test/shell/pvcreate-md-fake-hdr.sh +2 -1
@@ -95,6 +95,7 @@ sleep 1 # (when mdadm supports repair) if mdadm --action=repair "$mddev" ; then sleep 1 + pvscan -vvvv # should be showing correctly PV3 & PV4 - pvs + pvs -vvvv "$dev3" "$dev4" fi