]> sourceware.org Git - lvm2.git/commitdiff
Suppress repeated errors about the same missing PV uuids.
authorAlasdair Kergon <agk@redhat.com>
Wed, 17 Mar 2010 02:11:18 +0000 (02:11 +0000)
committerAlasdair Kergon <agk@redhat.com>
Wed, 17 Mar 2010 02:11:18 +0000 (02:11 +0000)
Bypass full device scans when using internally-cached VG metadata.

WHATS_NEW
lib/cache/lvmcache.c
lib/cache/lvmcache.h
lib/format_text/import-export.h
lib/format_text/import.c
lib/format_text/import_vsn1.c

index b3ff206fec4c7dba972e1ee08efed8dddce12178..409288b142ea2550067d0769020f2cd68c166077 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,7 @@
 Version 2.02.63 - 
 ================================
+  Suppress repeated errors about the same missing PV uuids.
+  Bypass full device scans when using internally-cached VG metadata.
   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.
index e5e5fbe18dc49f31a072c0307cbca646ac587c80..0ce034a79cb47bd6efb40684ece881de07762769 100644 (file)
@@ -704,7 +704,7 @@ struct dm_list *lvmcache_get_pvids(struct cmd_context *cmd, const char *vgname,
 }
 
 struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid,
-                               int *scan_done_once)
+                               unsigned *scan_done_once)
 {
        struct label *label;
        struct lvmcache_info *info;
index ba11ff31f4d9543e33cf35c68cfaabe873efc4e0..8eeb49511ba9a685d7e434523d7ba15082a0aee2 100644 (file)
@@ -94,7 +94,7 @@ 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,
-                               int *scan_done_once);
+                               unsigned *scan_done_once);
 int vgs_locked(void);
 int vgname_is_locked(const char *vgname);
 
index edb01f2e2128fec9498db3c259ebaecf0f89d273..019c739e7b52d4d1c425d5ac1e1a9d4f765877e9 100644 (file)
@@ -46,7 +46,8 @@ enum {
 struct text_vg_version_ops {
        int (*check_version) (struct config_tree * cf);
        struct volume_group *(*read_vg) (struct format_instance * fid,
-                                        struct config_tree * cf);
+                                        struct config_tree * cf,
+                                        unsigned use_cached_pvs);
        void (*read_desc) (struct dm_pool * mem, struct config_tree * cf,
                           time_t *when, char **desc);
        const char *(*read_vgname) (const struct format_type *fmt,
index 39626b89a450cf4295cfd79a839610025b37b58a..03ff990788acb8b806a708e08751e526f0278e4f 100644 (file)
@@ -111,7 +111,7 @@ struct volume_group *text_vg_import_fd(struct format_instance *fid,
                if (!(*vsn)->check_version(cft))
                        continue;
 
-               if (!(vg = (*vsn)->read_vg(fid, cft)))
+               if (!(vg = (*vsn)->read_vg(fid, cft, 0)))
                        goto_out;
 
                (*vsn)->read_desc(fid->fmt->cmd->mem, cft, when, desc);
@@ -146,7 +146,11 @@ struct volume_group *import_vg_from_buffer(char *buf,
        for (vsn = &_text_vsn_list[0]; *vsn; vsn++) {
                if (!(*vsn)->check_version(cft))
                        continue;
-               if (!(vg = (*vsn)->read_vg(fid, cft)))
+               /*
+                * The only path to this point uses cached vgmetadata,
+                * so it can use cached PV state too.
+                */
+               if (!(vg = (*vsn)->read_vg(fid, cft, 1)))
                        stack;
                break;
        }
index 83c95fbefb2d6175b5fdc5810b2f3f1d30cb92f7..7e7d60f70b4f97effa968e83317f60ef8053612e 100644 (file)
@@ -28,7 +28,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,
-                          int *scan_done_once);
+                          unsigned *scan_done_once,
+                          unsigned report_missing_devices);
 
 #define _read_int32(root, path, result) \
        get_config_uint32(root, path, (uint32_t *) result)
@@ -154,7 +155,8 @@ 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, int *scan_done_once)
+                   struct dm_hash_table *pv_hash, unsigned *scan_done_once,
+                   unsigned report_missing_devices)
 {
        struct physical_volume *pv;
        struct pv_list *pvl;
@@ -191,10 +193,11 @@ static int _read_pv(struct format_instance *fid, struct dm_pool *mem,
                char buffer[64] __attribute((aligned(8)));
 
                if (!id_write_format(&pv->id, buffer, sizeof(buffer)))
-                       log_error("Couldn't find device.");
+                       buffer[0] = '\0';
+               if (report_missing_devices)
+                       log_error("Couldn't find device with uuid %s.", buffer);
                else
-                       log_error("Couldn't find device with uuid '%s'.",
-                                 buffer);
+                       log_very_verbose("Couldn't find device with uuid %s.", buffer);
        }
 
        if (!(pv->vg_name = dm_pool_strdup(mem, vg->name)))
@@ -492,7 +495,8 @@ static int _read_lvnames(struct format_instance *fid __attribute((unused)),
                         struct volume_group *vg, struct config_node *lvn,
                         struct config_node *vgn __attribute((unused)),
                         struct dm_hash_table *pv_hash __attribute((unused)),
-                        int *scan_done_once __attribute((unused)))
+                        unsigned *scan_done_once __attribute((unused)),
+                        unsigned report_missing_devices __attribute((unused)))
 {
        struct logical_volume *lv;
        struct config_node *cn;
@@ -559,7 +563,8 @@ static int _read_lvsegs(struct format_instance *fid __attribute((unused)),
                        struct volume_group *vg, struct config_node *lvn,
                        struct config_node *vgn __attribute((unused)),
                        struct dm_hash_table *pv_hash,
-                       int *scan_done_once __attribute((unused)))
+                       unsigned *scan_done_once __attribute((unused)),
+                       unsigned report_missing_devices __attribute((unused)))
 {
        struct logical_volume *lv;
        struct lv_list *lvl;
@@ -612,10 +617,12 @@ static int _read_sections(struct format_instance *fid,
                          const char *section, section_fn fn,
                          struct dm_pool *mem,
                          struct volume_group *vg, struct config_node *vgn,
-                         struct dm_hash_table *pv_hash, int optional)
+                         struct dm_hash_table *pv_hash, int optional,
+                         unsigned *scan_done_once)
 {
        struct config_node *n;
-       int scan_done_once = 0;
+       /* Only report missing devices when doing a scan */
+       unsigned report_missing_devices = scan_done_once ? !*scan_done_once : 1;
 
        if (!(n = find_config_node(vgn, section))) {
                if (!optional) {
@@ -627,7 +634,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, &scan_done_once))
+               if (!fn(fid, mem, vg, n, vgn, pv_hash, scan_done_once, report_missing_devices))
                        return_0;
        }
 
