login
Header Space

 
 

[PATCH 11/21] Unionfs: Combine unionfs_write with __unionfs_write.

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-kernel@...>, <linux-fsdevel@...>
Cc: <akpm@...>, Josef 'Jeff' Sipek <jsipek@...>
Date: Wednesday, May 23, 2007 - 8:36 pm

The __unionfs_write helper function was used only by unionfs_write, and
there is really no reason why they should not be combined.

Signed-off-by: Josef 'Jeff' Sipek <jsipek@cs.sunysb.edu>
---
 fs/unionfs/file.c |   30 ++++++++++--------------------
 1 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/fs/unionfs/file.c b/fs/unionfs/file.c
index 1dfcfcb..2e5ec42 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;
 }
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[GIT PULL -mm] Unionfs cleanups and fixes, Josef 'Jeff' Sipek, (Wed May 23, 8:35 pm)
[PATCH 18/21] Unionfs: Remove defunct unionfs_put_inode supe..., Josef 'Jeff' Sipek, (Wed May 23, 8:36 pm)
[PATCH 14/21] Unionfs: Call realloc unconditionally, Josef 'Jeff' Sipek, (Wed May 23, 8:36 pm)
[PATCH 02/21] Unionfs: Coding style fixes, Josef 'Jeff' Sipek, (Wed May 23, 8:35 pm)
[PATCH 20/21] Unionfs: Removed a trailing whitespace, Josef 'Jeff' Sipek, (Wed May 23, 8:36 pm)
[PATCH 13/21] Unionfs: Don't leak resources when copyup fail..., Josef 'Jeff' Sipek, (Wed May 23, 8:36 pm)
[PATCH 06/21] Unionfs: Added numerous comments, Josef 'Jeff' Sipek, (Wed May 23, 8:35 pm)
[PATCH 05/21] Unionfs: Cleanup of strings and comments, Josef 'Jeff' Sipek, (Wed May 23, 8:35 pm)
[PATCH 15/21] Unionfs: Use krealloc instead of open-coding t..., Josef 'Jeff' Sipek, (Wed May 23, 8:36 pm)
[PATCH 04/21] Unionfs: Add missing copyright notices, Josef 'Jeff' Sipek, (Wed May 23, 8:35 pm)
[PATCH 08/21] Unionfs: Rename Unionfs's double_lock_dentry t..., Josef 'Jeff' Sipek, (Wed May 23, 8:35 pm)
[PATCH 10/21] Unionfs: Move unionfs_query_file to commonfops.c, Josef 'Jeff' Sipek, (Wed May 23, 8:36 pm)
[PATCH 12/21] Unionfs: Prefix external functions with 'exter..., Josef 'Jeff' Sipek, (Wed May 23, 8:36 pm)
[PATCH 17/21] Unionfs: Documentation update regarding overla..., Josef 'Jeff' Sipek, (Wed May 23, 8:36 pm)
[PATCH 21/21] Unionfs: Correctly decrement refcounts of mnt'..., Josef 'Jeff' Sipek, (Wed May 23, 8:36 pm)
[PATCH 11/21] Unionfs: Combine unionfs_write with __unionfs_..., Josef 'Jeff' Sipek, (Wed May 23, 8:36 pm)
[PATCH 07/21] Unionfs: Consistent pointer declaration spacing, Josef 'Jeff' Sipek, (Wed May 23, 8:35 pm)
[PATCH 03/21] Unionfs: Every printk should prefix with "unio..., Josef 'Jeff' Sipek, (Wed May 23, 8:35 pm)
[PATCH 09/21] Unionfs: Rename our "do_rename" to __unionfs_r..., Josef 'Jeff' Sipek, (Wed May 23, 8:35 pm)
[PATCH 16/21] Unionfs: Disallow setting leftmost branch to r..., Josef 'Jeff' Sipek, (Wed May 23, 8:36 pm)
[PATCH 19/21] Unionfs: Actually catch bad use of unionfs_mnt..., Josef 'Jeff' Sipek, (Wed May 23, 8:36 pm)
[PATCH 01/21] Unionfs: Tiny documentation fixups, Josef 'Jeff' Sipek, (Wed May 23, 8:35 pm)
speck-geostationary