diff options
Diffstat (limited to 'fs/dlm/rcom.c')
-rw-r--r-- | fs/dlm/rcom.c | 58 |
1 files changed, 44 insertions, 14 deletions
diff --git a/fs/dlm/rcom.c b/fs/dlm/rcom.c index 518239a8b1e9..4cc31be9cd9d 100644 --- a/fs/dlm/rcom.c +++ b/fs/dlm/rcom.c | |||
@@ -90,13 +90,28 @@ static int check_config(struct dlm_ls *ls, struct rcom_config *rf, int nodeid) | |||
90 | return 0; | 90 | return 0; |
91 | } | 91 | } |
92 | 92 | ||
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 | |||
93 | int dlm_rcom_status(struct dlm_ls *ls, int nodeid) | 109 | int dlm_rcom_status(struct dlm_ls *ls, int nodeid) |
94 | { | 110 | { |
95 | struct dlm_rcom *rc; | 111 | struct dlm_rcom *rc; |
96 | struct dlm_mhandle *mh; | 112 | struct dlm_mhandle *mh; |
97 | int error = 0; | 113 | int error = 0; |
98 | 114 | ||
99 | memset(ls->ls_recover_buf, 0, dlm_config.buffer_size); | ||
100 | ls->ls_recover_nodeid = nodeid; | 115 | ls->ls_recover_nodeid = nodeid; |
101 | 116 | ||
102 | if (nodeid == dlm_our_nodeid()) { | 117 | if (nodeid == dlm_our_nodeid()) { |
@@ -108,12 +123,14 @@ int dlm_rcom_status(struct dlm_ls *ls, int nodeid) | |||
108 | error = create_rcom(ls, nodeid, DLM_RCOM_STATUS, 0, &rc, &mh); | 123 | error = create_rcom(ls, nodeid, DLM_RCOM_STATUS, 0, &rc, &mh); |
109 | if (error) | 124 | if (error) |
110 | goto out; | 125 | goto out; |
111 | rc->rc_id = ++ls->ls_rcom_seq; | 126 | |
127 | allow_sync_reply(ls, &rc->rc_id); | ||
128 | memset(ls->ls_recover_buf, 0, dlm_config.buffer_size); | ||
112 | 129 | ||
113 | send_rcom(ls, mh, rc); | 130 | send_rcom(ls, mh, rc); |
114 | 131 | ||
115 | error = dlm_wait_function(ls, &rcom_response); | 132 | error = dlm_wait_function(ls, &rcom_response); |
116 | clear_bit(LSFL_RCOM_READY, &ls->ls_flags); | 133 | disallow_sync_reply(ls); |
117 | if (error) | 134 | if (error) |
118 | goto out; | 135 | goto out; |
119 | 136 | ||
@@ -150,14 +167,21 @@ static void receive_rcom_status(struct dlm_ls *ls, struct dlm_rcom *rc_in) | |||
150 | 167 | ||
151 | static void receive_sync_reply(struct dlm_ls *ls, struct dlm_rcom *rc_in) | 168 | static void receive_sync_reply(struct dlm_ls *ls, struct dlm_rcom *rc_in) |
152 | { | 169 | { |
153 | if (rc_in->rc_id != ls->ls_rcom_seq) { | 170 | spin_lock(&ls->ls_rcom_spin); |
154 | log_debug(ls, "reject old reply %d got %llx wanted %llx", | 171 | if (!test_bit(LSFL_RCOM_WAIT, &ls->ls_flags) || |
155 | rc_in->rc_type, rc_in->rc_id, ls->ls_rcom_seq); | 172 | rc_in->rc_id != ls->ls_rcom_seq) { |
156 | return; | 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 | (unsigned long long)rc_in->rc_id, | ||
176 | (unsigned long long)ls->ls_rcom_seq); | ||
177 | goto out; | ||
157 | } | 178 | } |
158 | memcpy(ls->ls_recover_buf, rc_in, rc_in->rc_header.h_length); | 179 | memcpy(ls->ls_recover_buf, rc_in, rc_in->rc_header.h_length); |
159 | set_bit(LSFL_RCOM_READY, &ls->ls_flags); | 180 | set_bit(LSFL_RCOM_READY, &ls->ls_flags); |
181 | clear_bit(LSFL_RCOM_WAIT, &ls->ls_flags); | ||
160 | wake_up(&ls->ls_wait_general); | 182 | wake_up(&ls->ls_wait_general); |
183 | out: | ||
184 | spin_unlock(&ls->ls_rcom_spin); | ||
161 | } | 185 | } |
162 | 186 | ||
163 | static void receive_rcom_status_reply(struct dlm_ls *ls, struct dlm_rcom *rc_in) | 187 | static void receive_rcom_status_reply(struct dlm_ls *ls, struct dlm_rcom *rc_in) |
@@ -171,7 +195,6 @@ int dlm_rcom_names(struct dlm_ls *ls, int nodeid, char *last_name, int last_len) | |||
171 | struct dlm_mhandle *mh; | 195 | struct dlm_mhandle *mh; |
172 | int error = 0, len = sizeof(struct dlm_rcom); | 196 | int error = 0, len = sizeof(struct dlm_rcom); |
173 | 197 | ||
174 | memset(ls->ls_recover_buf, 0, dlm_config.buffer_size); | ||
175 | ls->ls_recover_nodeid = nodeid; | 198 | ls->ls_recover_nodeid = nodeid; |
176 | 199 | ||
177 | if (nodeid == dlm_our_nodeid()) { | 200 | if (nodeid == dlm_our_nodeid()) { |
@@ -185,12 +208,14 @@ int dlm_rcom_names(struct dlm_ls *ls, int nodeid, char *last_name, int last_len) | |||
185 | if (error) | 208 | if (error) |
186 | goto out; | 209 | goto out; |
187 | memcpy(rc->rc_buf, last_name, last_len); | 210 | memcpy(rc->rc_buf, last_name, last_len); |
188 | rc->rc_id = ++ls->ls_rcom_seq; | 211 | |
212 | allow_sync_reply(ls, &rc->rc_id); | ||
213 | memset(ls->ls_recover_buf, 0, dlm_config.buffer_size); | ||
189 | 214 | ||
190 | send_rcom(ls, mh, rc); | 215 | send_rcom(ls, mh, rc); |
191 | 216 | ||
192 | error = dlm_wait_function(ls, &rcom_response); | 217 | error = dlm_wait_function(ls, &rcom_response); |
193 | clear_bit(LSFL_RCOM_READY, &ls->ls_flags); | 218 | disallow_sync_reply(ls); |
194 | out: | 219 | out: |
195 | return error; | 220 | return error; |
196 | } | 221 | } |
@@ -370,9 +395,10 @@ static void receive_rcom_lock_reply(struct dlm_ls *ls, struct dlm_rcom *rc_in) | |||
370 | static int send_ls_not_ready(int nodeid, struct dlm_rcom *rc_in) | 395 | static int send_ls_not_ready(int nodeid, struct dlm_rcom *rc_in) |
371 | { | 396 | { |
372 | struct dlm_rcom *rc; | 397 | struct dlm_rcom *rc; |
398 | struct rcom_config *rf; | ||
373 | struct dlm_mhandle *mh; | 399 | struct dlm_mhandle *mh; |
374 | char *mb; | 400 | char *mb; |
375 | int mb_len = sizeof(struct dlm_rcom); | 401 | int mb_len = sizeof(struct dlm_rcom) + sizeof(struct rcom_config); |
376 | 402 | ||
377 | mh = dlm_lowcomms_get_buffer(nodeid, mb_len, GFP_KERNEL, &mb); | 403 | mh = dlm_lowcomms_get_buffer(nodeid, mb_len, GFP_KERNEL, &mb); |
378 | if (!mh) | 404 | if (!mh) |
@@ -391,6 +417,9 @@ static int send_ls_not_ready(int nodeid, struct dlm_rcom *rc_in) | |||
391 | rc->rc_id = rc_in->rc_id; | 417 | rc->rc_id = rc_in->rc_id; |
392 | rc->rc_result = -ESRCH; | 418 | rc->rc_result = -ESRCH; |
393 | 419 | ||
420 | rf = (struct rcom_config *) rc->rc_buf; | ||
421 | rf->rf_lvblen = -1; | ||
422 | |||
394 | dlm_rcom_out(rc); | 423 | dlm_rcom_out(rc); |
395 | dlm_lowcomms_commit_buffer(mh); | 424 | dlm_lowcomms_commit_buffer(mh); |
396 | 425 | ||
@@ -412,9 +441,10 @@ void dlm_receive_rcom(struct dlm_header *hd, int nodeid) | |||
412 | 441 | ||
413 | ls = dlm_find_lockspace_global(hd->h_lockspace); | 442 | ls = dlm_find_lockspace_global(hd->h_lockspace); |
414 | if (!ls) { | 443 | if (!ls) { |
415 | log_print("lockspace %x from %d not found", | 444 | log_print("lockspace %x from %d type %x not found", |
416 | hd->h_lockspace, nodeid); | 445 | hd->h_lockspace, nodeid, rc->rc_type); |
417 | send_ls_not_ready(nodeid, rc); | 446 | if (rc->rc_type == DLM_RCOM_STATUS) |
447 | send_ls_not_ready(nodeid, rc); | ||
418 | return; | 448 | return; |
419 | } | 449 | } |
420 | 450 | ||