member.c (ac0c955d5048c2c580fa7166a89133f0fd76c125) member.c (c36258b5925e6cf6bf72904635100593573bfcff)
1/******************************************************************************
2*******************************************************************************
3**
4** Copyright (C) 2005-2007 Red Hat, Inc. All rights reserved.
5**
6** This copyrighted material is made available to anyone wishing to use,
7** modify, copy, or redistribute it subject to the terms and conditions
8** of the GNU General Public License v.2.

--- 4 unchanged lines hidden (view full) ---

13#include "dlm_internal.h"
14#include "lockspace.h"
15#include "member.h"
16#include "recoverd.h"
17#include "recover.h"
18#include "rcom.h"
19#include "config.h"
20
1/******************************************************************************
2*******************************************************************************
3**
4** Copyright (C) 2005-2007 Red Hat, Inc. All rights reserved.
5**
6** This copyrighted material is made available to anyone wishing to use,
7** modify, copy, or redistribute it subject to the terms and conditions
8** of the GNU General Public License v.2.

--- 4 unchanged lines hidden (view full) ---

13#include "dlm_internal.h"
14#include "lockspace.h"
15#include "member.h"
16#include "recoverd.h"
17#include "recover.h"
18#include "rcom.h"
19#include "config.h"
20
21/*
22 * Following called by dlm_recoverd thread
23 */
24
25static void add_ordered_member(struct dlm_ls *ls, struct dlm_member *new)
26{
27 struct dlm_member *memb = NULL;
28 struct list_head *tmp;
29 struct list_head *newlist = &new->list;
30 struct list_head *head = &ls->ls_nodes;
31
32 list_for_each(tmp, head) {

--- 212 unchanged lines hidden (view full) ---

245 goto out;
246
247 error = dlm_recover_members_wait(ls);
248 out:
249 log_debug(ls, "total members %d error %d", ls->ls_num_nodes, error);
250 return error;
251}
252
21static void add_ordered_member(struct dlm_ls *ls, struct dlm_member *new)
22{
23 struct dlm_member *memb = NULL;
24 struct list_head *tmp;
25 struct list_head *newlist = &new->list;
26 struct list_head *head = &ls->ls_nodes;
27
28 list_for_each(tmp, head) {

--- 212 unchanged lines hidden (view full) ---

241 goto out;
242
243 error = dlm_recover_members_wait(ls);
244 out:
245 log_debug(ls, "total members %d error %d", ls->ls_num_nodes, error);
246 return error;
247}
248
253/*
254 * Following called from lockspace.c
255 */
249/* Userspace guarantees that dlm_ls_stop() has completed on all nodes before
250 dlm_ls_start() is called on any of them to start the new recovery. */
256
257int dlm_ls_stop(struct dlm_ls *ls)
258{
259 int new;
260
261 /*
251
252int dlm_ls_stop(struct dlm_ls *ls)
253{
254 int new;
255
256 /*
262 * A stop cancels any recovery that's in progress (see RECOVERY_STOP,
263 * dlm_recovery_stopped()) and prevents any new locks from being
264 * processed (see RUNNING, dlm_locking_stopped()).
257 * Prevent dlm_recv from being in the middle of something when we do
258 * the stop. This includes ensuring dlm_recv isn't processing a
259 * recovery message (rcom), while dlm_recoverd is aborting and
260 * resetting things from an in-progress recovery. i.e. we want
261 * dlm_recoverd to abort its recovery without worrying about dlm_recv
262 * processing an rcom at the same time. Stopping dlm_recv also makes
263 * it easy for dlm_receive_message() to check locking stopped and add a
264 * message to the requestqueue without races.
265 */
266
265 */
266
267 down_write(&ls->ls_recv_active);
268
269 /*
270 * Abort any recovery that's in progress (see RECOVERY_STOP,
271 * dlm_recovery_stopped()) and tell any other threads running in the
272 * dlm to quit any processing (see RUNNING, dlm_locking_stopped()).
273 */
274
267 spin_lock(&ls->ls_recover_lock);
268 set_bit(LSFL_RECOVERY_STOP, &ls->ls_flags);
269 new = test_and_clear_bit(LSFL_RUNNING, &ls->ls_flags);
270 ls->ls_recover_seq++;
271 spin_unlock(&ls->ls_recover_lock);
272
273 /*
275 spin_lock(&ls->ls_recover_lock);
276 set_bit(LSFL_RECOVERY_STOP, &ls->ls_flags);
277 new = test_and_clear_bit(LSFL_RUNNING, &ls->ls_flags);
278 ls->ls_recover_seq++;
279 spin_unlock(&ls->ls_recover_lock);
280
281 /*
282 * Let dlm_recv run again, now any normal messages will be saved on the
283 * requestqueue for later.
284 */
285
286 up_write(&ls->ls_recv_active);
287
288 /*
274 * This in_recovery lock does two things:
289 * This in_recovery lock does two things:
275 *
276 * 1) Keeps this function from returning until all threads are out
277 * of locking routines and locking is truely stopped.
278 * 2) Keeps any new requests from being processed until it's unlocked
279 * when recovery is complete.
280 */
281
282 if (new)
283 down_write(&ls->ls_in_recovery);
284
285 /*
286 * The recoverd suspend/resume makes sure that dlm_recoverd (if
290 * 1) Keeps this function from returning until all threads are out
291 * of locking routines and locking is truely stopped.
292 * 2) Keeps any new requests from being processed until it's unlocked
293 * when recovery is complete.
294 */
295
296 if (new)
297 down_write(&ls->ls_in_recovery);
298
299 /*
300 * The recoverd suspend/resume makes sure that dlm_recoverd (if
287 * running) has noticed the clearing of RUNNING above and quit
288 * processing the previous recovery. This will be true for all nodes
289 * before any nodes start the new recovery.
301 * running) has noticed RECOVERY_STOP above and quit processing the
302 * previous recovery.
290 */
291
292 dlm_recoverd_suspend(ls);
293 ls->ls_recover_status = 0;
294 dlm_recoverd_resume(ls);
295
296 if (!ls->ls_recover_begin)
297 ls->ls_recover_begin = jiffies;

--- 49 unchanged lines hidden ---
303 */
304
305 dlm_recoverd_suspend(ls);
306 ls->ls_recover_status = 0;
307 dlm_recoverd_resume(ls);
308
309 if (!ls->ls_recover_begin)
310 ls->ls_recover_begin = jiffies;

--- 49 unchanged lines hidden ---