From: Alasdair Kergon Date: Tue, 16 Mar 2010 17:30:00 +0000 (+0000) Subject: Only do one full device scan during each read of text format metadata. X-Git-Tag: old-v2_02_63~177 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=5197fd72c408010894d5283cd92772af3fe48458;p=lvm2.git Only do one full device scan during each read of text format metadata. --- diff --git a/WHATS_NEW b/WHATS_NEW index 44278deae..b3ff206fe 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.63 - ================================ + Only do one full device scan during each read of text format metadata. Remove unnecessary full_scan parameter from get_vgids and get_vgnames calls. Look up missing PVs by uuid not dev_name in _pvs_single to avoid invalid stat. Make find_pv_in_vg_by_uuid() return same type as related functions. diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c index 7f59aa636..05e908d13 100644 --- a/lib/cache/lvmcache.c +++ b/lib/cache/lvmcache.c @@ -703,7 +703,8 @@ struct dm_list *lvmcache_get_pvids(struct cmd_context *cmd, const char *vgname, return pvids; } -struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid) +struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid, + int *scan_done_once) { struct label *label; struct lvmcache_info *info; @@ -728,10 +729,11 @@ struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid) } } - if (memlock()) + if (memlock() || (scan_done_once && *scan_done_once)) return NULL; lvmcache_label_scan(cmd, 2); + *scan_done_once = 1; /* Try again */ if ((info = info_from_pvid((char *) pvid, 0))) { diff --git a/lib/cache/lvmcache.h b/lib/cache/lvmcache.h index 37193a90f..ba11ff31f 100644 --- a/lib/cache/lvmcache.h +++ b/lib/cache/lvmcache.h @@ -93,7 +93,8 @@ struct lvmcache_vginfo *vginfo_from_vgname(const char *vgname, struct lvmcache_vginfo *vginfo_from_vgid(const char *vgid); struct lvmcache_info *info_from_pvid(const char *pvid, int valid_only); const char *vgname_from_vgid(struct dm_pool *mem, const char *vgid); -struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid); +struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid, + int *scan_done_once); int vgs_locked(void); int vgname_is_locked(const char *vgname); diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c index 079a2a3a9..ad4db345d 100644 --- a/lib/format_text/format-text.c +++ b/lib/format_text/format-text.c @@ -2025,7 +2025,7 @@ static int _get_config_disk_area(struct cmd_context *cmd, return 0; } - if (!(dev_area.dev = device_from_pvid(cmd, &id))) { + if (!(dev_area.dev = device_from_pvid(cmd, &id, NULL))) { char buffer[64] __attribute((aligned(8))); if (!id_write_format(&id, buffer, sizeof(buffer))) diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c index fd045cc6c..83c95fbef 100644 --- a/lib/format_text/import_vsn1.c +++ b/lib/format_text/import_vsn1.c @@ -27,7 +27,8 @@ typedef int (*section_fn) (struct format_instance * fid, struct dm_pool * mem, struct volume_group * vg, struct config_node * pvn, struct config_node * vgn, - struct dm_hash_table * pv_hash); + struct dm_hash_table * pv_hash, + int *scan_done_once); #define _read_int32(root, path, result) \ get_config_uint32(root, path, (uint32_t *) result) @@ -153,7 +154,7 @@ static int _read_flag_config(struct config_node *n, uint64_t *status, int type) static int _read_pv(struct format_instance *fid, struct dm_pool *mem, struct volume_group *vg, struct config_node *pvn, struct config_node *vgn __attribute((unused)), - struct dm_hash_table *pv_hash) + struct dm_hash_table *pv_hash, int *scan_done_once) { struct physical_volume *pv; struct pv_list *pvl; @@ -186,7 +187,7 @@ static int _read_pv(struct format_instance *fid, struct dm_pool *mem, /* * Convert the uuid into a device. */ - if (!(pv->dev = device_from_pvid(fid->fmt->cmd, &pv->id))) { + if (!(pv->dev = device_from_pvid(fid->fmt->cmd, &pv->id, scan_done_once))) { char buffer[64] __attribute((aligned(8))); if (!id_write_format(&pv->id, buffer, sizeof(buffer))) @@ -490,7 +491,8 @@ static int _read_lvnames(struct format_instance *fid __attribute((unused)), struct dm_pool *mem, struct volume_group *vg, struct config_node *lvn, struct config_node *vgn __attribute((unused)), - struct dm_hash_table *pv_hash __attribute((unused))) + struct dm_hash_table *pv_hash __attribute((unused)), + int *scan_done_once __attribute((unused))) { struct logical_volume *lv; struct config_node *cn; @@ -556,7 +558,8 @@ static int _read_lvsegs(struct format_instance *fid __attribute((unused)), struct dm_pool *mem, struct volume_group *vg, struct config_node *lvn, struct config_node *vgn __attribute((unused)), - struct dm_hash_table *pv_hash) + struct dm_hash_table *pv_hash, + int *scan_done_once __attribute((unused))) { struct logical_volume *lv; struct lv_list *lvl; @@ -612,6 +615,7 @@ static int _read_sections(struct format_instance *fid, struct dm_hash_table *pv_hash, int optional) { struct config_node *n; + int scan_done_once = 0; if (!(n = find_config_node(vgn, section))) { if (!optional) { @@ -623,7 +627,7 @@ static int _read_sections(struct format_instance *fid, } for (n = n->child; n; n = n->sib) { - if (!fn(fid, mem, vg, n, vgn, pv_hash)) + if (!fn(fid, mem, vg, n, vgn, pv_hash, &scan_done_once)) return_0; } diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index 11376ef1a..dcf1aa919 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -1416,7 +1416,7 @@ struct physical_volume * pvcreate_single(struct cmd_context *cmd, pp = &default_pp; if (pp->idp) { - if ((dev = device_from_pvid(cmd, pp->idp)) && + if ((dev = device_from_pvid(cmd, pp->idp, NULL)) && (dev != dev_cache_get(pv_name, cmd->filter))) { if (!id_write_format((const struct id*)&pp->idp->uuid, buffer, sizeof(buffer)))