Whamcloud - gitweb
LU-6215 llite: handle kernel symlink api changes in 4.2+ 76/16376/4
authorJames Simmons <uja.ornl@yahoo.com>
Tue, 15 Sep 2015 22:13:20 +0000 (18:13 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 22 Sep 2015 23:23:19 +0000 (23:23 +0000)
 kernels

Starting with 4.2 kernels the inode operations handling
symlinks follow_link() and put_link() stop passing in
struct nameidata as an argument. This patch handles this
change.

Change-Id: I204daa1469f6661ced3a519873e1aa26463c8c72
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: http://review.whamcloud.com/16376
Tested-by: Jenkins
Reviewed-by: frank zago <fzago@cray.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/autoconf/lustre-core.m4
lustre/llite/symlink.c

index 6c18234..97f1a2d 100644 (file)
@@ -1890,6 +1890,28 @@ new_cancel_dirty_page, [
 ]) # LC_NEW_CANCEL_DIRTY_PAGE
 
 #
+# LC_SYMLINK_OPS_USE_NAMEIDATA
+#
+# For the 4.2+ kernels the file system internal symlink api no
+# longer uses struct nameidata as a argument
+#
+AC_DEFUN([LC_SYMLINK_OPS_USE_NAMEIDATA], [
+LB_CHECK_COMPILE([if symlink inode operations have struct nameidata argument],
+symlink_use_nameidata, [
+       #include <linux/namei.h>
+       #include <linux/fs.h>
+],[
+       struct nameidata *nd = NULL;
+
+       ((struct inode_operations *)0)->follow_link(NULL, nd);
+       ((struct inode_operations *)0)->put_link(NULL, nd, NULL);
+],[
+       AC_DEFINE(HAVE_SYMLINK_OPS_USE_NAMEIDATA, 1,
+               [symlink inode operations need struct nameidata argument])
+])
+]) # LC_SYMLINK_OPS_USE_NAMEIDATA
+
+#
 # LC_PROG_LINUX
 #
 # Lustre linux kernel checks
@@ -2046,6 +2068,7 @@ AC_DEFUN([LC_PROG_LINUX], [
 
        # 4.2
        LC_NEW_CANCEL_DIRTY_PAGE
+       LC_SYMLINK_OPS_USE_NAMEIDATA
 
        #
        AS_IF([test "x$enable_server" != xno], [
index aabb076..4b1a9da 100644 (file)
@@ -121,6 +121,7 @@ failed:
         RETURN (rc);
 }
 
+#ifdef HAVE_SYMLINK_OPS_USE_NAMEIDATA
 static void *ll_follow_link(struct dentry *dentry, struct nameidata *nd)
 {
        struct inode *inode = dentry->d_inode;
@@ -154,8 +155,37 @@ static void *ll_follow_link(struct dentry *dentry, struct nameidata *nd)
         */
        RETURN(request);
 }
+#else
+static const char *ll_follow_link(struct dentry *dentry, void **cookie)
+{
+       struct inode *inode = d_inode(dentry);
+       struct ptlrpc_request *request;
+       char *symname;
+       int rc;
+       ENTRY;
+
+       CDEBUG(D_VFSTRACE, "VFS Op\n");
+       ll_inode_size_lock(inode);
+       rc = ll_readlink_internal(inode, &request, &symname);
+       ll_inode_size_unlock(inode);
+       if (rc < 0) {
+               ptlrpc_req_finished(request);
+               return ERR_PTR(rc);
+       }
+
+       /* symname may contain a pointer to the request message buffer,
+        * we delay request releasing until ll_put_link then.
+        */
+       *cookie = request;
+       RETURN(symname);
+}
+#endif /* HAVE_SYMLINK_OPS_USE_NAMEIDATA */
 
+#ifdef HAVE_SYMLINK_OPS_USE_NAMEIDATA
 static void ll_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
+#else
+static void ll_put_link(struct inode *unused, void *cookie)
+#endif
 {
        ptlrpc_req_finished(cookie);
 }