Skip to content

Commit 38aa8b0

Browse files
teiglandswhiteho
authored andcommitted
[DLM] fix old rcom messages
A reply to a recovery message will often be received after the relevant recovery sequence has aborted and the next recovery sequence has begun. We need to ignore replies to these old messages from the previous recovery. There's already a way to do this for synchronous recovery requests using the rc_id number, but not for async. Each recovery sequence already has a locally unique sequence number associated with it. This patch adds a field to the rcom (recovery message) structure where this recovery sequence number can be placed, rc_seq. When a node sends a reply to a recovery request, it copies the rc_seq number it received into rc_seq_reply. When the first node receives the reply to its recovery message, it will check whether rc_seq_reply matches the current recovery sequence number, ls_recover_seq, and if not then it ignores the old reply. An old, inadequate approach to filtering out old replies (checking if the current stage of recovery has moved back to the start) has been removed from two spots. The protocol version number is changed to reflect the different rcom structures. Signed-off-by: David Teigland <teigland@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
1 parent dc200a8 commit 38aa8b0

3 files changed

Lines changed: 46 additions & 25 deletions

File tree

‎fs/dlm/dlm_internal.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ static inline int rsb_flag(struct dlm_rsb *r, enum rsb_flags flag)
309309

310310
/* dlm_header is first element of all structs sent between nodes */
311311

312-
#define DLM_HEADER_MAJOR 0x00020000
313-
#define DLM_HEADER_MINOR 0x00000001
312+
#define DLM_HEADER_MAJOR 0x00030000
313+
#define DLM_HEADER_MINOR 0x00000000
314314

315315
#define DLM_MSG 1
316316
#define DLM_RCOM 2
@@ -386,6 +386,8 @@ struct dlm_rcom {
386386
uint32_t rc_type; /* DLM_RCOM_ */
387387
int rc_result; /* multi-purpose */
388388
uint64_t rc_id; /* match reply with request */
389+
uint64_t rc_seq; /* sender's ls_recover_seq */
390+
uint64_t rc_seq_reply; /* remote ls_recover_seq */
389391
char rc_buf[0];
390392
};
391393

‎fs/dlm/rcom.c‎

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ static int create_rcom(struct dlm_ls *ls, int to_nodeid, int type, int len,
5656

5757
rc->rc_type = type;
5858

59+
spin_lock(&ls->ls_recover_lock);
60+
rc->rc_seq = ls->ls_recover_seq;
61+
spin_unlock(&ls->ls_recover_lock);
62+
5963
*mh_ret = mh;
6064
*rc_ret = rc;
6165
return 0;
@@ -159,6 +163,7 @@ static void receive_rcom_status(struct dlm_ls *ls, struct dlm_rcom *rc_in)
159163
if (error)
160164
return;
161165
rc->rc_id = rc_in->rc_id;
166+
rc->rc_seq_reply = rc_in->rc_seq;
162167
rc->rc_result = dlm_recover_status(ls);
163168
make_config(ls, (struct rcom_config *) rc->rc_buf);
164169

@@ -224,21 +229,7 @@ static void receive_rcom_names(struct dlm_ls *ls, struct dlm_rcom *rc_in)
224229
{
225230
struct dlm_rcom *rc;
226231
struct dlm_mhandle *mh;
227-
int error, inlen, outlen;
228-
int nodeid = rc_in->rc_header.h_nodeid;
229-
uint32_t status = dlm_recover_status(ls);
230-
231-
/*
232-
* We can't run dlm_dir_rebuild_send (which uses ls_nodes) while
233-
* dlm_recoverd is running ls_nodes_reconfig (which changes ls_nodes).
234-
* It could only happen in rare cases where we get a late NAMES
235-
* message from a previous instance of recovery.
236-
*/
237-
238-
if (!(status & DLM_RS_NODES)) {
239-
log_debug(ls, "ignoring RCOM_NAMES from %u", nodeid);
240-
return;
241-
}
232+
int error, inlen, outlen, nodeid;
242233

243234
nodeid = rc_in->rc_header.h_nodeid;
244235
inlen = rc_in->rc_header.h_length - sizeof(struct dlm_rcom);
@@ -248,6 +239,7 @@ static void receive_rcom_names(struct dlm_ls *ls, struct dlm_rcom *rc_in)
248239
if (error)
249240
return;
250241
rc->rc_id = rc_in->rc_id;
242+
rc->rc_seq_reply = rc_in->rc_seq;
251243

252244
dlm_copy_master_names(ls, rc_in->rc_buf, inlen, rc->rc_buf, outlen,
253245
nodeid);
@@ -294,6 +286,7 @@ static void receive_rcom_lookup(struct dlm_ls *ls, struct dlm_rcom *rc_in)
294286
ret_nodeid = error;
295287
rc->rc_result = ret_nodeid;
296288
rc->rc_id = rc_in->rc_id;
289+
rc->rc_seq_reply = rc_in->rc_seq;
297290

298291
send_rcom(ls, mh, rc);
299292
}
@@ -375,20 +368,13 @@ static void receive_rcom_lock(struct dlm_ls *ls, struct dlm_rcom *rc_in)
375368

376369
memcpy(rc->rc_buf, rc_in->rc_buf, sizeof(struct rcom_lock));
377370
rc->rc_id = rc_in->rc_id;
371+
rc->rc_seq_reply = rc_in->rc_seq;
378372

379373
send_rcom(ls, mh, rc);
380374
}
381375

