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

lvmcache: handle reinit without error

Since commit f12ee43f2e call destroy,
it start to check all VGs are unlocked. However when we become_daemon,
we simply reset locking (since lock is still kept by parent process).
So implement a simple 'reset' flag.
This commit is contained in:
Zdenek Kabelac 2014-03-21 22:26:39 +01:00
parent bdd7baeab3
commit fc280bcc42
8 changed files with 14 additions and 11 deletions

View File

@ -1621,7 +1621,7 @@ static void _lvmcache_destroy_lockname(struct dm_hash_node *n)
dm_hash_get_key(_lock_hash, n));
}
void lvmcache_destroy(struct cmd_context *cmd, int retain_orphans)
void lvmcache_destroy(struct cmd_context *cmd, int retain_orphans, int reset)
{
struct dm_hash_node *n;
log_verbose("Wiping internal VG cache");
@ -1647,6 +1647,9 @@ void lvmcache_destroy(struct cmd_context *cmd, int retain_orphans)
}
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);

View File

@ -42,7 +42,7 @@ struct lvmcache_vginfo;
int lvmcache_init(void);
void lvmcache_allow_reads_with_lvmetad(void);
void lvmcache_destroy(struct cmd_context *cmd, int retain_orphans);
void lvmcache_destroy(struct cmd_context *cmd, int retain_orphans, int reset);
/* Set full_scan to 1 to reread every filtered device label or
* 2 to rescan /dev for new devices */

View File

@ -1596,7 +1596,7 @@ int refresh_toolcontext(struct cmd_context *cmd)
*/
activation_release();
lvmcache_destroy(cmd, 0);
lvmcache_destroy(cmd, 0, 0);
label_exit();
_destroy_segtypes(&cmd->segtypes);
_destroy_formats(cmd, &cmd->formats);
@ -1688,7 +1688,7 @@ void destroy_toolcontext(struct cmd_context *cmd)
archive_exit(cmd);
backup_exit(cmd);
lvmcache_destroy(cmd, 0);
lvmcache_destroy(cmd, 0, 0);
label_exit();
_destroy_segtypes(&cmd->segtypes);
_destroy_formats(cmd, &cmd->formats);

View File

@ -1185,7 +1185,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
out:
if (test_mode()) {
log_verbose("Test mode: Wiping internal cache");
lvmcache_destroy(cmd, 1);
lvmcache_destroy(cmd, 1, 0);
}
if ((old_cft = remove_config_tree_by_source(cmd, CONFIG_STRING))) {

View File

@ -363,7 +363,7 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
if (cmd->filter->wipe)
cmd->filter->wipe(cmd->filter);
lvmcache_destroy(cmd, 1);
lvmcache_destroy(cmd, 1, 0);
/* populate lvmcache */
if (!lvmetad_vg_list_to_lvmcache(cmd))

View File

@ -91,8 +91,8 @@ int become_daemon(struct cmd_context *cmd, int skip_lvm)
strncpy(*cmd->argv, "(lvm2)", strlen(*cmd->argv));
if (!skip_lvm) {
lvmcache_destroy(cmd, 1);
reset_locking();
lvmcache_destroy(cmd, 1, 1);
if (!lvmcache_init())
/* FIXME Clean up properly here */
_exit(ECMD_FAILED);

View File

@ -185,7 +185,7 @@ static int vg_rename_path(struct cmd_context *cmd, const char *old_vg_path,
/* FIXME lvmcache corruption - vginfo duplicated instead of renamed */
if (cmd->filter->wipe)
cmd->filter->wipe(cmd->filter);
lvmcache_destroy(cmd, 1);
lvmcache_destroy(cmd, 1, 0);
return 1;

View File

@ -44,7 +44,7 @@ int vgscan(struct cmd_context *cmd, int argc, char **argv)
if (cmd->filter->wipe)
cmd->filter->wipe(cmd->filter);
lvmcache_destroy(cmd, 1);
lvmcache_destroy(cmd, 1, 0);
if (arg_count(cmd, cache_ARG)) {
if (lvmetad_active()) {