// SPDX-License-Identifier: GPL-2.0-only /****************************************************************************** ******************************************************************************* ** ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. ** Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. ** ** *******************************************************************************
******************************************************************************/
/* * Recovery waiting routines: these functions wait for a particular reply from * a remote node, or for the remote node to report a certain status. They need * to abort if the lockspace is stopped indicating a node has failed (perhaps * the one being waited for).
*/
/* * Wait until given function returns non-zero or lockspace is stopped * (LS_RECOVERY_STOP set due to failure of a node in ls_nodes). When another * function thinks it could have completed the waited-on task, they should wake * up ls_wait_general to get an immediate response rather than waiting for the * timeout. This uses a timeout so it can check periodically if the wait * should abort due to node failure (which doesn't cause a wake_up). * This should only be called by the dlm_recoverd thread.
*/
int dlm_wait_function(struct dlm_ls *ls, int (*testfn) (struct dlm_ls *ls))
{ int error = 0; int rv;
while (1) {
rv = wait_event_timeout(ls->ls_wait_general,
testfn(ls) || dlm_recovery_stopped(ls),
dlm_config.ci_recover_timer * HZ); if (rv) break; if (test_bit(LSFL_RCOM_WAIT, &ls->ls_flags)) {
log_debug(ls, "dlm_wait_function timed out"); return -ETIMEDOUT;
}
}
/* * An efficient way for all nodes to wait for all others to have a certain * status. The node with the lowest nodeid polls all the others for their * status (wait_status_all) and all the others poll the node with the low id * for its accumulated result (wait_status_low). When all nodes have set * status flag X, then status flag X_ALL will be set on the low nodeid.
*/
/* * The recover_list contains all the rsb's for which we've requested the new * master nodeid. As replies are returned from the resource directories the * rsb's are removed from the list. When the list is empty we're done. * * The recover_list is later similarly used for all rsb's for which we've sent * new lkb's and need to receive new corresponding lkid's. * * We use the address of the rsb struct as a simple local identifier for the * rsb so we can match an rcom reply with the rsb it was sent for.
*/
staticint recover_list_empty(struct dlm_ls *ls)
{ int empty;
/* * Set the lock master for all LKBs in a lock queue * If we are the new master of the rsb, we may have received new * MSTCPY locks from other nodes already which we need to ignore * when setting the new nodeid.
*/
staticvoid set_lock_master(struct list_head *queue, int nodeid)
{ struct dlm_lkb *lkb;
/* * Propagate the new master nodeid to locks * The NEW_MASTER flag tells dlm_recover_locks() which rsb's to consider. * The NEW_MASTER2 flag tells recover_lvb() and recover_grant() which * rsb's to consider.
*/
/* * We do async lookups on rsb's that need new masters. The rsb's * waiting for a lookup reply are kept on the recover_list. * * Another node recovering the master may have sent us a rcom lookup, * and our dlm_master_lookup() set it as the new master, along with * NEW_MASTER so that we'll recover it here (this implies dir_nodeid * equals our_nodeid below).
*/
staticint recover_master(struct dlm_rsb *r, unsignedint *count, uint64_t seq)
{ struct dlm_ls *ls = r->res_ls; int our_nodeid, dir_nodeid; int is_removed = 0; int error;
if (r->res_nodeid != -1 && is_master(r)) return 0;
if (r->res_nodeid != -1)
is_removed = dlm_is_removed(ls, r->res_nodeid);
if (!is_removed && !rsb_flag(r, RSB_NEW_MASTER)) return 0;
if (dir_nodeid == our_nodeid) { if (is_removed) {
r->res_master_nodeid = our_nodeid;
r->res_nodeid = 0;
}
/* set master of lkbs to ourself when is_removed, or to another new master which we set along with NEW_MASTER
in dlm_master_lookup */
set_new_master(r);
error = 0;
} else {
recover_xa_add(r);
error = dlm_send_rcom_lookup(r, dir_nodeid, seq);
}
(*count)++; return error;
}
/* * All MSTCPY locks are purged and rebuilt, even if the master stayed the same. * This is necessary because recovery can be started, aborted and restarted, * causing the master nodeid to briefly change during the aborted recovery, and * change back to the original value in the second recovery. The MSTCPY locks * may or may not have been purged during the aborted recovery. Another node * with an outstanding request in waiters list and a request reply saved in the * requestqueue, cannot know whether it should ignore the reply and resend the * request, or accept the reply and complete the request. It must do the * former if the remote node purged MSTCPY locks, and it must do the later if * the remote node did not. This is solved by always purging MSTCPY locks, in * which case, the request reply would always be ignored and the request * resent.
*/
staticint recover_master_static(struct dlm_rsb *r, unsignedint *count)
{ int dir_nodeid = dlm_dir_nodeid(r); int new_master = dir_nodeid;
if (dir_nodeid == dlm_our_nodeid())
new_master = 0;
/* * Go through local root resources and for each rsb which has a master which * has departed, get the new master nodeid from the directory. The dir will * assign mastery to the first node to look up the new master. That means * we'll discover in this lookup if we're the new master of any rsb's. * * We fire off all the dir lookup requests individually and asynchronously to * the correct dir node.
*/
int dlm_recover_masters(struct dlm_ls *ls, uint64_t seq, conststruct list_head *root_list)
{ struct dlm_rsb *r; unsignedint total = 0; unsignedint count = 0; int nodir = dlm_no_directory(ls); int error;
int dlm_recover_master_reply(struct dlm_ls *ls, conststruct dlm_rcom *rc)
{ struct dlm_rsb *r; int ret_nodeid, new_master;
r = recover_xa_find(ls, le64_to_cpu(rc->rc_id)); if (!r) {
log_error(ls, "dlm_recover_master_reply no id %llx",
(unsignedlonglong)le64_to_cpu(rc->rc_id)); goto out;
}
r->res_recover_locks_count--; if (!r->res_recover_locks_count) {
rsb_clear_flag(r, RSB_NEW_MASTER);
recover_list_del(r);
}
if (recover_list_empty(r->res_ls))
wake_up(&r->res_ls->ls_wait_general);
}
/* * The lvb needs to be recovered on all master rsb's. This includes setting * the VALNOTVALID flag if necessary, and determining the correct lvb contents * based on the lvb's of the locks held on the rsb. * * RSB_VALNOTVALID is set in two cases: * * 1. we are master, but not new, and we purged an EX/PW lock held by a * failed node (in dlm_recover_purge which set RSB_RECOVER_LVB_INVAL) * * 2. we are a new master, and there are only NL/CR locks left. * (We could probably improve this by only invaliding in this way when * the previous master left uncleanly. VMS docs mention that.) * * The LVB contents are only considered for changing when this is a new master * of the rsb (NEW_MASTER2). Then, the rsb's lvb is taken from any lkb with * mode > CR. If no lkb's exist with mode above CR, the lvb contents are taken * from the lkb with the largest lvb sequence number.
*/
/* All master rsb's flagged RECOVER_CONVERT need to be looked at. The locks * converting PR->CW or CW->PR may need to have their lkb_grmode changed.
*/
list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) { /* Lock recovery created incompatible granted modes, so * change the granted mode of the converting lock to * NL. The rqmode of the converting lock should be CW, * which means the converting lock should be granted at * the end of recovery.
*/ if (((lkb->lkb_grmode == DLM_LOCK_PR) && (other_grmode == DLM_LOCK_CW)) ||
((lkb->lkb_grmode == DLM_LOCK_CW) && (other_grmode == DLM_LOCK_PR))) {
log_rinfo(ls, "%s %x gr %d rq %d, remote %d %x, other_lkid %u, other gr %d, set gr=NL",
__func__, lkb->lkb_id, lkb->lkb_grmode,
lkb->lkb_rqmode, lkb->lkb_nodeid,
lkb->lkb_remid, other_lkid, other_grmode);
lkb->lkb_grmode = DLM_LOCK_NL;
}
}
}
/* We've become the new master for this rsb and waiting/converting locks may need to be granted in dlm_recover_grant() due to locks that may have
existed from a removed node. */
if (count)
log_rinfo(ls, "dlm_clear_inactive %u done", count);
}
Messung V0.5
¤ 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.0.27Bemerkung:
(vorverarbeitet)
¤
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.