Skip to content

Commit 85f0379

Browse files
committed
dlm: keep cached master rsbs during recovery
To prevent the master of an rsb from changing rapidly, an unused rsb is kept on the "toss list" for a period of time to be reused. The toss list was being cleared completely for each recovery, which is unnecessary. Much of the benefit of the toss list can be maintained if nodes keep rsb's in their toss list that they are the master of. These rsb's need to be included when the resource directory is rebuilt during recovery. Signed-off-by: David Teigland <teigland@redhat.com>
1 parent 594199e commit 85f0379

5 files changed

Lines changed: 61 additions & 49 deletions

File tree

‎fs/dlm/dir.c‎

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -329,49 +329,47 @@ int dlm_dir_lookup(struct dlm_ls *ls, int nodeid, char *name, int namelen,
329329
return get_entry(ls, nodeid, name, namelen, r_nodeid);
330330
}
331331

332-
/* Copy the names of master rsb's into the buffer provided.
333-
Only select names whose dir node is the given nodeid. */
332+
static struct dlm_rsb *find_rsb_root(struct dlm_ls *ls, char *name, int len)
333+
{
334+
struct dlm_rsb *r;
335+
336+
down_read(&ls->ls_root_sem);
337+
list_for_each_entry(r, &ls->ls_root_list, res_root_list) {
338+
if (len == r->res_length && !memcmp(name, r->res_name, len)) {
339+
up_read(&ls->ls_root_sem);
340+
return r;
341+
}
342+
}
343+
up_read(&ls->ls_root_sem);
344+
return NULL;
345+
}
346+
347+
/* Find the rsb where we left off (or start again), then send rsb names
348+
for rsb's we're master of and whose directory node matches the requesting
349+
node. inbuf is the rsb name last sent, inlen is the name's length */
334350

335351
void dlm_copy_master_names(struct dlm_ls *ls, char *inbuf, int inlen,
336352
char *outbuf, int outlen, int nodeid)
337353
{
338354
struct list_head *list;
339-
struct dlm_rsb *start_r = NULL, *r = NULL;
340-
int offset = 0, start_namelen, error, dir_nodeid;
341-
char *start_name;
355+
struct dlm_rsb *r;
356+
int offset = 0, dir_nodeid;
342357
uint16_t be_namelen;
343358

344-
/*
345-
* Find the rsb where we left off (or start again)
346-
*/
347-
348-
start_namelen = inlen;
349-
start_name = inbuf;
350-
351-
if (start_namelen > 1) {
352-
/*
353-
* We could also use a find_rsb_root() function here that
354-
* searched the ls_root_list.
355-
*/
356-
error = dlm_find_rsb(ls, start_name, start_namelen, R_MASTER,
357-
&start_r);
358-
DLM_ASSERT(!error && start_r,
359-
printk("error %d\n", error););
360-
DLM_ASSERT(!list_empty(&start_r->res_root_list),
361-
dlm_print_rsb(start_r););
362-
dlm_put_rsb(start_r);
363-
}
364-
365-
/*
366-
* Send rsb names for rsb's we're master of and whose directory node
367-
* matches the requesting node.
368-
*/
369-
370359
down_read(&ls->ls_root_sem);
371-
if (start_r)
372-
list = start_r->res_root_list.next;
373-
else
360+
361+
if (inlen > 1) {
362+
r = find_rsb_root(ls, inbuf, inlen);
363+
if (!r) {
364+
inbuf[inlen - 1] = '\0';
365+
log_error(ls, "copy_master_names from %d start %d %s",
366+
nodeid, inlen, inbuf);
367+
goto out;
368+
}
369+
list = r->res_root_list.next;
370+
} else {
374371
list = ls->ls_root_list.next;
372+
}
375373

376374
for (offset = 0; list != &ls->ls_root_list; list = list->next) {
377375
r = list_entry(list, struct dlm_rsb, res_root_list);

‎fs/dlm/lock.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -489,12 +489,6 @@ static int find_rsb(struct dlm_ls *ls, char *name, int namelen,
489489
return error;
490490
}
491491

492-
int dlm_find_rsb(struct dlm_ls *ls, char *name, int namelen,
493-
unsigned int flags, struct dlm_rsb **r_ret)
494-
{
495-
return find_rsb(ls, name, namelen, flags, r_ret);
496-
}
497-
498492
/* This is only called to add a reference when the code already holds
499493
a valid reference to the rsb, so there's no need for locking. */
500494

‎fs/dlm/lock.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ void dlm_print_lkb(struct dlm_lkb *lkb);
1919
void dlm_receive_message_saved(struct dlm_ls *ls, struct dlm_message *ms);
2020
void dlm_receive_buffer(struct dlm_header *hd, int nodeid);
2121
int dlm_modes_compat(int mode1, int mode2);
22-
int dlm_find_rsb(struct dlm_ls *ls, char *name, int namelen,
23-
unsigned int flags, struct dlm_rsb **r_ret);
2422
void dlm_put_rsb(struct dlm_rsb *r);
2523
void dlm_hold_rsb(struct dlm_rsb *r);
2624
int dlm_put_lkb(struct dlm_lkb *lkb);

‎fs/dlm/recover.c‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,20 @@ int dlm_create_root_list(struct dlm_ls *ls)
731731
list_add(&r->res_root_list, &ls->ls_root_list);
732732
dlm_hold_rsb(r);
733733
}
734+
735+
/* If we're using a directory, add tossed rsbs to the root
736+
list; they'll have entries created in the new directory,
737+
but no other recovery steps should do anything with them. */
738+
739+
if (dlm_no_directory(ls)) {
740+
read_unlock(&ls->ls_rsbtbl[i].lock);
741+
continue;
742+
}
743+
744+
list_for_each_entry(r, &ls->ls_rsbtbl[i].toss, res_hashchain) {
745+
list_add(&r->res_root_list, &ls->ls_root_list);
746+
dlm_hold_rsb(r);
747+
}
734748
read_unlock(&ls->ls_rsbtbl[i].lock);
735749
}
736750
out:
@@ -750,6 +764,11 @@ void dlm_release_root_list(struct dlm_ls *ls)
750764
up_write(&ls->ls_root_sem);
751765
}
752766

