aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/vfs_compat.h13
-rw-r--r--module/zfs/zpl_file.c23
2 files changed, 21 insertions, 15 deletions
diff --git a/include/linux/vfs_compat.h b/include/linux/vfs_compat.h
index c25cf4477..dce2b6f28 100644
--- a/include/linux/vfs_compat.h
+++ b/include/linux/vfs_compat.h
@@ -27,19 +27,6 @@
#define _ZFS_VFS_H
/*
- * 2.6.35 API change,
- * The dentry argument to the .fsync() vfs hook was deemed unused by
- * all filesystem consumers and dropped. Add a compatibility prototype
- * to ensure correct usage when defining this callback.
- */
-#ifdef HAVE_2ARGS_FSYNC
-#define ZPL_FSYNC_PROTO(fn, x, y, z) static int fn(struct file *x, int z)
-#else
-#define ZPL_FSYNC_PROTO(fn, x, y, z) static int fn(struct file *x, \
- struct dentry *y, int z)
-#endif /* HAVE_2ARGS_FSYNC */
-
-/*
* 2.6.28 API change,
* Added insert_inode_locked() helper function, prior to this most callers
* used insert_inode_hash(). The older method doesn't check for collisions
diff --git a/module/zfs/zpl_file.c b/module/zfs/zpl_file.c
index c8a3fedb7..de66ff4b4 100644
--- a/module/zfs/zpl_file.c
+++ b/module/zfs/zpl_file.c
@@ -76,13 +76,32 @@ zpl_readdir(struct file *filp, void *dirent, filldir_t filldir)
return (error);
}
-ZPL_FSYNC_PROTO(zpl_fsync, filp, unused_dentry, datasync)
+/*
+ * 2.6.35 API change,
+ * As of 2.6.35 the dentry argument to the .fsync() vfs hook was deemed
+ * redundant. The dentry is still accessible via filp->f_path.dentry,
+ * and we are guaranteed that filp will never be NULL.
+ *
+ * 2.6.34 API change,
+ * Prior to 2.6.34 the nfsd kernel server would pass a NULL file struct *
+ * to the .fsync() hook. For this reason, we must be careful not to use
+ * filp unconditionally in the 3 argument case.
+ */
+#ifdef HAVE_2ARGS_FSYNC
+static int
+zpl_fsync(struct file *filp, int datasync)
+{
+ struct dentry *dentry = filp->f_path.dentry;
+#else
+static int
+zpl_fsync(struct file *filp, struct dentry *dentry, int datasync)
{
+#endif /* HAVE_2ARGS_FSYNC */
cred_t *cr = CRED();
int error;
crhold(cr);
- error = -zfs_fsync(filp->f_path.dentry->d_inode, datasync, cr);
+ error = -zfs_fsync(dentry->d_inode, datasync, cr);
crfree(cr);
ASSERT3S(error, <=, 0);