Commit ee19cc406d4c0ae3118f59e000984d935b372871
Committed by
J. Bruce Fields
1 parent
ae82a8d06f
Exists in
master
and in
20 other branches
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>
Showing 1 changed file with 10 additions and 31 deletions Side-by-side Diff
fs/locks.c
... | ... | @@ -160,26 +160,20 @@ |
160 | 160 | |
161 | 161 | static struct kmem_cache *filelock_cache __read_mostly; |
162 | 162 | |
163 | -static void locks_init_lock_always(struct file_lock *fl) | |
163 | +static void locks_init_lock_heads(struct file_lock *fl) | |
164 | 164 | { |
165 | - fl->fl_next = NULL; | |
166 | - fl->fl_fasync = NULL; | |
167 | - fl->fl_owner = NULL; | |
168 | - fl->fl_pid = 0; | |
169 | - fl->fl_nspid = NULL; | |
170 | - fl->fl_file = NULL; | |
171 | - fl->fl_flags = 0; | |
172 | - fl->fl_type = 0; | |
173 | - fl->fl_start = fl->fl_end = 0; | |
165 | + INIT_LIST_HEAD(&fl->fl_link); | |
166 | + INIT_LIST_HEAD(&fl->fl_block); | |
167 | + init_waitqueue_head(&fl->fl_wait); | |
174 | 168 | } |
175 | 169 | |
176 | 170 | /* Allocate an empty lock structure. */ |
177 | 171 | struct file_lock *locks_alloc_lock(void) |
178 | 172 | { |
179 | - struct file_lock *fl = kmem_cache_alloc(filelock_cache, GFP_KERNEL); | |
173 | + struct file_lock *fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL); | |
180 | 174 | |
181 | 175 | if (fl) |
182 | - locks_init_lock_always(fl); | |
176 | + locks_init_lock_heads(fl); | |
183 | 177 | |
184 | 178 | return fl; |
185 | 179 | } |
186 | 180 | |
... | ... | @@ -215,27 +209,12 @@ |
215 | 209 | |
216 | 210 | void locks_init_lock(struct file_lock *fl) |
217 | 211 | { |
218 | - INIT_LIST_HEAD(&fl->fl_link); | |
219 | - INIT_LIST_HEAD(&fl->fl_block); | |
220 | - init_waitqueue_head(&fl->fl_wait); | |
221 | - fl->fl_ops = NULL; | |
222 | - fl->fl_lmops = NULL; | |
223 | - locks_init_lock_always(fl); | |
212 | + memset(fl, 0, sizeof(struct file_lock)); | |
213 | + locks_init_lock_heads(fl); | |
224 | 214 | } |
225 | 215 | |
226 | 216 | EXPORT_SYMBOL(locks_init_lock); |
227 | 217 | |
228 | -/* | |
229 | - * Initialises the fields of the file lock which are invariant for | |
230 | - * free file_locks. | |
231 | - */ | |
232 | -static void init_once(void *foo) | |
233 | -{ | |
234 | - struct file_lock *lock = (struct file_lock *) foo; | |
235 | - | |
236 | - locks_init_lock(lock); | |
237 | -} | |
238 | - | |
239 | 218 | static void locks_copy_private(struct file_lock *new, struct file_lock *fl) |
240 | 219 | { |
241 | 220 | if (fl->fl_ops) { |
... | ... | @@ -2333,8 +2312,8 @@ |
2333 | 2312 | static int __init filelock_init(void) |
2334 | 2313 | { |
2335 | 2314 | filelock_cache = kmem_cache_create("file_lock_cache", |
2336 | - sizeof(struct file_lock), 0, SLAB_PANIC, | |
2337 | - init_once); | |
2315 | + sizeof(struct file_lock), 0, SLAB_PANIC, NULL); | |
2316 | + | |
2338 | 2317 | return 0; |
2339 | 2318 | } |
2340 | 2319 |