@@ -635,12 +642,14 @@ static int _read_sections(struct format_instance *fid,
 }
 
 static struct volume_group *_read_vg(struct format_instance *fid,
-                                    struct config_tree *cft)
+                                    struct config_tree *cft,
+                                    unsigned use_cached_pvs)
 {
        struct config_node *vgn, *cn;
        struct volume_group *vg;
        struct dm_hash_table *pv_hash = NULL;
        struct dm_pool *mem = dm_pool_create("lvm2 vg_read", VG_MEMPOOL_CHUNK);
+       unsigned scan_done_once = use_cached_pvs;
 
        if (!mem)
                return_NULL;
@@ -743,7 +752,7 @@ static struct volume_group *_read_vg(struct format_instance *fid,
 
        dm_list_init(&vg->pvs);
        if (!_read_sections(fid, "physical_volumes", _read_pv, mem, vg,
-                           vgn, pv_hash, 0)) {
+                           vgn, pv_hash, 0, &scan_done_once)) {
                log_error("Couldn't find all physical volumes for volume "
                          "group %s.", vg->name);
                goto bad;
@@ -761,14 +770,14 @@ static struct volume_group *_read_vg(struct format_instance *fid,
        }
 
        if (!_read_sections(fid, "logical_volumes", _read_lvnames, mem, vg,
-                           vgn, pv_hash, 1)) {
+                           vgn, pv_hash, 1, NULL)) {
                log_error("Couldn't read all logical volume names for volume "
                          "group %s.", vg->name);
                goto bad;
        }
 
        if (!_read_sections(fid, "logical_volumes", _read_lvsegs, mem, vg,
-                           vgn, pv_hash, 1)) {
+                           vgn, pv_hash, 1, NULL)) {
                log_error("Couldn't read all logical volumes for "
                          "volume group %s.", vg->name);
                goto bad;
This page took 0.050881 seconds and 5 git commands to generate.