[PATCH 9/10] Rewrite ecryptfs_fsync()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rewrite ecryptfs_fsync() to be more concise. Note that i_fop is always
valid.

Signed-off-by: Michael Halcrow <[email protected]>

---

 fs/ecryptfs/file.c |   29 ++++++++---------------------
 1 files changed, 8 insertions(+), 21 deletions(-)

fb9079aa454161fdbdc53021b987eec7513fec06
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index 3a9cd15..c984ea6 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -322,29 +322,16 @@ static int ecryptfs_release(struct inode
 static int
 ecryptfs_fsync(struct file *file, struct dentry *dentry, int datasync)
 {
+	struct file *lower_file = ecryptfs_file_to_lower(file);
+	struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
+	struct inode *lower_inode = lower_dentry->d_inode;
 	int rc = -EINVAL;
-	struct file *lower_file = NULL;
-	struct dentry *lower_dentry;
 
-	if (!file) {
-		lower_dentry = ecryptfs_dentry_to_lower(dentry);
-		if (lower_dentry->d_inode->i_fop
-		    && lower_dentry->d_inode->i_fop->fsync) {
-			mutex_lock(&lower_dentry->d_inode->i_mutex);
-			rc = lower_dentry->d_inode->i_fop->fsync(lower_file,
-								 lower_dentry,
-								 datasync);
-			mutex_unlock(&lower_dentry->d_inode->i_mutex);
-		}
-	} else {
-		lower_file = ecryptfs_file_to_lower(file);
-		lower_dentry = ecryptfs_dentry_to_lower(dentry);
-		if (lower_file->f_op && lower_file->f_op->fsync) {
-			mutex_lock(&lower_dentry->d_inode->i_mutex);
-			rc = lower_file->f_op->fsync(lower_file, lower_dentry,
-						     datasync);
-			mutex_unlock(&lower_dentry->d_inode->i_mutex);
-		}
+	if (lower_inode->i_fop->fsync) {
+		mutex_lock(&lower_inode->i_mutex);
+		rc = lower_inode->i_fop->fsync(lower_file, lower_dentry,
+					       datasync);
+		mutex_unlock(&lower_inode->i_mutex);
 	}
 	return rc;
 }
-- 
1.3.3

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

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux