[GFS2] Use slab properly with glocks
We can take advantage of the slab allocator to ensure that all the list heads and the spinlock (plus one or two other fields) are initialised by slab to speed up allocation of glocks. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/gfs2_ondisk.h>
|
||||
#include <asm/atomic.h>
|
||||
|
||||
#include "gfs2.h"
|
||||
#include "lm_interface.h"
|
||||
@@ -35,6 +36,25 @@ static void gfs2_init_inode_once(void *foo, kmem_cache_t *cachep, unsigned long
|
||||
}
|
||||
}
|
||||
|
||||
static void gfs2_init_glock_once(void *foo, kmem_cache_t *cachep, unsigned long flags)
|
||||
{
|
||||
struct gfs2_glock *gl = foo;
|
||||
if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
|
||||
SLAB_CTOR_CONSTRUCTOR) {
|
||||
INIT_LIST_HEAD(&gl->gl_list);
|
||||
spin_lock_init(&gl->gl_spin);
|
||||
INIT_LIST_HEAD(&gl->gl_holders);
|
||||
INIT_LIST_HEAD(&gl->gl_waiters1);
|
||||
INIT_LIST_HEAD(&gl->gl_waiters2);
|
||||
INIT_LIST_HEAD(&gl->gl_waiters3);
|
||||
gl->gl_lvb = NULL;
|
||||
atomic_set(&gl->gl_lvb_count, 0);
|
||||
INIT_LIST_HEAD(&gl->gl_reclaim);
|
||||
INIT_LIST_HEAD(&gl->gl_ail_list);
|
||||
atomic_set(&gl->gl_ail_count, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* init_gfs2_fs - Register GFS2 as a filesystem
|
||||
*
|
||||
@@ -55,7 +75,8 @@ static int __init init_gfs2_fs(void)
|
||||
|
||||
gfs2_glock_cachep = kmem_cache_create("gfs2_glock",
|
||||
sizeof(struct gfs2_glock),
|
||||
0, 0, NULL, NULL);
|
||||
0, 0,
|
||||
gfs2_init_glock_once, NULL);
|
||||
if (!gfs2_glock_cachep)
|
||||
goto fail;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user