mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-15 08:44:14 +08:00
fs: locks: remove init_once
From: Miklos Szeredi <mszeredi@suse.cz> Remove SLAB initialization entirely, as suggested by Bruce and Linus. Allocate with __GFP_ZERO instead and only initialize list heads. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
This commit is contained in:
parent
ae82a8d06f
commit
ee19cc406d
41
fs/locks.c
41
fs/locks.c
@ -160,26 +160,20 @@ EXPORT_SYMBOL_GPL(unlock_flocks);
|
|||||||
|
|
||||||
static struct kmem_cache *filelock_cache __read_mostly;
|
static struct kmem_cache *filelock_cache __read_mostly;
|
||||||
|
|
||||||
static void locks_init_lock_always(struct file_lock *fl)
|
static void locks_init_lock_heads(struct file_lock *fl)
|
||||||
{
|
{
|
||||||
fl->fl_next = NULL;
|
INIT_LIST_HEAD(&fl->fl_link);
|
||||||
fl->fl_fasync = NULL;
|
INIT_LIST_HEAD(&fl->fl_block);
|
||||||
fl->fl_owner = NULL;
|
init_waitqueue_head(&fl->fl_wait);
|
||||||
fl->fl_pid = 0;
|
|
||||||
fl->fl_nspid = NULL;
|
|
||||||
fl->fl_file = NULL;
|
|
||||||
fl->fl_flags = 0;
|
|
||||||
fl->fl_type = 0;
|
|
||||||
fl->fl_start = fl->fl_end = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate an empty lock structure. */
|
/* Allocate an empty lock structure. */
|
||||||
struct file_lock *locks_alloc_lock(void)
|
struct file_lock *locks_alloc_lock(void)
|
||||||
{
|
{
|
||||||
struct file_lock *fl = kmem_cache_alloc(filelock_cache, GFP_KERNEL);
|
struct file_lock *fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
|
||||||
|
|
||||||
if (fl)
|
if (fl)
|
||||||
locks_init_lock_always(fl);
|
locks_init_lock_heads(fl);
|
||||||
|
|
||||||
return fl;
|
return fl;
|
||||||
}
|
}
|
||||||
@ -215,27 +209,12 @@ EXPORT_SYMBOL(locks_free_lock);
|
|||||||
|
|
||||||
void locks_init_lock(struct file_lock *fl)
|
void locks_init_lock(struct file_lock *fl)
|
||||||
{
|
{
|
||||||
INIT_LIST_HEAD(&fl->fl_link);
|
memset(fl, 0, sizeof(struct file_lock));
|
||||||
INIT_LIST_HEAD(&fl->fl_block);
|
locks_init_lock_heads(fl);
|
||||||
init_waitqueue_head(&fl->fl_wait);
|
|
||||||
fl->fl_ops = NULL;
|
|
||||||
fl->fl_lmops = NULL;
|
|
||||||
locks_init_lock_always(fl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(locks_init_lock);
|
EXPORT_SYMBOL(locks_init_lock);
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialises the fields of the file lock which are invariant for
|
|
||||||
* free file_locks.
|
|
||||||
*/
|
|
||||||
static void init_once(void *foo)
|
|
||||||
{
|
|
||||||
struct file_lock *lock = (struct file_lock *) foo;
|
|
||||||
|
|
||||||
locks_init_lock(lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void locks_copy_private(struct file_lock *new, struct file_lock *fl)
|
static void locks_copy_private(struct file_lock *new, struct file_lock *fl)
|
||||||
{
|
{
|
||||||
if (fl->fl_ops) {
|
if (fl->fl_ops) {
|
||||||
@ -2333,8 +2312,8 @@ EXPORT_SYMBOL(lock_may_write);
|
|||||||
static int __init filelock_init(void)
|
static int __init filelock_init(void)
|
||||||
{
|
{
|
||||||
filelock_cache = kmem_cache_create("file_lock_cache",
|
filelock_cache = kmem_cache_create("file_lock_cache",
|
||||||
sizeof(struct file_lock), 0, SLAB_PANIC,
|
sizeof(struct file_lock), 0, SLAB_PANIC, NULL);
|
||||||
init_once);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user