mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
If anything bad happens and unlocking fails
(here clvmd crashed in the middle of operation), lock is not removed from cache - here is one example: locking/cluster_locking.c:497 Locking VG V_vg_test UN (VG) (0x6) locking/cluster_locking.c:113 Error writing data to clvmd: Broken pipe locking/locking.c:399 <backtrace> locking/locking.c:461 <backtrace> Internal error: Volume Group vg_test was not unlocked Code should always remove lock info from lvmcache and update counters on unlock, even if unlock fails.
This commit is contained in:
parent
5ddda8cd56
commit
05960a0c55
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.87 -
|
Version 2.02.87 -
|
||||||
===============================
|
===============================
|
||||||
|
Remove lock from cache even if unlock fails.
|
||||||
Initialise clvmd locks before lvm context to avoid open descriptor leaks.
|
Initialise clvmd locks before lvm context to avoid open descriptor leaks.
|
||||||
Remove obsoleted GULM clvmd cluster locking support.
|
Remove obsoleted GULM clvmd cluster locking support.
|
||||||
Suppress low-level locking errors and warnings while using --sysinit.
|
Suppress low-level locking errors and warnings while using --sysinit.
|
||||||
|
@ -359,6 +359,8 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname)
|
|||||||
static int _lock_vol(struct cmd_context *cmd, const char *resource,
|
static int _lock_vol(struct cmd_context *cmd, const char *resource,
|
||||||
uint32_t flags, lv_operation_t lv_op)
|
uint32_t flags, lv_operation_t lv_op)
|
||||||
{
|
{
|
||||||
|
uint32_t lck_type = flags & LCK_TYPE_MASK;
|
||||||
|
uint32_t lck_scope = flags & LCK_SCOPE_MASK;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
_block_signals(flags);
|
_block_signals(flags);
|
||||||
@ -376,21 +378,16 @@ static int _lock_vol(struct cmd_context *cmd, const char *resource,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd->metadata_read_only &&
|
if (cmd->metadata_read_only && lck_type == LCK_WRITE &&
|
||||||
((flags & LCK_TYPE_MASK) == LCK_WRITE) &&
|
|
||||||
strcmp(resource, VG_GLOBAL)) {
|
strcmp(resource, VG_GLOBAL)) {
|
||||||
log_error("Operation prohibited while global/metadata_read_only is set.");
|
log_error("Operation prohibited while global/metadata_read_only is set.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = _locking.lock_resource(cmd, resource, flags))) {
|
if ((ret = _locking.lock_resource(cmd, resource, flags))) {
|
||||||
if ((flags & LCK_SCOPE_MASK) == LCK_VG &&
|
if (lck_scope == LCK_VG && !(flags & LCK_CACHE)) {
|
||||||
!(flags & LCK_CACHE)) {
|
if (lck_type != LCK_UNLOCK)
|
||||||
if ((flags & LCK_TYPE_MASK) == LCK_UNLOCK)
|
lvmcache_lock_vgname(resource, lck_type == LCK_READ);
|
||||||
lvmcache_unlock_vgname(resource);
|
|
||||||
else
|
|
||||||
lvmcache_lock_vgname(resource, (flags & LCK_TYPE_MASK)
|
|
||||||
== LCK_READ);
|
|
||||||
dev_reset_error_count(cmd);
|
dev_reset_error_count(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,6 +395,13 @@ static int _lock_vol(struct cmd_context *cmd, const char *resource,
|
|||||||
} else
|
} else
|
||||||
stack;
|
stack;
|
||||||
|
|
||||||
|
/* If unlocking, always remove lock from lvmcache even if operation failed. */
|
||||||
|
if (lck_scope == LCK_VG && !(flags & LCK_CACHE) && lck_type == LCK_UNLOCK) {
|
||||||
|
lvmcache_unlock_vgname(resource);
|
||||||
|
if (!ret)
|
||||||
|
_update_vg_lock_count(resource, flags);
|
||||||
|
}
|
||||||
|
|
||||||
_unlock_memory(cmd, lv_op);
|
_unlock_memory(cmd, lv_op);
|
||||||
_unblock_signals();
|
_unblock_signals();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user