aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys-cluster/lustre/files/0001-LU-1337-vfs-kernel-3.1-renames-lock-manager-ops.patch190
-rw-r--r--sys-cluster/lustre/files/0002-LU-1337-vfs-kernel-3.1-kills-inode-i_alloc_sem.patch446
-rw-r--r--sys-cluster/lustre/files/0003-LU-1337-vfs-kernel-3.1-changes-open_to_namei_flags.patch95
-rw-r--r--sys-cluster/lustre/files/0004-LU-1337-vfs-provides-ll_get_acl-to-i_op-get_acl.patch150
-rw-r--r--sys-cluster/lustre/files/0005-LU-1337-block-kernel-3.2-make_request_fn-returns-voi.patch108
-rw-r--r--sys-cluster/lustre/files/0006-LU-1337-vfs-kernel-3.2-protects-inode-i_nlink.patch194
-rw-r--r--sys-cluster/lustre/files/0007-LU-1337-vfs-3.3-changes-super_operations-inode_opera.patch217
-rw-r--r--sys-cluster/lustre/files/0008-LU-1337-kernel-remove-unnecessary-includings-of-syst.patch211
-rw-r--r--sys-cluster/lustre/files/0009-LU-1337-vfs-kernel-3.4-touch_atime-switchs-to-1-argu.patch89
-rw-r--r--sys-cluster/lustre/files/0010-LU-1337-vfs-kernel-3.4-converts-d_alloc_root-to-d_ma.patch128
-rw-r--r--sys-cluster/lustre/files/0011-LU-1337-kernel-v3.5-defines-INVALID_UID.patch31
-rw-r--r--sys-cluster/lustre/files/0012-LU-1337-llite-kernel-3.5-renames-end_writeback-to-cl.patch90
-rw-r--r--sys-cluster/lustre/files/0013-LU-1337-kernel-3.5-kernel-encode_fh-passes-in-parent.patch88
-rw-r--r--sys-cluster/lustre/lustre-9999.ebuild72
-rw-r--r--sys-cluster/lustre/metadata.xml11
15 files changed, 2120 insertions, 0 deletions
diff --git a/sys-cluster/lustre/files/0001-LU-1337-vfs-kernel-3.1-renames-lock-manager-ops.patch b/sys-cluster/lustre/files/0001-LU-1337-vfs-kernel-3.1-renames-lock-manager-ops.patch
new file mode 100644
index 000000000..44cc8cec3
--- /dev/null
+++ b/sys-cluster/lustre/files/0001-LU-1337-vfs-kernel-3.1-renames-lock-manager-ops.patch
@@ -0,0 +1,190 @@
+From 0635f4d7cde2da46e05ba6be6d6dd26e72814ff8 Mon Sep 17 00:00:00 2001
+From: Liu Xuezhao <xuezhao.liu@emc.com>
+Date: Thu, 9 Aug 2012 10:37:39 +0800
+Subject: [PATCH 01/13] LU-1337 vfs: kernel 3.1 renames lock-manager ops
+
+Kernel 3.1 renames lock-manager ops(lock_manager_operations) from
+fl_xxx to lm_xxx (commit 8fb47a4fbf858a164e973b8ea8ef5e83e61f2e50).
+
+Add LC_LM_XXX_LOCK_MANAGER_OPS/HAVE_LM_XXX_LOCK_MANAGER_OPS to check.
+
+Re-arrange several macro definitions in lustre-core.m4 as kernel
+version sequence.
+
+Signed-off-by: Liu Xuezhao <xuezhao.liu@emc.com>
+Change-Id: Ic86ec9db2f8262ef7ab9f5f2fb51ca79591120a4
+---
+ lustre/autoconf/lustre-core.m4 | 85 +++++++++++++++++++++-------------
+ lustre/include/linux/lustre_compat25.h | 4 ++
+ lustre/llite/file.c | 18 +++----
+ 3 files changed, 67 insertions(+), 40 deletions(-)
+
+diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4
+index 64c14e5..403add5 100644
+--- a/lustre/autoconf/lustre-core.m4
++++ b/lustre/autoconf/lustre-core.m4
+@@ -1729,6 +1729,18 @@ EXTRA_KCFLAGS="$tmp_flags"
+ ])
+
+ #
++# 2.6.38 export simple_setattr
++#
++AC_DEFUN([LC_EXPORT_SIMPLE_SETATTR],
++[LB_CHECK_SYMBOL_EXPORT([simple_setattr],
++[fs/libfs.c],[
++AC_DEFINE(HAVE_SIMPLE_SETATTR, 1,
++ [simple_setattr is exported by the kernel])
++],[
++])
++])
++
++#
+ # 2.6.39 remove unplug_fn from request_queue.
+ #
+ AC_DEFUN([LC_REQUEST_QUEUE_UNPLUG_FN],
+@@ -1798,14 +1810,42 @@ LB_LINUX_TRY_COMPILE([
+ ])
+
+ #
+-# 2.6.38 export simple_setattr
++# 3.1.1 has ext4_blocks_for_truncate
+ #
+-AC_DEFUN([LC_EXPORT_SIMPLE_SETATTR],
+-[LB_CHECK_SYMBOL_EXPORT([simple_setattr],
+-[fs/libfs.c],[
+-AC_DEFINE(HAVE_SIMPLE_SETATTR, 1,
+- [simple_setattr is exported by the kernel])
++AC_DEFUN([LC_BLOCKS_FOR_TRUNCATE],
++[AC_MSG_CHECKING([if kernel has ext4_blocks_for_truncate])
++LB_LINUX_TRY_COMPILE([
++ #include <linux/fs.h>
++ #include "$LINUX/fs/ext4/ext4_jbd2.h"
++ #include "$LINUX/fs/ext4/truncate.h"
+ ],[
++ ext4_blocks_for_truncate(NULL);
++],[
++ AC_MSG_RESULT([yes])
++ AC_DEFINE(HAVE_BLOCKS_FOR_TRUNCATE, 1,
++ [kernel has ext4_blocks_for_truncate])
++],[
++ AC_MSG_RESULT([no])
++])
++])
++
++#
++# 3.1 renames lock-manager ops(lock_manager_operations) from fl_xxx to lm_xxx
++# see kernel commit 8fb47a4fbf858a164e973b8ea8ef5e83e61f2e50
++#
++AC_DEFUN([LC_LM_XXX_LOCK_MANAGER_OPS],
++[AC_MSG_CHECKING([if lock-manager ops renamed to lm_xxx])
++LB_LINUX_TRY_COMPILE([
++ #include <linux/fs.h>
++],[
++ struct lock_manager_operations lm_ops;
++ lm_ops.lm_compare_owner = NULL;
++],[
++ AC_DEFINE(HAVE_LM_XXX_LOCK_MANAGER_OPS, 1,
++ [lock-manager ops renamed to lm_xxx])
++ AC_MSG_RESULT([yes])
++],[
++ AC_MSG_RESULT([no])
+ ])
+ ])
+
+@@ -1848,26 +1888,6 @@ LB_LINUX_TRY_COMPILE([
+ ])
+
+ #
+-# 3.1.1 has ext4_blocks_for_truncate
+-#
+-AC_DEFUN([LC_BLOCKS_FOR_TRUNCATE],
+-[AC_MSG_CHECKING([if kernel has ext4_blocks_for_truncate])
+-LB_LINUX_TRY_COMPILE([
+- #include <linux/fs.h>
+- #include "$LINUX/fs/ext4/ext4_jbd2.h"
+- #include "$LINUX/fs/ext4/truncate.h"
+-],[
+- ext4_blocks_for_truncate(NULL);
+-],[
+- AC_MSG_RESULT([yes])
+- AC_DEFINE(HAVE_BLOCKS_FOR_TRUNCATE, 1,
+- [kernel has ext4_blocks_for_truncate])
+-],[
+- AC_MSG_RESULT([no])
+-])
+-])
+-
+-#
+ # LC_PROG_LINUX
+ #
+ # Lustre linux kernel checks
+@@ -2008,15 +2028,18 @@ AC_DEFUN([LC_PROG_LINUX],
+
+ # 2.6.39
+ LC_REQUEST_QUEUE_UNPLUG_FN
+- LC_HAVE_FSTYPE_MOUNT
+-
+- # 3.3
+- LC_HAVE_MIGRATE_HEADER
+- LC_MIGRATEPAGE_4ARGS
++ LC_HAVE_FSTYPE_MOUNT
+
+ # 3.1.1
+ LC_BLOCKS_FOR_TRUNCATE
+
++ # 3.1
++ LC_LM_XXX_LOCK_MANAGER_OPS
++
++ # 3.3
++ LC_HAVE_MIGRATE_HEADER
++ LC_MIGRATEPAGE_4ARGS
++
+ #
+ if test x$enable_server = xyes ; then
+ AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server])
+diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h
+index 172da72..41b4516 100644
+--- a/lustre/include/linux/lustre_compat25.h
++++ b/lustre/include/linux/lustre_compat25.h
+@@ -808,5 +808,9 @@ static inline bool selinux_is_enabled(void)
+ }
+ #endif
+
++#ifndef HAVE_LM_XXX_LOCK_MANAGER_OPS
++# define lm_compare_owner fl_compare_owner
++#endif
++
+ #endif /* __KERNEL__ */
+ #endif /* _COMPAT25_H */
+diff --git a/lustre/llite/file.c b/lustre/llite/file.c
+index 96379d6..1525b07 100644
+--- a/lustre/llite/file.c
++++ b/lustre/llite/file.c
+@@ -2150,15 +2150,15 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
+ }
+ flock.l_flock.pid = file_lock->fl_pid;
+
+- /* Somewhat ugly workaround for svc lockd.
+- * lockd installs custom fl_lmops->fl_compare_owner that checks
+- * for the fl_owner to be the same (which it always is on local node
+- * I guess between lockd processes) and then compares pid.
+- * As such we assign pid to the owner field to make it all work,
+- * conflict with normal locks is unlikely since pid space and
+- * pointer space for current->files are not intersecting */
+- if (file_lock->fl_lmops && file_lock->fl_lmops->fl_compare_owner)
+- flock.l_flock.owner = (unsigned long)file_lock->fl_pid;
++ /* Somewhat ugly workaround for svc lockd.
++ * lockd installs custom fl_lmops->lm_compare_owner that checks
++ * for the fl_owner to be the same (which it always is on local node
++ * I guess between lockd processes) and then compares pid.
++ * As such we assign pid to the owner field to make it all work,
++ * conflict with normal locks is unlikely since pid space and
++ * pointer space for current->files are not intersecting */
++ if (file_lock->fl_lmops && file_lock->fl_lmops->lm_compare_owner)
++ flock.l_flock.owner = (unsigned long)file_lock->fl_pid;
+
+ switch (file_lock->fl_type) {
+ case F_RDLCK:
+--
+1.7.12
+
diff --git a/sys-cluster/lustre/files/0002-LU-1337-vfs-kernel-3.1-kills-inode-i_alloc_sem.patch b/sys-cluster/lustre/files/0002-LU-1337-vfs-kernel-3.1-kills-inode-i_alloc_sem.patch
new file mode 100644
index 000000000..04ccefe11
--- /dev/null
+++ b/sys-cluster/lustre/files/0002-LU-1337-vfs-kernel-3.1-kills-inode-i_alloc_sem.patch
@@ -0,0 +1,446 @@
+From 13a22da522d306d69511e439406d2f986a596adb Mon Sep 17 00:00:00 2001
+From: Liu Xuezhao <xuezhao.liu@emc.com>
+Date: Sun, 22 Jul 2012 01:07:18 +0800
+Subject: [PATCH 02/13] LU-1337 vfs: kernel 3.1 kills inode->i_alloc_sem
+
+Kernel 3.1 kills inode->i_alloc_sem, use i_dio_count and
+inode_dio_wait/inode_dio_done instead.
+(kernel commit bd5fe6c5eb9c548d7f07fe8f89a150bb6705e8e3).
+
+Add HAVE_INODE_DIO_WAIT to differentiate it.
+Add INODE_DIO_LOCK_WRITE/INODE_DIO_RELEASE_WRITE,
+ INODE_DIO_LOCK_READ/INODE_DIO_RELEASE_READ macros.
+
+Signed-off-by: Liu Xuezhao <xuezhao.liu@emc.com>
+Change-Id: Ife36e07a85c76153985a4a86ee1973262c4c0e27
+---
+ lustre/autoconf/lustre-core.m4 | 22 ++++++++++++
+ lustre/include/linux/lustre_compat25.h | 18 ++++++----
+ lustre/llite/llite_lib.c | 4 +--
+ lustre/llite/vvp_io.c | 27 ++++++--------
+ lustre/llite/vvp_page.c | 1 -
+ lustre/obdfilter/filter.c | 65 +++++++++++++++++-----------------
+ lustre/obdfilter/filter_io.c | 28 ++++++++-------
+ lustre/obdfilter/filter_io_26.c | 10 +++---
+ lustre/osc/osc_cache.c | 6 ++--
+ lustre/osd-ldiskfs/osd_io.c | 1 -
+ 10 files changed, 102 insertions(+), 80 deletions(-)
+
+diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4
+index 403add5..0aef14f 100644
+--- a/lustre/autoconf/lustre-core.m4
++++ b/lustre/autoconf/lustre-core.m4
+@@ -1850,6 +1850,27 @@ LB_LINUX_TRY_COMPILE([
+ ])
+
+ #
++# 3.1 kills inode->i_alloc_sem, use i_dio_count and inode_dio_wait/
++# inode_dio_done instead.
++# see kernel commit bd5fe6c5eb9c548d7f07fe8f89a150bb6705e8e3
++#
++AC_DEFUN([LC_INODE_DIO_WAIT],
++[AC_MSG_CHECKING([if inode->i_alloc_sem is killed and use inode_dio_wait/done.])
++LB_LINUX_TRY_COMPILE([
++ #include <linux/fs.h>
++],[
++ inode_dio_wait((struct inode *)0);
++ inode_dio_done((struct inode *)0);
++],[
++ AC_DEFINE(HAVE_INODE_DIO_WAIT, 1,
++ [inode->i_alloc_sem is killed and use inode_dio_wait/done])
++ AC_MSG_RESULT([yes])
++],[
++ AC_MSG_RESULT([no])
++])
++])
++
++#
+ # 3.3 introduces migrate_mode.h and migratepage has 4 args
+ #
+ AC_DEFUN([LC_HAVE_MIGRATE_HEADER],
+@@ -2035,6 +2056,7 @@ AC_DEFUN([LC_PROG_LINUX],
+
+ # 3.1
+ LC_LM_XXX_LOCK_MANAGER_OPS
++ LC_INODE_DIO_WAIT
+
+ # 3.3
+ LC_HAVE_MIGRATE_HEADER
+diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h
+index 41b4516..bb45125 100644
+--- a/lustre/include/linux/lustre_compat25.h
++++ b/lustre/include/linux/lustre_compat25.h
+@@ -269,13 +269,17 @@ static inline int mapping_has_pages(struct address_space *mapping)
+ (type *)( (char *)__mptr - offsetof(type,member) );})
+ #endif
+
+-#define UP_WRITE_I_ALLOC_SEM(i) up_write(&(i)->i_alloc_sem)
+-#define DOWN_WRITE_I_ALLOC_SEM(i) down_write(&(i)->i_alloc_sem)
+-#define LASSERT_I_ALLOC_SEM_WRITE_LOCKED(i) LASSERT(down_read_trylock(&(i)->i_alloc_sem) == 0)
+-
+-#define UP_READ_I_ALLOC_SEM(i) up_read(&(i)->i_alloc_sem)
+-#define DOWN_READ_I_ALLOC_SEM(i) down_read(&(i)->i_alloc_sem)
+-#define LASSERT_I_ALLOC_SEM_READ_LOCKED(i) LASSERT(down_write_trylock(&(i)->i_alloc_sem) == 0)
++#ifdef HAVE_INODE_DIO_WAIT
++# define INODE_DIO_LOCK_WRITE(i) inode_dio_wait(i)
++# define INODE_DIO_RELEASE_WRITE(i) do {} while (0)
++# define INODE_DIO_LOCK_READ(i) atomic_inc(&(i)->i_dio_count)
++# define INODE_DIO_RELEASE_READ(i) inode_dio_done(i)
++#else
++# define INODE_DIO_LOCK_WRITE(i) down_write(&(i)->i_alloc_sem)
++# define INODE_DIO_RELEASE_WRITE(i) up_write(&(i)->i_alloc_sem)
++# define INODE_DIO_LOCK_READ(i) down_read(&(i)->i_alloc_sem)
++# define INODE_DIO_RELEASE_READ(i) up_read(&(i)->i_alloc_sem)
++#endif
+
+ #include <linux/mpage.h> /* for generic_writepages */
+
+diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c
+index 9980c2c..7f3ac28 100644
+--- a/lustre/llite/llite_lib.c
++++ b/lustre/llite/llite_lib.c
+@@ -1439,12 +1439,12 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr)
+
+ if (!S_ISDIR(inode->i_mode)) {
+ if (ia_valid & ATTR_SIZE)
+- UP_WRITE_I_ALLOC_SEM(inode);
++ INODE_DIO_RELEASE_WRITE(inode);
+ mutex_unlock(&inode->i_mutex);
+ cfs_down_write(&lli->lli_trunc_sem);
+ mutex_lock(&inode->i_mutex);
+ if (ia_valid & ATTR_SIZE)
+- DOWN_WRITE_I_ALLOC_SEM(inode);
++ INODE_DIO_LOCK_WRITE(inode);
+ }
+
+ /* We need a steady stripe configuration for setattr to avoid
+diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c
+index 50a19c9..0b4cfb5 100644
+--- a/lustre/llite/vvp_io.c
++++ b/lustre/llite/vvp_io.c
+@@ -295,7 +295,7 @@ static int vvp_io_setattr_iter_init(const struct lu_env *env,
+ */
+ mutex_unlock(&inode->i_mutex);
+ if (cl_io_is_trunc(ios->cis_io))
+- UP_WRITE_I_ALLOC_SEM(inode);
++ INODE_DIO_RELEASE_WRITE(inode);
+ cio->u.setattr.cui_locks_released = 1;
+ return 0;
+ }
+@@ -348,7 +348,7 @@ static int vvp_io_setattr_trunc(const struct lu_env *env,
+ const struct cl_io_slice *ios,
+ struct inode *inode, loff_t size)
+ {
+- DOWN_WRITE_I_ALLOC_SEM(inode);
++ INODE_DIO_LOCK_WRITE(inode);
+ return 0;
+ }
+
+@@ -420,7 +420,7 @@ static void vvp_io_setattr_fini(const struct lu_env *env,
+ if (cio->u.setattr.cui_locks_released) {
+ mutex_lock(&inode->i_mutex);
+ if (cl_io_is_trunc(io))
+- DOWN_WRITE_I_ALLOC_SEM(inode);
++ INODE_DIO_LOCK_WRITE(inode);
+ cio->u.setattr.cui_locks_released = 0;
+ }
+ vvp_io_fini(env, ios);
+@@ -689,28 +689,26 @@ static int vvp_io_fault_start(const struct lu_env *env,
+
+ /* must return locked page */
+ if (fio->ft_mkwrite) {
+- /* we grab alloc_sem to exclude truncate case.
+- * Otherwise, we could add dirty pages into osc cache
+- * while truncate is on-going. */
+- DOWN_READ_I_ALLOC_SEM(inode);
+-
+- LASSERT(cfio->ft_vmpage != NULL);
+- lock_page(cfio->ft_vmpage);
++ LASSERT(cfio->ft_vmpage != NULL);
++ lock_page(cfio->ft_vmpage);
+ } else {
+ result = vvp_io_kernel_fault(cfio);
+ if (result != 0)
+ return result;
+ }
+
+- vmpage = cfio->ft_vmpage;
+- LASSERT(PageLocked(vmpage));
++ vmpage = cfio->ft_vmpage;
++ LASSERT(PageLocked(vmpage));
+
+ if (OBD_FAIL_CHECK(OBD_FAIL_LLITE_FAULT_TRUNC_RACE))
+ ll_invalidate_page(vmpage);
+
++
++ size = i_size_read(inode);
+ /* Though we have already held a cl_lock upon this page, but
+ * it still can be truncated locally. */
+- if (unlikely(vmpage->mapping == NULL)) {
++ if (unlikely((vmpage->mapping != inode->i_mapping) ||
++ (page_offset(vmpage) > size))) {
+ CDEBUG(D_PAGE, "llite: fault and truncate race happened!\n");
+
+ /* return +1 to stop cl_io_loop() and ll_fault() will catch
+@@ -758,7 +756,6 @@ static int vvp_io_fault_start(const struct lu_env *env,
+ }
+ }
+
+- size = i_size_read(inode);
+ last = cl_index(obj, size - 1);
+ LASSERT(fio->ft_index <= last);
+ if (fio->ft_index == last)
+@@ -777,8 +774,6 @@ out:
+ /* return unlocked vmpage to avoid deadlocking */
+ if (vmpage != NULL)
+ unlock_page(vmpage);
+- if (fio->ft_mkwrite)
+- UP_READ_I_ALLOC_SEM(inode);
+ #ifdef HAVE_VM_OP_FAULT
+ cfio->fault.ft_flags &= ~VM_FAULT_LOCKED;
+ #endif
+diff --git a/lustre/llite/vvp_page.c b/lustre/llite/vvp_page.c
+index b428744..66842a0 100644
+--- a/lustre/llite/vvp_page.c
++++ b/lustre/llite/vvp_page.c
+@@ -420,7 +420,6 @@ static void vvp_transient_page_verify(const struct cl_page *page)
+ struct inode *inode = ccc_object_inode(page->cp_obj);
+
+ LASSERT(!mutex_trylock(&inode->i_mutex));
+- /* LASSERT_SEM_LOCKED(&inode->i_alloc_sem); */
+ }
+
+ static int vvp_transient_page_own(const struct lu_env *env,
+diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c
+index 23a992e..a93501d 100644
+--- a/lustre/obdfilter/filter.c
++++ b/lustre/obdfilter/filter.c
+@@ -3343,13 +3343,13 @@ int filter_setattr_internal(struct obd_export *exp, struct dentry *dentry,
+ }
+ if (ia_valid & (ATTR_SIZE | ATTR_UID | ATTR_GID)) {
+ unsigned long now = jiffies;
+- /* Filter truncates and writes are serialized by
+- * i_alloc_sem, see the comment in
+- * filter_preprw_write.*/
+- if (ia_valid & ATTR_SIZE)
+- down_write(&inode->i_alloc_sem);
++ /* Filter truncates and writes are serialized.
++ * See the comment in filter_preprw_write.*/
+ mutex_lock(&inode->i_mutex);
+- fsfilt_check_slow(exp->exp_obd, now, "i_alloc_sem and i_mutex");
++ if (ia_valid & ATTR_SIZE)
++ INODE_DIO_LOCK_WRITE(inode);
++ fsfilt_check_slow(exp->exp_obd, now,
++ "i_mutex and INODE_DIO_LOCK_WRITE");
+ old_size = i_size_read(inode);
+ }
+
+@@ -3473,7 +3473,7 @@ out_unlock:
+ if (ia_valid & (ATTR_SIZE | ATTR_UID | ATTR_GID))
+ mutex_unlock(&inode->i_mutex);
+ if (ia_valid & ATTR_SIZE)
+- up_write(&inode->i_alloc_sem);
++ INODE_DIO_RELEASE_WRITE(inode);
+ if (fcc)
+ OBD_FREE(fcc, sizeof(*fcc));
+
+@@ -3554,14 +3554,14 @@ int filter_setattr(const struct lu_env *env, struct obd_export *exp,
+ */
+ if (oa->o_valid &
+ (OBD_MD_FLMTIME | OBD_MD_FLATIME | OBD_MD_FLCTIME)) {
+- unsigned long now = jiffies;
+- down_write(&dentry->d_inode->i_alloc_sem);
+- fsfilt_check_slow(exp->exp_obd, now, "i_alloc_sem");
+- fmd = filter_fmd_get(exp, oa->o_id, oa->o_seq);
+- if (fmd && fmd->fmd_mactime_xid < oti->oti_xid)
+- fmd->fmd_mactime_xid = oti->oti_xid;
+- filter_fmd_put(exp, fmd);
+- up_write(&dentry->d_inode->i_alloc_sem);
++ unsigned long now = jiffies;
++ INODE_DIO_LOCK_WRITE(dentry->d_inode);
++ fsfilt_check_slow(exp->exp_obd, now, "INODE_DIO_LOCK_WRITE");
++ fmd = filter_fmd_get(exp, oa->o_id, oa->o_seq);
++ if (fmd && fmd->fmd_mactime_xid < oti->oti_xid)
++ fmd->fmd_mactime_xid = oti->oti_xid;
++ filter_fmd_put(exp, fmd);
++ INODE_DIO_RELEASE_WRITE(dentry->d_inode);
+ }
+
+ /* setting objects attributes (including owner/group) */
+@@ -4292,28 +4292,29 @@ int filter_destroy(const struct lu_env *env, struct obd_export *exp,
+ *fcc = oa->o_lcookie;
+ }
+
+- /* we're gonna truncate it first in order to avoid possible deadlock:
+- * P1 P2
+- * open trasaction open transaction
+- * down(i_zombie) down(i_zombie)
+- * restart transaction
+- * (see BUG 4180) -bzzz
+- *
+- * take i_alloc_sem too to prevent other threads from writing to the
+- * file while we are truncating it. This can cause lock ordering issue
+- * between page lock, i_mutex & starting new journal handle.
+- * (see bug 20321) -johann
+- */
++ /* we're gonna truncate it first in order to avoid possible deadlock:
++ * P1 P2
++ * open trasaction open transaction
++ * down(i_zombie) down(i_zombie)
++ * restart transaction
++ * (see BUG 4180) -bzzz
++ *
++ * INODE_DIO_LOCK_WRITE too to prevent other threads from writing to the
++ * file while we are truncating it. This can cause lock ordering issue
++ * between page lock, i_mutex & starting new journal handle.
++ * (see bug 20321) -johann
++ */
+ now = jiffies;
+- down_write(&dchild->d_inode->i_alloc_sem);
++ INODE_DIO_LOCK_WRITE(dchild->d_inode);
+ mutex_lock(&dchild->d_inode->i_mutex);
+- fsfilt_check_slow(exp->exp_obd, now, "i_alloc_sem and i_mutex");
++ fsfilt_check_slow(exp->exp_obd, now,
++ "INODE_DIO_LOCK_WRITE and i_mutex");
+
+ /* VBR: version recovery check */
+ rc = filter_version_get_check(exp, oti, dchild->d_inode);
+ if (rc) {
+ mutex_unlock(&dchild->d_inode->i_mutex);
+- up_write(&dchild->d_inode->i_alloc_sem);
++ INODE_DIO_RELEASE_WRITE(dchild->d_inode);
+ GOTO(cleanup, rc);
+ }
+
+@@ -4321,7 +4322,7 @@ int filter_destroy(const struct lu_env *env, struct obd_export *exp,
+ NULL, 1);
+ if (IS_ERR(handle)) {
+ mutex_unlock(&dchild->d_inode->i_mutex);
+- up_write(&dchild->d_inode->i_alloc_sem);
++ INODE_DIO_RELEASE_WRITE(dchild->d_inode);
+ GOTO(cleanup, rc = PTR_ERR(handle));
+ }
+
+@@ -4333,7 +4334,7 @@ int filter_destroy(const struct lu_env *env, struct obd_export *exp,
+ rc = fsfilt_setattr(obd, dchild, handle, &iattr, 1);
+ rc2 = fsfilt_commit(obd, dchild->d_inode, handle, 0);
+ mutex_unlock(&dchild->d_inode->i_mutex);
+- up_write(&dchild->d_inode->i_alloc_sem);
++ INODE_DIO_RELEASE_WRITE(dchild->d_inode);
+ if (rc)
+ GOTO(cleanup, rc);
+ if (rc2)
+diff --git a/lustre/obdfilter/filter_io.c b/lustre/obdfilter/filter_io.c
+index a946d90..3c4dcad 100644
+--- a/lustre/obdfilter/filter_io.c
++++ b/lustre/obdfilter/filter_io.c
+@@ -634,7 +634,8 @@ static int filter_grant_check(struct obd_export *exp, struct obdo *oa,
+ * on mulitple inodes. That isn't all, because there still exists the
+ * possibility of a truncate starting a new transaction while holding the ext3
+ * rwsem = write while some writes (which have started their transactions here)
+- * blocking on the ext3 rwsem = read => lock inversion.
++ * blocking on the ext3 rwsem = read => lock inversion. (kernel 3.1 kills the
++ * rwsem and replaces it by i_dio_count and inode_dio_wait/done.)
+ *
+ * The handling gets very ugly when dealing with locked pages. It may be easier
+ * to just get rid of the locked page code (which has problems of its own) and
+@@ -730,14 +731,15 @@ static int filter_preprw_write(int cmd, struct obd_export *exp, struct obdo *oa,
+
+ fsfilt_check_slow(obd, now, "preprw_write setup");
+
+- /* Filter truncate first locks i_mutex then partially truncated
+- * page, filter write code first locks pages then take
+- * i_mutex. To avoid a deadlock in case of concurrent
+- * punch/write requests from one client, filter writes and
+- * filter truncates are serialized by i_alloc_sem, allowing
+- * multiple writes or single truncate. */
+- down_read(&dentry->d_inode->i_alloc_sem);
+- fsfilt_check_slow(obd, now, "i_alloc_sem");
++ /* Filter truncate first locks i_mutex then partially truncated
++ * page, filter write code first locks pages then take
++ * i_mutex. To avoid a deadlock in case of concurrent
++ * punch/write requests from one client, filter writes and
++ * filter truncates are serialized by INODE_DIO_LOCK_READ, allowing
++ * multiple writes or single truncate. */
++
++ INODE_DIO_LOCK_READ(dentry->d_inode);
++ fsfilt_check_slow(obd, now, "INODE_DIO_LOCK_READ");
+
+ /* Don't update inode timestamps if this write is older than a
+ * setattr which modifies the timestamps. b=10150 */
+@@ -895,11 +897,11 @@ cleanup:
+ }
+ }
+ }
+- case 3:
+- if (rc)
+- up_read(&dentry->d_inode->i_alloc_sem);
++ case 3:
++ if (rc)
++ INODE_DIO_RELEASE_READ(dentry->d_inode);
+
+- filter_iobuf_put(&obd->u.filter, iobuf, oti);
++ filter_iobuf_put(&obd->u.filter, iobuf, oti);
+ case 2:
+ pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+ if (rc)
+diff --git a/lustre/obdfilter/filter_io_26.c b/lustre/obdfilter/filter_io_26.c
+index 853e4f5..6d2b89f 100644
+--- a/lustre/obdfilter/filter_io_26.c
++++ b/lustre/obdfilter/filter_io_26.c
+@@ -635,10 +635,10 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa,
+ LASSERT(PageLocked(lnb->page));
+ LASSERT(!PageWriteback(lnb->page));
+
+- /* since write & truncate are serialized by the i_alloc_sem,
+- * even partial truncate should not leave dirty pages in
+- * the page cache */
+- LASSERT(!PageDirty(lnb->page));
++ /* since write & truncate are serialized by the inode_dio_wait,
++ * even partial truncate should not leave dirty pages in
++ * the page cache */
++ LASSERT(!PageDirty(lnb->page));
+
+ SetPageUptodate(lnb->page);
+
+@@ -867,7 +867,7 @@ cleanup:
+ if (fo->fo_writethrough_cache == 0 ||
+ i_size_read(inode) > fo->fo_readcache_max_filesize)
+ filter_release_cache(obd, obj, nb, inode);
+- up_read(&inode->i_alloc_sem);
++ INODE_DIO_RELEASE_READ(inode);
+ }
+
+ RETURN(rc);
+diff --git a/lustre/osc/osc_cache.c b/lustre/osc/osc_cache.c
+index 23dc755..b42e41c 100644
+--- a/lustre/osc/osc_cache.c
++++ b/lustre/osc/osc_cache.c
+@@ -2695,9 +2695,9 @@ void osc_cache_truncate_end(const struct lu_env *env, struct osc_io *oio,
+ * The caller must have called osc_cache_writeback_range() to issue IO
+ * otherwise it will take a long time for this function to finish.
+ *
+- * Caller must hold inode_mutex and i_alloc_sem, or cancel exclusive
+- * dlm lock so that nobody else can dirty this range of file while we're
+- * waiting for extents to be written.
++ * Caller must hold inode_mutex , or cancel exclusive dlm lock so that
++ * nobody else can dirty this range of file while we're waiting for
++ * extents to be written.
+ */
+ int osc_cache_wait_range(const struct lu_env *env, struct osc_object *obj,
+ pgoff_t start, pgoff_t end)
+diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c
+index af3d6af..d266805 100644
+--- a/lustre/osd-ldiskfs/osd_io.c
++++ b/lustre/osd-ldiskfs/osd_io.c
+@@ -433,7 +433,6 @@ struct page *osd_get_page(struct dt_object *dt, loff_t offset, int rw)
+ /*
+ * there are following "locks":
+ * journal_start
+- * i_alloc_sem
+ * i_mutex
+ * page lock
+
+--
+1.7.12
+
diff --git a/sys-cluster/lustre/files/0003-LU-1337-vfs-kernel-3.1-changes-open_to_namei_flags.patch b/sys-cluster/lustre/files/0003-LU-1337-vfs-kernel-3.1-changes-open_to_namei_flags.patch
new file mode 100644
index 000000000..19e29ffb2
--- /dev/null
+++ b/sys-cluster/lustre/files/0003-LU-1337-vfs-kernel-3.1-changes-open_to_namei_flags.patch
@@ -0,0 +1,95 @@
+From 1bece6cbb7d810ef085d00ac4c664bbb37c8bc7b Mon Sep 17 00:00:00 2001
+From: Liu Xuezhao <xuezhao.liu@emc.com>
+Date: Thu, 26 Jul 2012 15:38:30 +0800
+Subject: [PATCH 03/13] LU-1337 vfs: kernel 3.1 changes open_to_namei_flags
+
+Kernel 3.1 changes the translation from open_flag to namei_flag,
+(kernel commit 8a5e929dd2e05ab4d3d89f58c5e8fca596af8f3a).
+
+So after 3.1, kernel's nameidata.intent.open.flags is different
+with lustre's lookup_intent.it_flags, as lustre's it_flags'
+lower bits equal to FMODE_xxx while kernel doesn't transliterate
+lower bits of nameidata.intent.open.flags to FMODE_xxx.
+
+This patch keeps lustre it_flags' semantics and add
+ll_namei_to_lookup_intent_flag for translation.
+
+Signed-off-by: Liu Xuezhao <xuezhao.liu@emc.com>
+Change-Id: I408685040688bae574d04cf288abb6ca967607df
+---
+ lustre/include/linux/lustre_compat25.h | 15 +++++++++++++++
+ lustre/llite/namei.c | 32 ++++++++++++++++----------------
+ 2 files changed, 31 insertions(+), 16 deletions(-)
+
+diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h
+index bb45125..914069a 100644
+--- a/lustre/include/linux/lustre_compat25.h
++++ b/lustre/include/linux/lustre_compat25.h
+@@ -816,5 +816,20 @@ static inline bool selinux_is_enabled(void)
+ # define lm_compare_owner fl_compare_owner
+ #endif
+
++/*
++ * After 3.1, kernel's nameidata.intent.open.flags is different
++ * with lustre's lookup_intent.it_flags, as lustre's it_flags'
++ * lower bits equal to FMODE_xxx while kernel doesn't transliterate
++ * lower bits of nameidata.intent.open.flags to FMODE_xxx.
++ * */
++#include <linux/version.h>
++static inline int ll_namei_to_lookup_intent_flag(int flag)
++{
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0)
++ flag = (flag & ~O_ACCMODE) | OPEN_FMODE(flag);
++#endif
++ return flag;
++}
++
+ #endif /* __KERNEL__ */
+ #endif /* _COMPAT25_H */
+diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c
+index 7521e3d..4cb3bf4 100644
+--- a/lustre/llite/namei.c
++++ b/lustre/llite/namei.c
+@@ -552,23 +552,23 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
+ struct lookup_intent *ll_convert_intent(struct open_intent *oit,
+ int lookup_flags)
+ {
+- struct lookup_intent *it;
+-
+- OBD_ALLOC(it, sizeof(*it));
+- if (!it)
+- return ERR_PTR(-ENOMEM);
+-
+- if (lookup_flags & LOOKUP_OPEN) {
+- it->it_op = IT_OPEN;
+- if (lookup_flags & LOOKUP_CREATE)
+- it->it_op |= IT_CREAT;
+- it->it_create_mode = (oit->create_mode & S_IALLUGO) | S_IFREG;
+- it->it_flags = oit->flags;
+- } else {
+- it->it_op = IT_GETATTR;
+- }
++ struct lookup_intent *it;
++
++ OBD_ALLOC(it, sizeof(*it));
++ if (!it)
++ return ERR_PTR(-ENOMEM);
++
++ if (lookup_flags & LOOKUP_OPEN) {
++ it->it_op = IT_OPEN;
++ if (lookup_flags & LOOKUP_CREATE)
++ it->it_op |= IT_CREAT;
++ it->it_create_mode = (oit->create_mode & S_IALLUGO) | S_IFREG;
++ it->it_flags = ll_namei_to_lookup_intent_flag(oit->flags);
++ } else {
++ it->it_op = IT_GETATTR;
++ }
+
+- return it;
++ return it;
+ }
+
+ static struct dentry *ll_lookup_nd(struct inode *parent, struct dentry *dentry,
+--
+1.7.12
+
diff --git a/sys-cluster/lustre/files/0004-LU-1337-vfs-provides-ll_get_acl-to-i_op-get_acl.patch b/sys-cluster/lustre/files/0004-LU-1337-vfs-provides-ll_get_acl-to-i_op-get_acl.patch
new file mode 100644
index 000000000..deaf4ad54
--- /dev/null
+++ b/sys-cluster/lustre/files/0004-LU-1337-vfs-provides-ll_get_acl-to-i_op-get_acl.patch
@@ -0,0 +1,150 @@
+From 734984d6c88784cde03d17e115dd6478a67daa58 Mon Sep 17 00:00:00 2001
+From: Liu Xuezhao <xuezhao.liu@emc.com>
+Date: Mon, 27 Aug 2012 17:19:22 +0800
+Subject: [PATCH 04/13] LU-1337 vfs: provides ll_get_acl to ->i_op->get_acl
+
+Since kernel 3.1 generic_permission() has lost the check_acl
+argument, ACL checking has been taken to VFS and filesystems
+need to provide a non-NULL ->i_op->get_acl to read an ACL
+from disk.
+
+This patch is a complementarity to http://review.whamcloud.com/3397
+(d018b087c962b8c66e8dc479fc66e964a2e5fd94), to fix failure of test_25
+of sanityn.sh.
+
+Signed-off-by: Liu Xuezhao <xuezhao.liu@emc.com>
+Change-Id: Ica96adac03c1792e2e8b668b959457a4ffec9a43
+---
+ lustre/autoconf/lustre-core.m4 | 3 +++
+ lustre/llite/file.c | 28 +++++++++++++++++++++-------
+ lustre/llite/llite_internal.h | 3 +++
+ lustre/llite/namei.c | 6 ++++++
+ 4 files changed, 33 insertions(+), 7 deletions(-)
+
+diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4
+index 0aef14f..a2d8efc 100644
+--- a/lustre/autoconf/lustre-core.m4
++++ b/lustre/autoconf/lustre-core.m4
+@@ -1783,6 +1783,9 @@ LB_LINUX_TRY_COMPILE([
+ #
+ # 3.1 generic_permission taken 2 parameters.
+ # see kernel commit 2830ba7f34ebb27c4e5b8b6ef408cd6d74860890
++# When generic_permission taken 2 parameters, it also means
++# inode_operations has get_acl member function,
++# see kernel commit 4e34e719e457f2e031297175410fc0bd4016a085
+ #
+ AC_DEFUN([LC_GENERIC_PERMISSION],
+ [AC_MSG_CHECKING([if generic_permission take 2 or 4 arguments])
+diff --git a/lustre/llite/file.c b/lustre/llite/file.c
+index 1525b07..bf9ba2f 100644
+--- a/lustre/llite/file.c
++++ b/lustre/llite/file.c
+@@ -2536,16 +2536,29 @@ int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
+ }
+ #endif
+
++struct posix_acl * ll_get_acl(struct inode *inode, int type)
++{
++ struct ll_inode_info *lli = ll_i2info(inode);
++ struct posix_acl *acl = NULL;
++ ENTRY;
++
++ cfs_spin_lock(&lli->lli_lock);
++ /* VFS' acl_permission_check->check_acl will release the refcount */
++ acl = posix_acl_dup(lli->lli_posix_acl);
++ cfs_spin_unlock(&lli->lli_lock);
++
++ RETURN(acl);
++}
++
+ #ifndef HAVE_GENERIC_PERMISSION_2ARGS
+ static int
+ # ifdef HAVE_GENERIC_PERMISSION_4ARGS
+-lustre_check_acl(struct inode *inode, int mask, unsigned int flags)
++ll_check_acl(struct inode *inode, int mask, unsigned int flags)
+ # else
+-lustre_check_acl(struct inode *inode, int mask)
++ll_check_acl(struct inode *inode, int mask)
+ # endif
+ {
+ # ifdef CONFIG_FS_POSIX_ACL
+- struct ll_inode_info *lli = ll_i2info(inode);
+ struct posix_acl *acl;
+ int rc;
+ ENTRY;
+@@ -2554,9 +2567,7 @@ lustre_check_acl(struct inode *inode, int mask)
+ if (flags & IPERM_FLAG_RCU)
+ return -ECHILD;
+ # endif
+- cfs_spin_lock(&lli->lli_lock);
+- acl = posix_acl_dup(lli->lli_posix_acl);
+- cfs_spin_unlock(&lli->lli_lock);
++ acl = ll_get_acl(inode, ACL_TYPE_ACCESS);
+
+ if (!acl)
+ RETURN(-EAGAIN);
+@@ -2608,7 +2619,7 @@ int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd)
+ return lustre_check_remote_perm(inode, mask);
+
+ ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_INODE_PERM, 1);
+- rc = ll_generic_permission(inode, mask, flags, lustre_check_acl);
++ rc = ll_generic_permission(inode, mask, flags, ll_check_acl);
+
+ RETURN(rc);
+ }
+@@ -2703,6 +2714,9 @@ struct inode_operations ll_file_inode_operations = {
+ #ifdef HAVE_LINUX_FIEMAP_H
+ .fiemap = ll_fiemap,
+ #endif
++#ifdef HAVE_GENERIC_PERMISSION_2ARGS
++ .get_acl = ll_get_acl,
++#endif
+ };
+
+ /* dynamic ioctl number support routins */
+diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h
+index 0c9f6d6..a1c02e5 100644
+--- a/lustre/llite/llite_internal.h
++++ b/lustre/llite/llite_internal.h
+@@ -748,6 +748,8 @@ int ll_getattr_it(struct vfsmount *mnt, struct dentry *de,
+ struct lookup_intent *it, struct kstat *stat);
+ int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat);
+ struct ll_file_data *ll_file_data_get(void);
++struct posix_acl * ll_get_acl(struct inode *inode, int type);
++
+ #ifdef HAVE_GENERIC_PERMISSION_4ARGS
+ int ll_inode_permission(struct inode *inode, int mask, unsigned int flags);
+ #else
+@@ -757,6 +759,7 @@ int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd);
+ int ll_inode_permission(struct inode *inode, int mask);
+ # endif
+ #endif
++
+ int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
+ int flags, struct lov_user_md *lum,
+ int lum_size);
+diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c
+index 4cb3bf4..036674f 100644
+--- a/lustre/llite/namei.c
++++ b/lustre/llite/namei.c
+@@ -1193,6 +1193,9 @@ struct inode_operations ll_dir_inode_operations = {
+ .getxattr = ll_getxattr,
+ .listxattr = ll_listxattr,
+ .removexattr = ll_removexattr,
++#ifdef HAVE_GENERIC_PERMISSION_2ARGS
++ .get_acl = ll_get_acl,
++#endif
+ };
+
+ struct inode_operations ll_special_inode_operations = {
+@@ -1203,4 +1206,7 @@ struct inode_operations ll_special_inode_operations = {
+ .getxattr = ll_getxattr,
+ .listxattr = ll_listxattr,
+ .removexattr = ll_removexattr,
++#ifdef HAVE_GENERIC_PERMISSION_2ARGS
++ .get_acl = ll_get_acl,
++#endif
+ };
+--
+1.7.12
+
diff --git a/sys-cluster/lustre/files/0005-LU-1337-block-kernel-3.2-make_request_fn-returns-voi.patch b/sys-cluster/lustre/files/0005-LU-1337-block-kernel-3.2-make_request_fn-returns-voi.patch
new file mode 100644
index 000000000..3630fc24f
--- /dev/null
+++ b/sys-cluster/lustre/files/0005-LU-1337-block-kernel-3.2-make_request_fn-returns-voi.patch
@@ -0,0 +1,108 @@
+From b489d154ef9a88421939b20b146361122a4704d6 Mon Sep 17 00:00:00 2001
+From: Liu Xuezhao <xuezhao.liu@emc.com>
+Date: Thu, 9 Aug 2012 10:18:32 +0800
+Subject: [PATCH 05/13] LU-1337 block: kernel 3.2 make_request_fn returns void
+
+3.2 request_queue.make_request_fn defined as function returns void.
+(kernel commit 5a7bbad27a410350e64a2d7f5ec18fc73836c14f)
+Add LC_HAVE_VOID_MAKE_REQUEST_FN/HAVE_VOID_MAKE_REQUEST_FN for check.
+
+Signed-off-by: Liu Xuezhao <xuezhao.liu@emc.com>
+Change-Id: I49a27873c1754addc9fef7c5f50cbf84592adf05
+---
+ lustre/autoconf/lustre-core.m4 | 24 ++++++++++++++++++++++++
+ lustre/include/linux/lustre_compat25.h | 8 ++++++++
+ lustre/llite/lloop.c | 9 +++++----
+ 3 files changed, 37 insertions(+), 4 deletions(-)
+
+diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4
+index a2d8efc..420d81e 100644
+--- a/lustre/autoconf/lustre-core.m4
++++ b/lustre/autoconf/lustre-core.m4
+@@ -1874,6 +1874,27 @@ LB_LINUX_TRY_COMPILE([
+ ])
+
+ #
++# 3.2 request_queue.make_request_fn defined as function returns with void
++# see kernel commit 5a7bbad27a410350e64a2d7f5ec18fc73836c14f
++#
++AC_DEFUN([LC_HAVE_VOID_MAKE_REQUEST_FN],
++[AC_MSG_CHECKING([if request_queue.make_request_fn returns void but not int])
++LB_LINUX_TRY_COMPILE([
++ #include <linux/blkdev.h>
++],[
++ int ret;
++ make_request_fn *mrf;
++ ret = mrf(NULL, NULL);
++],[
++ AC_MSG_RESULT([no])
++],[
++ AC_DEFINE(HAVE_VOID_MAKE_REQUEST_FN, 1,
++ [request_queue.make_request_fn returns void but not int])
++ AC_MSG_RESULT([yes])
++])
++])
++
++#
+ # 3.3 introduces migrate_mode.h and migratepage has 4 args
+ #
+ AC_DEFUN([LC_HAVE_MIGRATE_HEADER],
+@@ -2061,6 +2082,9 @@ AC_DEFUN([LC_PROG_LINUX],
+ LC_LM_XXX_LOCK_MANAGER_OPS
+ LC_INODE_DIO_WAIT
+
++ # 3.2
++ LC_HAVE_VOID_MAKE_REQUEST_FN
++
+ # 3.3
+ LC_HAVE_MIGRATE_HEADER
+ LC_MIGRATEPAGE_4ARGS
+diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h
+index 914069a..2d0dd0e 100644
+--- a/lustre/include/linux/lustre_compat25.h
++++ b/lustre/include/linux/lustre_compat25.h
+@@ -831,5 +831,13 @@ static inline int ll_namei_to_lookup_intent_flag(int flag)
+ return flag;
+ }
+
++#ifdef HAVE_VOID_MAKE_REQUEST_FN
++# define ll_mrf_ret void
++# define LL_MRF_RETURN(rc) EXIT
++#else
++# define ll_mrf_ret int
++# define LL_MRF_RETURN(rc) RETURN(rc)
++#endif
++
+ #endif /* __KERNEL__ */
+ #endif /* _COMPAT25_H */
+diff --git a/lustre/llite/lloop.c b/lustre/llite/lloop.c
+index 5f4dec3..59814e6 100644
+--- a/lustre/llite/lloop.c
++++ b/lustre/llite/lloop.c
+@@ -338,7 +338,8 @@ static unsigned int loop_get_bio(struct lloop_device *lo, struct bio **req)
+ return count;
+ }
+
+-static int loop_make_request(struct request_queue *q, struct bio *old_bio)
++static ll_mrf_ret
++loop_make_request(struct request_queue *q, struct bio *old_bio)
+ {
+ struct lloop_device *lo = q->queuedata;
+ int rw = bio_rw(old_bio);
+@@ -366,10 +367,10 @@ static int loop_make_request(struct request_queue *q, struct bio *old_bio)
+ goto err;
+ }
+ loop_add_bio(lo, old_bio);
+- return 0;
++ LL_MRF_RETURN(0);
+ err:
+- cfs_bio_io_error(old_bio, old_bio->bi_size);
+- return 0;
++ cfs_bio_io_error(old_bio, old_bio->bi_size);
++ LL_MRF_RETURN(0);
+ }
+
+ #ifdef HAVE_REQUEST_QUEUE_UNPLUG_FN
+--
+1.7.12
+
diff --git a/sys-cluster/lustre/files/0006-LU-1337-vfs-kernel-3.2-protects-inode-i_nlink.patch b/sys-cluster/lustre/files/0006-LU-1337-vfs-kernel-3.2-protects-inode-i_nlink.patch
new file mode 100644
index 000000000..4866ce2dd
--- /dev/null
+++ b/sys-cluster/lustre/files/0006-LU-1337-vfs-kernel-3.2-protects-inode-i_nlink.patch
@@ -0,0 +1,194 @@
+From 7fefbc7487f55b0edaa7a85f0e5b9fea68d5ff15 Mon Sep 17 00:00:00 2001
+From: Liu Xuezhao <xuezhao.liu@emc.com>
+Date: Thu, 9 Aug 2012 10:31:10 +0800
+Subject: [PATCH 06/13] LU-1337 vfs: kernel 3.2 protects inode->i_nlink
+
+Kernel 3.2 protects inode->i_nlink from direct modification.
+Filesystems may only read i_nlink directly. They shall use the
+(set|clear|inc|drop)_nlink for modification.
+See kernel commit a78ef704a8dd430225955f0709b22d4a6ba21deb.
+
+This patch adds LC_HAVE_PROTECT_I_NLINK checking and implements
+set_nlink for old kernel, clear/inc/drop_nlink exists after 2.6.18
+so need not to be re-implemented.
+
+Signed-off-by: Liu Xuezhao <xuezhao.liu@emc.com>
+Change-Id: Ie958cb308291ecc48d409a1282fed7ea3549a561
+---
+ lustre/autoconf/lustre-core.m4 | 22 ++++++++++++++++++++++
+ lustre/include/linux/lustre_compat25.h | 8 ++++++++
+ lustre/llite/dcache.c | 4 ++--
+ lustre/llite/file.c | 2 +-
+ lustre/llite/llite_lib.c | 4 ++--
+ lustre/osd-ldiskfs/osd_handler.c | 12 ++++++------
+ 6 files changed, 41 insertions(+), 11 deletions(-)
+
+diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4
+index 420d81e..84f1678 100644
+--- a/lustre/autoconf/lustre-core.m4
++++ b/lustre/autoconf/lustre-core.m4
+@@ -1895,6 +1895,27 @@ LB_LINUX_TRY_COMPILE([
+ ])
+
+ #
++# 3.2 protects inode->i_nlink from direct modification
++# see kernel commit a78ef704a8dd430225955f0709b22d4a6ba21deb
++# at the same time, add set_nlink()
++#
++AC_DEFUN([LC_HAVE_PROTECT_I_NLINK],
++[AC_MSG_CHECKING([if inode->i_nlink is protected from direct modification])
++LB_LINUX_TRY_COMPILE([
++ #include <linux/fs.h>
++],[
++ struct inode i;
++ i.i_nlink = 0;
++],[
++ AC_MSG_RESULT([no])
++],[
++ AC_DEFINE(HAVE_PROTECT_I_NLINK, 1,
++ [inode->i_nlink is protected from direct modification])
++ AC_MSG_RESULT([yes])
++])
++])
++
++#
+ # 3.3 introduces migrate_mode.h and migratepage has 4 args
+ #
+ AC_DEFUN([LC_HAVE_MIGRATE_HEADER],
+@@ -2084,6 +2105,7 @@ AC_DEFUN([LC_PROG_LINUX],
+
+ # 3.2
+ LC_HAVE_VOID_MAKE_REQUEST_FN
++ LC_HAVE_PROTECT_I_NLINK
+
+ # 3.3
+ LC_HAVE_MIGRATE_HEADER
+diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h
+index 2d0dd0e..7ead133 100644
+--- a/lustre/include/linux/lustre_compat25.h
++++ b/lustre/include/linux/lustre_compat25.h
+@@ -839,5 +839,13 @@ static inline int ll_namei_to_lookup_intent_flag(int flag)
+ # define LL_MRF_RETURN(rc) RETURN(rc)
+ #endif
+
++#include <linux/fs.h>
++#ifndef HAVE_PROTECT_I_NLINK
++static inline void set_nlink(struct inode *inode, unsigned int nlink)
++{
++ inode->i_nlink = nlink;
++}
++#endif
++
+ #endif /* __KERNEL__ */
+ #endif /* _COMPAT25_H */
+diff --git a/lustre/llite/dcache.c b/lustre/llite/dcache.c
+index 14fb634..b507408 100644
+--- a/lustre/llite/dcache.c
++++ b/lustre/llite/dcache.c
+@@ -187,7 +187,7 @@ static int ll_ddelete(HAVE_D_DELETE_CONST struct dentry *de)
+ /* if not ldlm lock for this inode, set i_nlink to 0 so that
+ * this inode can be recycled later b=20433 */
+ if (de->d_inode && !find_cbdata(de->d_inode))
+- de->d_inode->i_nlink = 0;
++ clear_nlink(de->d_inode);
+ #endif
+
+ if (d_lustre_invalid((struct dentry *)de))
+@@ -687,7 +687,7 @@ void ll_d_iput(struct dentry *de, struct inode *inode)
+ {
+ LASSERT(inode);
+ if (!find_cbdata(inode))
+- inode->i_nlink = 0;
++ clear_nlink(inode);
+ iput(inode);
+ }
+
+diff --git a/lustre/llite/file.c b/lustre/llite/file.c
+index bf9ba2f..8840295 100644
+--- a/lustre/llite/file.c
++++ b/lustre/llite/file.c
+@@ -2315,7 +2315,7 @@ ldlm_mode_t ll_take_md_lock(struct inode *inode, __u64 bits,
+ static int ll_inode_revalidate_fini(struct inode *inode, int rc) {
+ if (rc == -ENOENT) { /* Already unlinked. Just update nlink
+ * and return success */
+- inode->i_nlink = 0;
++ clear_nlink(inode);
+ /* This path cannot be hit for regular files unless in
+ * case of obscure races, so no need to to validate
+ * size. */
+diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c
+index 7f3ac28..07efcfc 100644
+--- a/lustre/llite/llite_lib.c
++++ b/lustre/llite/llite_lib.c
+@@ -1218,7 +1218,7 @@ int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data,
+ if (rc) {
+ ptlrpc_req_finished(request);
+ if (rc == -ENOENT) {
+- inode->i_nlink = 0;
++ clear_nlink(inode);
+ /* Unlinked special device node? Or just a race?
+ * Pretend we done everything. */
+ if (!S_ISREG(inode->i_mode) &&
+@@ -1724,7 +1724,7 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md)
+ if (body->valid & OBD_MD_FLFLAGS)
+ inode->i_flags = ll_ext_to_inode_flags(body->flags);
+ if (body->valid & OBD_MD_FLNLINK)
+- inode->i_nlink = body->nlink;
++ set_nlink(inode, body->nlink);
+ if (body->valid & OBD_MD_FLRDEV)
+ inode->i_rdev = old_decode_dev(body->rdev);
+
+diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c
+index 1c37bd9..ec9dfb6 100644
+--- a/lustre/osd-ldiskfs/osd_handler.c
++++ b/lustre/osd-ldiskfs/osd_handler.c
+@@ -1518,7 +1518,7 @@ static int osd_inode_setattr(const struct lu_env *env,
+ if (bits & LA_GID)
+ inode->i_gid = attr->la_gid;
+ if (bits & LA_NLINK)
+- inode->i_nlink = attr->la_nlink;
++ set_nlink(inode, attr->la_nlink);
+ if (bits & LA_RDEV)
+ inode->i_rdev = attr->la_rdev;
+
+@@ -2076,7 +2076,7 @@ static int osd_object_destroy(const struct lu_env *env,
+ LASSERT(osd_inode_unlinked(inode) ||
+ inode->i_nlink == 1);
+ cfs_spin_lock(&obj->oo_guard);
+- inode->i_nlink = 0;
++ clear_nlink(inode);
+ cfs_spin_unlock(&obj->oo_guard);
+ inode->i_sb->s_op->dirty_inode(inode);
+ } else {
+@@ -2283,11 +2283,11 @@ static int osd_object_ref_add(const struct lu_env *env,
+ * do not actually care whether this flag is set or not.
+ */
+ cfs_spin_lock(&obj->oo_guard);
+- inode->i_nlink++;
++ inc_nlink(inode);
+ if (S_ISDIR(inode->i_mode) && inode->i_nlink > 1) {
+ if (inode->i_nlink >= LDISKFS_LINK_MAX ||
+ inode->i_nlink == 2)
+- inode->i_nlink = 1;
++ set_nlink(inode, 1);
+ }
+ LASSERT(inode->i_nlink <= LDISKFS_LINK_MAX);
+ cfs_spin_unlock(&obj->oo_guard);
+@@ -2333,12 +2333,12 @@ static int osd_object_ref_del(const struct lu_env *env, struct dt_object *dt,
+
+ cfs_spin_lock(&obj->oo_guard);
+ LASSERT(inode->i_nlink > 0);
+- inode->i_nlink--;
++ drop_nlink(inode);
+ /* If this is/was a many-subdir directory (nlink > LDISKFS_LINK_MAX)
+ * then the nlink count is 1. Don't let it be set to 0 or the directory
+ * inode will be deleted incorrectly. */
+ if (S_ISDIR(inode->i_mode) && inode->i_nlink == 0)
+- inode->i_nlink++;
++ inc_nlink(inode);
+ cfs_spin_unlock(&obj->oo_guard);
+ inode->i_sb->s_op->dirty_inode(inode);
+ LINVRNT(osd_invariant(obj));
+--
+1.7.12
+
diff --git a/sys-cluster/lustre/files/0007-LU-1337-vfs-3.3-changes-super_operations-inode_opera.patch b/sys-cluster/lustre/files/0007-LU-1337-vfs-3.3-changes-super_operations-inode_opera.patch
new file mode 100644
index 000000000..43cc7842d
--- /dev/null
+++ b/sys-cluster/lustre/files/0007-LU-1337-vfs-3.3-changes-super_operations-inode_opera.patch
@@ -0,0 +1,217 @@
+From 87c734aec5ec3a73c8eeab425f501568b05874ba Mon Sep 17 00:00:00 2001
+From: Liu Xuezhao <xuezhao.liu@emc.com>
+Date: Thu, 19 Jul 2012 17:43:16 +0800
+Subject: [PATCH 07/13] LU-1337 vfs: 3.3 changes
+ super_operations/inode_operations
+
+1. Kernel 3.3 switchs super_operations to use dentry as parameter
+ (kernel commit 34c80b1d93e6e20ca9dea0baf583a5b5510d92d4).
+ Add LC_SUPEROPS_USE_DENTRY/HAVE_SUPEROPS_USE_DENTRY to check it.
+2. Kernel 3.3 switchs inode_operations to use umode_t as parameter
+ (kernel commit 1a67aafb5f72a436ca044293309fa7e6351d6a35).
+ Add LC_INODEOPS_USE_UMODE_T/HAVE_INODEOPS_USE_UMODE_T to check it.
+
+Signed-off-by: Liu Xuezhao <xuezhao.liu@emc.com>
+Change-Id: I7564506cf4365c8da113a81058f68b9ef8b092a4
+---
+ lustre/autoconf/lustre-core.m4 | 57 ++++++++++++++++++++++++++++++++++
+ lustre/include/linux/lustre_compat25.h | 6 ++++
+ lustre/llite/llite_internal.h | 4 +++
+ lustre/llite/llite_lib.c | 13 ++++++--
+ lustre/llite/namei.c | 13 +++++---
+ 5 files changed, 87 insertions(+), 6 deletions(-)
+
+diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4
+index 84f1678..15f58ab 100644
+--- a/lustre/autoconf/lustre-core.m4
++++ b/lustre/autoconf/lustre-core.m4
+@@ -1954,6 +1954,61 @@ LB_LINUX_TRY_COMPILE([
+ ])
+
+ #
++# 3.3 switchs super_operations to use dentry as parameter (but not vfsmount)
++# see kernel commit 34c80b1d93e6e20ca9dea0baf583a5b5510d92d4
++#
++AC_DEFUN([LC_SUPEROPS_USE_DENTRY],
++[AC_MSG_CHECKING([if super_operations use dentry as parameter])
++tmp_flags="$EXTRA_KCFLAGS"
++EXTRA_KCFLAGS="-Werror"
++LB_LINUX_TRY_COMPILE([
++ #include <linux/fs.h>
++ int show_options(struct seq_file *seq, struct dentry *root){
++ return 0;
++ }
++],[
++ struct super_operations ops;
++ ops.show_options = show_options;
++],[
++ AC_DEFINE(HAVE_SUPEROPS_USE_DENTRY, 1,
++ [super_operations use dentry as parameter])
++ AC_MSG_RESULT([yes])
++],[
++ AC_MSG_RESULT([no])
++])
++EXTRA_KCFLAGS="$tmp_flags"
++])
++
++#
++# 3.3 switchs inode_operations to use umode_t as parameter (but not int)
++# see kernel commit 1a67aafb5f72a436ca044293309fa7e6351d6a35
++#
++AC_DEFUN([LC_INODEOPS_USE_UMODE_T],
++[AC_MSG_CHECKING([if inode_operations use umode_t as parameter])
++tmp_flags="$EXTRA_KCFLAGS"
++EXTRA_KCFLAGS="-Werror"
++LB_LINUX_TRY_COMPILE([
++ #include <linux/fs.h>
++ #include <linux/types.h>
++ int my_mknod(struct inode *dir, struct dentry *dchild,
++ umode_t mode, dev_t dev)
++ {
++ return 0;
++ }
++],[
++ struct inode_operations ops;
++ ops.mknod = my_mknod;
++],[
++ AC_DEFINE(HAVE_INODEOPS_USE_UMODE_T, 1,
++ [inode_operations use umode_t as parameter])
++ AC_MSG_RESULT([yes])
++],[
++ AC_MSG_RESULT([no])
++])
++EXTRA_KCFLAGS="$tmp_flags"
++])
++
++#
+ # LC_PROG_LINUX
+ #
+ # Lustre linux kernel checks
+@@ -2110,6 +2165,8 @@ AC_DEFUN([LC_PROG_LINUX],
+ # 3.3
+ LC_HAVE_MIGRATE_HEADER
+ LC_MIGRATEPAGE_4ARGS
++ LC_SUPEROPS_USE_DENTRY
++ LC_INODEOPS_USE_UMODE_T
+
+ #
+ if test x$enable_server = xyes ; then
+diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h
+index 7ead133..070ad83 100644
+--- a/lustre/include/linux/lustre_compat25.h
++++ b/lustre/include/linux/lustre_compat25.h
+@@ -847,5 +847,11 @@ static inline void set_nlink(struct inode *inode, unsigned int nlink)
+ }
+ #endif
+
++#ifdef HAVE_INODEOPS_USE_UMODE_T
++# define ll_umode_t umode_t
++#else
++# define ll_umode_t int
++#endif
++
+ #endif /* __KERNEL__ */
+ #endif /* _COMPAT25_H */
+diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h
+index a1c02e5..a942134 100644
+--- a/lustre/llite/llite_internal.h
++++ b/lustre/llite/llite_internal.h
+@@ -830,7 +830,11 @@ void ll_umount_begin(struct vfsmount *vfsmnt, int flags);
+ void ll_umount_begin(struct super_block *sb);
+ #endif
+ int ll_remount_fs(struct super_block *sb, int *flags, char *data);
++#ifdef HAVE_SUPEROPS_USE_DENTRY
++int ll_show_options(struct seq_file *seq, struct dentry *dentry);
++#else
+ int ll_show_options(struct seq_file *seq, struct vfsmount *vfs);
++#endif
+ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
+ struct super_block *);
+ void lustre_dump_dentry(struct dentry *, int recur);
+diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c
+index 07efcfc..18246ac 100644
+--- a/lustre/llite/llite_lib.c
++++ b/lustre/llite/llite_lib.c
+@@ -2294,12 +2294,21 @@ void ll_finish_md_op_data(struct md_op_data *op_data)
+ OBD_FREE_PTR(op_data);
+ }
+
++#ifdef HAVE_SUPEROPS_USE_DENTRY
++int ll_show_options(struct seq_file *seq, struct dentry *dentry)
++#else
+ int ll_show_options(struct seq_file *seq, struct vfsmount *vfs)
++#endif
+ {
+ struct ll_sb_info *sbi;
+
+- LASSERT((seq != NULL) && (vfs != NULL));
+- sbi = ll_s2sbi(vfs->mnt_sb);
++#ifdef HAVE_SUPEROPS_USE_DENTRY
++ LASSERT((seq != NULL) && (dentry != NULL));
++ sbi = ll_s2sbi(dentry->d_sb);
++#else
++ LASSERT((seq != NULL) && (vfs != NULL));
++ sbi = ll_s2sbi(vfs->mnt_sb);
++#endif
+
+ if (sbi->ll_flags & LL_SBI_NOLCK)
+ seq_puts(seq, ",nolock");
+diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c
+index 036674f..a439e2f 100644
+--- a/lustre/llite/namei.c
++++ b/lustre/llite/namei.c
+@@ -815,7 +815,7 @@ static int ll_mknod_generic(struct inode *dir, struct qstr *name, int mode,
+ }
+
+ static int ll_create_nd(struct inode *dir, struct dentry *dentry,
+- int mode, struct nameidata *nd)
++ ll_umode_t mode, struct nameidata *nd)
+ {
+ struct lookup_intent *it = ll_d2d(dentry)->lld_it;
+ int rc;
+@@ -1128,8 +1128,8 @@ static int ll_rename_generic(struct inode *src, struct dentry *src_dparent,
+ RETURN(err);
+ }
+
+-static int ll_mknod(struct inode *dir, struct dentry *dchild, int mode,
+- ll_dev_t rdev)
++static int ll_mknod(struct inode *dir, struct dentry *dchild,
++ ll_umode_t mode, ll_dev_t rdev)
+ {
+ return ll_mknod_generic(dir, &dchild->d_name, mode,
+ old_encode_dev(rdev), dchild);
+@@ -1139,25 +1139,30 @@ static int ll_unlink(struct inode * dir, struct dentry *dentry)
+ {
+ return ll_unlink_generic(dir, NULL, dentry, &dentry->d_name);
+ }
+-static int ll_mkdir(struct inode *dir, struct dentry *dentry, int mode)
++
++static int ll_mkdir(struct inode *dir, struct dentry *dentry, ll_umode_t mode)
+ {
+ return ll_mkdir_generic(dir, &dentry->d_name, mode, dentry);
+ }
++
+ static int ll_rmdir(struct inode *dir, struct dentry *dentry)
+ {
+ return ll_rmdir_generic(dir, NULL, dentry, &dentry->d_name);
+ }
++
+ static int ll_symlink(struct inode *dir, struct dentry *dentry,
+ const char *oldname)
+ {
+ return ll_symlink_generic(dir, &dentry->d_name, oldname, dentry);
+ }
++
+ static int ll_link(struct dentry *old_dentry, struct inode *dir,
+ struct dentry *new_dentry)
+ {
+ return ll_link_generic(old_dentry->d_inode, dir, &new_dentry->d_name,
+ new_dentry);
+ }
++
+ static int ll_rename(struct inode *old_dir, struct dentry *old_dentry,
+ struct inode *new_dir, struct dentry *new_dentry)
+ {
+--
+1.7.12
+
diff --git a/sys-cluster/lustre/files/0008-LU-1337-kernel-remove-unnecessary-includings-of-syst.patch b/sys-cluster/lustre/files/0008-LU-1337-kernel-remove-unnecessary-includings-of-syst.patch
new file mode 100644
index 000000000..5b22c94a9
--- /dev/null
+++ b/sys-cluster/lustre/files/0008-LU-1337-kernel-remove-unnecessary-includings-of-syst.patch
@@ -0,0 +1,211 @@
+From 3d5f9b7679cfc5bb0a1c21c232478c17cfeb77e2 Mon Sep 17 00:00:00 2001
+From: Liu Xuezhao <xuezhao.liu@emc.com>
+Date: Mon, 16 Jul 2012 11:08:56 +0800
+Subject: [PATCH 08/13] LU-1337 kernel: remove unnecessary includings of
+ system.h
+
+<asm/system.h> is removed in kernel 3.4, and it is indeed not needed.
+
+Signed-off-by: Liu Xuezhao <xuezhao.liu@emc.com>
+Change-Id: Ic4d0a086656c5dfb05669aae40680b41e8ea00c7
+---
+ libcfs/include/libcfs/linux/kp30.h | 1 -
+ libcfs/libcfs/linux/linux-debug.c | 1 -
+ libcfs/libcfs/linux/linux-proc.c | 1 -
+ lnet/klnds/mxlnd/mxlnd.h | 1 -
+ lnet/klnds/o2iblnd/o2iblnd.h | 1 -
+ lnet/klnds/ptllnd/ptllnd.h | 1 -
+ lnet/klnds/qswlnd/qswlnd.h | 1 -
+ lnet/klnds/ralnd/ralnd.h | 1 -
+ lnet/klnds/socklnd/socklnd_lib-linux.h | 1 -
+ lustre/llite/llite_mmap.c | 1 -
+ lustre/llite/rw.c | 1 -
+ lustre/llite/rw26.c | 1 -
+ lustre/mdt/mdt_identity.c | 1 -
+ lustre/mdt/mdt_idmap.c | 1 -
+ lustre/obdclass/linux/linux-module.c | 1 -
+ 15 files changed, 15 deletions(-)
+
+diff --git a/libcfs/include/libcfs/linux/kp30.h b/libcfs/include/libcfs/linux/kp30.h
+index 2e1ead7..b8c0aff 100644
+--- a/libcfs/include/libcfs/linux/kp30.h
++++ b/libcfs/include/libcfs/linux/kp30.h
+@@ -45,7 +45,6 @@
+ #include <linux/init.h>
+ #include <linux/errno.h>
+ #include <linux/unistd.h>
+-#include <asm/system.h>
+ #include <linux/kmod.h>
+ #include <linux/notifier.h>
+ #include <linux/fs.h>
+diff --git a/libcfs/libcfs/linux/linux-debug.c b/libcfs/libcfs/linux/linux-debug.c
+index 9fc64e6..5ff5771 100644
+--- a/libcfs/libcfs/linux/linux-debug.c
++++ b/libcfs/libcfs/linux/linux-debug.c
+@@ -51,7 +51,6 @@
+ #endif
+ #include <linux/unistd.h>
+ #include <linux/interrupt.h>
+-#include <asm/system.h>
+ #include <asm/uaccess.h>
+ #include <linux/completion.h>
+
+diff --git a/libcfs/libcfs/linux/linux-proc.c b/libcfs/libcfs/linux/linux-proc.c
+index 5294e08..e9c5018 100644
+--- a/libcfs/libcfs/linux/linux-proc.c
++++ b/libcfs/libcfs/linux/linux-proc.c
+@@ -50,7 +50,6 @@
+ #include <net/sock.h>
+ #include <linux/uio.h>
+
+-#include <asm/system.h>
+ #include <asm/uaccess.h>
+
+ #include <linux/fs.h>
+diff --git a/lnet/klnds/mxlnd/mxlnd.h b/lnet/klnds/mxlnd/mxlnd.h
+index 69b2978..fdb0942 100644
+--- a/lnet/klnds/mxlnd/mxlnd.h
++++ b/lnet/klnds/mxlnd/mxlnd.h
+@@ -49,7 +49,6 @@
+ #include <linux/uio.h>
+ #include <linux/fs.h>
+
+-#include <asm/system.h>
+ #include <asm/uaccess.h>
+ #include <asm/io.h>
+
+diff --git a/lnet/klnds/o2iblnd/o2iblnd.h b/lnet/klnds/o2iblnd/o2iblnd.h
+index ce80d76..f3add0b 100644
+--- a/lnet/klnds/o2iblnd/o2iblnd.h
++++ b/lnet/klnds/o2iblnd/o2iblnd.h
+@@ -47,7 +47,6 @@
+ #include <linux/unistd.h>
+ #include <linux/uio.h>
+
+-#include <asm/system.h>
+ #include <asm/uaccess.h>
+ #include <asm/io.h>
+
+diff --git a/lnet/klnds/ptllnd/ptllnd.h b/lnet/klnds/ptllnd/ptllnd.h
+index c51d82d..7862952 100644
+--- a/lnet/klnds/ptllnd/ptllnd.h
++++ b/lnet/klnds/ptllnd/ptllnd.h
+@@ -45,7 +45,6 @@
+ #include <linux/unistd.h>
+ #include <linux/uio.h>
+
+-#include <asm/system.h>
+ #include <asm/uaccess.h>
+ #include <asm/io.h>
+
+diff --git a/lnet/klnds/qswlnd/qswlnd.h b/lnet/klnds/qswlnd/qswlnd.h
+index 33e44b0..14a2845 100644
+--- a/lnet/klnds/qswlnd/qswlnd.h
++++ b/lnet/klnds/qswlnd/qswlnd.h
+@@ -55,7 +55,6 @@
+ #include <net/sock.h>
+ #include <linux/uio.h>
+
+-#include <asm/system.h>
+ #include <asm/uaccess.h>
+
+ #include <linux/fs.h>
+diff --git a/lnet/klnds/ralnd/ralnd.h b/lnet/klnds/ralnd/ralnd.h
+index fbea48d..606e8cd 100644
+--- a/lnet/klnds/ralnd/ralnd.h
++++ b/lnet/klnds/ralnd/ralnd.h
+@@ -45,7 +45,6 @@
+ #include <linux/unistd.h>
+ #include <linux/uio.h>
+
+-#include <asm/system.h>
+ #include <asm/uaccess.h>
+ #include <asm/io.h>
+
+diff --git a/lnet/klnds/socklnd/socklnd_lib-linux.h b/lnet/klnds/socklnd/socklnd_lib-linux.h
+index 2a943c0..41ba9c3 100644
+--- a/lnet/klnds/socklnd/socklnd_lib-linux.h
++++ b/lnet/klnds/socklnd/socklnd_lib-linux.h
+@@ -50,7 +50,6 @@
+ #include <linux/uio.h>
+ #include <linux/if.h>
+
+-#include <asm/system.h>
+ #include <asm/uaccess.h>
+ #include <asm/irq.h>
+
+diff --git a/lustre/llite/llite_mmap.c b/lustre/llite/llite_mmap.c
+index 2549bad..5310b14 100644
+--- a/lustre/llite/llite_mmap.c
++++ b/lustre/llite/llite_mmap.c
+@@ -41,7 +41,6 @@
+ #include <linux/errno.h>
+ #include <linux/unistd.h>
+ #include <linux/version.h>
+-#include <asm/system.h>
+ #include <asm/uaccess.h>
+
+ #include <linux/fs.h>
+diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c
+index 310cf45..76e259d 100644
+--- a/lustre/llite/rw.c
++++ b/lustre/llite/rw.c
+@@ -45,7 +45,6 @@
+ #include <linux/errno.h>
+ #include <linux/unistd.h>
+ #include <linux/version.h>
+-#include <asm/system.h>
+ #include <asm/uaccess.h>
+
+ #include <linux/fs.h>
+diff --git a/lustre/llite/rw26.c b/lustre/llite/rw26.c
+index 917ba3f..83cbe55 100644
+--- a/lustre/llite/rw26.c
++++ b/lustre/llite/rw26.c
+@@ -45,7 +45,6 @@
+ #include <linux/errno.h>
+ #include <linux/unistd.h>
+ #include <linux/version.h>
+-#include <asm/system.h>
+ #include <asm/uaccess.h>
+
+ #ifdef HAVE_MIGRATE_H
+diff --git a/lustre/mdt/mdt_identity.c b/lustre/mdt/mdt_identity.c
+index 23c7ce4..0e2a3e2 100644
+--- a/lustre/mdt/mdt_identity.c
++++ b/lustre/mdt/mdt_identity.c
+@@ -50,7 +50,6 @@
+ #include <linux/errno.h>
+ #include <linux/version.h>
+ #include <linux/unistd.h>
+-#include <asm/system.h>
+ #include <asm/uaccess.h>
+ #include <linux/fs.h>
+ #include <linux/stat.h>
+diff --git a/lustre/mdt/mdt_idmap.c b/lustre/mdt/mdt_idmap.c
+index 2b50225..68f4391 100644
+--- a/lustre/mdt/mdt_idmap.c
++++ b/lustre/mdt/mdt_idmap.c
+@@ -48,7 +48,6 @@
+ #include <linux/errno.h>
+ #include <linux/version.h>
+ #include <linux/unistd.h>
+-#include <asm/system.h>
+ #include <asm/uaccess.h>
+ #include <linux/fs.h>
+ #include <linux/stat.h>
+diff --git a/lustre/obdclass/linux/linux-module.c b/lustre/obdclass/linux/linux-module.c
+index af3fd9a..cae8397 100644
+--- a/lustre/obdclass/linux/linux-module.c
++++ b/lustre/obdclass/linux/linux-module.c
+@@ -62,7 +62,6 @@
+ #include <linux/highmem.h>
+ #include <asm/io.h>
+ #include <asm/ioctls.h>
+-#include <asm/system.h>
+ #include <asm/poll.h>
+ #include <asm/uaccess.h>
+ #include <linux/miscdevice.h>
+--
+1.7.12
+
diff --git a/sys-cluster/lustre/files/0009-LU-1337-vfs-kernel-3.4-touch_atime-switchs-to-1-argu.patch b/sys-cluster/lustre/files/0009-LU-1337-vfs-kernel-3.4-touch_atime-switchs-to-1-argu.patch
new file mode 100644
index 000000000..9e4311797
--- /dev/null
+++ b/sys-cluster/lustre/files/0009-LU-1337-vfs-kernel-3.4-touch_atime-switchs-to-1-argu.patch
@@ -0,0 +1,89 @@
+From 9e6789a41f3b1afd1a8a2575a4abbc49f0b10727 Mon Sep 17 00:00:00 2001
+From: Liu Xuezhao <xuezhao.liu@emc.com>
+Date: Thu, 9 Aug 2012 10:34:49 +0800
+Subject: [PATCH 09/13] LU-1337 vfs: kernel 3.4 touch_atime switchs to 1
+ argument
+
+touch_atime switchs to use 1 argument of struct path since
+kernel 3.4 (commit 68ac1234fb949b66941d94dce4157742799fc581).
+
+Add LC_TOUCH_ATIME_1ARG/HAVE_TOUCH_ATIME_1ARG to check it.
+
+Signed-off-by: Liu Xuezhao <xuezhao.liu@emc.com>
+Change-Id: I1a0478459538376761b96e1dc65328eeeef60d0f
+---
+ lustre/autoconf/lustre-core.m4 | 22 ++++++++++++++++++++++
+ lustre/llite/dir.c | 9 +++++++++
+ 2 files changed, 31 insertions(+)
+
+diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4
+index 15f58ab..3b3115c 100644
+--- a/lustre/autoconf/lustre-core.m4
++++ b/lustre/autoconf/lustre-core.m4
+@@ -2009,6 +2009,25 @@ EXTRA_KCFLAGS="$tmp_flags"
+ ])
+
+ #
++# 3.4 switchs touch_atime to struct path
++# see kernel commit 68ac1234fb949b66941d94dce4157742799fc581
++#
++AC_DEFUN([LC_TOUCH_ATIME_1ARG],
++[AC_MSG_CHECKING([if touch_atime use one argument])
++LB_LINUX_TRY_COMPILE([
++ #include <linux/fs.h>
++],[
++ touch_atime((struct path *)NULL);
++],[
++ AC_DEFINE(HAVE_TOUCH_ATIME_1ARG, 1,
++ [touch_atime use one argument])
++ AC_MSG_RESULT([yes])
++],[
++ AC_MSG_RESULT([no])
++])
++])
++
++#
+ # LC_PROG_LINUX
+ #
+ # Lustre linux kernel checks
+@@ -2168,6 +2187,9 @@ AC_DEFUN([LC_PROG_LINUX],
+ LC_SUPEROPS_USE_DENTRY
+ LC_INODEOPS_USE_UMODE_T
+
++ # 3.4
++ LC_TOUCH_ATIME_1ARG
++
+ #
+ if test x$enable_server = xyes ; then
+ AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server])
+diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c
+index f985625..f418631 100644
+--- a/lustre/llite/dir.c
++++ b/lustre/llite/dir.c
+@@ -500,6 +500,9 @@ int ll_readdir(struct file *filp, void *cookie, filldir_t filldir)
+ int hash64 = sbi->ll_flags & LL_SBI_64BIT_HASH;
+ struct page *page;
+ struct ll_dir_chain chain;
++#ifdef HAVE_TOUCH_ATIME_1ARG
++ struct path path;
++#endif
+ int done;
+ int rc;
+ ENTRY;
+@@ -627,7 +630,13 @@ int ll_readdir(struct file *filp, void *cookie, filldir_t filldir)
+ filp->f_pos = pos;
+ }
+ filp->f_version = inode->i_version;
++#ifdef HAVE_TOUCH_ATIME_1ARG
++ path.mnt = filp->f_vfsmnt;
++ path.dentry = filp->f_dentry;
++ touch_atime(&path);
++#else
+ touch_atime(filp->f_vfsmnt, filp->f_dentry);
++#endif
+
+ ll_dir_chain_fini(&chain);
+
+--
+1.7.12
+
diff --git a/sys-cluster/lustre/files/0010-LU-1337-vfs-kernel-3.4-converts-d_alloc_root-to-d_ma.patch b/sys-cluster/lustre/files/0010-LU-1337-vfs-kernel-3.4-converts-d_alloc_root-to-d_ma.patch
new file mode 100644
index 000000000..6f727170e
--- /dev/null
+++ b/sys-cluster/lustre/files/0010-LU-1337-vfs-kernel-3.4-converts-d_alloc_root-to-d_ma.patch
@@ -0,0 +1,128 @@
+From 9d5b2096640f5a9ed1d9307748cc79a35def59fb Mon Sep 17 00:00:00 2001
+From: Liu Xuezhao <xuezhao.liu@emc.com>
+Date: Mon, 16 Jul 2012 17:05:04 +0800
+Subject: [PATCH 10/13] LU-1337 vfs: kernel 3.4 converts d_alloc_root to
+ d_make_root
+
+kernel 3.4 converts d_alloc_root to d_make_root.
+(kernel commit 32991ab305ace7017c62f8eecbe5eb36dc32e13b)
+
+Add LC_HAVE_D_MAKE_ROOT/HAVE_D_MAKE_ROOT to ckeck it.
+
+Signed-off-by: Liu Xuezhao <xuezhao.liu@emc.com>
+Change-Id: I7ff1f0eff25495b655e650997016377ca0a200aa
+---
+ lustre/autoconf/lustre-core.m4 | 20 ++++++++++++++++++++
+ lustre/include/linux/lustre_compat25.h | 14 ++++++++++++++
+ lustre/llite/llite_lib.c | 7 ++++++-
+ lustre/obdclass/obd_mount.c | 13 ++++++-------
+ 4 files changed, 46 insertions(+), 8 deletions(-)
+
+diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4
+index 3b3115c..bc92b4f 100644
+--- a/lustre/autoconf/lustre-core.m4
++++ b/lustre/autoconf/lustre-core.m4
+@@ -2028,6 +2028,25 @@ LB_LINUX_TRY_COMPILE([
+ ])
+
+ #
++# 3.4 converts d_alloc_root to d_make_root
++# see kernel commit 32991ab305ace7017c62f8eecbe5eb36dc32e13b
++#
++AC_DEFUN([LC_HAVE_D_MAKE_ROOT],
++[AC_MSG_CHECKING([if have d_make_root])
++LB_LINUX_TRY_COMPILE([
++ #include <linux/fs.h>
++],[
++ d_make_root((struct inode *)NULL);
++],[
++ AC_DEFINE(HAVE_D_MAKE_ROOT, 1,
++ [have d_make_root])
++ AC_MSG_RESULT([yes])
++],[
++ AC_MSG_RESULT([no])
++])
++])
++
++#
+ # LC_PROG_LINUX
+ #
+ # Lustre linux kernel checks
+@@ -2189,6 +2208,7 @@ AC_DEFUN([LC_PROG_LINUX],
+
+ # 3.4
+ LC_TOUCH_ATIME_1ARG
++ LC_HAVE_D_MAKE_ROOT
+
+ #
+ if test x$enable_server = xyes ; then
+diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h
+index 070ad83..b1d3056 100644
+--- a/lustre/include/linux/lustre_compat25.h
++++ b/lustre/include/linux/lustre_compat25.h
+@@ -853,5 +853,19 @@ static inline void set_nlink(struct inode *inode, unsigned int nlink)
+ # define ll_umode_t int
+ #endif
+
++#include <linux/dcache.h>
++#ifndef HAVE_D_MAKE_ROOT
++static inline struct dentry *d_make_root(struct inode *root_inode)
++{
++ struct dentry *res;
++
++ res = d_alloc_root(root_inode);
++ if (res == NULL)
++ iput(root_inode);
++
++ return res;
++}
++#endif
++
+ #endif /* __KERNEL__ */
+ #endif /* _COMPAT25_H */
+diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c
+index 18246ac..f125461 100644
+--- a/lustre/llite/llite_lib.c
++++ b/lustre/llite/llite_lib.c
+@@ -539,7 +539,12 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
+ NULL);
+ cl_sb_init(sb);
+
+- sb->s_root = d_alloc_root(root);
++ sb->s_root = d_make_root(root);
++ if (sb->s_root == NULL) {
++ CERROR("Can't make root dentry\n");
++ GOTO(out_lock_cn_cb, err = -ENOMEM);
++ }
++
+ #ifdef HAVE_DCACHE_LOCK
+ sb->s_root->d_op = &ll_d_root_ops;
+ #else
+diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c
+index b2ec636..c2481bf 100644
+--- a/lustre/obdclass/obd_mount.c
++++ b/lustre/obdclass/obd_mount.c
+@@ -1609,14 +1609,13 @@ static int server_fill_super_common(struct super_block *sb)
+ /* apparently we need to be a directory for the mount to finish */
+ root->i_mode = S_IFDIR;
+
+- sb->s_root = d_alloc_root(root);
+- if (!sb->s_root) {
+- CERROR("Can't make root dentry\n");
+- iput(root);
+- RETURN(-EIO);
+- }
++ sb->s_root = d_make_root(root);
++ if (!sb->s_root) {
++ CERROR("Can't make root dentry\n");
++ RETURN(-EIO);
++ }
+
+- RETURN(0);
++ RETURN(0);
+ }
+
+ static int osd_start(struct lustre_sb_info *lsi, unsigned long mflags)
+--
+1.7.12
+
diff --git a/sys-cluster/lustre/files/0011-LU-1337-kernel-v3.5-defines-INVALID_UID.patch b/sys-cluster/lustre/files/0011-LU-1337-kernel-v3.5-defines-INVALID_UID.patch
new file mode 100644
index 000000000..7f20e90b1
--- /dev/null
+++ b/sys-cluster/lustre/files/0011-LU-1337-kernel-v3.5-defines-INVALID_UID.patch
@@ -0,0 +1,31 @@
+From 2c89f077618a5017fb61b57a8d358a5fb9542a5f Mon Sep 17 00:00:00 2001
+From: Peng Tao <tao.peng@emc.com>
+Date: Wed, 22 Aug 2012 16:55:22 +0800
+Subject: [PATCH 11/13] LU-1337 kernel: v3.5 defines INVALID_UID
+
+With kernel commit 7a4e7408, Lustre doesn't need to redefine
+INVALID_UID.
+
+Signed-off-by: Peng Tao <tao.peng@emc.com>
+Change-Id: I96b854cc51db735d8c985528c879fbeb5b049ab9
+---
+ lustre/include/lustre_cfg.h | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/lustre/include/lustre_cfg.h b/lustre/include/lustre_cfg.h
+index 7262be3..9d0fd52 100644
+--- a/lustre/include/lustre_cfg.h
++++ b/lustre/include/lustre_cfg.h
+@@ -286,7 +286,9 @@ static inline int lustre_cfg_sanity_check(void *buf, int len)
+
+ #include <lustre/lustre_user.h>
+
++#ifndef INVALID_UID
+ #define INVALID_UID (-1)
++#endif
+
+ /** @} cfg */
+
+--
+1.7.12
+
diff --git a/sys-cluster/lustre/files/0012-LU-1337-llite-kernel-3.5-renames-end_writeback-to-cl.patch b/sys-cluster/lustre/files/0012-LU-1337-llite-kernel-3.5-renames-end_writeback-to-cl.patch
new file mode 100644
index 000000000..3289fded2
--- /dev/null
+++ b/sys-cluster/lustre/files/0012-LU-1337-llite-kernel-3.5-renames-end_writeback-to-cl.patch
@@ -0,0 +1,90 @@
+From 9e05a2ac1524f4d7d3aa3f5cc6f278ee3e460b17 Mon Sep 17 00:00:00 2001
+From: Peng Tao <tao.peng@emc.com>
+Date: Wed, 22 Aug 2012 17:57:04 +0800
+Subject: [PATCH 12/13] LU-1337 llite: kernel 3.5 renames end_writeback to
+ clear_inode
+
+kernel commit dbd5768f8 renames end_writeback to clear_inode,
+which used to exist for ~2.6.36 kernels.
+
+Signed-off-by: Peng Tao <tao.peng@emc.com>
+Change-Id: I2435e820092085c0fb55539818f4bad9e48ff386
+---
+ lustre/autoconf/lustre-core.m4 | 22 ++++++++++++++++++++++
+ lustre/include/linux/lustre_compat25.h | 3 +++
+ lustre/llite/llite_lib.c | 4 +---
+ 3 files changed, 26 insertions(+), 3 deletions(-)
+
+diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4
+index bc92b4f..3f47dab 100644
+--- a/lustre/autoconf/lustre-core.m4
++++ b/lustre/autoconf/lustre-core.m4
+@@ -2047,6 +2047,25 @@ LB_LINUX_TRY_COMPILE([
+ ])
+
+ #
++# 3.5 renames end_writeback() back to clear_inode()...
++# see kernel commit dbd5768f87ff6fb0a4fe09c4d7b6c4a24de99430
++#
++AC_DEFUN([LC_HAVE_CLEAR_INODE],
++[AC_MSG_CHECKING([if have clear_inode])
++LB_LINUX_TRY_COMPILE([
++ #include <linux/fs.h>
++],[
++ clear_inode((struct inode *)NULL);
++],[
++ AC_DEFINE(HAVE_CLEAR_INODE, 1,
++ [have clear_inode])
++ AC_MSG_RESULT([yes])
++],[
++ AC_MSG_RESULT([no])
++])
++])
++
++#
+ # LC_PROG_LINUX
+ #
+ # Lustre linux kernel checks
+@@ -2210,6 +2229,9 @@ AC_DEFUN([LC_PROG_LINUX],
+ LC_TOUCH_ATIME_1ARG
+ LC_HAVE_D_MAKE_ROOT
+
++ # 3.5
++ LC_HAVE_CLEAR_INODE
++
+ #
+ if test x$enable_server = xyes ; then
+ AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server])
+diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h
+index b1d3056..b2bba25 100644
+--- a/lustre/include/linux/lustre_compat25.h
++++ b/lustre/include/linux/lustre_compat25.h
+@@ -866,6 +866,9 @@ static inline struct dentry *d_make_root(struct inode *root_inode)
+ return res;
+ }
+ #endif
++#ifndef HAVE_CLEAR_INODE
++#define clear_inode(i) end_writeback(i)
++#endif
+
+ #endif /* __KERNEL__ */
+ #endif /* _COMPAT25_H */
+diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c
+index f125461..ccbaad0 100644
+--- a/lustre/llite/llite_lib.c
++++ b/lustre/llite/llite_lib.c
+@@ -1881,10 +1881,8 @@ void ll_delete_inode(struct inode *inode)
+
+ #ifdef HAVE_SBOPS_EVICT_INODE
+ ll_clear_inode(inode);
+- end_writeback(inode);
+-#else
+- clear_inode(inode);
+ #endif
++ clear_inode(inode);
+
+ EXIT;
+ }
+--
+1.7.12
+
diff --git a/sys-cluster/lustre/files/0013-LU-1337-kernel-3.5-kernel-encode_fh-passes-in-parent.patch b/sys-cluster/lustre/files/0013-LU-1337-kernel-3.5-kernel-encode_fh-passes-in-parent.patch
new file mode 100644
index 000000000..28f02823c
--- /dev/null
+++ b/sys-cluster/lustre/files/0013-LU-1337-kernel-3.5-kernel-encode_fh-passes-in-parent.patch
@@ -0,0 +1,88 @@
+From c3b73bfe1e157ec42be9015d231da66808483554 Mon Sep 17 00:00:00 2001
+From: Peng Tao <tao.peng@emc.com>
+Date: Thu, 23 Aug 2012 13:55:46 +0800
+Subject: [PATCH 13/13] LU-1337 kernel: 3.5 kernel encode_fh passes in parent
+ inode
+
+Changed by upsteam commit b0b0382b.
+
+Signed-off-by: Peng Tao <tao.peng@emc.com>
+Change-Id: I6d7223b934bfe4151371744ad72bdab6b170c700
+---
+ lustre/autoconf/lustre-core.m4 | 30 ++++++++++++++++++++++++++++++
+ lustre/llite/llite_nfs.c | 6 ++++++
+ 2 files changed, 36 insertions(+)
+
+diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4
+index 3f47dab..dbf7233 100644
+--- a/lustre/autoconf/lustre-core.m4
++++ b/lustre/autoconf/lustre-core.m4
+@@ -2066,6 +2066,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
+@@ -2231,6 +2260,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 809a564..ba4f9f1 100644
+--- a/lustre/llite/llite_nfs.c
++++ b/lustre/llite/llite_nfs.c
+@@ -173,11 +173,17 @@ 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)
+ {
+ 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;
+
+--
+1.7.12
+
diff --git a/sys-cluster/lustre/lustre-9999.ebuild b/sys-cluster/lustre/lustre-9999.ebuild
new file mode 100644
index 000000000..994a9ce09
--- /dev/null
+++ b/sys-cluster/lustre/lustre-9999.ebuild
@@ -0,0 +1,72 @@
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+EAPI=5_pre1
+
+WANT_AUTOCONF="2.5"
+WANT_AUTOMAKE="1.9"
+
+inherit git-2 autotools linux-mod linux-info toolchain-funcs
+
+DESCRIPTION="Lustre is a parallel distributed file system"
+HOMEPAGE="http://wiki.whamcloud.com/"
+EGIT_REPO_URI="git://git.whamcloud.com/fs/lustre-release.git"
+SRC_URI=""
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS=""
+IUSE="utils"
+
+DEPEND=""
+RDEPEND="${DEPEND}"
+
+BUILD_PARAMS="-C ${KV_DIR} SUBDIRS=${S}"
+
+PATCHES=(
+"${FILESDIR}/0001-LU-1337-vfs-kernel-3.1-renames-lock-manager-ops.patch"
+"${FILESDIR}/0002-LU-1337-vfs-kernel-3.1-kills-inode-i_alloc_sem.patch"
+"${FILESDIR}/0003-LU-1337-vfs-kernel-3.1-changes-open_to_namei_flags.patch"
+"${FILESDIR}/0004-LU-1337-vfs-provides-ll_get_acl-to-i_op-get_acl.patch"
+"${FILESDIR}/0005-LU-1337-block-kernel-3.2-make_request_fn-returns-voi.patch"
+"${FILESDIR}/0006-LU-1337-vfs-kernel-3.2-protects-inode-i_nlink.patch"
+"${FILESDIR}/0007-LU-1337-vfs-3.3-changes-super_operations-inode_opera.patch"
+"${FILESDIR}/0008-LU-1337-kernel-remove-unnecessary-includings-of-syst.patch"
+"${FILESDIR}/0009-LU-1337-vfs-kernel-3.4-touch_atime-switchs-to-1-argu.patch"
+"${FILESDIR}/0010-LU-1337-vfs-kernel-3.4-converts-d_alloc_root-to-d_ma.patch"
+"${FILESDIR}/0011-LU-1337-kernel-v3.5-defines-INVALID_UID.patch"
+"${FILESDIR}/0012-LU-1337-llite-kernel-3.5-renames-end_writeback-to-cl.patch"
+"${FILESDIR}/0013-LU-1337-kernel-3.5-kernel-encode_fh-passes-in-parent.patch"
+)
+
+pkg_setup() {
+ linux-mod_pkg_setup
+ linux-info_pkg_setup
+ ARCH="$(tc-arch-kernel)"
+ ABI="${KERNEL_ABI}"
+}
+
+src_prepare() {
+ epatch ${PATCHES[@]}
+ sh ./autogen.sh
+}
+
+src_configure() {
+ econf \
+ --enable-client \
+ --disable-server \
+ --without-ldiskfs \
+ --disable-ldiskfs-build \
+ --with-linux="${KERNEL_DIR}" \
+ --with-linux-release=${KV_FULL} \
+ $(use_enable utils)
+}
+
+src_compile() {
+ default
+}
+
+src_install() {
+ default
+}
diff --git a/sys-cluster/lustre/metadata.xml b/sys-cluster/lustre/metadata.xml
new file mode 100644
index 000000000..29db6a2a1
--- /dev/null
+++ b/sys-cluster/lustre/metadata.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<herd>cluster</herd>
+<longdescription>
+Lustre is a parallel distributed file system, generally used for large scale cluster computing
+</longdescription>
+<use>
+ <flag name='utils'>Enable lustre utils</flag>
+</use>
+</pkgmetadata>