summaryrefslogtreecommitdiff
path: root/lib/misc
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2017-11-01 09:35:40 -0500
committerDavid Teigland <teigland@redhat.com>2018-04-20 11:22:45 -0500
commitd9a77e8bb4d25af33625d3cdddf5288207101d5b (patch)
tree25237c7113d4c6c236b7821e30aa27af9d0177d5 /lib/misc
parent79c4971210a6337563ffa2fca08fb636423d93d4 (diff)
downloadlvm2-d9a77e8bb4d25af33625d3cdddf5288207101d5b.tar.gz
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.
Diffstat (limited to 'lib/misc')
-rw-r--r--lib/misc/lvm-globals.c12
-rw-r--r--lib/misc/lvm-globals.h2
2 files changed, 0 insertions, 14 deletions
diff --git a/lib/misc/lvm-globals.c b/lib/misc/lvm-globals.c
index 0575d21a4..0f384bbec 100644
--- a/lib/misc/lvm-globals.c
+++ b/lib/misc/lvm-globals.c
@@ -53,8 +53,6 @@ static int _activation_checks = 0;
static char _sysfs_dir_path[PATH_MAX] = "";
static int _dev_disable_after_error_count = DEFAULT_DISABLE_AFTER_ERROR_COUNT;
static uint64_t _pv_min_size = (DEFAULT_PV_MIN_SIZE_KB * 1024L >> SECTOR_SHIFT);
-static int _detect_internal_vg_cache_corruption =
- DEFAULT_DETECT_INTERNAL_VG_CACHE_CORRUPTION;
static const char *_unknown_device_name = DEFAULT_UNKNOWN_DEVICE_NAME;
void init_verbose(int level)
@@ -197,11 +195,6 @@ void init_pv_min_size(uint64_t sectors)
_pv_min_size = sectors;
}
-void init_detect_internal_vg_cache_corruption(int detect)
-{
- _detect_internal_vg_cache_corruption = detect;
-}
-
void set_cmd_name(const char *cmd)
{
(void) dm_strncpy(_cmd_name, cmd, sizeof(_cmd_name));
@@ -384,11 +377,6 @@ uint64_t pv_min_size(void)
return _pv_min_size;
}
-int detect_internal_vg_cache_corruption(void)
-{
- return _detect_internal_vg_cache_corruption;
-}
-
const char *unknown_device_name(void)
{
return _unknown_device_name;
diff --git a/lib/misc/lvm-globals.h b/lib/misc/lvm-globals.h
index 14a7d4366..e23d5984d 100644
--- a/lib/misc/lvm-globals.h
+++ b/lib/misc/lvm-globals.h
@@ -51,7 +51,6 @@ void init_udev_checking(int checking);
void init_dev_disable_after_error_count(int value);
void init_pv_min_size(uint64_t sectors);
void init_activation_checks(int checks);
-void init_detect_internal_vg_cache_corruption(int detect);
void init_retry_deactivation(int retry);
void init_unknown_device_name(const char *name);
@@ -85,7 +84,6 @@ int udev_checking(void);
const char *sysfs_dir_path(void);
uint64_t pv_min_size(void);
int activation_checks(void);
-int detect_internal_vg_cache_corruption(void);
int retry_deactivation(void);
const char *unknown_device_name(void);