mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Lock memory for shared VG
Use debug pool locking functionality. So the command could check, whether the memory in the pool has not been modified. For lv_postoder() instead of unlocking and locking for every changed struct status member do it once when entering and leaving function. (mprotect would trap each such memory access). Currently lv_postoder() does not modify other part of vg structure then status flags of each LV with flags that are reverted back to its original state after function exit.
This commit is contained in:
parent
ed463ccf51
commit
031c986ea8
@ -1,5 +1,6 @@
|
||||
Version 2.02.87 -
|
||||
===============================
|
||||
Use memory pool locking to check for corruption of internal VG structs.
|
||||
Cache and share generated VG structs.
|
||||
Fix possible format instance memory leaks and premature releases in _vg_read.
|
||||
Suppress locking error messages in monitoring init scripts.
|
||||
|
8
lib/cache/lvmcache.c
vendored
8
lib/cache/lvmcache.c
vendored
@ -689,6 +689,9 @@ struct volume_group *lvmcache_get_vg(const char *vgid, unsigned precommitted)
|
||||
vginfo->vg_use_count = 0;
|
||||
vg->vginfo = vginfo;
|
||||
|
||||
if (!dm_pool_lock(vg->vgmem, 1))
|
||||
goto_bad;
|
||||
|
||||
out:
|
||||
vginfo->holders++;
|
||||
vginfo->vg_use_count++;
|
||||
@ -715,6 +718,11 @@ int vginfo_holders_dec_and_test_for_zero(struct lvmcache_vginfo *vginfo)
|
||||
log_debug("VG %s reused %d times.",
|
||||
vginfo->cached_vg->name, vginfo->vg_use_count);
|
||||
|
||||
/* Debug perform crc check only when it's been used more then once */
|
||||
if (!dm_pool_unlock(vginfo->cached_vg->vgmem,
|
||||
(vginfo->vg_use_count > 1)))
|
||||
stack;
|
||||
|
||||
vginfo->cached_vg->vginfo = NULL;
|
||||
vginfo->cached_vg = NULL;
|
||||
|
||||
|
@ -2107,8 +2107,17 @@ static int _lv_postorder(struct logical_volume *lv,
|
||||
void *data)
|
||||
{
|
||||
int r;
|
||||
int pool_locked = dm_pool_locked(lv->vg->vgmem);
|
||||
|
||||
if (pool_locked && !dm_pool_unlock(lv->vg->vgmem, 0))
|
||||
return_0;
|
||||
|
||||
r = _lv_postorder_visit(lv, fn, data);
|
||||
_lv_postorder_cleanup(lv, 0);
|
||||
|
||||
if (pool_locked && !dm_pool_lock(lv->vg->vgmem, 0))
|
||||
return_0;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -2122,6 +2131,10 @@ static int _lv_postorder_vg(struct volume_group *vg,
|
||||
{
|
||||
struct lv_list *lvl;
|
||||
int r = 1;
|
||||
int pool_locked = dm_pool_locked(vg->vgmem);
|
||||
|
||||
if (pool_locked && !dm_pool_unlock(vg->vgmem, 0))
|
||||
return_0;
|
||||
|
||||
dm_list_iterate_items(lvl, &vg->lvs)
|
||||
if (!_lv_postorder_visit(lvl->lv, fn, data)) {
|
||||
@ -2132,6 +2145,9 @@ static int _lv_postorder_vg(struct volume_group *vg,
|
||||
dm_list_iterate_items(lvl, &vg->lvs)
|
||||
_lv_postorder_cleanup(lvl->lv, 0);
|
||||
|
||||
if (pool_locked && !dm_pool_lock(vg->vgmem, 0))
|
||||
return_0;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user