1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-30 17:18:21 +03:00
lvm2/lib/misc
David Teigland d9a77e8bb4 lvmcache: simplify metadata cache
The copy of VG metadata stored in lvmcache was not being used
in general.  It pretended to be a generic VG metadata cache,
but was not being used except for clvmd activation.  There
it was used to avoid reading from disk while devices were
suspended, i.e. in resume.

This removes the code that attempted to make this look
like a generic metadata cache, and replaces with with
something narrowly targetted to what it's actually used for.

This is a way of passing the VG from suspend to resume in
clvmd.  Since in the case of clvmd one caller can't simply
pass the same VG to both suspend and resume, suspend needs
to stash the VG somewhere that resume can grab it from.
(resume doesn't want to read it from disk since devices
are suspended.)  The lvmcache vginfo struct is used as a
convenient place to stash the VG to pass it from suspend
to resume, even though it isn't related to the lvmcache
or vginfo.  These suspended_vg* vginfo fields should
not be used or touched anywhere else, they are only to
be used for passing the VG data from suspend to resume
in clvmd.  The VG data being passed between suspend and
resume is never modified, and will only exist in the
brief period between suspend and resume in clvmd.

suspend has both old (current) and new (precommitted)
copies of the VG metadata.  It stashes both of these in
the vginfo prior to suspending devices.  When vg_commit
is successful, it sets a flag in vginfo as before,
signaling the transition from old to new metadata.

resume grabs the VG stashed by suspend.  If the vg_commit
happened, it grabs the new VG, and if the vg_commit didn't
happen it grabs the old VG.  The VG is then used to resume
LVs.

This isolates clvmd-specific code and usage from the
normal lvm vg_read code, making the code simpler and
the behavior easier to verify.

Sequence of operations:

- lv_suspend() has both vg_old and vg_new
  and stashes a copy of each onto the vginfo:
  lvmcache_save_suspended_vg(vg_old);
  lvmcache_save_suspended_vg(vg_new);

- vg_commit() happens, which causes all clvmd
  instances to call lvmcache_commit_metadata(vg).
  A flag is set in the vginfo indicating the
  transition from the old to new VG:
  vginfo->suspended_vg_committed = 1;

- lv_resume() needs either vg_old or vg_new
  to use in resuming LVs.  It doesn't want to
  read the VG from disk since devices are
  suspended, so it gets the VG stashed by
  lv_suspend:
  vg = lvmcache_get_suspended_vg(vgid);

If the vg_commit did not happen, suspended_vg_committed
will not be set, and in this case, lvmcache_get_suspended_vg()
will return the old VG instead of the new VG, and it will
resume LVs based on the old metadata.
2018-04-20 11:22:45 -05:00
..
crc_gen.c doc: change fsf address 2016-01-21 12:11:37 +01:00
crc.c cleanup: whitespace 2017-07-11 16:26:12 +02:00
crc.h doc: change fsf address 2016-01-21 12:11:37 +01:00
intl.h doc: change fsf address 2016-01-21 12:11:37 +01:00
last-path-component.h doc: change fsf address 2016-01-21 12:11:37 +01:00
lib.h lib: Move lcm and gcd to lib/misc for wider use. 2016-08-18 14:06:13 +01:00
lvm-exec.c doc: change fsf address 2016-01-21 12:11:37 +01:00
lvm-exec.h doc: change fsf address 2016-01-21 12:11:37 +01:00
lvm-file.c doc: change fsf address 2016-01-21 12:11:37 +01:00
lvm-file.h log: separate output and make it possible to use given FDs 2016-08-09 18:24:45 +02:00
lvm-flock.c locking: avoid descriptor leak for nonblocking mode 2017-08-25 14:12:55 +02:00
lvm-flock.h doc: change fsf address 2016-01-21 12:11:37 +01:00
lvm-globals.c lvmcache: simplify metadata cache 2018-04-20 11:22:45 -05:00
lvm-globals.h lvmcache: simplify metadata cache 2018-04-20 11:22:45 -05:00
lvm-maths.c lib: Move lcm and gcd to lib/misc for wider use. 2016-08-18 14:06:13 +01:00
lvm-maths.h lib: Move lcm and gcd to lib/misc for wider use. 2016-08-18 14:06:13 +01:00
lvm-percent.c doc: change fsf address 2016-01-21 12:11:37 +01:00
lvm-percent.h doc: change fsf address 2016-01-21 12:11:37 +01:00
lvm-signal.c signals: fix comparison flaw 2017-04-10 18:41:28 +02:00
lvm-signal.h doc: change fsf address 2016-01-21 12:11:37 +01:00
lvm-string.c lvm-string: add function to detect component LV suffix 2017-12-19 15:28:07 +01:00
lvm-string.h lvm-string: add function to detect component LV suffix 2017-12-19 15:28:07 +01:00
lvm-wrappers.c fix: make udev_get_library_context available also for non-udev compilations 2016-04-01 15:35:22 +02:00
lvm-wrappers.h fix: make udev_get_library_context available also for non-udev compilations 2016-04-01 15:35:22 +02:00
sharedlib.c cleanup: more usage of dm_strncpy 2018-03-06 15:40:34 +01:00
sharedlib.h doc: change fsf address 2016-01-21 12:11:37 +01:00
util.h util: add clz() and use __builtin_clz() if available 2016-12-13 20:41:29 +00:00