mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
lockd: fix error message after a failing to get lock
There are two different failure conditions detected in access_vg_lock_type() that should have different error messages. This adds another failure flag so the two cases can be distinguished to avoid printing a misleading error message.
This commit is contained in:
parent
ac3143c093
commit
681f779a3c
@ -181,6 +181,7 @@
|
||||
#define FAILED_RECOVERY 0x00000200U
|
||||
#define FAILED_SYSTEMID 0x00000400U
|
||||
#define FAILED_LOCK_TYPE 0x00000800U
|
||||
#define FAILED_LOCK_MODE 0x00001000U
|
||||
#define SUCCESS 0x00000000U
|
||||
|
||||
#define VGMETADATACOPIES_ALL UINT32_MAX
|
||||
|
@ -4747,7 +4747,7 @@ static int _access_vg_clustered(struct cmd_context *cmd, struct volume_group *vg
|
||||
}
|
||||
|
||||
static int _access_vg_lock_type(struct cmd_context *cmd, struct volume_group *vg,
|
||||
uint32_t lockd_state)
|
||||
uint32_t lockd_state, uint32_t *failure)
|
||||
{
|
||||
if (!is_real_vg(vg->name))
|
||||
return 1;
|
||||
@ -4791,6 +4791,7 @@ static int _access_vg_lock_type(struct cmd_context *cmd, struct volume_group *vg
|
||||
vg->name, vg->lock_type);
|
||||
}
|
||||
|
||||
*failure |= FAILED_LOCK_TYPE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -4804,6 +4805,7 @@ static int _access_vg_lock_type(struct cmd_context *cmd, struct volume_group *vg
|
||||
if (lockd_state & LDST_FAIL) {
|
||||
if (lockd_state & LDST_EX) {
|
||||
log_error("Cannot access VG %s due to failed lock.", vg->name);
|
||||
*failure |= FAILED_LOCK_MODE;
|
||||
return 0;
|
||||
} else {
|
||||
log_warn("Reading VG %s without a lock.", vg->name);
|
||||
@ -4904,8 +4906,8 @@ static int _vg_access_permitted(struct cmd_context *cmd, struct volume_group *vg
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!_access_vg_lock_type(cmd, vg, lockd_state)) {
|
||||
*failure |= FAILED_LOCK_TYPE;
|
||||
if (!_access_vg_lock_type(cmd, vg, lockd_state, failure)) {
|
||||
/* Either FAILED_LOCK_TYPE or FAILED_LOCK_MODE were set. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -221,14 +221,22 @@ static int _ignore_vg(struct volume_group *vg, const char *vg_name,
|
||||
/*
|
||||
* Accessing a lockd VG when lvmlockd is not used is similar
|
||||
* to accessing a foreign VG.
|
||||
* This is also the point where a command fails if it failed
|
||||
* to acquire the necessary lock from lvmlockd.
|
||||
* The two cases are distinguished by FAILED_LOCK_TYPE (the
|
||||
* VG lock_type requires lvmlockd), and FAILED_LOCK_MODE (the
|
||||
* command failed to acquire the necessary lock.)
|
||||
*/
|
||||
if (read_error & FAILED_LOCK_TYPE) {
|
||||
if (read_error & (FAILED_LOCK_TYPE | FAILED_LOCK_MODE)) {
|
||||
if (arg_vgnames && str_list_match_item(arg_vgnames, vg->name)) {
|
||||
log_error("Cannot access VG %s with lock_type %s that requires lvmlockd.",
|
||||
vg->name, vg->lock_type);
|
||||
if (read_error & FAILED_LOCK_TYPE)
|
||||
log_error("Cannot access VG %s with lock type %s that requires lvmlockd.",
|
||||
vg->name, vg->lock_type);
|
||||
/* For FAILED_LOCK_MODE, the error is printed in vg_read. */
|
||||
return 1;
|
||||
} else {
|
||||
read_error &= ~FAILED_LOCK_TYPE; /* Check for other errors */
|
||||
read_error &= ~FAILED_LOCK_MODE;
|
||||
log_verbose("Skipping volume group %s", vg_name);
|
||||
*skip = 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user