Unionfs: remove custom read/write methods
authorErez Zadok <ezk@cs.sunysb.edu>
Tue, 25 Dec 2007 04:07:20 +0000 (23:07 -0500)
committerErez Zadok <ezk@cs.sunysb.edu>
Fri, 29 Apr 2011 02:25:34 +0000 (22:25 -0400)
Having them results in lockdep warnings about having locks and grabbing the
same class locks in do_sync_read/write which were called from
unionfs_read/write.  All they did was revalidate out file object sooner,
which will now be deferred till a bit later.  Instead, use generic
do_sync_read and do_sync_write.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
fs/unionfs/file.c

index c922173011e2c12ebe2e587df316bab95f8d3d2d..94784c3ce78ba65ffdd61b04f529eefbcde0930b 100644 (file)
 
 #include "union.h"
 
-static ssize_t unionfs_read(struct file *file, char __user *buf,
-                           size_t count, loff_t *ppos)
-{
-       int err;
-
-       unionfs_read_lock(file->f_path.dentry->d_sb);
-       err = unionfs_file_revalidate(file, false);
-       if (unlikely(err))
-               goto out;
-       unionfs_check_file(file);
-
-       err = do_sync_read(file, buf, count, ppos);
-
-out:
-       unionfs_check_file(file);
-       unionfs_read_unlock(file->f_path.dentry->d_sb);
-       return err;
-}
-
-static ssize_t unionfs_write(struct file *file, const char __user *buf,
-                            size_t count, loff_t *ppos)
-{
-       int err = 0;
-
-       unionfs_read_lock(file->f_path.dentry->d_sb);
-       err = unionfs_file_revalidate(file, true);
-       if (unlikely(err))
-               goto out;
-       unionfs_check_file(file);
-
-       err = do_sync_write(file, buf, count, ppos);
-       /* update our inode times upon a successful lower write */
-       if (err >= 0) {
-               unionfs_copy_attr_times(file->f_path.dentry->d_inode);
-               unionfs_check_file(file);
-       }
-
-out:
-       unionfs_read_unlock(file->f_path.dentry->d_sb);
-       return err;
-}
-
 static int unionfs_file_readdir(struct file *file, void *dirent,
                                filldir_t filldir)
 {
@@ -210,9 +168,9 @@ out:
 
 struct file_operations unionfs_main_fops = {
        .llseek         = generic_file_llseek,
-       .read           = unionfs_read,
+       .read           = do_sync_read,
        .aio_read       = generic_file_aio_read,
-       .write          = unionfs_write,
+       .write          = do_sync_write,
        .aio_write      = generic_file_aio_write,
        .readdir        = unionfs_file_readdir,
        .unlocked_ioctl = unionfs_ioctl,