Skip to content

Commit 6c64803

Browse files
Alexander Aringteigland
authored andcommitted
dlm: switch to use rhashtable for rsbs
Replace our own hash table with the more advanced rhashtable for keeping rsb structs. Signed-off-by: Alexander Aring <[email protected]> Signed-off-by: David Teigland <[email protected]>
1 parent 93a693d commit 6c64803

File tree

8 files changed

+86
-160
lines changed

8 files changed

+86
-160
lines changed

fs/dlm/config.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ static void release_node(struct config_item *);
6363
static struct configfs_attribute *comm_attrs[];
6464
static struct configfs_attribute *node_attrs[];
6565

66+
const struct rhashtable_params dlm_rhash_rsb_params = {
67+
.nelem_hint = 3, /* start small */
68+
.key_len = DLM_RESNAME_MAXLEN,
69+
.key_offset = offsetof(struct dlm_rsb, res_name),
70+
.head_offset = offsetof(struct dlm_rsb, res_node),
71+
.automatic_shrinking = true,
72+
};
73+
6674
struct dlm_cluster {
6775
struct config_group group;
6876
unsigned int cl_tcp_port;

fs/dlm/config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ struct dlm_config_node {
2121
uint32_t comm_seq;
2222
};
2323

24+
extern const struct rhashtable_params dlm_rhash_rsb_params;
25+
2426
#define DLM_MAX_ADDR_COUNT 3
2527

2628
#define DLM_PROTO_TCP 0

fs/dlm/dir.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,10 @@ static struct dlm_rsb *find_rsb_root(struct dlm_ls *ls, const char *name,
198198
int len)
199199
{
200200
struct dlm_rsb *r;
201-
uint32_t hash, bucket;
202201
int rv;
203202

204-
hash = jhash(name, len, 0);
205-
bucket = hash & (ls->ls_rsbtbl_size - 1);
206-
207203
spin_lock_bh(&ls->ls_rsbtbl_lock);
208-
rv = dlm_search_rsb_tree(&ls->ls_rsbtbl[bucket].r, name, len, &r);
204+
rv = dlm_search_rsb_tree(&ls->ls_rsbtbl, name, len, &r);
209205
spin_unlock_bh(&ls->ls_rsbtbl_lock);
210206
if (!rv)
211207
return r;

fs/dlm/dlm_internal.h

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <linux/kernel.h>
3535
#include <linux/jhash.h>
3636
#include <linux/miscdevice.h>
37+
#include <linux/rhashtable.h>
3738
#include <linux/mutex.h>
3839
#include <linux/idr.h>
3940
#include <linux/ratelimit.h>
@@ -99,15 +100,6 @@ do { \
99100
} \
100101
}
101102

102-
103-
#define DLM_RTF_SHRINK_BIT 0
104-
105-
struct dlm_rsbtable {
106-
struct rb_root r;
107-
unsigned long flags;
108-
};
109-
110-
111103
/*
112104
* Lockspace member (per node in a ls)
113105
*/
@@ -327,13 +319,12 @@ struct dlm_rsb {
327319
int res_id; /* for ls_recover_idr */
328320
uint32_t res_lvbseq;
329321
uint32_t res_hash;
330-
uint32_t res_bucket; /* rsbtbl */
331322
unsigned long res_toss_time;
332323
uint32_t res_first_lkid;
333324
struct list_head res_lookup; /* lkbs waiting on first */
334325
union {
335326
struct list_head res_hashchain;
336-
struct rb_node res_hashnode; /* rsbtbl */
327+
struct rhash_head res_node; /* rsbtbl */
337328
};
338329
struct list_head res_grantqueue;
339330
struct list_head res_convertqueue;
@@ -592,9 +583,10 @@ struct dlm_ls {
592583
struct idr ls_lkbidr;
593584
spinlock_t ls_lkbidr_spin;
594585

595-
struct dlm_rsbtable *ls_rsbtbl;
586+
struct rhashtable ls_rsbtbl;
587+
#define DLM_RTF_SHRINK_BIT 0
588+
unsigned long ls_rsbtbl_flags;
596589
spinlock_t ls_rsbtbl_lock;
597-
uint32_t ls_rsbtbl_size;
598590

599591
struct list_head ls_toss;
600592
struct list_head ls_keep;

0 commit comments

Comments
 (0)