From fa0fff00272216dd0947e67cfb43f258239b8f27 Mon Sep 17 00:00:00 2001 From: Li Dongyang Date: Mon, 10 Jun 2019 22:55:30 -0700 Subject: [PATCH] LU-11838 llite: address_space ->page_tree renamed ->i_pages kernel 4.17 renamed address_space renamed ->page_tree to ->i_pages, and switched to xa_lock on the radix_tree_root. Linux-commit: b93b016313b3ba8003c3b8bb71f569af91f19fc7 This patch is back-ported from the following one: Lustre-commit: 2d0c621d21be4e67b6075b76017af6e6fcd18c64 Lustre-change: https://review.whamcloud.com/34673 Signed-off-by: Li Dongyang Change-Id: Iadbc5eda884dbe8ad0d694e0f88255bc496dea5b Reviewed-by: Gu Zheng Reviewed-by: James Simmons Reviewed-on: https://review.whamcloud.com/35156 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/autoconf/lustre-core.m4 | 23 +++++++++++++++++++++++ lustre/include/lustre_compat.h | 8 ++++++++ lustre/llite/llite_lib.c | 4 ++-- lustre/mdc/mdc_request.c | 6 +++--- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index d33c284..cad07ff 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -2997,6 +2997,26 @@ bi_bdev, [ ]) # LC_BI_BDEV # +# LC_I_PAGES +# +# kernel 4.17 commit b93b016313b3ba8003c3b8bb71f569af91f19fc7 +# +AC_DEFUN([LC_I_PAGES], [ +LB_CHECK_COMPILE([if struct address_space has i_pages], +i_pages, [ + #include +],[ + struct address_space mapping = {}; + void *i_pages; + + i_pages = &mapping.i_pages; +],[ + AC_DEFINE(HAVE_I_PAGES, 1, + [struct address_space has i_pages]) +]) +]) # LC_I_PAGES + +# # LC_PROG_LINUX # # Lustre linux kernel checks @@ -3238,6 +3258,9 @@ AC_DEFUN([LC_PROG_LINUX], [ LC_PAGEVEC_INIT_ONE_PARAM LC_BI_BDEV + # 4.17 + LC_I_PAGES + # kernel patch to extend integrity interface LC_BIO_INTEGRITY_PREP_FN diff --git a/lustre/include/lustre_compat.h b/lustre/include/lustre_compat.h index b1045002..862c1c7 100644 --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -779,4 +779,12 @@ static inline bool bdev_integrity_enabled(struct block_device *bdev, int rw) #define ll_pagevec_init(pvec, n) pagevec_init(pvec, n) #endif +#ifdef HAVE_I_PAGES +#define page_tree i_pages +#else +#define i_pages tree_lock +#define xa_lock_irq(lockp) spin_lock_irq(lockp) +#define xa_unlock_irq(lockp) spin_unlock_irq(lockp) +#endif + #endif /* _LUSTRE_COMPAT_H */ diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 0fe13af..b80562c 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -2115,9 +2115,9 @@ void ll_delete_inode(struct inode *inode) */ nrpages = mapping->nrpages; if (nrpages) { - spin_lock_irq(&mapping->tree_lock); + xa_lock_irq(&mapping->i_pages); nrpages = mapping->nrpages; - spin_unlock_irq(&mapping->tree_lock); + xa_unlock_irq(&mapping->i_pages); } /* Workaround end */ LASSERTF(nrpages == 0, "%s: inode="DFID"(%p) nrpages=%lu, " diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 8904739..825f2c4 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -1104,14 +1104,14 @@ static struct page *mdc_page_locate(struct address_space *mapping, __u64 *hash, struct page *page; int found; - spin_lock_irq(&mapping->tree_lock); + xa_lock_irq(&mapping->i_pages); found = radix_tree_gang_lookup(&mapping->page_tree, (void **)&page, offset, 1); if (found > 0 && !radix_tree_exceptional_entry(page)) { struct lu_dirpage *dp; get_page(page); - spin_unlock_irq(&mapping->tree_lock); + xa_unlock_irq(&mapping->i_pages); /* * In contrast to find_lock_page() we are sure that directory * page cannot be truncated (while DLM lock is held) and, @@ -1160,7 +1160,7 @@ static struct page *mdc_page_locate(struct address_space *mapping, __u64 *hash, page = ERR_PTR(-EIO); } } else { - spin_unlock_irq(&mapping->tree_lock); + xa_unlock_irq(&mapping->i_pages); page = NULL; } return page; -- 1.8.3.1