summaryrefslogtreecommitdiffstats
path: root/module/zfs/zpl_inode.c
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2015-07-15 10:54:26 -0700
committerBrian Behlendorf <[email protected]>2015-07-17 09:18:16 -0700
commitbd29109f1ac5be68f7f7c8bcb49e1b706fe899f0 (patch)
tree6aa5f76ed5f9748ffbb8949b752826001c9fbb1e /module/zfs/zpl_inode.c
parent7eb333fbdde32dbebdcc88c35610159e207237c9 (diff)
Linux 4.2 compat: follow_link() / put_link()
As of Linux 4.2 the kernel has completely retired the nameidata structure. One of the few remaining consumers of this interface were the follow_link() and put_link() callbacks. This patch adds the required checks to configure to detect the interface change and updates the functions accordingly. Migrating to the simple_follow_link() interface was considered but was decided against ironically due to the increased complexity. It also should be noted that the kernel follow_link() and put_link() interfaces changes several times after 4.1 and but before 4.2. This means there is a narrow range of kernel commits which never appear in an official tag of the Linux kernel which ZoL will not build. Signed-off-by: Brian Behlendorf <[email protected]> Signed-off-by: Richard Yao <[email protected]> Issue #3596
Diffstat (limited to 'module/zfs/zpl_inode.c')
-rw-r--r--module/zfs/zpl_inode.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/module/zfs/zpl_inode.c b/module/zfs/zpl_inode.c
index 31251e730..70b5e1239 100644
--- a/module/zfs/zpl_inode.c
+++ b/module/zfs/zpl_inode.c
@@ -348,8 +348,13 @@ zpl_symlink(struct inode *dir, struct dentry *dentry, const char *name)
return (error);
}
+#ifdef HAVE_FOLLOW_LINK_NAMEIDATA
static void *
zpl_follow_link(struct dentry *dentry, struct nameidata *nd)
+#else
+const char *
+zpl_follow_link(struct dentry *dentry, void **symlink_cookie)
+#endif
{
cred_t *cr = CRED();
struct inode *ip = dentry->d_inode;
@@ -372,17 +377,28 @@ zpl_follow_link(struct dentry *dentry, struct nameidata *nd)
cookie = spl_fstrans_mark();
error = -zfs_readlink(ip, &uio, cr);
spl_fstrans_unmark(cookie);
- if (error) {
+
+ if (error)
kmem_free(link, MAXPATHLEN);
+
+ crfree(cr);
+
+#ifdef HAVE_FOLLOW_LINK_NAMEIDATA
+ if (error)
nd_set_link(nd, ERR_PTR(error));
- } else {
+ else
nd_set_link(nd, link);
- }
- crfree(cr);
return (NULL);
+#else
+ if (error)
+ return (ERR_PTR(error));
+ else
+ return (*symlink_cookie = link);
+#endif
}
+#ifdef HAVE_PUT_LINK_NAMEIDATA
static void
zpl_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
{
@@ -391,6 +407,13 @@ zpl_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
if (!IS_ERR(link))
kmem_free(link, MAXPATHLEN);
}
+#else
+static void
+zpl_put_link(struct inode *unused, void *symlink_cookie)
+{
+ kmem_free(symlink_cookie, MAXPATHLEN);
+}
+#endif
static int
zpl_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)