[patch-2.4.0-test9-pre4] file_table.c cleanup

From: Tigran Aivazian (tigran@veritas.com)
Date: Tue Sep 19 2000 - 05:37:55 EST


Hi Linus,

a) in fget, file=NULL is not needed

b) removing _fput and __fput makes fput() code a lot more readable because
   on their own _fput/__fput are meaningless and not used at all.

Please consider this patch. Fully tested under 2.4.0-test9-pre4.

Regards,
Tigran

--- linux/fs/file_table.c Fri Jul 28 09:58:59 2000
+++ work/fs/file_table.c Tue Sep 19 11:29:13 2000
@@ -98,48 +98,35 @@
                 return 0;
 }
 
-/*
- * Called when retiring the last use of a file pointer.
- */
-static void __fput(struct file *filp)
+void fput(struct file * file)
 {
- struct dentry * dentry = filp->f_dentry;
- struct vfsmount * mnt = filp->f_vfsmnt;
+ struct dentry * dentry = file->f_dentry;
+ struct vfsmount * mnt = file->f_vfsmnt;
         struct inode * inode = dentry->d_inode;
 
- if (filp->f_op && filp->f_op->release)
- filp->f_op->release(inode, filp);
- fops_put(filp->f_op);
- filp->f_dentry = NULL;
- filp->f_vfsmnt = NULL;
- if (filp->f_mode & FMODE_WRITE)
- put_write_access(inode);
- dput(dentry);
- if (mnt)
- mntput(mnt);
-}
-
-static void _fput(struct file *file)
-{
- locks_remove_flock(file);
- __fput(file);
-
- file_list_lock();
- list_del(&file->f_list);
- list_add(&file->f_list, &free_list);
- files_stat.nr_free_files++;
- file_list_unlock();
-}
-
-void fput(struct file * file)
-{
- if (atomic_dec_and_test(&file->f_count))
- _fput(file);
+ if (atomic_dec_and_test(&file->f_count)) {
+ locks_remove_flock(file);
+ if (file->f_op && file->f_op->release)
+ file->f_op->release(inode, file);
+ fops_put(file->f_op);
+ file->f_dentry = NULL;
+ file->f_vfsmnt = NULL;
+ if (file->f_mode & FMODE_WRITE)
+ put_write_access(inode);
+ dput(dentry);
+ if (mnt)
+ mntput(mnt);
+ file_list_lock();
+ list_del(&file->f_list);
+ list_add(&file->f_list, &free_list);
+ files_stat.nr_free_files++;
+ file_list_unlock();
+ }
 }
 
 struct file * fget(unsigned int fd)
 {
- struct file * file = NULL;
+ struct file * file;
         struct files_struct *files = current->files;
 
         read_lock(&files->file_lock);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Sep 23 2000 - 21:00:20 EST