^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) **
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) ** Copyright (C) 2005-2008 Red Hat, Inc. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) **
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) **
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) *******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "dlm_internal.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "lockspace.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "member.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "lowcomms.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include "midcomms.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include "rcom.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include "recover.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include "dir.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include "config.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include "memory.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include "lock.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include "util.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) static int rcom_response(struct dlm_ls *ls)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) return test_bit(LSFL_RCOM_READY, &ls->ls_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) static int create_rcom(struct dlm_ls *ls, int to_nodeid, int type, int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) struct dlm_rcom **rc_ret, struct dlm_mhandle **mh_ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct dlm_rcom *rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct dlm_mhandle *mh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) char *mb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) int mb_len = sizeof(struct dlm_rcom) + len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) mh = dlm_lowcomms_get_buffer(to_nodeid, mb_len, GFP_NOFS, &mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) if (!mh) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) log_print("create_rcom to %d type %d len %d ENOBUFS",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) to_nodeid, type, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) return -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) memset(mb, 0, mb_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) rc = (struct dlm_rcom *) mb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) rc->rc_header.h_version = (DLM_HEADER_MAJOR | DLM_HEADER_MINOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) rc->rc_header.h_lockspace = ls->ls_global_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) rc->rc_header.h_nodeid = dlm_our_nodeid();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) rc->rc_header.h_length = mb_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) rc->rc_header.h_cmd = DLM_RCOM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) rc->rc_type = type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) spin_lock(&ls->ls_recover_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) rc->rc_seq = ls->ls_recover_seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) spin_unlock(&ls->ls_recover_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) *mh_ret = mh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) *rc_ret = rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) static void send_rcom(struct dlm_ls *ls, struct dlm_mhandle *mh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct dlm_rcom *rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) dlm_rcom_out(rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) dlm_lowcomms_commit_buffer(mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) static void set_rcom_status(struct dlm_ls *ls, struct rcom_status *rs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) uint32_t flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) rs->rs_flags = cpu_to_le32(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /* When replying to a status request, a node also sends back its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) configuration values. The requesting node then checks that the remote
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) node is configured the same way as itself. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) static void set_rcom_config(struct dlm_ls *ls, struct rcom_config *rf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) uint32_t num_slots)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) rf->rf_lvblen = cpu_to_le32(ls->ls_lvblen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) rf->rf_lsflags = cpu_to_le32(ls->ls_exflags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) rf->rf_our_slot = cpu_to_le16(ls->ls_slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) rf->rf_num_slots = cpu_to_le16(num_slots);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) rf->rf_generation = cpu_to_le32(ls->ls_generation);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) static int check_rcom_config(struct dlm_ls *ls, struct dlm_rcom *rc, int nodeid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) struct rcom_config *rf = (struct rcom_config *) rc->rc_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) if ((rc->rc_header.h_version & 0xFFFF0000) != DLM_HEADER_MAJOR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) log_error(ls, "version mismatch: %x nodeid %d: %x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) DLM_HEADER_MAJOR | DLM_HEADER_MINOR, nodeid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) rc->rc_header.h_version);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) return -EPROTO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) if (le32_to_cpu(rf->rf_lvblen) != ls->ls_lvblen ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) le32_to_cpu(rf->rf_lsflags) != ls->ls_exflags) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) log_error(ls, "config mismatch: %d,%x nodeid %d: %d,%x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) ls->ls_lvblen, ls->ls_exflags, nodeid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) le32_to_cpu(rf->rf_lvblen),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) le32_to_cpu(rf->rf_lsflags));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) return -EPROTO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static void allow_sync_reply(struct dlm_ls *ls, uint64_t *new_seq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) spin_lock(&ls->ls_rcom_spin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) *new_seq = ++ls->ls_rcom_seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) set_bit(LSFL_RCOM_WAIT, &ls->ls_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) spin_unlock(&ls->ls_rcom_spin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) static void disallow_sync_reply(struct dlm_ls *ls)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) spin_lock(&ls->ls_rcom_spin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) clear_bit(LSFL_RCOM_WAIT, &ls->ls_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) clear_bit(LSFL_RCOM_READY, &ls->ls_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) spin_unlock(&ls->ls_rcom_spin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) * low nodeid gathers one slot value at a time from each node.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) * it sets need_slots=0, and saves rf_our_slot returned from each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) * rcom_config.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) * other nodes gather all slot values at once from the low nodeid.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) * they set need_slots=1, and ignore the rf_our_slot returned from each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * rcom_config. they use the rf_num_slots returned from the low
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) * node's rcom_config.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) int dlm_rcom_status(struct dlm_ls *ls, int nodeid, uint32_t status_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) struct dlm_rcom *rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) struct dlm_mhandle *mh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) int error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) ls->ls_recover_nodeid = nodeid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) if (nodeid == dlm_our_nodeid()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) rc = ls->ls_recover_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) rc->rc_result = dlm_recover_status(ls);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) retry:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) error = create_rcom(ls, nodeid, DLM_RCOM_STATUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) sizeof(struct rcom_status), &rc, &mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) set_rcom_status(ls, (struct rcom_status *)rc->rc_buf, status_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) allow_sync_reply(ls, &rc->rc_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) memset(ls->ls_recover_buf, 0, dlm_config.ci_buffer_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) send_rcom(ls, mh, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) error = dlm_wait_function(ls, &rcom_response);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) disallow_sync_reply(ls);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) if (error == -ETIMEDOUT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) goto retry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) rc = ls->ls_recover_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) if (rc->rc_result == -ESRCH) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) /* we pretend the remote lockspace exists with 0 status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) log_debug(ls, "remote node %d not ready", nodeid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) rc->rc_result = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) error = check_rcom_config(ls, rc, nodeid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) /* the caller looks at rc_result for the remote recovery status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) static void receive_rcom_status(struct dlm_ls *ls, struct dlm_rcom *rc_in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) struct dlm_rcom *rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) struct dlm_mhandle *mh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) struct rcom_status *rs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) uint32_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) int nodeid = rc_in->rc_header.h_nodeid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) int len = sizeof(struct rcom_config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) int num_slots = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) if (!dlm_slots_version(&rc_in->rc_header)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) status = dlm_recover_status(ls);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) goto do_create;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) rs = (struct rcom_status *)rc_in->rc_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) if (!(le32_to_cpu(rs->rs_flags) & DLM_RSF_NEED_SLOTS)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) status = dlm_recover_status(ls);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) goto do_create;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) spin_lock(&ls->ls_recover_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) status = ls->ls_recover_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) num_slots = ls->ls_num_slots;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) spin_unlock(&ls->ls_recover_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) len += num_slots * sizeof(struct rcom_slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) do_create:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) error = create_rcom(ls, nodeid, DLM_RCOM_STATUS_REPLY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) len, &rc, &mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) rc->rc_id = rc_in->rc_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) rc->rc_seq_reply = rc_in->rc_seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) rc->rc_result = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) set_rcom_config(ls, (struct rcom_config *)rc->rc_buf, num_slots);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) if (!num_slots)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) goto do_send;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) spin_lock(&ls->ls_recover_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) if (ls->ls_num_slots != num_slots) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) spin_unlock(&ls->ls_recover_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) log_debug(ls, "receive_rcom_status num_slots %d to %d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) num_slots, ls->ls_num_slots);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) rc->rc_result = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) set_rcom_config(ls, (struct rcom_config *)rc->rc_buf, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) goto do_send;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) dlm_slots_copy_out(ls, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) spin_unlock(&ls->ls_recover_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) do_send:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) send_rcom(ls, mh, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) static void receive_sync_reply(struct dlm_ls *ls, struct dlm_rcom *rc_in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) spin_lock(&ls->ls_rcom_spin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) if (!test_bit(LSFL_RCOM_WAIT, &ls->ls_flags) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) rc_in->rc_id != ls->ls_rcom_seq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) log_debug(ls, "reject reply %d from %d seq %llx expect %llx",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) rc_in->rc_type, rc_in->rc_header.h_nodeid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) (unsigned long long)rc_in->rc_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) (unsigned long long)ls->ls_rcom_seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) memcpy(ls->ls_recover_buf, rc_in, rc_in->rc_header.h_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) set_bit(LSFL_RCOM_READY, &ls->ls_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) clear_bit(LSFL_RCOM_WAIT, &ls->ls_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) wake_up(&ls->ls_wait_general);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) spin_unlock(&ls->ls_rcom_spin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) int dlm_rcom_names(struct dlm_ls *ls, int nodeid, char *last_name, int last_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) struct dlm_rcom *rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) struct dlm_mhandle *mh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) int error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) ls->ls_recover_nodeid = nodeid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) retry:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) error = create_rcom(ls, nodeid, DLM_RCOM_NAMES, last_len, &rc, &mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) memcpy(rc->rc_buf, last_name, last_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) allow_sync_reply(ls, &rc->rc_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) memset(ls->ls_recover_buf, 0, dlm_config.ci_buffer_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) send_rcom(ls, mh, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) error = dlm_wait_function(ls, &rcom_response);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) disallow_sync_reply(ls);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) if (error == -ETIMEDOUT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) goto retry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) static void receive_rcom_names(struct dlm_ls *ls, struct dlm_rcom *rc_in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) struct dlm_rcom *rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) struct dlm_mhandle *mh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) int error, inlen, outlen, nodeid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) nodeid = rc_in->rc_header.h_nodeid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) inlen = rc_in->rc_header.h_length - sizeof(struct dlm_rcom);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) outlen = dlm_config.ci_buffer_size - sizeof(struct dlm_rcom);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) error = create_rcom(ls, nodeid, DLM_RCOM_NAMES_REPLY, outlen, &rc, &mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) rc->rc_id = rc_in->rc_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) rc->rc_seq_reply = rc_in->rc_seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) dlm_copy_master_names(ls, rc_in->rc_buf, inlen, rc->rc_buf, outlen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) nodeid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) send_rcom(ls, mh, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) int dlm_send_rcom_lookup(struct dlm_rsb *r, int dir_nodeid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) struct dlm_rcom *rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) struct dlm_mhandle *mh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) struct dlm_ls *ls = r->res_ls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) error = create_rcom(ls, dir_nodeid, DLM_RCOM_LOOKUP, r->res_length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) &rc, &mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) memcpy(rc->rc_buf, r->res_name, r->res_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) rc->rc_id = (unsigned long) r->res_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) send_rcom(ls, mh, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) static void receive_rcom_lookup(struct dlm_ls *ls, struct dlm_rcom *rc_in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) struct dlm_rcom *rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) struct dlm_mhandle *mh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) int error, ret_nodeid, nodeid = rc_in->rc_header.h_nodeid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) int len = rc_in->rc_header.h_length - sizeof(struct dlm_rcom);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) error = create_rcom(ls, nodeid, DLM_RCOM_LOOKUP_REPLY, 0, &rc, &mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) /* Old code would send this special id to trigger a debug dump. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) if (rc_in->rc_id == 0xFFFFFFFF) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) log_error(ls, "receive_rcom_lookup dump from %d", nodeid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) dlm_dump_rsb_name(ls, rc_in->rc_buf, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) error = dlm_master_lookup(ls, nodeid, rc_in->rc_buf, len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) DLM_LU_RECOVER_MASTER, &ret_nodeid, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) ret_nodeid = error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) rc->rc_result = ret_nodeid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) rc->rc_id = rc_in->rc_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) rc->rc_seq_reply = rc_in->rc_seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) send_rcom(ls, mh, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) static void receive_rcom_lookup_reply(struct dlm_ls *ls, struct dlm_rcom *rc_in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) dlm_recover_master_reply(ls, rc_in);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) static void pack_rcom_lock(struct dlm_rsb *r, struct dlm_lkb *lkb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) struct rcom_lock *rl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) memset(rl, 0, sizeof(*rl));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) rl->rl_ownpid = cpu_to_le32(lkb->lkb_ownpid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) rl->rl_lkid = cpu_to_le32(lkb->lkb_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) rl->rl_exflags = cpu_to_le32(lkb->lkb_exflags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) rl->rl_flags = cpu_to_le32(lkb->lkb_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) rl->rl_lvbseq = cpu_to_le32(lkb->lkb_lvbseq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) rl->rl_rqmode = lkb->lkb_rqmode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) rl->rl_grmode = lkb->lkb_grmode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) rl->rl_status = lkb->lkb_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) rl->rl_wait_type = cpu_to_le16(lkb->lkb_wait_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) if (lkb->lkb_bastfn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) rl->rl_asts |= DLM_CB_BAST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) if (lkb->lkb_astfn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) rl->rl_asts |= DLM_CB_CAST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) rl->rl_namelen = cpu_to_le16(r->res_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) memcpy(rl->rl_name, r->res_name, r->res_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) /* FIXME: might we have an lvb without DLM_LKF_VALBLK set ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) If so, receive_rcom_lock_args() won't take this copy. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) if (lkb->lkb_lvbptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) memcpy(rl->rl_lvb, lkb->lkb_lvbptr, r->res_ls->ls_lvblen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) int dlm_send_rcom_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) struct dlm_ls *ls = r->res_ls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) struct dlm_rcom *rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) struct dlm_mhandle *mh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) struct rcom_lock *rl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) int error, len = sizeof(struct rcom_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) if (lkb->lkb_lvbptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) len += ls->ls_lvblen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) error = create_rcom(ls, r->res_nodeid, DLM_RCOM_LOCK, len, &rc, &mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) rl = (struct rcom_lock *) rc->rc_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) pack_rcom_lock(r, lkb, rl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) rc->rc_id = (unsigned long) r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) send_rcom(ls, mh, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) /* needs at least dlm_rcom + rcom_lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) static void receive_rcom_lock(struct dlm_ls *ls, struct dlm_rcom *rc_in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) struct dlm_rcom *rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) struct dlm_mhandle *mh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) int error, nodeid = rc_in->rc_header.h_nodeid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) dlm_recover_master_copy(ls, rc_in);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) error = create_rcom(ls, nodeid, DLM_RCOM_LOCK_REPLY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) sizeof(struct rcom_lock), &rc, &mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) /* We send back the same rcom_lock struct we received, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) dlm_recover_master_copy() has filled in rl_remid and rl_result */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) memcpy(rc->rc_buf, rc_in->rc_buf, sizeof(struct rcom_lock));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) rc->rc_id = rc_in->rc_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) rc->rc_seq_reply = rc_in->rc_seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) send_rcom(ls, mh, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) /* If the lockspace doesn't exist then still send a status message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) back; it's possible that it just doesn't have its global_id yet. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) int dlm_send_ls_not_ready(int nodeid, struct dlm_rcom *rc_in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) struct dlm_rcom *rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) struct rcom_config *rf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) struct dlm_mhandle *mh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) char *mb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) int mb_len = sizeof(struct dlm_rcom) + sizeof(struct rcom_config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) mh = dlm_lowcomms_get_buffer(nodeid, mb_len, GFP_NOFS, &mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) if (!mh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) return -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) memset(mb, 0, mb_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) rc = (struct dlm_rcom *) mb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) rc->rc_header.h_version = (DLM_HEADER_MAJOR | DLM_HEADER_MINOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) rc->rc_header.h_lockspace = rc_in->rc_header.h_lockspace;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) rc->rc_header.h_nodeid = dlm_our_nodeid();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) rc->rc_header.h_length = mb_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) rc->rc_header.h_cmd = DLM_RCOM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) rc->rc_type = DLM_RCOM_STATUS_REPLY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) rc->rc_id = rc_in->rc_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) rc->rc_seq_reply = rc_in->rc_seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) rc->rc_result = -ESRCH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) rf = (struct rcom_config *) rc->rc_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) rf->rf_lvblen = cpu_to_le32(~0U);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) dlm_rcom_out(rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) dlm_lowcomms_commit_buffer(mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) * Ignore messages for stage Y before we set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) * recover_status bit for stage X:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) * recover_status = 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) * dlm_recover_members()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) * - send nothing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) * - recv nothing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) * - ignore NAMES, NAMES_REPLY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) * - ignore LOOKUP, LOOKUP_REPLY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) * - ignore LOCK, LOCK_REPLY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) * recover_status |= NODES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) * dlm_recover_members_wait()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) * dlm_recover_directory()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) * - send NAMES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) * - recv NAMES_REPLY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) * - ignore LOOKUP, LOOKUP_REPLY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) * - ignore LOCK, LOCK_REPLY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) * recover_status |= DIR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) * dlm_recover_directory_wait()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) * dlm_recover_masters()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) * - send LOOKUP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) * - recv LOOKUP_REPLY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) * dlm_recover_locks()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) * - send LOCKS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) * - recv LOCKS_REPLY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) * recover_status |= LOCKS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) * dlm_recover_locks_wait()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) * recover_status |= DONE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) /* Called by dlm_recv; corresponds to dlm_receive_message() but special
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) recovery-only comms are sent through here. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) void dlm_receive_rcom(struct dlm_ls *ls, struct dlm_rcom *rc, int nodeid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) int lock_size = sizeof(struct dlm_rcom) + sizeof(struct rcom_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) int stop, reply = 0, names = 0, lookup = 0, lock = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) uint32_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) uint64_t seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) switch (rc->rc_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) case DLM_RCOM_STATUS_REPLY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) reply = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) case DLM_RCOM_NAMES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) names = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) case DLM_RCOM_NAMES_REPLY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) names = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) reply = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) case DLM_RCOM_LOOKUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) lookup = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) case DLM_RCOM_LOOKUP_REPLY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) lookup = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) reply = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) case DLM_RCOM_LOCK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) lock = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) case DLM_RCOM_LOCK_REPLY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) lock = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) reply = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) spin_lock(&ls->ls_recover_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) status = ls->ls_recover_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) stop = test_bit(LSFL_RECOVER_STOP, &ls->ls_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) seq = ls->ls_recover_seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) spin_unlock(&ls->ls_recover_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) if (stop && (rc->rc_type != DLM_RCOM_STATUS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) goto ignore;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) if (reply && (rc->rc_seq_reply != seq))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) goto ignore;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) if (!(status & DLM_RS_NODES) && (names || lookup || lock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) goto ignore;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) if (!(status & DLM_RS_DIR) && (lookup || lock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) goto ignore;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) switch (rc->rc_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) case DLM_RCOM_STATUS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) receive_rcom_status(ls, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) case DLM_RCOM_NAMES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) receive_rcom_names(ls, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) case DLM_RCOM_LOOKUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) receive_rcom_lookup(ls, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) case DLM_RCOM_LOCK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) if (rc->rc_header.h_length < lock_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) goto Eshort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) receive_rcom_lock(ls, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) case DLM_RCOM_STATUS_REPLY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) receive_sync_reply(ls, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) case DLM_RCOM_NAMES_REPLY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) receive_sync_reply(ls, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) case DLM_RCOM_LOOKUP_REPLY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) receive_rcom_lookup_reply(ls, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) case DLM_RCOM_LOCK_REPLY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) if (rc->rc_header.h_length < lock_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) goto Eshort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) dlm_recover_process_copy(ls, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) log_error(ls, "receive_rcom bad type %d", rc->rc_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) ignore:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) log_limit(ls, "dlm_receive_rcom ignore msg %d "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) "from %d %llu %llu recover seq %llu sts %x gen %u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) rc->rc_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) nodeid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) (unsigned long long)rc->rc_seq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) (unsigned long long)rc->rc_seq_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) (unsigned long long)seq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) status, ls->ls_generation);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) Eshort:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) log_error(ls, "recovery message %d from %d is too short",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) rc->rc_type, nodeid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642)