diff options
Diffstat (limited to 'sys-cluster/lustre/files/2.4/0002-LU-1337-vfs-kernel-3.1-kills-inode-i_alloc_sem.patch')
-rw-r--r-- | sys-cluster/lustre/files/2.4/0002-LU-1337-vfs-kernel-3.1-kills-inode-i_alloc_sem.patch | 242 |
1 files changed, 242 insertions, 0 deletions
diff --git a/sys-cluster/lustre/files/2.4/0002-LU-1337-vfs-kernel-3.1-kills-inode-i_alloc_sem.patch b/sys-cluster/lustre/files/2.4/0002-LU-1337-vfs-kernel-3.1-kills-inode-i_alloc_sem.patch new file mode 100644 index 000000000..f1a28efbc --- /dev/null +++ b/sys-cluster/lustre/files/2.4/0002-LU-1337-vfs-kernel-3.1-kills-inode-i_alloc_sem.patch @@ -0,0 +1,242 @@ +From 47cc42154f7c0159d28dddc7cbe983056f5668a5 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/osc/osc_cache.c | 6 +++--- + lustre/osd-ldiskfs/osd_io.c | 1 - + 7 files changed, 49 insertions(+), 30 deletions(-) + +diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 +index 3762784..ec3723e 100644 +--- a/lustre/autoconf/lustre-core.m4 ++++ b/lustre/autoconf/lustre-core.m4 +@@ -1834,6 +1834,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], +@@ -2018,6 +2039,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 6b8d155..0d2a3eb 100644 +--- a/lustre/include/linux/lustre_compat25.h ++++ b/lustre/include/linux/lustre_compat25.h +@@ -247,13 +247,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 9769ec3..f2dcc92 100644 +--- a/lustre/llite/llite_lib.c ++++ b/lustre/llite/llite_lib.c +@@ -1451,12 +1451,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 c8f041e..158c15c 100644 +--- a/lustre/llite/vvp_io.c ++++ b/lustre/llite/vvp_io.c +@@ -294,7 +294,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; + } +@@ -347,7 +347,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; + } + +@@ -419,7 +419,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); +@@ -688,28 +688,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 +@@ -757,7 +755,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) +@@ -776,8 +773,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 c07cb29..711d2cc 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/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 ef045a5..db0999a 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 + |