GIT: unionfs2-2.6.27.y: Merge unionfs_write with __unionfs_write.

Erez Zadok ezk at fsl.cs.sunysb.edu
Thu Aug 12 23:16:09 EDT 2010


commit d8ac4145a04b523b14367a9c0247c104827329c3
Author: Erez Zadok <ezk at bigvaio.(none)>
Date:   Sun Mar 25 01:24:54 2007 -0400

    Merge unionfs_write with __unionfs_write.
    
    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.

diff --git a/fs/unionfs/file.c b/fs/unionfs/file.c
index 57f2bdd..972e696 100644
--- a/fs/unionfs/file.c
+++ b/fs/unionfs/file.c
@@ -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)
@@ -120,21 +125,6 @@ static ssize_t __unionfs_write(struct file * file, const char __user * buf,
 	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;
 }


More information about the unionfs-cvs mailing list