From ab8b977f77e44c3f4d57be2244e9df898fd15316 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Tue, 15 Sep 2015 18:13:20 -0400 Subject: [PATCH 1/1] LU-6215 llite: handle kernel symlink api changes in 4.2+ 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 Reviewed-on: http://review.whamcloud.com/16376 Tested-by: Jenkins Reviewed-by: frank zago Tested-by: Maloo Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin --- lustre/autoconf/lustre-core.m4 | 23 +++++++++++++++++++++++ lustre/llite/symlink.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 6c18234..97f1a2d 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -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 + #include +],[ + 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], [ diff --git a/lustre/llite/symlink.c b/lustre/llite/symlink.c index aabb076..4b1a9da 100644 --- a/lustre/llite/symlink.c +++ b/lustre/llite/symlink.c @@ -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); } -- 1.8.3.1