]> sourceware.org Git - lvm2.git/commitdiff
metadata: Avoid pv_read in find_pv_by_name.
authorPetr Rockai <prockai@redhat.com>
Tue, 19 Feb 2013 01:32:25 +0000 (02:32 +0100)
committerPetr Rockai <prockai@redhat.com>
Sun, 17 Nov 2013 20:41:27 +0000 (21:41 +0100)
lib/metadata/metadata.c

index 869d368fbddfbab9b6cd6c91d9032140d8fe022c..b67d59645d3abadf3bd6268ceacd1b62814d2645 100644 (file)
@@ -1330,7 +1330,7 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name,
        /* FIXME Check partition type is LVM unless --force is given */
 
        /* Is there a pv here already? */
-       if (!(pv = pv_read(cmd, name, 0, 0)))
+       if (!(pv = find_pv_by_name(cmd, name, 1)))
                stack;
 
        /*
@@ -1824,23 +1824,29 @@ struct physical_volume *find_pv_by_name(struct cmd_context *cmd,
                                        const char *pv_name,
                                        int allow_orphan)
 {
-       struct physical_volume *pv;
+       struct device *dev;
+       struct pv_list *pvl;
+       struct dm_list *pvslist;
+       struct physical_volume *pv = NULL;
+
+       lvmcache_seed_infos_from_lvmetad(cmd);
 
-       if (!(pv = _pv_read(cmd, cmd->mem, pv_name, NULL, 1, 0))) {
+       if (!(dev = dev_cache_get(pv_name, cmd->filter))) {
                log_error("Physical volume %s not found", pv_name);
-               goto bad;
+               return_NULL;
        }
 
-       if (is_orphan_vg(pv->vg_name) && dm_list_empty(&pv->fid->metadata_areas_in_use)) {
-               /* If a PV has no MDAs - need to search all VGs for it */
-               if (!scan_vgs_for_pvs(cmd, 1))
-                       goto_bad;
-               free_pv_fid(pv);
-               if (!(pv = _pv_read(cmd, cmd->mem, pv_name, NULL, 1, 0))) {
-                       log_error("Physical volume %s not found", pv_name);
-                       goto bad;
-               }
-       }
+       if (!(pvslist = get_pvs(cmd)))
+               return_NULL;
+
+       dm_list_iterate_items(pvl, pvslist)
+               if (pvl->pv->dev == dev)
+                       pv = pvl->pv;
+               else
+                       free_pv_fid(pvl->pv);
+
+       if (!pv)
+               log_error("Physical volume %s not found", pv_name);
 
        if (pv && !allow_orphan && is_orphan_vg(pv->vg_name)) {
                log_error("Physical volume %s not in a volume group", pv_name);
This page took 0.038957 seconds and 5 git commands to generate.