Skip to content

Commit c04fecb

Browse files
committed
dlm: use rsbtbl as resource directory
Remove the dir hash table (dirtbl), and use the rsb hash table (rsbtbl) as the resource directory. It has always been an unnecessary duplication of information. This improves efficiency by using a single rsbtbl lookup in many cases where both rsbtbl and dirtbl lookups were needed previously. This eliminates the need to handle cases of rsbtbl and dirtbl being out of sync. In many cases there will be memory savings because the dir hash table no longer exists. Signed-off-by: David Teigland <teigland@redhat.com>
1 parent ecc7284 commit c04fecb

14 files changed

Lines changed: 1215 additions & 588 deletions

File tree

‎fs/dlm/config.c‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ struct dlm_cluster {
9696
unsigned int cl_tcp_port;
9797
unsigned int cl_buffer_size;
9898
unsigned int cl_rsbtbl_size;
99-
unsigned int cl_dirtbl_size;
10099
unsigned int cl_recover_timer;
101100
unsigned int cl_toss_secs;
102101
unsigned int cl_scan_secs;
@@ -113,7 +112,6 @@ enum {
113112
CLUSTER_ATTR_TCP_PORT = 0,
114113
CLUSTER_ATTR_BUFFER_SIZE,
115114
CLUSTER_ATTR_RSBTBL_SIZE,
116-
CLUSTER_ATTR_DIRTBL_SIZE,
117115
CLUSTER_ATTR_RECOVER_TIMER,
118116
CLUSTER_ATTR_TOSS_SECS,
119117
CLUSTER_ATTR_SCAN_SECS,
@@ -189,7 +187,6 @@ __CONFIGFS_ATTR(name, 0644, name##_read, name##_write)
189187
CLUSTER_ATTR(tcp_port, 1);
190188
CLUSTER_ATTR(buffer_size, 1);
191189
CLUSTER_ATTR(rsbtbl_size, 1);
192-
CLUSTER_ATTR(dirtbl_size, 1);
193190
CLUSTER_ATTR(recover_timer, 1);
194191
CLUSTER_ATTR(toss_secs, 1);
195192
CLUSTER_ATTR(scan_secs, 1);
@@ -204,7 +201,6 @@ static struct configfs_attribute *cluster_attrs[] = {
204201
[CLUSTER_ATTR_TCP_PORT] = &cluster_attr_tcp_port.attr,
205202
[CLUSTER_ATTR_BUFFER_SIZE] = &cluster_attr_buffer_size.attr,
206203
[CLUSTER_ATTR_RSBTBL_SIZE] = &cluster_attr_rsbtbl_size.attr,
207-
[CLUSTER_ATTR_DIRTBL_SIZE] = &cluster_attr_dirtbl_size.attr,
208204
[CLUSTER_ATTR_RECOVER_TIMER] = &cluster_attr_recover_timer.attr,
209205
[CLUSTER_ATTR_TOSS_SECS] = &cluster_attr_toss_secs.attr,
210206
[CLUSTER_ATTR_SCAN_SECS] = &cluster_attr_scan_secs.attr,
@@ -478,7 +474,6 @@ static struct config_group *make_cluster(struct config_group *g,
478474
cl->cl_tcp_port = dlm_config.ci_tcp_port;
479475
cl->cl_buffer_size = dlm_config.ci_buffer_size;
480476
cl->cl_rsbtbl_size = dlm_config.ci_rsbtbl_size;
481-
cl->cl_dirtbl_size = dlm_config.ci_dirtbl_size;
482477
cl->cl_recover_timer = dlm_config.ci_recover_timer;
483478
cl->cl_toss_secs = dlm_config.ci_toss_secs;
484479
cl->cl_scan_secs = dlm_config.ci_scan_secs;
@@ -1050,7 +1045,6 @@ int dlm_our_addr(struct sockaddr_storage *addr, int num)
10501045
#define DEFAULT_TCP_PORT 21064
10511046
#define DEFAULT_BUFFER_SIZE 4096
10521047
#define DEFAULT_RSBTBL_SIZE 1024
1053-
#define DEFAULT_DIRTBL_SIZE 1024
10541048
#define DEFAULT_RECOVER_TIMER 5
10551049
#define DEFAULT_TOSS_SECS 10
10561050
#define DEFAULT_SCAN_SECS 5
@@ -1066,7 +1060,6 @@ struct dlm_config_info dlm_config = {
10661060
.ci_tcp_port = DEFAULT_TCP_PORT,
10671061
.ci_buffer_size = DEFAULT_BUFFER_SIZE,
10681062
.ci_rsbtbl_size = DEFAULT_RSBTBL_SIZE,
1069-
.ci_dirtbl_size = DEFAULT_DIRTBL_SIZE,
10701063
.ci_recover_timer = DEFAULT_RECOVER_TIMER,
10711064
.ci_toss_secs = DEFAULT_TOSS_SECS,
10721065
.ci_scan_secs = DEFAULT_SCAN_SECS,

‎fs/dlm/config.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ struct dlm_config_info {
2727
int ci_tcp_port;
2828
int ci_buffer_size;
2929
int ci_rsbtbl_size;
30-
int ci_dirtbl_size;
3130
int ci_recover_timer;
3231
int ci_toss_secs;
3332
int ci_scan_secs;

‎fs/dlm/debug_fs.c‎

Lines changed: 96 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,45 @@ static int print_format3(struct dlm_rsb *r, struct seq_file *s)
344344
return rv;
345345
}
346346

347+
static int print_format4(struct dlm_rsb *r, struct seq_file *s)
348+
{
349+
int our_nodeid = dlm_our_nodeid();
350+
int print_name = 1;
351+
int i, rv;
352+
353+
lock_rsb(r);
354+
355+
rv = seq_printf(s, "rsb %p %d %d %d %d %lu %lx %d ",
356+
r,
357+
r->res_nodeid,
358+
r->res_master_nodeid,
359+
r->res_dir_nodeid,
360+
our_nodeid,
361+
r->res_toss_time,
362+
r->res_flags,
363+
r->res_length);
364+
if (rv)
365+
goto out;
366+
367+
for (i = 0; i < r->res_length; i++) {
368+
if (!isascii(r->res_name[i]) || !isprint(r->res_name[i]))
369+
print_name = 0;
370+
}
371+
372+
seq_printf(s, "%s", print_name ? "str " : "hex");
373+
374+
for (i = 0; i < r->res_length; i++) {
375+
if (print_name)
376+
seq_printf(s, "%c", r->res_name[i]);
377+
else
378+
seq_printf(s, " %02x", (unsigned char)r->res_name[i]);
379+
}
380+
rv = seq_printf(s, "\n");
381+
out:
382+
unlock_rsb(r);
383+
return rv;
384+
}
385+
347386
struct rsbtbl_iter {
348387
struct dlm_rsb *rsb;
349388
unsigned bucket;
@@ -382,6 +421,13 @@ static int table_seq_show(struct seq_file *seq, void *iter_ptr)
382421
}
383422
rv = print_format3(ri->rsb, seq);
384423
break;
424+
case 4:
425+
if (ri->header) {
426+
seq_printf(seq, "version 4 rsb 2\n");
427+
ri->header = 0;
428+
}
429+
rv = print_format4(ri->rsb, seq);
430+
break;
385431
}
386432

387433
return rv;
@@ -390,15 +436,18 @@ static int table_seq_show(struct seq_file *seq, void *iter_ptr)
390436
static const struct seq_operations format1_seq_ops;
391437
static const struct seq_operations format2_seq_ops;
392438
static const struct seq_operations format3_seq_ops;
439+
static const struct seq_operations format4_seq_ops;
393440

394441
static void *table_seq_start(struct seq_file *seq, loff_t *pos)
395442
{
443+
struct rb_root *tree;
396444
struct rb_node *node;
397445
struct dlm_ls *ls = seq->private;
398446
struct rsbtbl_iter *ri;
399447
struct dlm_rsb *r;
400448
loff_t n = *pos;
401449
unsigned bucket, entry;
450+
int toss = (seq->op == &format4_seq_ops);
402451

403452
bucket = n >> 32;
404453
entry = n & ((1LL << 32) - 1);
@@ -417,11 +466,14 @@ static void *table_seq_start(struct seq_file *seq, loff_t *pos)
417466
ri->format = 2;
418467
if (seq->op == &format3_seq_ops)
419468
ri->format = 3;
469+
if (seq->op == &format4_seq_ops)
470+
ri->format = 4;
471+
472+
tree = toss ? &ls->ls_rsbtbl[bucket].toss : &ls->ls_rsbtbl[bucket].keep;
420473

421474
spin_lock(&ls->ls_rsbtbl[bucket].lock);
422-
if (!RB_EMPTY_ROOT(&ls->ls_rsbtbl[bucket].keep)) {
423-
for (node = rb_first(&ls->ls_rsbtbl[bucket].keep); node;
424-
node = rb_next(node)) {
475+
if (!RB_EMPTY_ROOT(tree)) {
476+
for (node = rb_first(tree); node; node = rb_next(node)) {
425477
r = rb_entry(node, struct dlm_rsb, res_hashnode);
426478
if (!entry--) {
427479
dlm_hold_rsb(r);
@@ -449,10 +501,11 @@ static void *table_seq_start(struct seq_file *seq, loff_t *pos)
449501
kfree(ri);
450502
return NULL;
451503
}
504+
tree = toss ? &ls->ls_rsbtbl[bucket].toss : &ls->ls_rsbtbl[bucket].keep;
452505

453506
spin_lock(&ls->ls_rsbtbl[bucket].lock);
454-
if (!RB_EMPTY_ROOT(&ls->ls_rsbtbl[bucket].keep)) {
455-
node = rb_first(&ls->ls_rsbtbl[bucket].keep);
507+
if (!RB_EMPTY_ROOT(tree)) {
508+
node = rb_first(tree);
456509
r = rb_entry(node, struct dlm_rsb, res_hashnode);
457510
dlm_hold_rsb(r);
458511
ri->rsb = r;
@@ -469,10 +522,12 @@ static void *table_seq_next(struct seq_file *seq, void *iter_ptr, loff_t *pos)
469522
{
470523
struct dlm_ls *ls = seq->private;
471524
struct rsbtbl_iter *ri = iter_ptr;
525+
struct rb_root *tree;
472526
struct rb_node *next;
473527
struct dlm_rsb *r, *rp;
474528
loff_t n = *pos;
475529
unsigned bucket;
530+
int toss = (seq->op == &format4_seq_ops);
476531

477532
bucket = n >> 32;
478533

@@ -511,10 +566,11 @@ static void *table_seq_next(struct seq_file *seq, void *iter_ptr, loff_t *pos)
511566
kfree(ri);
512567
return NULL;
513568
}
569+
tree = toss ? &ls->ls_rsbtbl[bucket].toss : &ls->ls_rsbtbl[bucket].keep;
514570

515571
spin_lock(&ls->ls_rsbtbl[bucket].lock);
516-
if (!RB_EMPTY_ROOT(&ls->ls_rsbtbl[bucket].keep)) {
517-
next = rb_first(&ls->ls_rsbtbl[bucket].keep);
572+
if (!RB_EMPTY_ROOT(tree)) {
573+
next = rb_first(tree);
518574
r = rb_entry(next, struct dlm_rsb, res_hashnode);
519575
dlm_hold_rsb(r);
520576
ri->rsb = r;
@@ -558,9 +614,17 @@ static const struct seq_operations format3_seq_ops = {
558614
.show = table_seq_show,
559615
};
560616

617+
static const struct seq_operations format4_seq_ops = {
618+
.start = table_seq_start,
619+
.next = table_seq_next,
620+
.stop = table_seq_stop,
621+
.show = table_seq_show,
622+
};
623+
561624
static const struct file_operations format1_fops;
562625
static const struct file_operations format2_fops;
563626
static const struct file_operations format3_fops;
627+
static const struct file_operations format4_fops;
564628

565629
static int table_open(struct inode *inode, struct file *file)
566630
{
@@ -573,6 +637,8 @@ static int table_open(struct inode *inode, struct file *file)
573637
ret = seq_open(file, &format2_seq_ops);
574638
else if (file->f_op == &format3_fops)
575639
ret = seq_open(file, &format3_seq_ops);
640+
else if (file->f_op == &format4_fops)
641+
ret = seq_open(file, &format4_seq_ops);
576642

577643
if (ret)
578644
return ret;
@@ -606,6 +672,14 @@ static const struct file_operations format3_fops = {
606672
.release = seq_release
607673
};
608674

675+
static const struct file_operations format4_fops = {
676+
.owner = THIS_MODULE,
677+
.open = table_open,
678+
.read = seq_read,
679+
.llseek = seq_lseek,
680+
.release = seq_release
681+
};
682+
609683
/*
610684
* dump lkb's on the ls_waiters list
611685
*/
@@ -652,6 +726,8 @@ void dlm_delete_debug_file(struct dlm_ls *ls)
652726
debugfs_remove(ls->ls_debug_locks_dentry);
653727
if (ls->ls_debug_all_dentry)
654728
debugfs_remove(ls->ls_debug_all_dentry);
729+
if (ls->ls_debug_toss_dentry)
730+
debugfs_remove(ls->ls_debug_toss_dentry);
655731
}
656732

657733
int dlm_create_debug_file(struct dlm_ls *ls)
@@ -694,6 +770,19 @@ int dlm_create_debug_file(struct dlm_ls *ls)
694770
if (!ls->ls_debug_all_dentry)
695771
goto fail;
696772

773+
/* format 4 */
774+
775+
memset(name, 0, sizeof(name));
776+
snprintf(name, DLM_LOCKSPACE_LEN+8, "%s_toss", ls->ls_name);
777+
778+
ls->ls_debug_toss_dentry = debugfs_create_file(name,
779+
S_IFREG | S_IRUGO,
780+
dlm_root,
781+
ls,
782+
&format4_fops);
783+
if (!ls->ls_debug_toss_dentry)
784+
goto fail;
785+
697786
memset(name, 0, sizeof(name));
698787
snprintf(name, DLM_LOCKSPACE_LEN+8, "%s_waiters", ls->ls_name);
699788

0 commit comments

Comments
 (0)