Commit d684d33e authored by Andrew Morton's avatar Andrew Morton Committed by Dave Jones

[PATCH] file_list cleanup

Replace the odd handling of f_list.next = NULL with list_emptiness.
parent ca364896
...@@ -74,7 +74,7 @@ static int old_max = 0; ...@@ -74,7 +74,7 @@ static int old_max = 0;
struct file * f; struct file * f;
if (likely(files_stat.nr_files < files_stat.max_files)) { if (likely(files_stat.nr_files < files_stat.max_files)) {
f = kmem_cache_alloc(filp_cachep, SLAB_KERNEL); f = kmem_cache_alloc(filp_cachep, GFP_KERNEL);
if (f) { if (f) {
got_one: got_one:
memset(f, 0, sizeof(*f)); memset(f, 0, sizeof(*f));
...@@ -90,7 +90,8 @@ static int old_max = 0; ...@@ -90,7 +90,8 @@ static int old_max = 0;
f->f_uid = current->fsuid; f->f_uid = current->fsuid;
f->f_gid = current->fsgid; f->f_gid = current->fsgid;
f->f_owner.lock = RW_LOCK_UNLOCKED; f->f_owner.lock = RW_LOCK_UNLOCKED;
/* f->f_version, f->f_list.next: 0 */ /* f->f_version: 0 */
INIT_LIST_HEAD(&f->f_list);
return f; return f;
} }
} }
...@@ -132,7 +133,7 @@ int open_private_file(struct file *filp, struct dentry *dentry, int flags) ...@@ -132,7 +133,7 @@ int open_private_file(struct file *filp, struct dentry *dentry, int flags)
filp->f_uid = current->fsuid; filp->f_uid = current->fsuid;
filp->f_gid = current->fsgid; filp->f_gid = current->fsgid;
filp->f_op = dentry->d_inode->i_fop; filp->f_op = dentry->d_inode->i_fop;
filp->f_list.next = NULL; INIT_LIST_HEAD(&filp->f_list);
error = security_file_alloc(filp); error = security_file_alloc(filp);
if (!error) if (!error)
if (filp->f_op && filp->f_op->open) { if (filp->f_op && filp->f_op->open) {
...@@ -187,7 +188,6 @@ void __fput(struct file * file) ...@@ -187,7 +188,6 @@ void __fput(struct file * file)
file_list_lock(); file_list_lock();
file->f_dentry = NULL; file->f_dentry = NULL;
file->f_vfsmnt = NULL; file->f_vfsmnt = NULL;
if (file->f_list.next)
list_del(&file->f_list); list_del(&file->f_list);
file_free(file); file_free(file);
file_list_unlock(); file_list_unlock();
...@@ -215,7 +215,6 @@ void put_filp(struct file *file) ...@@ -215,7 +215,6 @@ void put_filp(struct file *file)
if(atomic_dec_and_test(&file->f_count)) { if(atomic_dec_and_test(&file->f_count)) {
security_file_free(file); security_file_free(file);
file_list_lock(); file_list_lock();
if (file->f_list.next)
list_del(&file->f_list); list_del(&file->f_list);
file_free(file); file_free(file);
file_list_unlock(); file_list_unlock();
...@@ -227,18 +226,14 @@ void file_move(struct file *file, struct list_head *list) ...@@ -227,18 +226,14 @@ void file_move(struct file *file, struct list_head *list)
if (!list) if (!list)
return; return;
file_list_lock(); file_list_lock();
if (file->f_list.next) list_move(&file->f_list, list);
list_del(&file->f_list);
list_add(&file->f_list, list);
file_list_unlock(); file_list_unlock();
} }
void file_kill(struct file *file) void file_kill(struct file *file)
{ {
file_list_lock(); file_list_lock();
if (file->f_list.next) list_del_init(&file->f_list);
list_del(&file->f_list);
file->f_list.next = NULL;
file_list_unlock(); file_list_unlock();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment