mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Remove the unused lock_hash in lvmcache
It kept track of which VGs were locked, but is no longer used, so remove it.
This commit is contained in:
parent
981a3ba98e
commit
be3af7f93e
56
lib/cache/lvmcache.c
vendored
56
lib/cache/lvmcache.c
vendored
@ -67,14 +67,12 @@ struct lvmcache_vginfo {
|
||||
static struct dm_hash_table *_pvid_hash = NULL;
|
||||
static struct dm_hash_table *_vgid_hash = NULL;
|
||||
static struct dm_hash_table *_vgname_hash = NULL;
|
||||
static struct dm_hash_table *_lock_hash = NULL;
|
||||
static DM_LIST_INIT(_vginfos);
|
||||
static DM_LIST_INIT(_found_duplicate_devs);
|
||||
static DM_LIST_INIT(_unused_duplicate_devs);
|
||||
static int _scanning_in_progress = 0;
|
||||
static int _has_scanned = 0;
|
||||
static int _vgs_locked = 0;
|
||||
static int _vg_global_lock_held = 0; /* Global lock held when cache wiped? */
|
||||
static int _found_duplicate_pvs = 0; /* If we never see a duplicate PV we can skip checking for them later. */
|
||||
|
||||
int lvmcache_init(struct cmd_context *cmd)
|
||||
@ -98,19 +96,6 @@ int lvmcache_init(struct cmd_context *cmd)
|
||||
if (!(_pvid_hash = dm_hash_create(128)))
|
||||
return 0;
|
||||
|
||||
if (!(_lock_hash = dm_hash_create(128)))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Reinitialising the cache clears the internal record of
|
||||
* which locks are held. The global lock can be held during
|
||||
* this operation so its state must be restored afterwards.
|
||||
*/
|
||||
if (_vg_global_lock_held) {
|
||||
lvmcache_lock_vgname(VG_GLOBAL, 0);
|
||||
_vg_global_lock_held = 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -131,25 +116,12 @@ void lvmcache_seed_infos_from_lvmetad(struct cmd_context *cmd)
|
||||
|
||||
void lvmcache_lock_vgname(const char *vgname, int read_only __attribute__((unused)))
|
||||
{
|
||||
if (dm_hash_lookup(_lock_hash, vgname))
|
||||
log_error(INTERNAL_ERROR "Nested locking attempted on VG %s.",
|
||||
vgname);
|
||||
|
||||
if (!dm_hash_insert(_lock_hash, vgname, (void *) 1))
|
||||
log_error("Cache locking failure for %s", vgname);
|
||||
|
||||
if (strcmp(vgname, VG_GLOBAL))
|
||||
_vgs_locked++;
|
||||
}
|
||||
|
||||
void lvmcache_unlock_vgname(const char *vgname)
|
||||
{
|
||||
if (!dm_hash_lookup(_lock_hash, vgname))
|
||||
log_error(INTERNAL_ERROR "Attempt to unlock unlocked VG %s.",
|
||||
vgname);
|
||||
|
||||
dm_hash_remove(_lock_hash, vgname);
|
||||
|
||||
/* FIXME Do this per-VG */
|
||||
if (strcmp(vgname, VG_GLOBAL) && !--_vgs_locked) {
|
||||
dev_size_seqno_inc(); /* invalidate all cached dev sizes */
|
||||
@ -1912,26 +1884,8 @@ static void _lvmcache_destroy_vgnamelist(struct lvmcache_vginfo *vginfo)
|
||||
} while ((vginfo = next));
|
||||
}
|
||||
|
||||
static void _lvmcache_destroy_lockname(struct dm_hash_node *n)
|
||||
{
|
||||
char *vgname;
|
||||
|
||||
if (!dm_hash_get_data(_lock_hash, n))
|
||||
return;
|
||||
|
||||
vgname = dm_hash_get_key(_lock_hash, n);
|
||||
|
||||
if (!strcmp(vgname, VG_GLOBAL))
|
||||
_vg_global_lock_held = 1;
|
||||
else
|
||||
log_error(INTERNAL_ERROR "Volume Group %s was not unlocked",
|
||||
dm_hash_get_key(_lock_hash, n));
|
||||
}
|
||||
|
||||
void lvmcache_destroy(struct cmd_context *cmd, int retain_orphans, int reset)
|
||||
{
|
||||
struct dm_hash_node *n;
|
||||
|
||||
log_debug_cache("Dropping VG info");
|
||||
|
||||
_has_scanned = 0;
|
||||
@ -1954,16 +1908,6 @@ void lvmcache_destroy(struct cmd_context *cmd, int retain_orphans, int reset)
|
||||
_vgname_hash = NULL;
|
||||
}
|
||||
|
||||
if (_lock_hash) {
|
||||
if (reset)
|
||||
_vg_global_lock_held = 0;
|
||||
else
|
||||
dm_hash_iterate(n, _lock_hash)
|
||||
_lvmcache_destroy_lockname(n);
|
||||
dm_hash_destroy(_lock_hash);
|
||||
_lock_hash = NULL;
|
||||
}
|
||||
|
||||
if (!dm_list_empty(&_vginfos))
|
||||
log_error(INTERNAL_ERROR "_vginfos list should be empty");
|
||||
dm_list_init(&_vginfos);
|
||||
|
Loading…
Reference in New Issue
Block a user