Update lvm2 from LVM2.2.03.12 to LVM2.2.03.15 (latest version) OBS-URL: https://build.opensuse.org/request/show/958732 OBS-URL: https://build.opensuse.org/package/show/Base:System/lvm2?expand=0&rev=305
135 lines
4.4 KiB
Diff
135 lines
4.4 KiB
Diff
From 1126be8f8dbce482e82d8f98a7e7f4b7cd2cac34 Mon Sep 17 00:00:00 2001
|
|
From: David Teigland <teigland@redhat.com>
|
|
Date: Thu, 24 Feb 2022 15:57:29 -0600
|
|
Subject: devices: simplify dev_cache_get_by_devt
|
|
|
|
remove unused args, and no callers need or want a
|
|
repeated dev_cache_scan if there is no dev from the
|
|
lookup.
|
|
---
|
|
lib/device/dev-cache.c | 60 ++++--------------------------------------
|
|
lib/device/dev-cache.h | 2 +-
|
|
lib/label/label.c | 6 ++---
|
|
3 files changed, 9 insertions(+), 59 deletions(-)
|
|
|
|
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
|
|
index d3fae494869d..1777628a81a0 100644
|
|
--- a/lib/device/dev-cache.c
|
|
+++ b/lib/device/dev-cache.c
|
|
@@ -1577,63 +1577,13 @@ struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct d
|
|
return dev;
|
|
}
|
|
|
|
-struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t dev, struct dev_filter *f, int *filtered)
|
|
+struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t devt)
|
|
{
|
|
- char path[PATH_MAX];
|
|
- const char *sysfs_dir;
|
|
- struct stat info;
|
|
- struct device *d = (struct device *) btree_lookup(_cache.devices, (uint32_t) dev);
|
|
- int ret;
|
|
-
|
|
- if (filtered)
|
|
- *filtered = 0;
|
|
-
|
|
- if (!d) {
|
|
- sysfs_dir = dm_sysfs_dir();
|
|
- if (sysfs_dir && *sysfs_dir) {
|
|
- /* First check if dev is sysfs to avoid useless scan */
|
|
- if (dm_snprintf(path, sizeof(path), "%sdev/block/%d:%d",
|
|
- sysfs_dir, (int)MAJOR(dev), (int)MINOR(dev)) < 0) {
|
|
- log_error("dm_snprintf partition failed.");
|
|
- return NULL;
|
|
- }
|
|
-
|
|
- if (lstat(path, &info)) {
|
|
- log_debug("No sysfs entry for %d:%d errno %d at %s.",
|
|
- (int)MAJOR(dev), (int)MINOR(dev), errno, path);
|
|
- return NULL;
|
|
- }
|
|
- }
|
|
-
|
|
- log_debug_devs("Device num not found in dev_cache repeat dev_cache_scan for %d:%d",
|
|
- (int)MAJOR(dev), (int)MINOR(dev));
|
|
- dev_cache_scan(cmd);
|
|
- d = (struct device *) btree_lookup(_cache.devices, (uint32_t) dev);
|
|
-
|
|
- if (!d)
|
|
- return NULL;
|
|
- }
|
|
-
|
|
- if (d->flags & DEV_REGULAR)
|
|
- return d;
|
|
-
|
|
- if (!f)
|
|
- return d;
|
|
-
|
|
- ret = f->passes_filter(cmd, f, d, NULL);
|
|
-
|
|
- if (ret == -EAGAIN) {
|
|
- log_debug_devs("get device by number defer filter %s", dev_name(d));
|
|
- d->flags |= DEV_FILTER_AFTER_SCAN;
|
|
- ret = 1;
|
|
- }
|
|
-
|
|
- if (ret)
|
|
- return d;
|
|
-
|
|
- if (filtered)
|
|
- *filtered = 1;
|
|
+ struct device *dev = (struct device *) btree_lookup(_cache.devices, (uint32_t) devt);
|
|
|
|
+ if (dev)
|
|
+ return dev;
|
|
+ log_debug_devs("No devno %d:%d in dev cache.", (int)MAJOR(devt), (int)MINOR(devt));
|
|
return NULL;
|
|
}
|
|
|
|
diff --git a/lib/device/dev-cache.h b/lib/device/dev-cache.h
|
|
index 449bfeb7511c..a88e3c282207 100644
|
|
--- a/lib/device/dev-cache.h
|
|
+++ b/lib/device/dev-cache.h
|
|
@@ -54,7 +54,7 @@ int dev_cache_has_scanned(void);
|
|
int dev_cache_add_dir(const char *path);
|
|
struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct dev_filter *f);
|
|
|
|
-struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t device, struct dev_filter *f, int *filtered);
|
|
+struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t devt);
|
|
|
|
struct device *dev_hash_get(const char *name);
|
|
|
|
diff --git a/lib/label/label.c b/lib/label/label.c
|
|
index fe2bc8fec743..66d6e7db7a6e 100644
|
|
--- a/lib/label/label.c
|
|
+++ b/lib/label/label.c
|
|
@@ -1134,7 +1134,7 @@ int label_scan_vg_online(struct cmd_context *cmd, const char *vgname,
|
|
dm_list_iterate_items(po, &pvs_online) {
|
|
if (po->dev)
|
|
continue;
|
|
- if (!(po->dev = dev_cache_get_by_devt(cmd, po->devno, NULL, NULL))) {
|
|
+ if (!(po->dev = dev_cache_get_by_devt(cmd, po->devno))) {
|
|
log_error("No device found for %d:%d PVID %s",
|
|
(int)MAJOR(po->devno), (int)MINOR(po->devno), po->pvid);
|
|
goto bad;
|
|
@@ -1722,7 +1722,7 @@ void label_scan_invalidate_lv(struct cmd_context *cmd, struct logical_volume *lv
|
|
if (lv_info(cmd, lv, 0, &lvinfo, 0, 0) && lvinfo.exists) {
|
|
/* FIXME: Still unclear what is it supposed to find */
|
|
devt = MKDEV(lvinfo.major, lvinfo.minor);
|
|
- if ((dev = dev_cache_get_by_devt(cmd, devt, NULL, NULL)))
|
|
+ if ((dev = dev_cache_get_by_devt(cmd, devt)))
|
|
label_scan_invalidate(dev);
|
|
}
|
|
}
|
|
@@ -1742,7 +1742,7 @@ void label_scan_invalidate_lvs(struct cmd_context *cmd, struct dm_list *lvs)
|
|
if (dm_dev->uuid &&
|
|
strncmp(dm_dev->uuid, UUID_PREFIX, sizeof(UUID_PREFIX) - 1) == 0) {
|
|
devt = MKDEV(dm_dev->major, dm_dev->minor);
|
|
- if ((dev = dev_cache_get_by_devt(cmd, devt, NULL, NULL)))
|
|
+ if ((dev = dev_cache_get_by_devt(cmd, devt)))
|
|
label_scan_invalidate(dev);
|
|
}
|
|
/* ATM no further caching for any lvconvert command
|
|
--
|
|
2.34.1
|
|
|