382376
static void receive_rcom_lock_reply(struct dlm_ls *ls, struct dlm_rcom *rc_in)
383377
{
384-
uint32_t status = dlm_recover_status(ls);
385-
386-
if (!(status & DLM_RS_DIR)) {
387-
log_debug(ls, "ignoring RCOM_LOCK_REPLY from %u",
388-
rc_in->rc_header.h_nodeid);
389-
return;
390-
}
391-
392378
dlm_recover_process_copy(ls, rc_in);
393379
}
394380

@@ -415,6 +401,7 @@ static int send_ls_not_ready(int nodeid, struct dlm_rcom *rc_in)
415401

416402
rc->rc_type = DLM_RCOM_STATUS_REPLY;
417403
rc->rc_id = rc_in->rc_id;
404+
rc->rc_seq_reply = rc_in->rc_seq;
418405
rc->rc_result = -ESRCH;
419406

420407
rf = (struct rcom_config *) rc->rc_buf;
@@ -426,6 +413,31 @@ static int send_ls_not_ready(int nodeid, struct dlm_rcom *rc_in)
426413
return 0;
427414
}
428415

416+
static int is_old_reply(struct dlm_ls *ls, struct dlm_rcom *rc)
417+
{
418+
uint64_t seq;
419+
int rv = 0;
420+
421+
switch (rc->rc_type) {
422+
case DLM_RCOM_STATUS_REPLY:
423+
case DLM_RCOM_NAMES_REPLY:
424+
case DLM_RCOM_LOOKUP_REPLY:
425+
case DLM_RCOM_LOCK_REPLY:
426+
spin_lock(&ls->ls_recover_lock);
427+
seq = ls->ls_recover_seq;
428+
spin_unlock(&ls->ls_recover_lock);
429+
if (rc->rc_seq_reply != seq) {
430+
log_error(ls, "ignoring old reply %x from %d "
431+
"seq_reply %llx expect %llx",
432+
rc->rc_type, rc->rc_header.h_nodeid,
433+
(unsigned long long)rc->rc_seq_reply,
434+
(unsigned long long)seq);
435+
rv = 1;
436+
}
437+
}
438+
return rv;
439+
}
440+
429441
/* Called by dlm_recvd; corresponds to dlm_receive_message() but special
430442
recovery-only comms are sent through here. */
431443

@@ -454,6 +466,9 @@ void dlm_receive_rcom(struct dlm_header *hd, int nodeid)
454466
goto out;
455467
}
456468

469+
if (is_old_reply(ls, rc))
470+
goto out;
471+
457472
if (nodeid != rc->rc_header.h_nodeid) {
458473
log_error(ls, "bad rcom nodeid %d from %d",
459474
rc->rc_header.h_nodeid, nodeid);

‎fs/dlm/util.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ void dlm_rcom_out(struct dlm_rcom *rc)
134134
rc->rc_type = cpu_to_le32(rc->rc_type);
135135
rc->rc_result = cpu_to_le32(rc->rc_result);
136136
rc->rc_id = cpu_to_le64(rc->rc_id);
137+
rc->rc_seq = cpu_to_le64(rc->rc_seq);
138+
rc->rc_seq_reply = cpu_to_le64(rc->rc_seq_reply);
137139

138140
if (type == DLM_RCOM_LOCK)
139141
rcom_lock_out((struct rcom_lock *) rc->rc_buf);
@@ -151,6 +153,8 @@ void dlm_rcom_in(struct dlm_rcom *rc)
151153
rc->rc_type = le32_to_cpu(rc->rc_type);
152154
rc->rc_result = le32_to_cpu(rc->rc_result);
153155
rc->rc_id = le64_to_cpu(rc->rc_id);
156+
rc->rc_seq = le64_to_cpu(rc->rc_seq);
157+
rc->rc_seq_reply = le64_to_cpu(rc->rc_seq_reply);
154158

155159
if (rc->rc_type == DLM_RCOM_LOCK)
156160
rcom_lock_in((struct rcom_lock *) rc->rc_buf);

0 commit comments

Comments
 (0)