]> sourceware.org Git - lvm2.git/commitdiff
Only do one full device scan during each read of text format metadata.
authorAlasdair Kergon <agk@redhat.com>
Tue, 16 Mar 2010 17:30:00 +0000 (17:30 +0000)
committerAlasdair Kergon <agk@redhat.com>
Tue, 16 Mar 2010 17:30:00 +0000 (17:30 +0000)
WHATS_NEW
lib/cache/lvmcache.c
lib/cache/lvmcache.h
lib/format_text/format-text.c
lib/format_text/import_vsn1.c
lib/metadata/metadata.c

index 44278deae5e98ee707d46b31ee0e6fdcbb3c4e44..b3ff206fec4c7dba972e1ee08efed8dddce12178 100644 (file)
--- 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.
index 7f59aa6361f8ef094114914fa5d8822753c33a33..05e908d1315aa497d0abbb0e13bde0865080beea 100644 (file)
@@ -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))) {
index 37193a90f8a1016b4a7de7c6897ca88fe175f42e..ba11ff31f4d9543e33cf35c68cfaabe873efc4e0 100644 (file)
@@ -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);
 
index 079a2a3a9b00330e8f5d8f3753b1845c0d300c7f..ad4db345dbfcc2b8eea58839e36fa901d5a79e49 100644 (file)
@@ -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)))
index fd045cc6c8df91290a4f0320307d1b8079489234..83c95fbefb2d6175b5fdc5810b2f3f1d30cb92f7 100644 (file)
@@ -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;
        }
 
index 11376ef1a7fc9c05c21a00f007fda87bd037beb6..dcf1aa9191c439d01b6755201e2720c28c00a39d 100644 (file)
@@ -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)))
This page took 0.047623 seconds and 5 git commands to generate.