rcom.c 16 KB

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