Whamcloud - gitweb
LU-1994 kernel: 3.5 kernel encode_fh passes in parent inode
authorPeng Tao <tao.peng@emc.com>
Thu, 23 Aug 2012 05:55:46 +0000 (13:55 +0800)
committerOleg Drokin <green@whamcloud.com>
Mon, 17 Dec 2012 06:52:02 +0000 (01:52 -0500)
Changed by upsteam commit b0b0382b.

Signed-off-by: Peng Tao <tao.peng@emc.com>
Change-Id: I6d7223b934bfe4151371744ad72bdab6b170c700
Reviewed-on: http://review.whamcloud.com/3757
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Yang Sheng <yang.sheng@intel.com>
lustre/autoconf/lustre-core.m4
lustre/llite/llite_nfs.c

index c47dbc4..7745767 100644 (file)
@@ -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 <linux/exportfs.h>
+       #include <linux/fs.h>
+       #include <linux/types.h>
+       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
 # LC_PROG_LINUX
 #
 # Lustre linux kernel checks
@@ -2251,6 +2280,7 @@ AC_DEFUN([LC_PROG_LINUX],
 
         # 3.5
         LC_HAVE_CLEAR_INODE
 
         # 3.5
         LC_HAVE_CLEAR_INODE
+        LC_HAVE_ENCODE_FH_PARENT
 
         #
         if test x$enable_server = xyes ; then
 
         #
         if test x$enable_server = xyes ; then
index 3a0ffef..22ee627 100644 (file)
@@ -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.
  */
  * 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,
 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,
 }
 
 static int ll_nfs_get_name_filldir(void *cookie, const char *name, int namelen,