summaryrefslogtreecommitdiff
path: root/lib/label
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2021-12-15 11:45:22 +0100
committerZdenek Kabelac <zkabelac@redhat.com>2021-12-20 16:13:28 +0100
commit04fbffb116eaf5fb1b10785df92966d0083b270f (patch)
treea413bc19386ae583d649d6559120c44a777dbefa /lib/label
parent0d67bc96fd15b9f3110bdc824749805c8392b04a (diff)
downloadlvm2-04fbffb116eaf5fb1b10785df92966d0083b270f.tar.gz
label: cache dm device list
Since we check for present DM devices - cache result for futher use of checking presence of such device. lvm2 uses cache result for label scan, but also when it tries to activate or deactivate LV - however only simple target 'striped' is reasonably supported. Use disable_dm_devs to be able to control when lv_info() get cache or uncached results. TODO: support more type, however this is getting very complicated.
Diffstat (limited to 'lib/label')
-rw-r--r--lib/label/label.c35
-rw-r--r--lib/label/label.h1
2 files changed, 36 insertions, 0 deletions
diff --git a/lib/label/label.c b/lib/label/label.c
index 5c77a6923..8676b9e4a 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -1719,6 +1719,41 @@ void label_scan_invalidate_lv(struct cmd_context *cmd, struct logical_volume *lv
}
}
+void label_scan_invalidate_lvs(struct cmd_context *cmd, struct dm_list *lvs)
+{
+ struct dm_list *devs;
+ struct dm_active_device *dm_dev;
+ unsigned devs_features = 0;
+ struct device *dev;
+ struct lv_list *lvl;
+ dev_t devt;
+
+ if (get_device_list(NULL, &devs, &devs_features)) {
+ if (devs_features & DM_DEVICE_LIST_HAS_UUID) {
+ dm_list_iterate_items(dm_dev, devs)
+ 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)))
+ label_scan_invalidate(dev);
+ }
+ /* ATM no further caching for any lvconvert command
+ * TODO: any other command to be skipped ??
+ */
+ if (strcmp(cmd->name, "lvconvert")) {
+ dm_device_list_destroy(&cmd->cache_dm_devs);
+ cmd->cache_dm_devs = devs; /* cache to avoid unneeded checks */
+ devs = NULL;
+ }
+ }
+ dm_device_list_destroy(&devs);
+ }
+
+ if (!(devs_features & DM_DEVICE_LIST_HAS_UUID))
+ dm_list_iterate_items(lvl, lvs)
+ label_scan_invalidate_lv(cmd, lvl->lv);
+}
+
/*
* Empty the bcache of all blocks and close all open fds,
* but keep the bcache set up.
diff --git a/lib/label/label.h b/lib/label/label.h
index 3cda1818c..26784c3e8 100644
--- a/lib/label/label.h
+++ b/lib/label/label.h
@@ -110,6 +110,7 @@ int label_scan_devs_excl(struct cmd_context *cmd, struct dev_filter *f, struct d
int label_scan_dev(struct cmd_context *cmd, struct device *dev);
void label_scan_invalidate(struct device *dev);
void label_scan_invalidate_lv(struct cmd_context *cmd, struct logical_volume *lv);
+void label_scan_invalidate_lvs(struct cmd_context *cmd, struct dm_list *lvs);
void label_scan_drop(struct cmd_context *cmd);
void label_scan_destroy(struct cmd_context *cmd);
int label_scan_setup_bcache(void);