Lines Matching refs:ls
31 static int enable_locking(struct dlm_ls *ls, uint64_t seq) in enable_locking() argument
35 down_write(&ls->ls_recv_active); in enable_locking()
37 spin_lock(&ls->ls_recover_lock); in enable_locking()
38 if (ls->ls_recover_seq == seq) { in enable_locking()
39 set_bit(LSFL_RUNNING, &ls->ls_flags); in enable_locking()
41 up_write(&ls->ls_in_recovery); in enable_locking()
42 clear_bit(LSFL_RECOVER_LOCK, &ls->ls_flags); in enable_locking()
45 spin_unlock(&ls->ls_recover_lock); in enable_locking()
47 up_write(&ls->ls_recv_active); in enable_locking()
51 static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv) in ls_recover() argument
56 log_rinfo(ls, "dlm_recover %llu", (unsigned long long)rv->seq); in ls_recover()
58 mutex_lock(&ls->ls_recoverd_active); in ls_recover()
60 dlm_callback_suspend(ls); in ls_recover()
62 dlm_clear_toss(ls); in ls_recover()
69 dlm_create_root_list(ls); in ls_recover()
75 error = dlm_recover_members(ls, rv, &neg); in ls_recover()
77 log_rinfo(ls, "dlm_recover_members error %d", error); in ls_recover()
81 dlm_recover_dir_nodeid(ls); in ls_recover()
83 ls->ls_recover_dir_sent_res = 0; in ls_recover()
84 ls->ls_recover_dir_sent_msg = 0; in ls_recover()
85 ls->ls_recover_locks_in = 0; in ls_recover()
87 dlm_set_recover_status(ls, DLM_RS_NODES); in ls_recover()
89 error = dlm_recover_members_wait(ls); in ls_recover()
91 log_rinfo(ls, "dlm_recover_members_wait error %d", error); in ls_recover()
102 error = dlm_recover_directory(ls); in ls_recover()
104 log_rinfo(ls, "dlm_recover_directory error %d", error); in ls_recover()
108 dlm_set_recover_status(ls, DLM_RS_DIR); in ls_recover()
110 error = dlm_recover_directory_wait(ls); in ls_recover()
112 log_rinfo(ls, "dlm_recover_directory_wait error %d", error); in ls_recover()
116 log_rinfo(ls, "dlm_recover_directory %u out %u messages", in ls_recover()
117 ls->ls_recover_dir_sent_res, ls->ls_recover_dir_sent_msg); in ls_recover()
125 dlm_recover_waiters_pre(ls); in ls_recover()
127 if (dlm_recovery_stopped(ls)) { in ls_recover()
132 if (neg || dlm_no_directory(ls)) { in ls_recover()
137 dlm_recover_purge(ls); in ls_recover()
144 error = dlm_recover_masters(ls); in ls_recover()
146 log_rinfo(ls, "dlm_recover_masters error %d", error); in ls_recover()
154 error = dlm_recover_locks(ls); in ls_recover()
156 log_rinfo(ls, "dlm_recover_locks error %d", error); in ls_recover()
160 dlm_set_recover_status(ls, DLM_RS_LOCKS); in ls_recover()
162 error = dlm_recover_locks_wait(ls); in ls_recover()
164 log_rinfo(ls, "dlm_recover_locks_wait error %d", error); in ls_recover()
168 log_rinfo(ls, "dlm_recover_locks %u in", in ls_recover()
169 ls->ls_recover_locks_in); in ls_recover()
177 dlm_recover_rsbs(ls); in ls_recover()
184 dlm_set_recover_status(ls, DLM_RS_LOCKS); in ls_recover()
186 error = dlm_recover_locks_wait(ls); in ls_recover()
188 log_rinfo(ls, "dlm_recover_locks_wait error %d", error); in ls_recover()
193 dlm_release_root_list(ls); in ls_recover()
201 dlm_purge_requestqueue(ls); in ls_recover()
203 dlm_set_recover_status(ls, DLM_RS_DONE); in ls_recover()
205 error = dlm_recover_done_wait(ls); in ls_recover()
207 log_rinfo(ls, "dlm_recover_done_wait error %d", error); in ls_recover()
211 dlm_clear_members_gone(ls); in ls_recover()
213 dlm_adjust_timeouts(ls); in ls_recover()
215 dlm_callback_resume(ls); in ls_recover()
217 error = enable_locking(ls, rv->seq); in ls_recover()
219 log_rinfo(ls, "enable_locking error %d", error); in ls_recover()
223 error = dlm_process_requestqueue(ls); in ls_recover()
225 log_rinfo(ls, "dlm_process_requestqueue error %d", error); in ls_recover()
229 error = dlm_recover_waiters_post(ls); in ls_recover()
231 log_rinfo(ls, "dlm_recover_waiters_post error %d", error); in ls_recover()
235 dlm_recover_grant(ls); in ls_recover()
237 log_rinfo(ls, "dlm_recover %llu generation %u done: %u ms", in ls_recover()
238 (unsigned long long)rv->seq, ls->ls_generation, in ls_recover()
240 mutex_unlock(&ls->ls_recoverd_active); in ls_recover()
242 dlm_lsop_recover_done(ls); in ls_recover()
246 dlm_release_root_list(ls); in ls_recover()
247 log_rinfo(ls, "dlm_recover %llu error %d", in ls_recover()
249 mutex_unlock(&ls->ls_recoverd_active); in ls_recover()
257 static void do_ls_recovery(struct dlm_ls *ls) in do_ls_recovery() argument
261 spin_lock(&ls->ls_recover_lock); in do_ls_recovery()
262 rv = ls->ls_recover_args; in do_ls_recovery()
263 ls->ls_recover_args = NULL; in do_ls_recovery()
264 if (rv && ls->ls_recover_seq == rv->seq) in do_ls_recovery()
265 clear_bit(LSFL_RECOVER_STOP, &ls->ls_flags); in do_ls_recovery()
266 spin_unlock(&ls->ls_recover_lock); in do_ls_recovery()
269 ls_recover(ls, rv); in do_ls_recovery()
277 struct dlm_ls *ls; in dlm_recoverd() local
279 ls = dlm_find_lockspace_local(arg); in dlm_recoverd()
280 if (!ls) { in dlm_recoverd()
285 down_write(&ls->ls_in_recovery); in dlm_recoverd()
286 set_bit(LSFL_RECOVER_LOCK, &ls->ls_flags); in dlm_recoverd()
287 wake_up(&ls->ls_recover_lock_wait); in dlm_recoverd()
300 if (!test_bit(LSFL_RECOVER_WORK, &ls->ls_flags) && in dlm_recoverd()
301 !test_bit(LSFL_RECOVER_DOWN, &ls->ls_flags)) { in dlm_recoverd()
308 if (test_and_clear_bit(LSFL_RECOVER_DOWN, &ls->ls_flags)) { in dlm_recoverd()
309 down_write(&ls->ls_in_recovery); in dlm_recoverd()
310 set_bit(LSFL_RECOVER_LOCK, &ls->ls_flags); in dlm_recoverd()
311 wake_up(&ls->ls_recover_lock_wait); in dlm_recoverd()
314 if (test_and_clear_bit(LSFL_RECOVER_WORK, &ls->ls_flags)) in dlm_recoverd()
315 do_ls_recovery(ls); in dlm_recoverd()
318 if (test_bit(LSFL_RECOVER_LOCK, &ls->ls_flags)) in dlm_recoverd()
319 up_write(&ls->ls_in_recovery); in dlm_recoverd()
321 dlm_put_lockspace(ls); in dlm_recoverd()
325 int dlm_recoverd_start(struct dlm_ls *ls) in dlm_recoverd_start() argument
330 p = kthread_run(dlm_recoverd, ls, "dlm_recoverd"); in dlm_recoverd_start()
334 ls->ls_recoverd_task = p; in dlm_recoverd_start()
338 void dlm_recoverd_stop(struct dlm_ls *ls) in dlm_recoverd_stop() argument
340 kthread_stop(ls->ls_recoverd_task); in dlm_recoverd_stop()
343 void dlm_recoverd_suspend(struct dlm_ls *ls) in dlm_recoverd_suspend() argument
345 wake_up(&ls->ls_wait_general); in dlm_recoverd_suspend()
346 mutex_lock(&ls->ls_recoverd_active); in dlm_recoverd_suspend()
349 void dlm_recoverd_resume(struct dlm_ls *ls) in dlm_recoverd_resume() argument
351 mutex_unlock(&ls->ls_recoverd_active); in dlm_recoverd_resume()