diff options
author | Alasdair G Kergon <agk@redhat.com> | 2014-04-24 09:11:18 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2014-06-17 16:25:08 -0500 |
commit | fc53acd487d71c816ca4ca8ae29212f3028e9a83 (patch) | |
tree | 8bcacd05b8088faa99b9fab3a52175b6902a3558 | |
parent | 9f321c868efaa188118a02da0117681bfe568ceb (diff) | |
download | lvm2-dev-dct-process-v16.tar.gz |
TODO: add a description for thisdev-dct-process-v16
-rw-r--r-- | lib/cache/lvmcache.c | 15 | ||||
-rw-r--r-- | lib/format_pool/disk_rep.c | 4 | ||||
-rw-r--r-- | lib/format_text/format-text.c | 2 | ||||
-rw-r--r-- | lib/locking/file_locking.c | 2 | ||||
-rw-r--r-- | lib/metadata/metadata.c | 9 |
5 files changed, 21 insertions, 11 deletions
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c index 3244205ae..caacb7df6 100644 --- a/lib/cache/lvmcache.c +++ b/lib/cache/lvmcache.c @@ -228,6 +228,10 @@ static void _update_cache_lock_state(const char *vgname, int locked) { struct lvmcache_vginfo *vginfo; + /* Ignore pure orphan lock because it doesn't correspond to lvmcache VG names */ + if (!strcmp(vgname, VG_ORPHANS)) + return; + if (!(vginfo = lvmcache_vginfo_from_vgname(vgname, NULL))) return; @@ -688,7 +692,10 @@ int lvmcache_label_scan(struct cmd_context *cmd, int full_scan) goto out; } - if (_has_scanned && !full_scan) { + if (_has_scanned && !full_scan) + goto out; + + if (_has_scanned && (full_scan == 1)) { r = _scan_invalid(); goto out; } @@ -853,7 +860,7 @@ struct dm_list *lvmcache_get_vgids(struct cmd_context *cmd, struct lvmcache_vginfo *vginfo; // TODO plug into lvmetad here automagically? - lvmcache_label_scan(cmd, 0); + lvmcache_label_scan(cmd, 1); if (!(vgids = str_list_create(cmd->mem))) { log_error("vgids list allocation failed"); @@ -880,7 +887,7 @@ struct dm_list *lvmcache_get_vgnames(struct cmd_context *cmd, struct dm_list *vgnames; struct lvmcache_vginfo *vginfo; - lvmcache_label_scan(cmd, 0); + lvmcache_label_scan(cmd, 1); if (!(vgnames = str_list_create(cmd->mem))) { log_errno(ENOMEM, "vgnames list allocation failed"); @@ -962,7 +969,7 @@ struct device *lvmcache_device_from_pvid(struct cmd_context *cmd, const struct i if (dev) return dev; - lvmcache_label_scan(cmd, 0); + lvmcache_label_scan(cmd, 1); /* Try again */ dev = _device_from_pvid(pvid, label_sector); diff --git a/lib/format_pool/disk_rep.c b/lib/format_pool/disk_rep.c index fef045198..8d428cacb 100644 --- a/lib/format_pool/disk_rep.c +++ b/lib/format_pool/disk_rep.c @@ -360,7 +360,7 @@ int read_pool_pds(const struct format_type *fmt, const char *vg_name, * accept partial pool if we've done a full rescan of * the cache */ - if (full_scan > 0) + if (full_scan > 1) return 1; } @@ -368,7 +368,7 @@ int read_pool_pds(const struct format_type *fmt, const char *vg_name, dm_list_init(pdhead); full_scan++; - if (full_scan > 1) { + if (full_scan > 2) { log_debug_metadata("No devices for vg %s found in cache", vg_name); return 0; diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c index 9b894fa65..0f57b6d0d 100644 --- a/lib/format_text/format-text.c +++ b/lib/format_text/format-text.c @@ -1939,7 +1939,7 @@ static int _create_vg_text_instance(struct format_instance *fid, */ if (!critical_section()) /* Scan PVs in VG for any further MDAs */ - lvmcache_label_scan(fid->fmt->cmd, 0); + lvmcache_label_scan(fid->fmt->cmd, 1); if (!(vginfo = lvmcache_vginfo_from_vgname(vg_name, vg_id))) goto_out; diff --git a/lib/locking/file_locking.c b/lib/locking/file_locking.c index d332101ed..efcc7a749 100644 --- a/lib/locking/file_locking.c +++ b/lib/locking/file_locking.c @@ -51,7 +51,7 @@ static int _file_lock_resource(struct cmd_context *cmd, const char *resource, switch (flags & LCK_SCOPE_MASK) { case LCK_VG: /* Skip cache refresh for VG_GLOBAL - the caller handles it */ - if (strcmp(resource, VG_GLOBAL)) + if (!is_orphan_vg(resource) && !is_global_vg(resource)) lvmcache_drop_metadata(resource, 0); if (!strcmp(resource, VG_SYNC_NAMES)) diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index 88555c967..f2f6dbed2 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -2861,6 +2861,7 @@ static int _vg_read_orphan_pv(struct lvmcache_info *info, void *baton) } /* Make orphan PVs look like a VG. */ +/* For accurate results for PVs without mdas, always read all real VGs first. */ static struct volume_group *_vg_read_orphans(struct cmd_context *cmd, uint32_t warn_flags, const char *orphan_vgname) @@ -2873,6 +2874,8 @@ static struct volume_group *_vg_read_orphans(struct cmd_context *cmd, struct pv_list head; dm_list_init(&head.list); + + /* If already scanned, assume all real VGs read and cache up-to-date. */ lvmcache_label_scan(cmd, 0); lvmcache_seed_infos_from_lvmetad(cmd); @@ -3110,7 +3113,7 @@ static struct volume_group *_vg_read(struct cmd_context *cmd, /* Find the vgname in the cache */ /* If it's not there we must do full scan to be completely sure */ if (!(fmt = lvmcache_fmt_from_vgname(cmd, vgname, vgid, 1))) { - lvmcache_label_scan(cmd, 0); + lvmcache_label_scan(cmd, 1); if (!(fmt = lvmcache_fmt_from_vgname(cmd, vgname, vgid, 1))) { /* Independent MDAs aren't supported under low memory */ if (!cmd->independent_metadata_areas && critical_section()) @@ -3810,7 +3813,7 @@ static int _get_pvs(struct cmd_context *cmd, uint32_t warn_flags, struct vg_list *vgl_item = NULL; int have_pv = 0; - lvmcache_label_scan(cmd, 0); + lvmcache_label_scan(cmd, 1); /* Get list of VGs */ if (!(vgids = get_vgids(cmd, 1))) { @@ -4359,7 +4362,7 @@ uint32_t vg_lock_newname(struct cmd_context *cmd, const char *vgname) /* Find the vgname in the cache */ /* If it's not there we must do full scan to be completely sure */ if (!lvmcache_fmt_from_vgname(cmd, vgname, NULL, 1)) { - lvmcache_label_scan(cmd, 0); + lvmcache_label_scan(cmd, 1); if (!lvmcache_fmt_from_vgname(cmd, vgname, NULL, 1)) { /* Independent MDAs aren't supported under low memory */ if (!cmd->independent_metadata_areas && critical_section()) { |