master - filter-usable: move check for pv_min_size from filter-partitioned to filter-usable and use new 'udev' external device info source for this check
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2fc126b00d83991c6a2f3ed9aa61457294a4c45e Commit: 2fc126b00d83991c6a2f3ed9aa61457294a4c45e Parent: 9c030e81a4e2d1e6b7024991c29114c59337553e Author: Peter Rajnoha <[email protected]> AuthorDate: Thu Jan 29 14:24:06 2015 +0100 Committer: Peter Rajnoha <[email protected]> CommitterDate: Fri Jan 30 13:01:12 2015 +0100
filter-usable: move check for pv_min_size from filter-partitioned to filter-usable and use new 'udev' external device info source for this check
The filter-partitioned code should contain only checks in "partition" domain.
The check for pv_min_size should actually be a part of filter-usable. If the device size is less than pv_min_size, such device is not usable as a PV so this check clearly belongs here logically.
With udev external info source, we can get device size via libudev's sysfs reading interface and we can avoid opening the device this way effectively.
--- lib/filters/filter-partitioned.c | 22 +------- lib/filters/filter-usable.c | 109 +++++++++++++++++++++++++++++++++++++- 2 files changed, 111 insertions(+), 20 deletions(-)
lib/filters/filter-partitioned.c +3 -19
@@ -19,39 +19,23 @@static int _passes_partitioned_filter (struct dev_filter *f,struct device *dev) {struct dev_types *dt = (struct dev_types *) f->private; -const char *name =dev_name (dev);int ret =0 ; -uint64_t size; -/* Check it's accessible */ if (!dev_open_readonly_quiet (dev)) { -log_debug_devs ("%s: Skipping: open failed" , name); +log_debug_devs ("%s: Skipping: open failed" ,dev_name (dev));return 0 ; } -/* Check it's not too small */ -if (!dev_get_size (dev, &size)) { -log_debug_devs ("%s: Skipping: dev_get_size failed" , name); - goto out; - } - -if (size <pv_min_size ()) { -log_debug_devs ("%s: Skipping: Too small to hold a PV" , name); - goto out; - } -if (dev_is_partitioned (dt, dev)) {log_debug_devs ("%s: Skipping: Partition table signature found" , - name); +dev_name (dev)); goto out; } ret =1 ; - - out: +out:if (!dev_close (dev)) stack; -return ret; }
lib/filters/filter-usable.c +108 -1
121 lines not on this page · raw message