// SPDX-License-Identifier: GPL-2.0-only /****************************************************************************** ******************************************************************************* ** ** Copyright (C) 2005-2011 Red Hat, Inc. All rights reserved. ** ** *******************************************************************************
******************************************************************************/
int dlm_slots_copy_in(struct dlm_ls *ls)
{ struct dlm_member *memb; struct dlm_rcom *rc = ls->ls_recover_buf; struct rcom_config *rf = (struct rcom_config *)rc->rc_buf; struct rcom_slot *ro0, *ro; int our_nodeid = dlm_our_nodeid(); int i, num_slots;
uint32_t gen;
if (!dlm_slots_version(&rc->rc_header)) return -1;
gen = le32_to_cpu(rf->rf_generation); if (gen <= ls->ls_generation) {
log_error(ls, "dlm_slots_copy_in gen %u old %u",
gen, ls->ls_generation);
}
ls->ls_generation = gen;
num_slots = le16_to_cpu(rf->rf_num_slots); if (!num_slots) return -1;
if (!memb->slot) {
log_error(ls, "dlm_slots_copy_in nodeid %d no slot",
memb->nodeid); return -1;
}
}
return 0;
}
/* for any nodes that do not support slots, we will not have set memb->slot in wait_status_all(), so memb->slot will remain -1, and we will not
assign slots or set ls_num_slots here */
int dlm_slots_assign(struct dlm_ls *ls, int *num_slots, int *slots_size, struct dlm_slot **slots_out, uint32_t *gen_out)
{ struct dlm_member *memb; struct dlm_slot *array; int our_nodeid = dlm_our_nodeid(); int array_size, max_slots, i; int need = 0; int max = 0; int num = 0;
uint32_t gen = 0;
if (!ls->ls_ops || !ls->ls_ops->recover_slot) return;
/* if there is no comms connection with this node or the present comms connection is newer than the one when this member was added, then we consider the node to have failed (versus
being removed due to dlm_release_lockspace) */
staticstruct dlm_config_node *find_config_node(struct dlm_recover *rv, int nodeid)
{ int i;
for (i = 0; i < rv->nodes_count; i++) { if (rv->nodes[i].nodeid == nodeid) return &rv->nodes[i];
} return NULL;
}
int dlm_recover_members(struct dlm_ls *ls, struct dlm_recover *rv, int *neg_out)
{ struct dlm_member *memb, *safe; struct dlm_config_node *node; int i, error, neg = 0, low = -1;
/* previously removed members that we've not finished removing need to * count as a negative change so the "neg" recovery steps will happen * * This functionality must report all member changes to lsops or * midcomms layer and must never return before.
*/
for (i = 0; i < rv->nodes_count; i++) {
node = &rv->nodes[i]; if (dlm_is_member(ls, node->nodeid)) continue;
error = dlm_add_member(ls, node); if (error) return error;
/* Userspace guarantees that dlm_ls_stop() has completed on all nodes before
dlm_ls_start() is called on any of them to start the new recovery. */
int dlm_ls_stop(struct dlm_ls *ls)
{ intnew;
/* * Prevent dlm_recv from being in the middle of something when we do * the stop. This includes ensuring dlm_recv isn't processing a * recovery message (rcom), while dlm_recoverd is aborting and * resetting things from an in-progress recovery. i.e. we want * dlm_recoverd to abort its recovery without worrying about dlm_recv * processing an rcom at the same time. Stopping dlm_recv also makes * it easy for dlm_receive_message() to check locking stopped and add a * message to the requestqueue without races.
*/
write_lock_bh(&ls->ls_recv_active);
/* * Abort any recovery that's in progress (see RECOVER_STOP, * dlm_recovery_stopped()) and tell any other threads running in the * dlm to quit any processing (see RUNNING, dlm_locking_stopped()).
*/
spin_lock_bh(&ls->ls_recover_lock);
set_bit(LSFL_RECOVER_STOP, &ls->ls_flags); new = test_and_clear_bit(LSFL_RUNNING, &ls->ls_flags); if (new)
timer_delete_sync(&ls->ls_scan_timer);
ls->ls_recover_seq++;
/* * Let dlm_recv run again, now any normal messages will be saved on the * requestqueue for later.
*/
write_unlock_bh(&ls->ls_recv_active);
/* * This in_recovery lock does two things: * 1) Keeps this function from returning until all threads are out * of locking routines and locking is truly stopped. * 2) Keeps any new requests from being processed until it's unlocked * when recovery is complete.
*/
if (new) {
set_bit(LSFL_RECOVER_DOWN, &ls->ls_flags);
wake_up_process(ls->ls_recoverd_task);
wait_event(ls->ls_recover_lock_wait,
test_bit(LSFL_RECOVER_LOCK, &ls->ls_flags));
}
/* * The recoverd suspend/resume makes sure that dlm_recoverd (if * running) has noticed RECOVER_STOP above and quit processing the * previous recovery.
*/
if (!ls->ls_recover_begin)
ls->ls_recover_begin = jiffies;
/* call recover_prep ops only once and not multiple times * for each possible dlm_ls_stop() when recovery is already * stopped. * * If we successful was able to clear LSFL_RUNNING bit and * it was set we know it is the first dlm_ls_stop() call.
*/ if (new)
dlm_lsop_recover_prep(ls);
return 0;
}
int dlm_ls_start(struct dlm_ls *ls)
{ struct dlm_recover *rv, *rv_old; struct dlm_config_node *nodes = NULL; int error, count;
rv = kzalloc(sizeof(*rv), GFP_NOFS); if (!rv) return -ENOMEM;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.