Merge unionfs_write with __unionfs_write.
authorErez Zadok <ezk@bigvaio.(none)>
Sun, 25 Mar 2007 05:24:54 +0000 (01:24 -0400)
committerErez Zadok <ezk@cs.sunysb.edu>
Mon, 12 Jan 2009 23:20:23 +0000 (18:20 -0500)
Merge the two functions because unionfs_write was a small function and the
only one which called the __unionfs_write.  This saves on stack space and
clarifies code a bit.

fs/unionfs/file.c

index 57f2bddc645754bf55703c076f27ad9fa3dab890..972e696063939360829c3b127c092400fe49363a 100644 (file)
@@ -77,17 +77,20 @@ out:
        return err;
 }
 
-/* helper function to unionfs_write */
-static ssize_t __unionfs_write(struct file * file, const char __user * buf,
-                              size_t count, loff_t * ppos)
+static ssize_t unionfs_write(struct file * file, const char __user * buf,
+                            size_t count, loff_t *ppos)
 {
-       int err = -EINVAL;
+       int err;
        struct file *hidden_file = NULL;
        struct inode *inode;
        struct inode *hidden_inode;
        loff_t pos = *ppos;
        int bstart, bend;
 
+       unionfs_read_lock(file->f_dentry->d_sb);
+       if ((err = unionfs_file_revalidate(file, 1)))
+               goto out;
+
        inode = file->f_dentry->d_inode;
 
        bstart = fbstart(file);
@@ -98,8 +101,10 @@ static ssize_t __unionfs_write(struct file * file, const char __user * buf,
        hidden_file = unionfs_lower_file(file);
        hidden_inode = hidden_file->f_dentry->d_inode;
 
-       if (!hidden_file->f_op || !hidden_file->f_op->write)
+       if (!hidden_file->f_op || !hidden_file->f_op->write) {
+               err = -EINVAL;
                goto out;
+       }
 
        /* adjust for append -- seek to the end of the file */
        if (file->f_flags & O_APPEND)
@@ -119,21 +124,6 @@ static ssize_t __unionfs_write(struct file * file, const char __user * buf,
        /* update this inode's size */
        if (pos > inode->i_size)
                inode->i_size = pos;
-out:
-       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_dentry->d_sb);
-       if ((err = unionfs_file_revalidate(file, 1)))
-               goto out;
-
-       err = __unionfs_write(file, buf, count, ppos);
-
 out:
        unionfs_read_unlock(file->f_dentry->d_sb);
        return err;