diff options
-rw-r--r-- | lib/cache/lvmcache.c | 21 | ||||
-rw-r--r-- | lib/cache/lvmcache.h | 3 | ||||
-rw-r--r-- | tools/toollib.c | 13 |
3 files changed, 33 insertions, 4 deletions
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c index 932b1ca33..6cdf766f3 100644 --- a/lib/cache/lvmcache.c +++ b/lib/cache/lvmcache.c @@ -1467,6 +1467,27 @@ int lvmcache_update_vg(struct volume_group *vg, unsigned precommitted) return 1; } +/* + * Replace pv->dev with dev so that dev will appear for reporting. + */ + +void lvmcache_replace_dev(struct cmd_context *cmd, struct physical_volume *pv, + struct device *dev) +{ + struct lvmcache_info *info; + char pvid_s[ID_LEN + 1] __attribute__((aligned(8))); + + strncpy(pvid_s, (char *) &pv->id, sizeof(pvid_s) - 1); + pvid_s[sizeof(pvid_s) - 1] = '\0'; + + if (!(info = lvmcache_info_from_pvid(pvid_s, 0))) + return; + + info->dev = dev; + info->label->dev = dev; + pv->dev = dev; +} + struct lvmcache_info *lvmcache_add(struct labeller *labeller, const char *pvid, struct device *dev, const char *vgname, const char *vgid, diff --git a/lib/cache/lvmcache.h b/lib/cache/lvmcache.h index d43866dca..7a049175b 100644 --- a/lib/cache/lvmcache.h +++ b/lib/cache/lvmcache.h @@ -157,4 +157,7 @@ unsigned lvmcache_mda_count(struct lvmcache_info *info); int lvmcache_vgid_is_cached(const char *vgid); uint64_t lvmcache_smallest_mda_size(struct lvmcache_info *info); +void lvmcache_replace_dev(struct cmd_context *cmd, struct physical_volume *pv, + struct device *dev); + #endif diff --git a/tools/toollib.c b/tools/toollib.c index e739ecf9e..9d2b88b8c 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -2221,6 +2221,7 @@ static int _process_pvs_in_vg(struct cmd_context *cmd, struct physical_volume *pv; struct pv_list *pvl; struct device_id_list *dil; + struct device *dev_orig; const char *pv_name; int process_pv; int dev_found; @@ -2298,17 +2299,21 @@ static int _process_pvs_in_vg(struct cmd_context *cmd, _device_list_remove(arg_devices, dil->dev); /* - * This will simply display the same PV - * multiple times. Further changes would - * be needed to make this display the details - * of dil->dev instead of pv->dev. + * Replace pv->dev with this dil->dev + * in lvmcache so the duplicate dev + * info will be reported. */ + dev_orig = pv->dev; + lvmcache_replace_dev(cmd, pv, dil->dev); ret = process_single_pv(cmd, vg, pv, handle); if (ret != ECMD_PROCESSED) stack; if (ret > ret_max) ret_max = ret; + + /* Put the cache state back as it was. */ + lvmcache_replace_dev(cmd, pv, dev_orig); } } } |