mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-26 22:50:36 +03:00
Add possibility to handle precommitted metadata in lvmcache.
- Add drop_precommitted flag to force drop precommitted metadata - add lvmcache_commit_metadata() which upgrades precommitted metadata in cache No functional change in this patch - just preparation for following change.
This commit is contained in:
parent
ac85c2e75b
commit
d37be0b865
@ -1,5 +1,6 @@
|
||||
Version 2.02.57 -
|
||||
====================================
|
||||
Add possibility to drop precommitted metadata in lvmcache.
|
||||
Move processing of VG locks to separate function in clvmd.
|
||||
Properly decode flags even for VG locks.
|
||||
Properly handle precommitted flag in cache when commited data only present.
|
||||
|
@ -693,7 +693,7 @@ void do_lock_vg(unsigned char command, unsigned char lock_flags, char *resource)
|
||||
|
||||
pthread_mutex_lock(&lvm_lock);
|
||||
DEBUGLOG("Dropping metadata for VG %s\n", vgname);
|
||||
lvmcache_drop_metadata(vgname);
|
||||
lvmcache_drop_metadata(vgname, 0);
|
||||
pthread_mutex_unlock(&lvm_lock);
|
||||
}
|
||||
|
||||
|
36
lib/cache/lvmcache.c
vendored
36
lib/cache/lvmcache.c
vendored
@ -158,7 +158,7 @@ static void _update_cache_lock_state(const char *vgname, int locked)
|
||||
_update_cache_vginfo_lock_state(vginfo, locked);
|
||||
}
|
||||
|
||||
static void _drop_metadata(const char *vgname)
|
||||
static void _drop_metadata(const char *vgname, int drop_precommitted)
|
||||
{
|
||||
struct lvmcache_vginfo *vginfo;
|
||||
struct lvmcache_info *info;
|
||||
@ -172,26 +172,48 @@ static void _drop_metadata(const char *vgname)
|
||||
* already invalidated the PV labels (before caching it)
|
||||
* and we must not do it again.
|
||||
*/
|
||||
if (!drop_precommitted && vginfo->precommitted && !vginfo->vgmetadata)
|
||||
log_error(INTERNAL_ERROR "metadata commit (or revert) missing before "
|
||||
"dropping metadata from cache.");
|
||||
|
||||
if (!vginfo->precommitted)
|
||||
if (drop_precommitted || !vginfo->precommitted)
|
||||
dm_list_iterate_items(info, &vginfo->infos)
|
||||
info->status |= CACHE_INVALID;
|
||||
|
||||
_free_cached_vgmetadata(vginfo);
|
||||
}
|
||||
|
||||
void lvmcache_drop_metadata(const char *vgname)
|
||||
/*
|
||||
* Remote node uses this to upgrade precommited metadata to commited state
|
||||
* when receives vg_commit notification.
|
||||
* (Note that devices can be suspended here, if so, precommited metadata are already read.)
|
||||
*/
|
||||
void lvmcache_commit_metadata(const char *vgname)
|
||||
{
|
||||
struct lvmcache_vginfo *vginfo;
|
||||
|
||||
if (!(vginfo = vginfo_from_vgname(vgname, NULL)))
|
||||
return;
|
||||
|
||||
if (vginfo->precommitted) {
|
||||
log_debug("Precommitted metadata cache: VG %s upgraded to committed.",
|
||||
vginfo->vgname);
|
||||
vginfo->precommitted = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void lvmcache_drop_metadata(const char *vgname, int drop_precommitted)
|
||||
{
|
||||
/* For VG_ORPHANS, we need to invalidate all labels on orphan PVs. */
|
||||
if (!strcmp(vgname, VG_ORPHANS)) {
|
||||
_drop_metadata(FMT_TEXT_ORPHAN_VG_NAME);
|
||||
_drop_metadata(FMT_LVM1_ORPHAN_VG_NAME);
|
||||
_drop_metadata(FMT_POOL_ORPHAN_VG_NAME);
|
||||
_drop_metadata(FMT_TEXT_ORPHAN_VG_NAME, 0);
|
||||
_drop_metadata(FMT_LVM1_ORPHAN_VG_NAME, 0);
|
||||
_drop_metadata(FMT_POOL_ORPHAN_VG_NAME, 0);
|
||||
|
||||
/* Indicate that PVs could now be missing from the cache */
|
||||
init_full_scan_done(0);
|
||||
} else if (!vgname_is_locked(VG_GLOBAL))
|
||||
_drop_metadata(vgname);
|
||||
_drop_metadata(vgname, drop_precommitted);
|
||||
}
|
||||
|
||||
/*
|
||||
|
3
lib/cache/lvmcache.h
vendored
3
lib/cache/lvmcache.h
vendored
@ -111,6 +111,7 @@ struct dm_list *lvmcache_get_pvids(struct cmd_context *cmd, const char *vgname,
|
||||
|
||||
/* Returns cached volume group metadata. */
|
||||
struct volume_group *lvmcache_get_vg(const char *vgid, unsigned precommitted);
|
||||
void lvmcache_drop_metadata(const char *vgname);
|
||||
void lvmcache_drop_metadata(const char *vgname, int drop_precommitted);
|
||||
void lvmcache_commit_metadata(const char *vgname);
|
||||
|
||||
#endif
|
||||
|
@ -259,7 +259,7 @@ static int _file_lock_resource(struct cmd_context *cmd, const char *resource,
|
||||
case LCK_VG:
|
||||
/* Skip cache refresh for VG_GLOBAL - the caller handles it */
|
||||
if (strcmp(resource, VG_GLOBAL))
|
||||
lvmcache_drop_metadata(resource);
|
||||
lvmcache_drop_metadata(resource, 0);
|
||||
|
||||
/* LCK_CACHE does not require a real lock */
|
||||
if (flags & LCK_CACHE)
|
||||
|
Loading…
x
Reference in New Issue
Block a user