mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-29 15:22:30 +03:00
mirror: improve table update
Shift refresh of mirror table right into monitor_dev_for_events(). Use !vg_write_lock_held() to recognize use of lvchange/vgchange. (this shall change if this would no longer work, but requires futher some API changes). With this patch dm mirror table is only refreshed when necassary. Also update WARNING message about mirror usage without monitoring and display LV name.
This commit is contained in:
parent
dd7ac793a0
commit
fade45b1d1
@ -1857,6 +1857,7 @@ int monitor_dev_for_events(struct cmd_context *cmd, const struct logical_volume
|
||||
int (*monitor_fn) (struct lv_segment *s, int e);
|
||||
uint32_t s;
|
||||
static const struct lv_activate_opts zlaopts = { 0 };
|
||||
struct lv_activate_opts mirr_laopts = { .origin_only = 1 };
|
||||
struct lvinfo info;
|
||||
const char *dso = NULL;
|
||||
int new_unmonitor;
|
||||
@ -2057,6 +2058,19 @@ int monitor_dev_for_events(struct cmd_context *cmd, const struct logical_volume
|
||||
} else
|
||||
continue;
|
||||
|
||||
if (!vg_write_lock_held() && lv_is_mirror(lv)) {
|
||||
mirr_laopts.exclusive = lv_is_active_exclusive_locally(lv) ? 1 : 0;
|
||||
/*
|
||||
* Commands vgchange and lvchange do use read-only lock when changing
|
||||
* monitoring (--monitor y|n). All other use cases hold 'write-lock'
|
||||
* so they skip this dm mirror table refreshing step.
|
||||
*/
|
||||
if (!_lv_activate_lv(lv, &mirr_laopts)) {
|
||||
stack;
|
||||
r = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check [un]monitor results */
|
||||
/* Try a couple times if pending, but not forever... */
|
||||
for (i = 0;; i++) {
|
||||
|
@ -315,12 +315,13 @@ static int _add_log(struct dm_pool *mem, struct lv_segment *seg,
|
||||
log_flags |= DM_NOSYNC;
|
||||
|
||||
if (_block_on_error_available && !(seg->status & PVMOVE)) {
|
||||
if (dmeventd_monitor_mode() > 0)
|
||||
if (dmeventd_monitor_mode() == 0) {
|
||||
log_warn_suppress(seg->lv->vg->cmd->mirror_warn_printed,
|
||||
"WARNING: Mirror %s without monitoring will not react on failures.",
|
||||
display_lvname(seg->lv));
|
||||
seg->lv->vg->cmd->mirror_warn_printed = 1; /* Do not print this more then once */
|
||||
} else
|
||||
log_flags |= DM_BLOCK_ON_ERROR;
|
||||
else {
|
||||
log_warn_suppress(seg->lv->vg->cmd->mirror_warn_printed, "WARNING: Mirrors without monitoring will not react on failures.");
|
||||
seg->lv->vg->cmd->mirror_warn_printed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return dm_tree_node_add_mirror_target_log(node, region_size, clustered, log_dlid, area_count, log_flags);
|
||||
|
@ -1603,10 +1603,6 @@ static int _lvchange_monitor_poll_single(struct cmd_context *cmd,
|
||||
struct logical_volume *lv,
|
||||
struct processing_handle *handle)
|
||||
{
|
||||
/* Mirror is using different table line when un/monitored */
|
||||
if (lv_is_mirror(lv) && !lv_refresh(cmd, lv))
|
||||
return_ECMD_FAILED;
|
||||
|
||||
if (arg_is_set(cmd, monitor_ARG) &&
|
||||
!_lvchange_monitoring(cmd, lv))
|
||||
return_ECMD_FAILED;
|
||||
|
Loading…
Reference in New Issue
Block a user