From f8539c8d1031cb380516497a4e752d57470cde4b Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Thu, 23 Aug 2012 13:55:46 +0800 Subject: [PATCH] LU-1994 kernel: 3.5 kernel encode_fh passes in parent inode Changed by upsteam commit b0b0382b. Signed-off-by: Peng Tao Change-Id: I6d7223b934bfe4151371744ad72bdab6b170c700 Reviewed-on: http://review.whamcloud.com/3757 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Yang Sheng --- lustre/autoconf/lustre-core.m4 | 30 ++++++++++++++++++++++++++++++ lustre/llite/llite_nfs.c | 34 ++++++++++++++++++++-------------- 2 files changed, 50 insertions(+), 14 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index c47dbc4..7745767 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -2085,6 +2085,35 @@ LB_LINUX_TRY_COMPILE([ ]) # +# 3.5 encode_fh has parent inode passed in directly +# see kernel commit b0b0382b +# +AC_DEFUN([LC_HAVE_ENCODE_FH_PARENT], +[AC_MSG_CHECKING([if encode_fh have parent inode as parameter]) +tmp_flags="$EXTRA_KCFLAGS" +EXTRA_KCFLAGS="-Werror" +LB_LINUX_TRY_COMPILE([ + #include + #include + #include + int ll_encode_fh(struct inode *i, __u32 *a, int *b, struct inode *p) + { + return 0; + } +],[ + struct export_operations exp_op; + exp_op.encode_fh = ll_encode_fh; +],[ + AC_DEFINE(HAVE_ENCODE_FH_PARENT, 1, + [have parent inode as parameter]) + AC_MSG_RESULT([yes]) +],[ + AC_MSG_RESULT([no]) +]) +EXTRA_KCFLAGS="$tmp_flags" +]) + +# # LC_PROG_LINUX # # Lustre linux kernel checks @@ -2251,6 +2280,7 @@ AC_DEFUN([LC_PROG_LINUX], # 3.5 LC_HAVE_CLEAR_INODE + LC_HAVE_ENCODE_FH_PARENT # if test x$enable_server = xyes ; then diff --git a/lustre/llite/llite_nfs.c b/lustre/llite/llite_nfs.c index 3a0ffef..22ee627 100644 --- a/lustre/llite/llite_nfs.c +++ b/lustre/llite/llite_nfs.c @@ -173,26 +173,32 @@ ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *paren * 2 -- contains child file handle and parent file handle; * 255 -- error. */ +#ifndef HAVE_ENCODE_FH_PARENT static int ll_encode_fh(struct dentry *de, __u32 *fh, int *plen, - int connectable) + int connectable) { - struct inode *inode = de->d_inode; - struct inode *parent = de->d_parent->d_inode; - struct lustre_nfs_fid *nfs_fid = (void *)fh; - ENTRY; + struct inode *inode = de->d_inode; + struct inode *parent = de->d_parent->d_inode; +#else +static int ll_encode_fh(struct inode *inode, __u32 *fh, int *plen, + struct inode *parent) +{ +#endif + struct lustre_nfs_fid *nfs_fid = (void *)fh; + ENTRY; - CDEBUG(D_INFO, "encoding for (%lu,"DFID") maxlen=%d minlen=%d\n", - inode->i_ino, PFID(ll_inode2fid(inode)), *plen, - (int)sizeof(struct lustre_nfs_fid)); + CDEBUG(D_INFO, "encoding for (%lu,"DFID") maxlen=%d minlen=%d\n", + inode->i_ino, PFID(ll_inode2fid(inode)), *plen, + (int)sizeof(struct lustre_nfs_fid)); - if (*plen < sizeof(struct lustre_nfs_fid)/4) - RETURN(255); + if (*plen < sizeof(struct lustre_nfs_fid) / 4) + RETURN(255); - nfs_fid->lnf_child = *ll_inode2fid(inode); - nfs_fid->lnf_parent = *ll_inode2fid(parent); - *plen = sizeof(struct lustre_nfs_fid)/4; + nfs_fid->lnf_child = *ll_inode2fid(inode); + nfs_fid->lnf_parent = *ll_inode2fid(parent); + *plen = sizeof(struct lustre_nfs_fid) / 4; - RETURN(LUSTRE_NFS_FID); + RETURN(LUSTRE_NFS_FID); } static int ll_nfs_get_name_filldir(void *cookie, const char *name, int namelen, -- 1.8.3.1