dlm: improve rsb searches
By pre-allocating rsb structs before searching the hash table, they can be inserted immediately. This avoids always having to repeat the search when adding the struct to hash list. This also adds space to the rsb struct for a max resource name, so an rsb allocation can be used by any request. The constant size also allows us to finally use a slab for the rsb structs. Signed-off-by: David Teigland <teigland@redhat.com>
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include "memory.h"
|
||||
|
||||
static struct kmem_cache *lkb_cache;
|
||||
static struct kmem_cache *rsb_cache;
|
||||
|
||||
|
||||
int __init dlm_memory_init(void)
|
||||
@@ -26,6 +27,14 @@ int __init dlm_memory_init(void)
|
||||
__alignof__(struct dlm_lkb), 0, NULL);
|
||||
if (!lkb_cache)
|
||||
ret = -ENOMEM;
|
||||
|
||||
rsb_cache = kmem_cache_create("dlm_rsb", sizeof(struct dlm_rsb),
|
||||
__alignof__(struct dlm_rsb), 0, NULL);
|
||||
if (!rsb_cache) {
|
||||
kmem_cache_destroy(lkb_cache);
|
||||
ret = -ENOMEM;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -33,6 +42,8 @@ void dlm_memory_exit(void)
|
||||
{
|
||||
if (lkb_cache)
|
||||
kmem_cache_destroy(lkb_cache);
|
||||
if (rsb_cache)
|
||||
kmem_cache_destroy(rsb_cache);
|
||||
}
|
||||
|
||||
char *dlm_allocate_lvb(struct dlm_ls *ls)
|
||||
@@ -48,16 +59,11 @@ void dlm_free_lvb(char *p)
|
||||
kfree(p);
|
||||
}
|
||||
|
||||
/* FIXME: have some minimal space built-in to rsb for the name and
|
||||
kmalloc a separate name if needed, like dentries are done */
|
||||
|
||||
struct dlm_rsb *dlm_allocate_rsb(struct dlm_ls *ls, int namelen)
|
||||
struct dlm_rsb *dlm_allocate_rsb(struct dlm_ls *ls)
|
||||
{
|
||||
struct dlm_rsb *r;
|
||||
|
||||
DLM_ASSERT(namelen <= DLM_RESNAME_MAXLEN,);
|
||||
|
||||
r = kzalloc(sizeof(*r) + namelen, GFP_NOFS);
|
||||
r = kmem_cache_zalloc(rsb_cache, GFP_NOFS);
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -65,7 +71,7 @@ void dlm_free_rsb(struct dlm_rsb *r)
|
||||
{
|
||||
if (r->res_lvbptr)
|
||||
dlm_free_lvb(r->res_lvbptr);
|
||||
kfree(r);
|
||||
kmem_cache_free(rsb_cache, r);
|
||||
}
|
||||
|
||||
struct dlm_lkb *dlm_allocate_lkb(struct dlm_ls *ls)
|
||||
|
Reference in New Issue
Block a user