From 407e7c90a97143d436ad3a6af6bbfa431c849191 Mon Sep 17 00:00:00 2001
From: Marc Dionne <marc.c.dionne@gmail.com>
Date: Sat, 2 Jun 2012 21:35:53 -0400
Subject: [PATCH] Linux 3.5: encode_fh API change

The encode_fh export operation now expects two inode arguments
instead of a dentry and a "connectable" flag.  Use the inode of
the dentry we're interested in, and NULL as the parent inode which
is the same as passing a 0 flag in the previous API.

Change-Id: I05cf146fb2a4bacdca20a9f108d04ccb11530804
Reviewed-on: http://gerrit.openafs.org/7523
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
(cherry picked from commit 5227148ae17949705487ea673d558ebfe143e635)
Reviewed-on: http://gerrit.openafs.org/7579
---
 acinclude.m4               |    1 +
 src/afs/LINUX/osi_compat.h |    4 ++++
 src/cf/linux-test4.m4      |   14 ++++++++++++++
 3 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/acinclude.m4 b/acinclude.m4
index c14b581..25484cf 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -958,6 +958,7 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
 		 LINUX_D_COUNT_IS_INT
 		 LINUX_IOP_MKDIR_TAKES_UMODE_T
 		 LINUX_IOP_CREATE_TAKES_UMODE_T
+		 LINUX_EXPORT_OP_ENCODE_FH_TAKES_INODES
 
 		 dnl If we are guaranteed that keyrings will work - that is
 		 dnl  a) The kernel has keyrings enabled
diff --git a/src/afs/LINUX/osi_compat.h b/src/afs/LINUX/osi_compat.h
index b94295c..4c7c261 100644
--- a/src/afs/LINUX/osi_compat.h
+++ b/src/afs/LINUX/osi_compat.h
@@ -333,7 +333,11 @@ afs_get_dentry_from_fh(struct super_block *afs_cacheSBp, afs_dcache_id_t *ainode
 static inline int
 afs_get_fh_from_dentry(struct dentry *dp, afs_ufs_dcache_id_t *ainode, int *max_lenp) {
     if (dp->d_sb->s_export_op->encode_fh)
+#if defined(EXPORT_OP_ENCODE_FH_TAKES_INODES)
+        return dp->d_sb->s_export_op->encode_fh(dp->d_inode, &ainode->raw[0], max_lenp, NULL);
+#else
         return dp->d_sb->s_export_op->encode_fh(dp, &ainode->raw[0], max_lenp, 0);
+#endif
 #if defined(NEW_EXPORT_OPS)
     /* If fs doesn't provide an encode_fh method, assume the default INO32 type */
     *max_lenp = sizeof(struct fid)/4;
diff --git a/src/cf/linux-test4.m4 b/src/cf/linux-test4.m4
index f5e91b1..f13e97d 100644
--- a/src/cf/linux-test4.m4
+++ b/src/cf/linux-test4.m4
@@ -661,3 +661,17 @@ AC_DEFUN([LINUX_IOP_CREATE_TAKES_UMODE_T], [
 			[define if inode.i_op->create takes a umode_t argument],
 			[-Werror])
 ])
+
+
+AC_DEFUN([LINUX_EXPORT_OP_ENCODE_FH_TAKES_INODES], [
+  AC_CHECK_LINUX_BUILD([whether export operation encode_fh takes inode arguments],
+			[ac_cv_linux_export_op_encode_fh__takes_inodes],
+			[#include <linux/exportfs.h>],
+			[struct export_operations _exp_ops;
+			int _encode_fh(struct inode *i, __u32 *fh, int *len, struct inode *p)
+				{return 0;};
+			_exp_ops.encode_fh = _encode_fh;],
+			[EXPORT_OP_ENCODE_FH_TAKES_INODES],
+			[define if encode_fh export op takes inode arguments],
+			[-Werror])
+])
-- 
1.7.2.5

