1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

Fix possible increasing in memory allocation if refreshing_context

(for example when CLVMD_CMD_LOCK_VG for is called during vgscan).

If clvmd calls LV lock, it calls
    /* clean the pool for another command */
	dm_pool_empty(cmd->mem);
to clean up memory pool after command.

Unfortunately, do_refresh_cache() do not call this
and because during it operation it allocates some memory,
the pool increases.

Also do_refresh_cache should use lvm_lock
(it manipulates with lvm internal data).

The same applies for lvm_backup command.

Signed-off-by: Milan Broz <mbroz@redhat.com>
This commit is contained in:
Milan Broz 2009-03-05 16:25:35 +00:00
parent ab5be5f065
commit fe3a28e2cc
2 changed files with 17 additions and 8 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.46 -
================================
Flush memory pool and fix locking in clvmd refresh and backup command.
Version 2.02.45 - 3rd March 2009
================================

View File

@ -406,16 +406,15 @@ int do_lock_lv(unsigned char command, unsigned char lock_flags, char *resource)
DEBUGLOG("do_lock_lv: resource '%s', cmd = %s, flags = %s\n",
resource, decode_locking_cmd(command), decode_flags(lock_flags));
pthread_mutex_lock(&lvm_lock);
if (!cmd->config_valid || config_files_changed(cmd)) {
/* Reinitialise various settings inc. logging, filters */
if (do_refresh_cache()) {
log_error("Updated config file invalid. Aborting.");
pthread_mutex_unlock(&lvm_lock);
return EINVAL;
}
}
pthread_mutex_lock(&lvm_lock);
if (lock_flags & LCK_MIRROR_NOSYNC_MODE)
init_mirror_in_sync(1);
@ -538,9 +537,14 @@ int do_refresh_cache()
DEBUGLOG("Refreshing context\n");
log_notice("Refreshing context");
pthread_mutex_lock(&lvm_lock);
ret = refresh_toolcontext(cmd);
init_full_scan_done(0);
lvmcache_label_scan(cmd, 2);
dm_pool_empty(cmd->mem);
pthread_mutex_unlock(&lvm_lock);
return ret==1?0:-1;
}
@ -711,14 +715,18 @@ void lvm_do_backup(const char *vgname)
DEBUGLOG("Triggering backup of VG metadata for %s. suspended=%d\n", vgname, suspended);
pthread_mutex_lock(&lvm_lock);
vg = vg_read_internal(cmd, vgname, NULL /*vgid*/, &consistent);
if (vg) {
if (consistent)
if (vg && consistent)
check_current_backup(vg);
}
else {
else
log_error("Error backing up metadata, can't find VG for group %s", vgname);
}
dm_pool_empty(cmd->mem);
pthread_mutex_unlock(&lvm_lock);
}
/* Called to initialise the LVM context of the daemon */