mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
refactor: move and rename _dev_is_mpath_component in lvmetad.c to udev_dev_is_mpath_component in dev-type.c
This commit is contained in:
parent
29d0317557
commit
5d323c37f3
@ -1,5 +1,6 @@
|
||||
Version 2.02.165 -
|
||||
===================================
|
||||
Use udev db to check for mpath components before running pvscan for lvmetad.
|
||||
Use lsblk -s and lsblk -O in lvmdump only if these options are supported.
|
||||
Fix number of stripes shown in lvcreate raid10 message when too many.
|
||||
Do not monitor cache-pool metadata when LV is just being cleared.
|
||||
|
64
lib/cache/lvmetad.c
vendored
64
lib/cache/lvmetad.c
vendored
@ -2040,64 +2040,6 @@ out:
|
||||
return vg_ret;
|
||||
}
|
||||
|
||||
#ifdef UDEV_SYNC_SUPPORT
|
||||
static int _dev_is_mpath_component(struct udev *udev_context, struct device *dev)
|
||||
{
|
||||
struct udev_device *udev_device = NULL;
|
||||
const char *value;
|
||||
int initialized = 0;
|
||||
int i;
|
||||
int ret = 0;
|
||||
|
||||
if (!udev_context) {
|
||||
log_debug("_dev_is_mpath_component: device %s: no udev context", dev_name(dev));
|
||||
return_0;
|
||||
}
|
||||
|
||||
for (i = 1; i <= 10; i++) {
|
||||
if (udev_device)
|
||||
udev_device_unref(udev_device);
|
||||
|
||||
if (!(udev_device = udev_device_new_from_devnum(udev_context, 'b', dev->dev))) {
|
||||
log_debug("_dev_is_mpath_component: device %s: no udev device", dev_name(dev));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (udev_device_get_is_initialized(udev_device)) {
|
||||
initialized = 1;
|
||||
break;
|
||||
} else {
|
||||
log_debug("_dev_is_mpath_component: device %s: not initialized (%d)", dev_name(dev), i);
|
||||
initialized = 0;
|
||||
}
|
||||
usleep(100000);
|
||||
}
|
||||
|
||||
if (!initialized) {
|
||||
log_debug("_dev_is_mpath_component: device %s: not initialized even after waiting", dev_name(dev));
|
||||
goto_out;
|
||||
}
|
||||
|
||||
value = udev_device_get_property_value(udev_device, DEV_EXT_UDEV_BLKID_TYPE);
|
||||
|
||||
if (value && !strcmp(value, DEV_EXT_UDEV_BLKID_TYPE_MPATH)) {
|
||||
log_debug("Dev %s is mpath component (%s)", dev_name(dev), value);
|
||||
ret = 1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
value = udev_device_get_property_value(udev_device, DEV_EXT_UDEV_MPATH_DEVICE_PATH);
|
||||
if (value && !strcmp(value, "1")) {
|
||||
log_debug("Dev %s is mpath component (device path)", dev_name(dev));
|
||||
ret = 1;
|
||||
goto out;
|
||||
}
|
||||
out:
|
||||
udev_device_unref(udev_device);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
int lvmetad_pvscan_single(struct cmd_context *cmd, struct device *dev,
|
||||
struct dm_list *found_vgnames,
|
||||
struct dm_list *changed_vgnames)
|
||||
@ -2113,14 +2055,10 @@ int lvmetad_pvscan_single(struct cmd_context *cmd, struct device *dev,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef UDEV_SYNC_SUPPORT
|
||||
struct udev *udev_context = udev_get_library_context();
|
||||
|
||||
if (_dev_is_mpath_component(udev_context, dev)) {
|
||||
if (udev_dev_is_mpath_component(dev)) {
|
||||
log_debug("Ignore multipath component for pvscan.");
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!label_read(dev, &label, 0)) {
|
||||
log_print_unless_silent("No PV label found on %s.", dev_name(dev));
|
||||
|
@ -976,3 +976,69 @@ int dev_is_rotational(struct dev_types *dt, struct device *dev)
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef UDEV_SYNC_SUPPORT
|
||||
int udev_dev_is_mpath_component(struct device *dev)
|
||||
{
|
||||
struct udev *udev_context = udev_get_library_context();
|
||||
struct udev_device *udev_device = NULL;
|
||||
const char *value;
|
||||
int initialized = 0;
|
||||
int i;
|
||||
int ret = 0;
|
||||
|
||||
if (!udev_context) {
|
||||
log_debug("udev_dev_is_mpath_component: device %s: no udev context", dev_name(dev));
|
||||
return_0;
|
||||
}
|
||||
|
||||
for (i = 1; i <= 10; i++) {
|
||||
if (udev_device)
|
||||
udev_device_unref(udev_device);
|
||||
|
||||
if (!(udev_device = udev_device_new_from_devnum(udev_context, 'b', dev->dev))) {
|
||||
log_debug("udev_dev_is_mpath_component: device %s: no udev device", dev_name(dev));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (udev_device_get_is_initialized(udev_device)) {
|
||||
initialized = 1;
|
||||
break;
|
||||
} else {
|
||||
log_debug("udev_dev_is_mpath_component: device %s: not initialized (%d)", dev_name(dev), i);
|
||||
initialized = 0;
|
||||
}
|
||||
usleep(100000);
|
||||
}
|
||||
|
||||
if (!initialized) {
|
||||
log_debug("udev_dev_is_mpath_component: device %s: not initialized even after waiting", dev_name(dev));
|
||||
goto_out;
|
||||
}
|
||||
|
||||
value = udev_device_get_property_value(udev_device, DEV_EXT_UDEV_BLKID_TYPE);
|
||||
|
||||
if (value && !strcmp(value, DEV_EXT_UDEV_BLKID_TYPE_MPATH)) {
|
||||
log_debug("Dev %s is mpath component (%s)", dev_name(dev), value);
|
||||
ret = 1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
value = udev_device_get_property_value(udev_device, DEV_EXT_UDEV_MPATH_DEVICE_PATH);
|
||||
if (value && !strcmp(value, "1")) {
|
||||
log_debug("Dev %s is mpath component (%s)", dev_name(dev), DEV_EXT_UDEV_MPATH_DEVICE_PATH);
|
||||
ret = 1;
|
||||
goto out;
|
||||
}
|
||||
out:
|
||||
udev_device_unref(udev_device);
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
|
||||
int udev_dev_is_mpath_component(struct device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -59,6 +59,7 @@ int dev_is_md(struct device *dev, uint64_t *sb);
|
||||
int dev_is_swap(struct device *dev, uint64_t *signature);
|
||||
int dev_is_luks(struct device *dev, uint64_t *signature);
|
||||
int dasd_is_cdl_formatted(struct device *dev);
|
||||
int udev_dev_is_mpath_component(struct device *dev);
|
||||
|
||||
/* Signature wiping. */
|
||||
#define TYPE_LVM1_MEMBER 0x001
|
||||
|
Loading…
Reference in New Issue
Block a user