mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
lvmlockd: skip LV unlocking with no lvmlockd or no lockspace
vgchange -an vg is permitted when the vg lockspace is not available, because LVs could still be active for some reason, and they should be inactive when not properly locked. In case lvmlockd was not running, or the lockspace was not started, the command was unnecessarily trying and failing to unlock every LV, printing errors for every LV. We can skip this when the lockspace is known to not be available.
This commit is contained in:
parent
d85ceff9c5
commit
f1d88007b0
@ -2808,9 +2808,28 @@ int lockd_lv(struct cmd_context *cmd, struct logical_volume *lv,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_lvmlockd_connected && !strcmp(def_mode, "un")) {
|
||||||
|
log_debug("Skip LV unlock: no lvmlockd");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!_lvmlockd_connected)
|
if (!_lvmlockd_connected)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This addresses the specific case of: vgchange -an vg
|
||||||
|
* when vg is a shared VG that is not started. Without
|
||||||
|
* this check, the command will try and fail to unlock
|
||||||
|
* every LV, which is wasted effort if the lockspace is
|
||||||
|
* not started, especially with many LVs in the VG.
|
||||||
|
* The command still attempts to deactivate the LVs,
|
||||||
|
* which it should in case they are active for some reason.
|
||||||
|
*/
|
||||||
|
if (lv->vg->lockd_not_started && !strcmp(def_mode, "un")) {
|
||||||
|
log_debug("Skip LV unlock: no lockspace");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (lv_is_thin_type(lv))
|
if (lv_is_thin_type(lv))
|
||||||
return _lockd_lv_thin(cmd, lv, def_mode, flags);
|
return _lockd_lv_thin(cmd, lv, def_mode, flags);
|
||||||
|
|
||||||
|
@ -3862,6 +3862,9 @@ static int _access_vg_lock_type(struct cmd_context *cmd, struct volume_group *vg
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lockd_state & (LDST_FAIL_NOLS | LDST_FAIL_STARTING))
|
||||||
|
vg->lockd_not_started = 1;
|
||||||
|
|
||||||
log_warn("Reading VG %s without a lock.", vg->name);
|
log_warn("Reading VG %s without a lock.", vg->name);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ struct volume_group {
|
|||||||
struct lvmcache_vginfo *vginfo;
|
struct lvmcache_vginfo *vginfo;
|
||||||
uint32_t seqno; /* Metadata sequence number */
|
uint32_t seqno; /* Metadata sequence number */
|
||||||
unsigned skip_validate_lock_args : 1;
|
unsigned skip_validate_lock_args : 1;
|
||||||
|
unsigned lockd_not_started : 1;
|
||||||
unsigned needs_backup : 1;
|
unsigned needs_backup : 1;
|
||||||
unsigned needs_write_and_commit : 1;
|
unsigned needs_write_and_commit : 1;
|
||||||
uint32_t write_count; /* count the number of vg_write calls */
|
uint32_t write_count; /* count the number of vg_write calls */
|
||||||
|
Loading…
Reference in New Issue
Block a user