From 2d0c621d21be4e67b6075b76017af6e6fcd18c64 Mon Sep 17 00:00:00 2001 From: Li Dongyang Date: Mon, 15 Apr 2019 14:15:40 +1000 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 Signed-off-by: Li Dongyang Change-Id: Iadbc5eda884dbe8ad0d694e0f88255bc496dea5b Reviewed-on: https://review.whamcloud.com/34673 Reviewed-by: Gu Zheng Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Tested-by: Jenkins Tested-by: Maloo --- 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 3dffc2c..4245ba7 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -3058,6 +3058,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 @@ -3302,6 +3322,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 4ea091a..1b74aa4 100644 --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -791,4 +791,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 2548dbd..11d6169 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -2149,9 +2149,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 0db1628..bc5ac2f 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -1112,14 +1112,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, @@ -1168,7 +1168,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