From ba0d551aab889a07fe024ddead9772ffbe25191f Mon Sep 17 00:00:00 2001
From: adilger <adilger>
Date: Thu, 29 Jan 2004 19:58:26 +0000
Subject: [PATCH] Fix build problems with RH ia64 kernel on TDEV/Thunder: -
 they back-ported PDE from 2.6, which broke our compat macro - they changed
 direct_IO method to pass struct file instead of struct inode

Both are now checked in portals/archdep.m4 directly instead of as a version
number check so we don't need to worry about other releases doing the same.
---
 lnet/archdep.m4                        | 20 ++++++++++++++++++++
 lustre/include/linux/lustre_compat25.h |  2 +-
 lustre/llite/rw24.c                    | 13 +++++++++++--
 lustre/portals/archdep.m4              | 20 ++++++++++++++++++++
 4 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/lnet/archdep.m4 b/lnet/archdep.m4
index b67e012941..4c9e5ae248 100644
--- a/lnet/archdep.m4
+++ b/lnet/archdep.m4
@@ -369,3 +369,23 @@ if test $RH_2_4_20 = 1; then
 else
 	AC_MSG_RESULT($LINUXRELEASE)
 fi 
+
+# ---------- Red Hat 2.4.21 backports some more 2.5 bits --------
+
+AC_MSG_CHECKING(if kernel defines PDE)
+HAVE_PDE="`grep -c 'proc_dir_entry..PDE' $LINUX/include/linux/proc_fs.h`"
+if test "$HAVE_PDE" != 0 ; then
+  CPPFLAGS="$CPPFLAGS -DHAVE_PDE"
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_RESULT(no)
+fi
+
+AC_MSG_CHECKING(if kernel passes struct file to direct_IO)
+HAVE_DIO_FILE="`grep -c 'direct_IO.*struct file' $LINUX/include/linux/fs.h`"
+if test "$HAVE_DIO_FILE" != 0 ; then
+  CPPFLAGS="$CPPFLAGS -DHAVE_DIO_FILE"
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_RESULT(no)
+fi
diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h
index 40620ac5ee..e6339dcde7 100644
--- a/lustre/include/linux/lustre_compat25.h
+++ b/lustre/include/linux/lustre_compat25.h
@@ -158,7 +158,7 @@ static inline void lustre_daemonize_helper(void)
 #endif
 
 /* to find proc_dir_entry from inode. 2.6 has native one -bzzz */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23)
+#ifndef HAVE_PDE
 #define PDE(ii)         ((ii)->u.generic_ip)
 #endif
 
diff --git a/lustre/llite/rw24.c b/lustre/llite/rw24.c
index 0adc60d63f..81467da5a7 100644
--- a/lustre/llite/rw24.c
+++ b/lustre/llite/rw24.c
@@ -131,9 +131,18 @@ out:
         RETURN(rc);
 }
 
-static int ll_direct_IO_24(int rw, struct inode *inode, struct kiobuf *iobuf,
-                           unsigned long blocknr, int blocksize)
+static int ll_direct_IO_24(int rw,
+#ifdef HAVE_DIO_FILE
+                           struct file *file,
+#else
+                           struct inode *inode,
+#endif
+                           struct kiobuf *iobuf, unsigned long blocknr,
+                           int blocksize)
 {
+#ifdef HAVE_DIO_FILE
+        struct inode *inode = file->f_dentry->d_inode;
+#endif
         struct ll_inode_info *lli = ll_i2info(inode);
         struct lov_stripe_md *lsm = lli->lli_smd;
         struct brw_page *pga;
diff --git a/lustre/portals/archdep.m4 b/lustre/portals/archdep.m4
index b67e012941..4c9e5ae248 100644
--- a/lustre/portals/archdep.m4
+++ b/lustre/portals/archdep.m4
@@ -369,3 +369,23 @@ if test $RH_2_4_20 = 1; then
 else
 	AC_MSG_RESULT($LINUXRELEASE)
 fi 
+
+# ---------- Red Hat 2.4.21 backports some more 2.5 bits --------
+
+AC_MSG_CHECKING(if kernel defines PDE)
+HAVE_PDE="`grep -c 'proc_dir_entry..PDE' $LINUX/include/linux/proc_fs.h`"
+if test "$HAVE_PDE" != 0 ; then
+  CPPFLAGS="$CPPFLAGS -DHAVE_PDE"
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_RESULT(no)
+fi
+
+AC_MSG_CHECKING(if kernel passes struct file to direct_IO)
+HAVE_DIO_FILE="`grep -c 'direct_IO.*struct file' $LINUX/include/linux/fs.h`"
+if test "$HAVE_DIO_FILE" != 0 ; then
+  CPPFLAGS="$CPPFLAGS -DHAVE_DIO_FILE"
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_RESULT(no)
+fi
-- 
GitLab