diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4
index 5f789c1872a781cc6ac77e178c18cf853bedbd62..37cb83682e3605fb8dd5e5ca85251edcb59f1ded 100644
--- a/lustre/autoconf/lustre-core.m4
+++ b/lustre/autoconf/lustre-core.m4
@@ -1350,6 +1350,7 @@ CFLAGS="$tmp_flags"
 AC_DEFUN([LC_PROG_LINUX],
          [LC_LUSTRE_VERSION_H
          if test x$enable_server = xyes ; then
+             AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server])
              LC_CONFIG_BACKINGFS
          fi
          LC_CONFIG_PINGER
diff --git a/lustre/include/linux/lustre_acl.h b/lustre/include/linux/lustre_acl.h
index bbf6471aca616f489bb486c1131c52950e3a14c4..0583ea48f369f9227f947626b560ad951f1d0c7f 100644
--- a/lustre/include/linux/lustre_acl.h
+++ b/lustre/include/linux/lustre_acl.h
@@ -32,8 +32,10 @@
 #  define MDS_XATTR_NAME_ACL_ACCESS XATTR_NAME_ACL_ACCESS
 #  define mds_xattr_acl_size(entry) xattr_acl_size(entry)
 # else /* HAVE_XATTR_ACL */
-#  define MDS_XATTR_NAME_ACL_ACCESS POSIX_ACL_XATTR_ACCESS
-#  define mds_xattr_acl_size(entry) posix_acl_xattr_size(entry)
+#  ifdef HAVE_LINUX_POSIX_ACL_XATTR_H
+#   define MDS_XATTR_NAME_ACL_ACCESS POSIX_ACL_XATTR_ACCESS
+#   define mds_xattr_acl_size(entry) posix_acl_xattr_size(entry)
+#  endif /* HAVE_LINUX_POSIX_ACL_XATTR_H */
 # endif /* HAVE_XATTR_ACL */
 
 # define LUSTRE_POSIX_ACL_MAX_ENTRIES   (32)
diff --git a/lustre/include/linux/obd.h b/lustre/include/linux/obd.h
index ba0d89e6af4ee33195abb519c1ce5ae76d3807a1..5bc3c4716992e7f31bbc239510b8b451900101b3 100644
--- a/lustre/include/linux/obd.h
+++ b/lustre/include/linux/obd.h
@@ -17,6 +17,9 @@
 # include <linux/smp_lock.h>
 # include <linux/proc_fs.h>
 # include <linux/mount.h>
+# ifndef HAVE_VFS_INTENT_PATCHES
+#  include <linux/lustre_intent.h>
+# endif
 #endif
 
 typedef spinlock_t client_obd_lock_t;
diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h
index 550d5b57b68d89a2356b6b7defff9fb8b60cc3b2..c7869cce37192e25ac0b5e449fba0320e5471614 100644
--- a/lustre/include/linux/obd_class.h
+++ b/lustre/include/linux/obd_class.h
@@ -39,6 +39,33 @@
 #include <linux/timer.h>
 #endif
 
+#ifdef __KERNEL__
+# ifndef HAVE_SERVER_SUPPORT
+
+/* hash info structure used by the directory hash */
+#  define LDISKFS_DX_HASH_LEGACY        0
+#  define LDISKFS_DX_HASH_HALF_MD4      1
+#  define LDISKFS_DX_HASH_TEA           2
+#  define LDISKFS_DX_HASH_R5            3
+#  define LDISKFS_DX_HASH_SAME          4
+#  define LDISKFS_DX_HASH_MAX           4
+
+/* hash info structure used by the directory hash */
+struct ldiskfs_dx_hash_info
+{
+        u32     hash;
+        u32     minor_hash;
+        int     hash_version;
+        u32     *seed;
+};
+
+#  define LDISKFS_HTREE_EOF     0x7fffffff
+
+int ldiskfsfs_dirhash(const char *name, int len, struct ldiskfs_dx_hash_info *hinfo);
+
+# endif /* HAVE_SERVER_SUPPORT */
+#endif /* __KERNEL__ */
+
 void obd_zombie_impexp_init(void);
 void obd_zombie_impexp_cull(void);
 extern void (*obd_zombie_impexp_notify)(void);
diff --git a/lustre/obdclass/hash.c b/lustre/obdclass/hash.c
index 4775939e4eedf0077e5c862dfaa86c11cbbcf4e9..5165e7c6ca2b9f7c5c6c3a3943d83adee4df2884 100644
--- a/lustre/obdclass/hash.c
+++ b/lustre/obdclass/hash.c
@@ -1,6 +1,4 @@
 /*
- *  linux/fs/ldiskfs/hash.c
- *
  * Copyright (C) 2002 by Theodore Ts'o
  *
  * This file is released under the GPL v2.
@@ -9,10 +7,20 @@
  * License.
  */
 
+/*
+ * obdclass/hash.c is copied from ldiskfs/hash.c.
+ * ldiskfs is used by server only.
+ * obdclass is shared by both client and server, it should not depend on ldiskfs.
+ */
+
 #include <linux/fs.h>
 #include <linux/jbd.h>
 #include <linux/sched.h>
-#include <linux/ldiskfs_fs.h>
+#ifdef HAVE_SERVER_SUPPORT
+# include <linux/ldiskfs_fs.h>
+#else
+# include <obd_class.h>
+#endif
 
 #define DELTA 0x9E3779B9
 
diff --git a/lustre/obdclass/mea.c b/lustre/obdclass/mea.c
index 10ab6ca19f14f5739541df7b1b06a994eb6a551a..15f15d895ce2e3059efbde90a34a14e4ae32a3f1 100644
--- a/lustre/obdclass/mea.c
+++ b/lustre/obdclass/mea.c
@@ -20,16 +20,15 @@
  */
 
 #define DEBUG_SUBSYSTEM S_CLASS
+#include <obd_class.h>
 #ifdef __KERNEL__
 #include <linux/kmod.h>   /* for request_module() */
 #include <linux/module.h>
-#include <obd_class.h>
 #include <linux/random.h>
 #include <linux/slab.h>
 #include <linux/pagemap.h>
 #else
 #include <liblustre.h>
-#include <obd_class.h>
 #include <obd.h>
 #endif
 #include <lprocfs_status.h>
@@ -37,9 +36,11 @@
 
 #ifdef __KERNEL__
 #include <linux/jbd.h>
+#ifdef HAVE_SERVER_SUPPORT
 /* LDISKFS_SB() */
 #include <linux/ldiskfs_fs.h>
 #endif
+#endif
 static int mea_last_char_hash(int count, char *name, int namelen)
 {
         unsigned int c;
diff --git a/lustre/tests/statmany.c b/lustre/tests/statmany.c
index 63a13adf77df10fd3fa85db50ba7d834317f9ed5..476aed9c73fc49fb5c050ba0601d12da45aa1e3a 100644
--- a/lustre/tests/statmany.c
+++ b/lustre/tests/statmany.c
@@ -11,9 +11,6 @@
 #include <limits.h>
 #include <sys/ioctl.h>
 
-#if 0
-#include <linux/ldiskfs_fs.h>
-#endif
 #include <liblustre.h>
 #include <lustre_lib.h>
 #include <obd.h>