David Teigland | e7fd417 | 2006-01-18 09:30:29 +0000 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | ******************************************************************************* |
| 3 | ** |
| 4 | ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. |
| 5 | ** Copyright (C) 2005 Red Hat, Inc. All rights reserved. |
| 6 | ** |
| 7 | ** This copyrighted material is made available to anyone wishing to use, |
| 8 | ** modify, copy, or redistribute it subject to the terms and conditions |
| 9 | ** of the GNU General Public License v.2. |
| 10 | ** |
| 11 | ******************************************************************************* |
| 12 | ******************************************************************************/ |
| 13 | |
| 14 | #include "dlm_internal.h" |
| 15 | #include "lockspace.h" |
| 16 | #include "member.h" |
| 17 | #include "lowcomms.h" |
| 18 | #include "midcomms.h" |
| 19 | #include "rcom.h" |
| 20 | #include "recover.h" |
| 21 | #include "dir.h" |
| 22 | #include "config.h" |
| 23 | #include "memory.h" |
| 24 | #include "lock.h" |
| 25 | #include "util.h" |
| 26 | |
| 27 | |
| 28 | static int rcom_response(struct dlm_ls *ls) |
| 29 | { |
| 30 | return test_bit(LSFL_RCOM_READY, &ls->ls_flags); |
| 31 | } |
| 32 | |
| 33 | static int create_rcom(struct dlm_ls *ls, int to_nodeid, int type, int len, |
| 34 | struct dlm_rcom **rc_ret, struct dlm_mhandle **mh_ret) |
| 35 | { |
| 36 | struct dlm_rcom *rc; |
| 37 | struct dlm_mhandle *mh; |
| 38 | char *mb; |
| 39 | int mb_len = sizeof(struct dlm_rcom) + len; |
| 40 | |
| 41 | mh = dlm_lowcomms_get_buffer(to_nodeid, mb_len, GFP_KERNEL, &mb); |
| 42 | if (!mh) { |
| 43 | log_print("create_rcom to %d type %d len %d ENOBUFS", |
| 44 | to_nodeid, type, len); |
| 45 | return -ENOBUFS; |
| 46 | } |
| 47 | memset(mb, 0, mb_len); |
| 48 | |
| 49 | rc = (struct dlm_rcom *) mb; |
| 50 | |
| 51 | rc->rc_header.h_version = (DLM_HEADER_MAJOR | DLM_HEADER_MINOR); |
| 52 | rc->rc_header.h_lockspace = ls->ls_global_id; |
| 53 | rc->rc_header.h_nodeid = dlm_our_nodeid(); |
| 54 | rc->rc_header.h_length = mb_len; |
| 55 | rc->rc_header.h_cmd = DLM_RCOM; |
| 56 | |
| 57 | rc->rc_type = type; |
| 58 | |
| 59 | *mh_ret = mh; |
| 60 | *rc_ret = rc; |
| 61 | return 0; |
| 62 | } |
| 63 | |
| 64 | static void send_rcom(struct dlm_ls *ls, struct dlm_mhandle *mh, |
| 65 | struct dlm_rcom *rc) |
| 66 | { |
| 67 | dlm_rcom_out(rc); |
| 68 | dlm_lowcomms_commit_buffer(mh); |
| 69 | } |
| 70 | |
| 71 | /* When replying to a status request, a node also sends back its |
| 72 | configuration values. The requesting node then checks that the remote |
| 73 | node is configured the same way as itself. */ |
| 74 | |
| 75 | static void make_config(struct dlm_ls *ls, struct rcom_config *rf) |
| 76 | { |
| 77 | rf->rf_lvblen = ls->ls_lvblen; |
| 78 | rf->rf_lsflags = ls->ls_exflags; |
| 79 | } |
| 80 | |
| 81 | static int check_config(struct dlm_ls *ls, struct rcom_config *rf, int nodeid) |
| 82 | { |
| 83 | if (rf->rf_lvblen != ls->ls_lvblen || |
| 84 | rf->rf_lsflags != ls->ls_exflags) { |
| 85 | log_error(ls, "config mismatch: %d,%x nodeid %d: %d,%x", |
| 86 | ls->ls_lvblen, ls->ls_exflags, |
| 87 | nodeid, rf->rf_lvblen, rf->rf_lsflags); |
| 88 | return -EINVAL; |
| 89 | } |
| 90 | return 0; |
| 91 | } |
| 92 | |
David Teigland | 98f176f | 2006-11-27 13:19:28 -0600 | [diff] [blame^] | 93 | static void allow_sync_reply(struct dlm_ls *ls, uint64_t *new_seq) |
| 94 | { |
| 95 | spin_lock(&ls->ls_rcom_spin); |
| 96 | *new_seq = ++ls->ls_rcom_seq; |
| 97 | set_bit(LSFL_RCOM_WAIT, &ls->ls_flags); |
| 98 | spin_unlock(&ls->ls_rcom_spin); |
| 99 | } |
| 100 | |
| 101 | static void disallow_sync_reply(struct dlm_ls *ls) |
| 102 | { |
| 103 | spin_lock(&ls->ls_rcom_spin); |
| 104 | clear_bit(LSFL_RCOM_WAIT, &ls->ls_flags); |
| 105 | clear_bit(LSFL_RCOM_READY, &ls->ls_flags); |
| 106 | spin_unlock(&ls->ls_rcom_spin); |
| 107 | } |
| 108 | |
David Teigland | e7fd417 | 2006-01-18 09:30:29 +0000 | [diff] [blame] | 109 | int dlm_rcom_status(struct dlm_ls *ls, int nodeid) |
| 110 | { |
| 111 | struct dlm_rcom *rc; |
| 112 | struct dlm_mhandle *mh; |
| 113 | int error = 0; |
| 114 | |
David Teigland | faa0f26 | 2006-08-08 17:08:42 -0500 | [diff] [blame] | 115 | ls->ls_recover_nodeid = nodeid; |
David Teigland | e7fd417 | 2006-01-18 09:30:29 +0000 | [diff] [blame] | 116 | |
| 117 | if (nodeid == dlm_our_nodeid()) { |
| 118 | rc = (struct dlm_rcom *) ls->ls_recover_buf; |
| 119 | rc->rc_result = dlm_recover_status(ls); |
| 120 | goto out; |
| 121 | } |
| 122 | |
| 123 | error = create_rcom(ls, nodeid, DLM_RCOM_STATUS, 0, &rc, &mh); |
| 124 | if (error) |
| 125 | goto out; |
David Teigland | 98f176f | 2006-11-27 13:19:28 -0600 | [diff] [blame^] | 126 | |
| 127 | allow_sync_reply(ls, &rc->rc_id); |
| 128 | memset(ls->ls_recover_buf, 0, dlm_config.buffer_size); |
David Teigland | e7fd417 | 2006-01-18 09:30:29 +0000 | [diff] [blame] | 129 | |
| 130 | send_rcom(ls, mh, rc); |
| 131 | |
| 132 | error = dlm_wait_function(ls, &rcom_response); |
David Teigland | 98f176f | 2006-11-27 13:19:28 -0600 | [diff] [blame^] | 133 | disallow_sync_reply(ls); |
David Teigland | e7fd417 | 2006-01-18 09:30:29 +0000 | [diff] [blame] | 134 | if (error) |
| 135 | goto out; |
| 136 | |
| 137 | rc = (struct dlm_rcom *) ls->ls_recover_buf; |
| 138 | |
| 139 | if (rc->rc_result == -ESRCH) { |
| 140 | /* we pretend the remote lockspace exists with 0 status */ |
| 141 | log_debug(ls, "remote node %d not ready", nodeid); |
| 142 | rc->rc_result = 0; |
| 143 | } else |
| 144 | error = check_config(ls, (struct rcom_config *) rc->rc_buf, |
| 145 | nodeid); |
| 146 | /* the caller looks at rc_result for the remote recovery status */ |
| 147 | out: |
| 148 | return error; |
| 149 | } |
| 150 | |
| 151 | static void receive_rcom_status(struct dlm_ls *ls, struct dlm_rcom *rc_in) |
| 152 | { |
| 153 | struct dlm_rcom *rc; |
| 154 | struct dlm_mhandle *mh; |
| 155 | int error, nodeid = rc_in->rc_header.h_nodeid; |
| 156 | |
| 157 | error = create_rcom(ls, nodeid, DLM_RCOM_STATUS_REPLY, |
| 158 | sizeof(struct rcom_config), &rc, &mh); |
| 159 | if (error) |
| 160 | return; |
David Teigland | 4a99c3d | 2006-08-09 11:20:15 -0500 | [diff] [blame] | 161 | rc->rc_id = rc_in->rc_id; |
David Teigland | e7fd417 | 2006-01-18 09:30:29 +0000 | [diff] [blame] | 162 | rc->rc_result = dlm_recover_status(ls); |
| 163 | make_config(ls, (struct rcom_config *) rc->rc_buf); |
| 164 | |
| 165 | send_rcom(ls, mh, rc); |
| 166 | } |
| 167 | |
David Teigland | 4a99c3d | 2006-08-09 11:20:15 -0500 | [diff] [blame] | 168 | static void receive_sync_reply(struct dlm_ls *ls, struct dlm_rcom *rc_in) |
David Teigland | e7fd417 | 2006-01-18 09:30:29 +0000 | [diff] [blame] | 169 | { |
David Teigland | 98f176f | 2006-11-27 13:19:28 -0600 | [diff] [blame^] | 170 | spin_lock(&ls->ls_rcom_spin); |
| 171 | if (!test_bit(LSFL_RCOM_WAIT, &ls->ls_flags) || |
| 172 | rc_in->rc_id != ls->ls_rcom_seq) { |
| 173 | log_debug(ls, "reject reply %d from %d seq %llx expect %llx", |
| 174 | rc_in->rc_type, rc_in->rc_header.h_nodeid, |
| 175 | rc_in->rc_id, ls->ls_rcom_seq); |
| 176 | goto out; |
David Teigland | 4a99c3d | 2006-08-09 11:20:15 -0500 | [diff] [blame] | 177 | } |
David Teigland | e7fd417 | 2006-01-18 09:30:29 +0000 | [diff] [blame] | 178 | memcpy(ls->ls_recover_buf, rc_in, rc_in->rc_header.h_length); |
| 179 | set_bit(LSFL_RCOM_READY, &ls->ls_flags); |
David Teigland | 98f176f | 2006-11-27 13:19:28 -0600 | [diff] [blame^] | 180 | clear_bit(LSFL_RCOM_WAIT, &ls->ls_flags); |
David Teigland | e7fd417 | 2006-01-18 09:30:29 +0000 | [diff] [blame] | 181 | wake_up(&ls->ls_wait_general); |
David Teigland | 98f176f | 2006-11-27 13:19:28 -0600 | [diff] [blame^] | 182 | out: |
| 183 | spin_unlock(&ls->ls_rcom_spin); |
David Teigland | e7fd417 | 2006-01-18 09:30:29 +0000 | [diff] [blame] | 184 | } |
| 185 | |
David Teigland | 4a99c3d | 2006-08-09 11:20:15 -0500 | [diff] [blame] | 186 | static void receive_rcom_status_reply(struct dlm_ls *ls, struct dlm_rcom *rc_in) |
| 187 | { |
| 188 | receive_sync_reply(ls, rc_in); |
| 189 | } |
| 190 | |
David Teigland | e7fd417 | 2006-01-18 09:30:29 +0000 | [diff] [blame] | 191 | int dlm_rcom_names(struct dlm_ls *ls, int nodeid, char *last_name, int last_len) |
| 192 | { |
| 193 | struct dlm_rcom *rc; |
| 194 | struct dlm_mhandle *mh; |
| 195 | int error = 0, len = sizeof(struct dlm_rcom); |
| 196 | |
David Teigland | faa0f26 | 2006-08-08 17:08:42 -0500 | [diff] [blame] | 197 | ls->ls_recover_nodeid = nodeid; |
David Teigland | e7fd417 | 2006-01-18 09:30:29 +0000 | [diff] [blame] | 198 | |
| 199 | if (nodeid == dlm_our_nodeid()) { |
| 200 | dlm_copy_master_names(ls, last_name, last_len, |
| 201 | ls->ls_recover_buf + len, |
| 202 | dlm_config.buffer_size - len, nodeid); |
| 203 | goto out; |
| 204 | } |
| 205 | |
| 206 | error = create_rcom(ls, nodeid, DLM_RCOM_NAMES, last_len, &rc, &mh); |
| 207 | if (error) |
| 208 | goto out; |
| 209 | memcpy(rc->rc_buf, last_name, last_len); |
David Teigland | 98f176f | 2006-11-27 13:19:28 -0600 | [diff] [blame^] | 210 | |
| 211 | allow_sync_reply(ls, &rc->rc_id); |
| 212 | memset(ls->ls_recover_buf, 0, dlm_config.buffer_size); |
David Teigland | e7fd417 | 2006-01-18 09:30:29 +0000 | [diff] [blame] | 213 | |
| 214 | send_rcom(ls, mh, rc); |
| 215 | |
| 216 | error = dlm_wait_function(ls, &rcom_response); |
David Teigland | 98f176f | 2006-11-27 13:19:28 -0600 | [diff] [blame^] | 217 | disallow_sync_reply(ls); |
David Teigland | e7fd417 | 2006-01-18 09:30:29 +0000 | [diff] [blame] | 218 | out: |
| 219 | return error; |
| 220 | } |
| 221 | |
| 222 | static void receive_rcom_names(struct dlm_ls *ls, struct dlm_rcom *rc_in) |
| 223 | { |
| 224 | struct dlm_rcom *rc; |
| 225 | struct dlm_mhandle *mh; |
| 226 | int error, inlen, outlen; |
| 227 | int nodeid = rc_in->rc_header.h_nodeid; |
| 228 | uint32_t status = dlm_recover_status(ls); |
| 229 | |
| 230 | /* |
| 231 | * We can't run dlm_dir_rebuild_send (which uses ls_nodes) while |
| 232 | * dlm_recoverd is running ls_nodes_reconfig (which changes ls_nodes). |
| 233 | * It could only happen in rare cases where we get a late NAMES |
| 234 | * message from a previous instance of recovery. |
| 235 | */ |
| 236 | |
| 237 | if (!(status & DLM_RS_NODES)) { |
| 238 | log_debug(ls, "ignoring RCOM_NAMES from %u", nodeid); |
| 239 | return; |
| 240 | } |
| 241 | |
| 242 | nodeid = rc_in->rc_header.h_nodeid; |
| 243 | inlen = rc_in->rc_header.h_length - sizeof(struct dlm_rcom); |
| 244 | outlen = dlm_config.buffer_size - sizeof(struct dlm_rcom); |
| 245 | |
| 246 | error = create_rcom(ls, nodeid, DLM_RCOM_NAMES_REPLY, outlen, &rc, &mh); |
| 247 | if (error) |
| 248 | return; |
David Teigland | 4a99c3d | 2006-08-09 11:20:15 -0500 | [diff] [blame] | 249 | rc->rc_id = rc_in->rc_id; |
David Teigland | e7fd417 | 2006-01-18 09:30:29 +0000 | [diff] [blame] | 250 | |
| 251 | dlm_copy_master_names(ls, rc_in->rc_buf, inlen, rc->rc_buf, outlen, |
| 252 | nodeid); |
| 253 | send_rcom(ls, mh, rc); |
| 254 | } |
| 255 | |
| 256 | static void receive_rcom_names_reply(struct dlm_ls *ls, struct dlm_rcom *rc_in) |
| 257 | { |
David Teigland | 4a99c3d | 2006-08-09 11:20:15 -0500 | [diff] [blame] | 258 | receive_sync_reply(ls, rc_in); |
David Teigland | e7fd417 | 2006-01-18 09:30:29 +0000 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | int dlm_send_rcom_lookup(struct dlm_rsb *r, int dir_nodeid) |
| 262 | { |
| 263 | struct dlm_rcom *rc; |
| 264 | struct dlm_mhandle *mh; |
| 265 | struct dlm_ls *ls = r->res_ls; |
| 266 | int error; |
| 267 | |
| 268 | error = create_rcom(ls, dir_nodeid, DLM_RCOM_LOOKUP, r->res_length, |
| 269 | &rc, &mh); |
| 270 | if (error) |
| 271 | goto out; |
| 272 | memcpy(rc->rc_buf, r->res_name, r->res_length); |
| 273 | rc->rc_id = (unsigned long) r; |
| 274 | |
| 275 | send_rcom(ls, mh, rc); |
| 276 | out: |
| 277 | return error; |
| 278 | } |
| 279 | |
| 280 | static void receive_rcom_lookup(struct dlm_ls *ls, struct dlm_rcom *rc_in) |
| 281 | { |
| 282 | struct dlm_rcom *rc; |
| 283 | struct dlm_mhandle *mh; |
| 284 | int error, ret_nodeid, nodeid = rc_in->rc_header.h_nodeid; |
| 285 | int len = rc_in->rc_header.h_length - sizeof(struct dlm_rcom); |
| 286 | |
| 287 | error = create_rcom(ls, nodeid, DLM_RCOM_LOOKUP_REPLY, 0, &rc, &mh); |
| 288 | if (error) |
| 289 | return; |
| 290 | |
| 291 | error = dlm_dir_lookup(ls, nodeid, rc_in->rc_buf, len, &ret_nodeid); |
| 292 | if (error) |
| 293 | ret_nodeid = error; |
| 294 | rc->rc_result = ret_nodeid; |
| 295 | rc->rc_id = rc_in->rc_id; |
| 296 | |
| 297 | send_rcom(ls, mh, rc); |
| 298 | } |
| 299 | |
| 300 | static void receive_rcom_lookup_reply(struct dlm_ls *ls, struct dlm_rcom *rc_in) |
| 301 | { |
| 302 | dlm_recover_master_reply(ls, rc_in); |
| 303 | } |
| 304 | |
| 305 | static void pack_rcom_lock(struct dlm_rsb *r, struct dlm_lkb *lkb, |
| 306 | struct rcom_lock *rl) |
| 307 | { |
| 308 | memset(rl, 0, sizeof(*rl)); |
| 309 | |
| 310 | rl->rl_ownpid = lkb->lkb_ownpid; |
| 311 | rl->rl_lkid = lkb->lkb_id; |
| 312 | rl->rl_exflags = lkb->lkb_exflags; |
| 313 | rl->rl_flags = lkb->lkb_flags; |
| 314 | rl->rl_lvbseq = lkb->lkb_lvbseq; |
| 315 | rl->rl_rqmode = lkb->lkb_rqmode; |
| 316 | rl->rl_grmode = lkb->lkb_grmode; |
| 317 | rl->rl_status = lkb->lkb_status; |
| 318 | rl->rl_wait_type = lkb->lkb_wait_type; |
| 319 | |
| 320 | if (lkb->lkb_bastaddr) |
| 321 | rl->rl_asts |= AST_BAST; |
| 322 | if (lkb->lkb_astaddr) |
| 323 | rl->rl_asts |= AST_COMP; |
| 324 | |
David Teigland | e7fd417 | 2006-01-18 09:30:29 +0000 | [diff] [blame] | 325 | rl->rl_namelen = r->res_length; |
| 326 | memcpy(rl->rl_name, r->res_name, r->res_length); |
| 327 | |
| 328 | /* FIXME: might we have an lvb without DLM_LKF_VALBLK set ? |
| 329 | If so, receive_rcom_lock_args() won't take this copy. */ |
| 330 | |
| 331 | if (lkb->lkb_lvbptr) |
| 332 | memcpy(rl->rl_lvb, lkb->lkb_lvbptr, r->res_ls->ls_lvblen); |
| 333 | } |
| 334 | |
| 335 | int dlm_send_rcom_lock(struct dlm_rsb *r, struct dlm_lkb *lkb) |
| 336 | { |
| 337 | struct dlm_ls *ls = r->res_ls; |
| 338 | struct dlm_rcom *rc; |
| 339 | struct dlm_mhandle *mh; |
| 340 | struct rcom_lock *rl; |
| 341 | int error, len = sizeof(struct rcom_lock); |
| 342 | |
| 343 | if (lkb->lkb_lvbptr) |
| 344 | len += ls->ls_lvblen; |
| 345 | |
| 346 | error = create_rcom(ls, r->res_nodeid, DLM_RCOM_LOCK, len, &rc, &mh); |
| 347 | if (error) |
| 348 | goto out; |
| 349 | |
| 350 | rl = (struct rcom_lock *) rc->rc_buf; |
| 351 | pack_rcom_lock(r, lkb, rl); |
| 352 | rc->rc_id = (unsigned long) r; |
| 353 | |
| 354 | send_rcom(ls, mh, rc); |
| 355 | out: |
| 356 | return error; |
| 357 | } |
| 358 | |
| 359 | static void receive_rcom_lock(struct dlm_ls *ls, struct dlm_rcom *rc_in) |
| 360 | { |
| 361 | struct dlm_rcom *rc; |
| 362 | struct dlm_mhandle *mh; |
| 363 | int error, nodeid = rc_in->rc_header.h_nodeid; |
| 364 | |
| 365 | dlm_recover_master_copy(ls, rc_in); |
| 366 | |
| 367 | error = create_rcom(ls, nodeid, DLM_RCOM_LOCK_REPLY, |
| 368 | sizeof(struct rcom_lock), &rc, &mh); |
| 369 | if (error) |
| 370 | return; |
| 371 | |
| 372 | /* We send back the same rcom_lock struct we received, but |
| 373 | dlm_recover_master_copy() has filled in rl_remid and rl_result */ |
| 374 | |
| 375 | memcpy(rc->rc_buf, rc_in->rc_buf, sizeof(struct rcom_lock)); |
| 376 | rc->rc_id = rc_in->rc_id; |
| 377 | |
| 378 | send_rcom(ls, mh, rc); |
| 379 | } |
| 380 | |
| 381 | static void receive_rcom_lock_reply(struct dlm_ls *ls, struct dlm_rcom *rc_in) |
| 382 | { |
| 383 | uint32_t status = dlm_recover_status(ls); |
| 384 | |
| 385 | if (!(status & DLM_RS_DIR)) { |
| 386 | log_debug(ls, "ignoring RCOM_LOCK_REPLY from %u", |
| 387 | rc_in->rc_header.h_nodeid); |
| 388 | return; |
| 389 | } |
| 390 | |
| 391 | dlm_recover_process_copy(ls, rc_in); |
| 392 | } |
| 393 | |
| 394 | static int send_ls_not_ready(int nodeid, struct dlm_rcom *rc_in) |
| 395 | { |
| 396 | struct dlm_rcom *rc; |
David Teigland | 1babdb4 | 2006-11-27 13:18:41 -0600 | [diff] [blame] | 397 | struct rcom_config *rf; |
David Teigland | e7fd417 | 2006-01-18 09:30:29 +0000 | [diff] [blame] | 398 | struct dlm_mhandle *mh; |
| 399 | char *mb; |
David Teigland | 1babdb4 | 2006-11-27 13:18:41 -0600 | [diff] [blame] | 400 | int mb_len = sizeof(struct dlm_rcom) + sizeof(struct rcom_config); |
David Teigland | e7fd417 | 2006-01-18 09:30:29 +0000 | [diff] [blame] | 401 | |
| 402 | mh = dlm_lowcomms_get_buffer(nodeid, mb_len, GFP_KERNEL, &mb); |
| 403 | if (!mh) |
| 404 | return -ENOBUFS; |
| 405 | memset(mb, 0, mb_len); |
| 406 | |
| 407 | rc = (struct dlm_rcom *) mb; |
| 408 | |
| 409 | rc->rc_header.h_version = (DLM_HEADER_MAJOR | DLM_HEADER_MINOR); |
| 410 | rc->rc_header.h_lockspace = rc_in->rc_header.h_lockspace; |
| 411 | rc->rc_header.h_nodeid = dlm_our_nodeid(); |
| 412 | rc->rc_header.h_length = mb_len; |
| 413 | rc->rc_header.h_cmd = DLM_RCOM; |
| 414 | |
| 415 | rc->rc_type = DLM_RCOM_STATUS_REPLY; |
David Teigland | f588875 | 2006-08-23 12:50:54 -0500 | [diff] [blame] | 416 | rc->rc_id = rc_in->rc_id; |
David Teigland | e7fd417 | 2006-01-18 09:30:29 +0000 | [diff] [blame] | 417 | rc->rc_result = -ESRCH; |
| 418 | |
David Teigland | 1babdb4 | 2006-11-27 13:18:41 -0600 | [diff] [blame] | 419 | rf = (struct rcom_config *) rc->rc_buf; |
| 420 | rf->rf_lvblen = -1; |
| 421 | |
David Teigland | e7fd417 | 2006-01-18 09:30:29 +0000 | [diff] [blame] | 422 | dlm_rcom_out(rc); |
| 423 | dlm_lowcomms_commit_buffer(mh); |
| 424 | |
| 425 | return 0; |
| 426 | } |
| 427 | |
| 428 | /* Called by dlm_recvd; corresponds to dlm_receive_message() but special |
| 429 | recovery-only comms are sent through here. */ |
| 430 | |
| 431 | void dlm_receive_rcom(struct dlm_header *hd, int nodeid) |
| 432 | { |
| 433 | struct dlm_rcom *rc = (struct dlm_rcom *) hd; |
| 434 | struct dlm_ls *ls; |
| 435 | |
| 436 | dlm_rcom_in(rc); |
| 437 | |
| 438 | /* If the lockspace doesn't exist then still send a status message |
| 439 | back; it's possible that it just doesn't have its global_id yet. */ |
| 440 | |
| 441 | ls = dlm_find_lockspace_global(hd->h_lockspace); |
| 442 | if (!ls) { |
David Teigland | 435618b | 2006-11-02 09:45:56 -0600 | [diff] [blame] | 443 | log_print("lockspace %x from %d type %x not found", |
| 444 | hd->h_lockspace, nodeid, rc->rc_type); |
| 445 | if (rc->rc_type == DLM_RCOM_STATUS) |
| 446 | send_ls_not_ready(nodeid, rc); |
David Teigland | e7fd417 | 2006-01-18 09:30:29 +0000 | [diff] [blame] | 447 | return; |
| 448 | } |
| 449 | |
| 450 | if (dlm_recovery_stopped(ls) && (rc->rc_type != DLM_RCOM_STATUS)) { |
| 451 | log_error(ls, "ignoring recovery message %x from %d", |
| 452 | rc->rc_type, nodeid); |
| 453 | goto out; |
| 454 | } |
| 455 | |
| 456 | if (nodeid != rc->rc_header.h_nodeid) { |
| 457 | log_error(ls, "bad rcom nodeid %d from %d", |
| 458 | rc->rc_header.h_nodeid, nodeid); |
| 459 | goto out; |
| 460 | } |
| 461 | |
| 462 | switch (rc->rc_type) { |
| 463 | case DLM_RCOM_STATUS: |
| 464 | receive_rcom_status(ls, rc); |
| 465 | break; |
| 466 | |
| 467 | case DLM_RCOM_NAMES: |
| 468 | receive_rcom_names(ls, rc); |
| 469 | break; |
| 470 | |
| 471 | case DLM_RCOM_LOOKUP: |
| 472 | receive_rcom_lookup(ls, rc); |
| 473 | break; |
| 474 | |
| 475 | case DLM_RCOM_LOCK: |
| 476 | receive_rcom_lock(ls, rc); |
| 477 | break; |
| 478 | |
| 479 | case DLM_RCOM_STATUS_REPLY: |
| 480 | receive_rcom_status_reply(ls, rc); |
| 481 | break; |
| 482 | |
| 483 | case DLM_RCOM_NAMES_REPLY: |
| 484 | receive_rcom_names_reply(ls, rc); |
| 485 | break; |
| 486 | |
| 487 | case DLM_RCOM_LOOKUP_REPLY: |
| 488 | receive_rcom_lookup_reply(ls, rc); |
| 489 | break; |
| 490 | |
| 491 | case DLM_RCOM_LOCK_REPLY: |
| 492 | receive_rcom_lock_reply(ls, rc); |
| 493 | break; |
| 494 | |
| 495 | default: |
| 496 | DLM_ASSERT(0, printk("rc_type=%x\n", rc->rc_type);); |
| 497 | } |
| 498 | out: |
| 499 | dlm_put_lockspace(ls); |
| 500 | } |
| 501 | |