Unionfs: ->fsync updates for new prototype
authorErez Zadok <ezk@cs.sunysb.edu>
Tue, 6 Sep 2011 04:57:42 +0000 (00:57 -0400)
committerErez Zadok <ezk@cs.sunysb.edu>
Tue, 11 Nov 2014 01:43:27 +0000 (20:43 -0500)
Also use lockdep_off/on in unionfs_fsync.

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

index 37c2654f6154f70e0e094604d4eaa93e15750b90..078ca2740884bf989eb3c43b9f29e6ece60d1e03 100644 (file)
@@ -325,8 +325,11 @@ static int __copyup_reg_data(struct dentry *dentry,
 
        kfree(buf);
 
+#if 0
+       /* XXX: code no longer needed? */
        if (!err)
                err = output_file->f_op->fsync(output_file, 0);
+#endif
 
        if (err)
                goto out_close_out;
index 416c52f4c48197aa20cfc70b4129afa5c79fe268..f583c8fc5a24d885dbb4caca78a3846844e17914 100644 (file)
@@ -188,7 +188,7 @@ out:
        return err;
 }
 
-int unionfs_fsync(struct file *file, int datasync)
+int unionfs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
 {
        int bindex, bstart, bend;
        struct file *lower_file;
@@ -198,6 +198,7 @@ int unionfs_fsync(struct file *file, int datasync)
        struct inode *lower_inode, *inode;
        int err = -EINVAL;
 
+       lockdep_off();
        unionfs_read_lock(dentry->d_sb, UNIONFS_SMUTEX_PARENT);
        parent = unionfs_lock_parent(dentry, UNIONFS_DMUTEX_PARENT);
        unionfs_lock_dentry(dentry, UNIONFS_DMUTEX_CHILD);
@@ -207,6 +208,10 @@ int unionfs_fsync(struct file *file, int datasync)
                goto out;
        unionfs_check_file(file);
 
+       err = generic_file_fsync(file, start, end, datasync);
+       if (err)
+               goto out;
+
        bstart = fbstart(file);
        bend = fbend(file);
        if (bstart < 0 || bend < 0)
@@ -224,11 +229,9 @@ int unionfs_fsync(struct file *file, int datasync)
                        continue;
                lower_file = unionfs_lower_file_idx(file, bindex);
                lower_dentry = unionfs_lower_dentry_idx(dentry, bindex);
-               mutex_lock(&lower_inode->i_mutex);
-               err = lower_inode->i_fop->fsync(lower_file, datasync);
+               err = vfs_fsync_range(lower_file, start, end, datasync);
                if (!err && bindex == bstart)
                        fsstack_copy_attr_times(inode, lower_inode);
-               mutex_unlock(&lower_inode->i_mutex);
                if (err)
                        goto out;
        }
@@ -239,6 +242,7 @@ out:
        unionfs_unlock_dentry(dentry);
        unionfs_unlock_parent(dentry, parent);
        unionfs_read_unlock(dentry->d_sb);
+       lockdep_on();
        return err;
 }
 
index 1821705bbc9541f97ba08753a75f48525e458501..07f6c2fdbd6c260a82e9e8c6307d4ecbf209e5f3 100644 (file)
@@ -416,7 +416,8 @@ extern int unionfs_file_release(struct inode *inode, struct file *file);
 extern int unionfs_flush(struct file *file, fl_owner_t id);
 extern long unionfs_ioctl(struct file *file, unsigned int cmd,
                          unsigned long arg);
-extern int unionfs_fsync(struct file *file, int datasync);
+extern int unionfs_fsync(struct file *file, loff_t start, loff_t end,
+                        int datasync);
 extern int unionfs_fasync(int fd, struct file *file, int flag);
 
 /* Inode operations */