767+
/* If not using a directory, clear the entire toss list, there's no benefit to
768+
caching the master value since it's fixed. If we are using a dir, keep the
769+
rsb's we're the master of. Recovery will add them to the root list and from
770+
there they'll be entered in the rebuilt directory. */
771+
753772
void dlm_clear_toss_list(struct dlm_ls *ls)
754773
{
755774
struct dlm_rsb *r, *safe;
@@ -759,8 +778,10 @@ void dlm_clear_toss_list(struct dlm_ls *ls)
759778
write_lock(&ls->ls_rsbtbl[i].lock);
760779
list_for_each_entry_safe(r, safe, &ls->ls_rsbtbl[i].toss,
761780
res_hashchain) {
762-
list_del(&r->res_hashchain);
763-
dlm_free_rsb(r);
781+
if (dlm_no_directory(ls) || !is_master(r)) {
782+
list_del(&r->res_hashchain);
783+
dlm_free_rsb(r);
784+
}
764785
}
765786
write_unlock(&ls->ls_rsbtbl[i].lock);
766787
}

‎fs/dlm/recoverd.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,18 @@ static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv)
6767
dlm_astd_resume();
6868

6969
/*
70-
* This list of root rsb's will be the basis of most of the recovery
71-
* routines.
70+
* Free non-master tossed rsb's. Master rsb's are kept on toss
71+
* list and put on root list to be included in resdir recovery.
7272
*/
7373

74-
dlm_create_root_list(ls);
74+
dlm_clear_toss_list(ls);
7575

7676
/*
77-
* Free all the tossed rsb's so we don't have to recover them.
77+
* This list of root rsb's will be the basis of most of the recovery
78+
* routines.
7879
*/
7980

80-
dlm_clear_toss_list(ls);
81+
dlm_create_root_list(ls);
8182

8283
/*
8384
* Add or remove nodes from the lockspace's ls_nodes list.

0 commit comments

Comments
 (0)