1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

cache: Set correct vgid when changing PV header.

pv_write is called both to write orphans and to rewrite PV headers
of PVs in VGs.  It needs to select the correct VG id so that the
internal cache state gets updated correctly.

It only affected commands that involved further steps after
the pv_write and was often masked because the metadata would
be re-read off disk and correct itself.

"Incorrect metadata area header checksum" warnings appeared.

Example:
  Create vg1 containing dev1, dev2 and dev3.
  Hide dev1 and dev2 from the system.
  Fix up vg1 with vgreduce --removemissing.
  Bring back dev1 and dev2.
  In a single operation reinstate dev1 and dev2 into vg1 (vgextend).
Done as separate operations (automatically fix-up dev1 and dev2 as orphans,
then vgextend) it worked, but done all in one go the internal cache got
corrupted and warnings about checksum errors appeared.
This commit is contained in:
Alasdair G Kergon 2015-04-09 21:13:55 +01:00
parent 249d4a921c
commit a9d48bae2f
3 changed files with 5 additions and 2 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.119 - Version 2.02.119 -
================================== ==================================
Set correct vgid when updating cache when writing PV metadata.
More efficient clvmd singlenode locking emulation. More efficient clvmd singlenode locking emulation.
Don't skip invalidation of cached orphans if vg write lck is held (2.02.118). Don't skip invalidation of cached orphans if vg write lck is held (2.02.118).
Log relevant PV tags when using cling allocation. Log relevant PV tags when using cling allocation.

View File

@ -1544,6 +1544,7 @@ struct lvmcache_info *lvmcache_add(struct labeller *labeller, const char *pvid,
.vgstatus = vgstatus, .vgstatus = vgstatus,
}; };
/* N.B. vgid is not NUL-terminated when called from _text_pv_write */
if (vgid) if (vgid)
strncpy((char *)&vgsummary.vgid, vgid, sizeof(vgsummary.vgid)); strncpy((char *)&vgsummary.vgid, vgid, sizeof(vgsummary.vgid));

View File

@ -1318,7 +1318,7 @@ static int _write_single_mda(struct metadata_area *mda, void *baton)
return 1; return 1;
} }
/* Only for orphans */ /* Only for orphans - FIXME That's not true any more */
static int _text_pv_write(const struct format_type *fmt, struct physical_volume *pv) static int _text_pv_write(const struct format_type *fmt, struct physical_volume *pv)
{ {
struct format_instance *fid = pv->fid; struct format_instance *fid = pv->fid;
@ -1332,7 +1332,8 @@ static int _text_pv_write(const struct format_type *fmt, struct physical_volume
/* Add a new cache entry with PV info or update existing one. */ /* Add a new cache entry with PV info or update existing one. */
if (!(info = lvmcache_add(fmt->labeller, (const char *) &pv->id, if (!(info = lvmcache_add(fmt->labeller, (const char *) &pv->id,
pv->dev, pv->vg_name, NULL, 0))) pv->dev, pv->vg_name,
is_orphan_vg(pv->vg_name) ? pv->vg_name : pv->vg ? &pv->vg->id : NULL, 0)))
return_0; return_0;
label = lvmcache_get_label(info); label = lvmcache_get_label(info);