Skip to content

Commit 29e345f

Browse files
Alexander Aringteigland
authored andcommitted
dlm: move root_list functionality to recover.c
Move dlm_create_root_list() and dlm_release_root_list() to recover.c and declare them static because they are only used there. Signed-off-by: Alexander Aring <aahringo@redhat.com> Signed-off-by: David Teigland <teigland@redhat.com>
1 parent 455597a commit 29e345f

3 files changed

Lines changed: 39 additions & 44 deletions

File tree

fs/dlm/recover.c

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -889,48 +889,6 @@ void dlm_recover_rsbs(struct dlm_ls *ls)
889889

890890
/* Create a single list of all root rsb's to be used during recovery */
891891

892-
int dlm_create_root_list(struct dlm_ls *ls)
893-
{
894-
struct rb_node *n;
895-
struct dlm_rsb *r;
896-
int i, error = 0;
897-
898-
down_write(&ls->ls_root_sem);
899-
if (!list_empty(&ls->ls_root_list)) {
900-
log_error(ls, "root list not empty");
901-
error = -EINVAL;
902-
goto out;
903-
}
904-
905-
for (i = 0; i < ls->ls_rsbtbl_size; i++) {
906-
spin_lock(&ls->ls_rsbtbl[i].lock);
907-
for (n = rb_first(&ls->ls_rsbtbl[i].keep); n; n = rb_next(n)) {
908-
r = rb_entry(n, struct dlm_rsb, res_hashnode);
909-
list_add(&r->res_root_list, &ls->ls_root_list);
910-
dlm_hold_rsb(r);
911-
}
912-
913-
if (!RB_EMPTY_ROOT(&ls->ls_rsbtbl[i].toss))
914-
log_error(ls, "dlm_create_root_list toss not empty");
915-
spin_unlock(&ls->ls_rsbtbl[i].lock);
916-
}
917-
out:
918-
up_write(&ls->ls_root_sem);
919-
return error;
920-
}
921-
922-
void dlm_release_root_list(struct dlm_ls *ls)
923-
{
924-
struct dlm_rsb *r, *safe;
925-
926-
down_write(&ls->ls_root_sem);
927-
list_for_each_entry_safe(r, safe, &ls->ls_root_list, res_root_list) {
928-
list_del_init(&r->res_root_list);
929-
dlm_put_rsb(r);
930-
}
931-
up_write(&ls->ls_root_sem);
932-
}
933-
934892
void dlm_clear_toss(struct dlm_ls *ls)
935893
{
936894
struct rb_node *n, *next;

fs/dlm/recover.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ int dlm_recover_masters(struct dlm_ls *ls, uint64_t seq);
2323
int dlm_recover_master_reply(struct dlm_ls *ls, const struct dlm_rcom *rc);
2424
int dlm_recover_locks(struct dlm_ls *ls, uint64_t seq);
2525
void dlm_recovered_lock(struct dlm_rsb *r);
26-
int dlm_create_root_list(struct dlm_ls *ls);
27-
void dlm_release_root_list(struct dlm_ls *ls);
2826
void dlm_clear_toss(struct dlm_ls *ls);
2927
void dlm_recover_rsbs(struct dlm_ls *ls);
3028

fs/dlm/recoverd.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,45 @@
2020
#include "requestqueue.h"
2121
#include "recoverd.h"
2222

23+
static void dlm_create_root_list(struct dlm_ls *ls)
24+
{
25+
struct rb_node *n;
26+
struct dlm_rsb *r;
27+
int i;
28+
29+
down_write(&ls->ls_root_sem);
30+
if (!list_empty(&ls->ls_root_list)) {
31+
log_error(ls, "root list not empty");
32+
goto out;
33+
}
34+
35+
for (i = 0; i < ls->ls_rsbtbl_size; i++) {
36+
spin_lock_bh(&ls->ls_rsbtbl[i].lock);
37+
for (n = rb_first(&ls->ls_rsbtbl[i].keep); n; n = rb_next(n)) {
38+
r = rb_entry(n, struct dlm_rsb, res_hashnode);
39+
list_add(&r->res_root_list, &ls->ls_root_list);
40+
dlm_hold_rsb(r);
41+
}
42+
43+
if (!RB_EMPTY_ROOT(&ls->ls_rsbtbl[i].toss))
44+
log_error(ls, "%s toss not empty", __func__);
45+
spin_unlock_bh(&ls->ls_rsbtbl[i].lock);
46+
}
47+
out:
48+
up_write(&ls->ls_root_sem);
49+
}
50+
51+
static void dlm_release_root_list(struct dlm_ls *ls)
52+
{
53+
struct dlm_rsb *r, *safe;
54+
55+
down_write(&ls->ls_root_sem);
56+
list_for_each_entry_safe(r, safe, &ls->ls_root_list, res_root_list) {
57+
list_del_init(&r->res_root_list);
58+
dlm_put_rsb(r);
59+
}
60+
up_write(&ls->ls_root_sem);
61+
}
2362

2463
/* If the start for which we're re-enabling locking (seq) has been superseded
2564
by a newer stop (ls_recover_seq), we need to leave locking disabled.

0 commit comments

Comments
 (0)