Skip to content

Commit dcdaad0

Browse files
Alexander Aringteigland
authored andcommitted
dlm: change to single hashtable lock
Prepare to replace our own hash table with rhashtable by replacing the per-bucket locks in our own hash table with a single lock. Signed-off-by: Alexander Aring <[email protected]> Signed-off-by: David Teigland <[email protected]>
1 parent 700b048 commit dcdaad0

File tree

7 files changed

+60
-61
lines changed

7 files changed

+60
-61
lines changed

fs/dlm/debug_fs.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -452,20 +452,20 @@ static void *table_seq_start(struct seq_file *seq, loff_t *pos)
452452

453453
tree = toss ? &ls->ls_rsbtbl[bucket].toss : &ls->ls_rsbtbl[bucket].keep;
454454

455-
spin_lock_bh(&ls->ls_rsbtbl[bucket].lock);
455+
spin_lock_bh(&ls->ls_rsbtbl_lock);
456456
if (!RB_EMPTY_ROOT(tree)) {
457457
for (node = rb_first(tree); node; node = rb_next(node)) {
458458
r = rb_entry(node, struct dlm_rsb, res_hashnode);
459459
if (!entry--) {
460460
dlm_hold_rsb(r);
461461
ri->rsb = r;
462462
ri->bucket = bucket;
463-
spin_unlock_bh(&ls->ls_rsbtbl[bucket].lock);
463+
spin_unlock_bh(&ls->ls_rsbtbl_lock);
464464
return ri;
465465
}
466466
}
467467
}
468-
spin_unlock_bh(&ls->ls_rsbtbl[bucket].lock);
468+
spin_unlock_bh(&ls->ls_rsbtbl_lock);
469469

470470
/*
471471
* move to the first rsb in the next non-empty bucket
@@ -484,18 +484,18 @@ static void *table_seq_start(struct seq_file *seq, loff_t *pos)
484484
}
485485
tree = toss ? &ls->ls_rsbtbl[bucket].toss : &ls->ls_rsbtbl[bucket].keep;
486486

487-
spin_lock_bh(&ls->ls_rsbtbl[bucket].lock);
487+
spin_lock_bh(&ls->ls_rsbtbl_lock);
488488
if (!RB_EMPTY_ROOT(tree)) {
489489
node = rb_first(tree);
490490
r = rb_entry(node, struct dlm_rsb, res_hashnode);
491491
dlm_hold_rsb(r);
492492
ri->rsb = r;
493493
ri->bucket = bucket;
494-
spin_unlock_bh(&ls->ls_rsbtbl[bucket].lock);
494+
spin_unlock_bh(&ls->ls_rsbtbl_lock);
495495
*pos = n;
496496
return ri;
497497
}
498-
spin_unlock_bh(&ls->ls_rsbtbl[bucket].lock);
498+
spin_unlock_bh(&ls->ls_rsbtbl_lock);
499499
}
500500
}
501501

@@ -516,20 +516,20 @@ static void *table_seq_next(struct seq_file *seq, void *iter_ptr, loff_t *pos)
516516
* move to the next rsb in the same bucket
517517
*/
518518

519-
spin_lock_bh(&ls->ls_rsbtbl[bucket].lock);
519+
spin_lock_bh(&ls->ls_rsbtbl_lock);
520520
rp = ri->rsb;
521521
next = rb_next(&rp->res_hashnode);
522522

523523
if (next) {
524524
r = rb_entry(next, struct dlm_rsb, res_hashnode);
525525
dlm_hold_rsb(r);
526526
ri->rsb = r;
527-
spin_unlock_bh(&ls->ls_rsbtbl[bucket].lock);
527+
spin_unlock_bh(&ls->ls_rsbtbl_lock);
528528
dlm_put_rsb(rp);
529529
++*pos;
530530
return ri;
531531
}
532-
spin_unlock_bh(&ls->ls_rsbtbl[bucket].lock);
532+
spin_unlock_bh(&ls->ls_rsbtbl_lock);
533533
dlm_put_rsb(rp);
534534

535535
/*
@@ -550,18 +550,18 @@ static void *table_seq_next(struct seq_file *seq, void *iter_ptr, loff_t *pos)
550550
}
551551
tree = toss ? &ls->ls_rsbtbl[bucket].toss : &ls->ls_rsbtbl[bucket].keep;
552552

553-
spin_lock_bh(&ls->ls_rsbtbl[bucket].lock);
553+
spin_lock_bh(&ls->ls_rsbtbl_lock);
554554
if (!RB_EMPTY_ROOT(tree)) {
555555
next = rb_first(tree);
556556
r = rb_entry(next, struct dlm_rsb, res_hashnode);
557557
dlm_hold_rsb(r);
558558
ri->rsb = r;
559559
ri->bucket = bucket;
560-
spin_unlock_bh(&ls->ls_rsbtbl[bucket].lock);
560+
spin_unlock_bh(&ls->ls_rsbtbl_lock);
561561
*pos = n;
562562
return ri;
563563
}
564-
spin_unlock_bh(&ls->ls_rsbtbl[bucket].lock);
564+
spin_unlock_bh(&ls->ls_rsbtbl_lock);
565565
}
566566
}
567567

fs/dlm/dir.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,12 @@ static struct dlm_rsb *find_rsb_root(struct dlm_ls *ls, const char *name,
204204
hash = jhash(name, len, 0);
205205
bucket = hash & (ls->ls_rsbtbl_size - 1);
206206

207-
spin_lock_bh(&ls->ls_rsbtbl[bucket].lock);
207+
spin_lock_bh(&ls->ls_rsbtbl_lock);
208208
rv = dlm_search_rsb_tree(&ls->ls_rsbtbl[bucket].keep, name, len, &r);
209209
if (rv)
210210
rv = dlm_search_rsb_tree(&ls->ls_rsbtbl[bucket].toss,
211211
name, len, &r);
212-
spin_unlock_bh(&ls->ls_rsbtbl[bucket].lock);
212+
spin_unlock_bh(&ls->ls_rsbtbl_lock);
213213

214214
if (!rv)
215215
return r;

fs/dlm/dlm_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ do { \
105105
struct dlm_rsbtable {
106106
struct rb_root keep;
107107
struct rb_root toss;
108-
spinlock_t lock;
109108
unsigned long flags;
110109
};
111110

@@ -593,6 +592,7 @@ struct dlm_ls {
593592
spinlock_t ls_lkbidr_spin;
594593

595594
struct dlm_rsbtable *ls_rsbtbl;
595+
spinlock_t ls_rsbtbl_lock;
596596
uint32_t ls_rsbtbl_size;
597597

598598
spinlock_t ls_waiters_lock;

0 commit comments

Comments
 (0)