From 32538d5bed904643291bac3db68e247e5bfd6284 Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Tue, 2 Apr 2024 15:52:02 -0700 Subject: [PATCH] LU-17592 build: compatibility updates for kernel 6.8 Linux commit v4.9-12227-g7b737965b331 introduced staging/lustre/libcfs: Convert to hotplug state machine Linux commit v4.10-rc1-5-g4205e4786d0b cpu/hotplug: Provide dynamic range for prepare stage Linux commit v6.7-rc2-1-g15bece7bec0d cpu/hotplug: Remove unused CPU hotplug states CPUHP_LUSTRE_CFS_DEAD was introduced in 4.9 and removed in 6.8 CPUHP_BP_PREPARE_DYN was introduced in 4.10 With no distro kernels between 4.10 and 4.11 switch to CPUHP_BP_PREPARE_DYN Linux commit v6.7-rc1-3-gda549bdd15c2 dentry: switch the lists of children to hlist Provide trival wrappers to abstract the changed members Linux commit v6.7-rc4-79-gaf7628d6ec19 fs: convert error_remove_page to error_remove_folio Proved a generic_error_remove_folio() for older kernels. Lustre-change: https://review.whamcloud.com/54229 Lustre-commit: TBD (from 2036974a891ffac3ecffc7b2a21ca50bc6c94f78) HPE-bug-id: LUS-12181 Fixes: ce98bfe5f72 ("LU-10499 pcc: add readonly mode for PCC") Signed-off-by: Shaun Tancheff Change-Id: Ib2e85c2acd3d0934e1c4712dad53b80f0ddb1b08 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/54586 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Jian Yu Reviewed-by: Andreas Dilger --- libcfs/autoconf/lustre-libcfs.m4 | 19 +++++++++++--- libcfs/libcfs/libcfs_cpu.c | 6 ++--- lustre/autoconf/lustre-core.m4 | 56 ++++++++++++++++++++++++++++++++++++++++ lustre/include/lustre_compat.h | 36 +++++++++++++++++++++++++- lustre/llite/dcache.c | 2 +- lustre/llite/namei.c | 2 +- lustre/llite/vvp_io.c | 2 +- lustre/llite/vvp_page.c | 3 ++- lustre/obdclass/cl_page.c | 2 +- lustre/osd-ldiskfs/osd_io.c | 11 ++++---- 10 files changed, 122 insertions(+), 17 deletions(-) diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4 index cab9f17..5902052c 100644 --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -920,14 +920,27 @@ AC_DEFUN([LIBCFS_GET_USER_PAGES_GUP_FLAGS], [ ]) # LIBCFS_GET_USER_PAGES_GUP_FLAGS # -# Kernel version 4.10 commit 7b737965b33188bd3dbb44e938535c4006d97fbb -# libcfs: Convert to hotplug state machine +# LIBCFS_HOTPLUG_STATE_MACHINE +# +# Linux commit v4.9-12227-g7b737965b331 introduced +# staging/lustre/libcfs: Convert to hotplug state machine +# Which introduced: CPUHP_LUSTRE_CFS_DEAD +# +# Linux commit v4.10-rc1-5-g4205e4786d0b +# cpu/hotplug: Provide dynamic range for prepare stage +# Which introduced: CPUHP_BP_PREPARE_DYN +# +# Linux commit v6.7-rc2-1-g15bece7bec0d +# cpu/hotplug: Remove unused CPU hotplug states +# Which removed: CPUHP_LUSTRE_CFS_DEAD +# +# With no distro kernels between 4.10 and 4.11 switch to CPUHP_BP_PREPARE_DYN # AC_DEFUN([LIBCFS_SRC_HOTPLUG_STATE_MACHINE], [ LB2_LINUX_TEST_SRC([cpu_hotplug_state_machine], [ #include ],[ - cpuhp_remove_state(CPUHP_LUSTRE_CFS_DEAD); + cpuhp_remove_state(CPUHP_BP_PREPARE_DYN); ]) ]) AC_DEFUN([LIBCFS_HOTPLUG_STATE_MACHINE], [ diff --git a/libcfs/libcfs/libcfs_cpu.c b/libcfs/libcfs/libcfs_cpu.c index 8a6faf2..e57a78c 100644 --- a/libcfs/libcfs/libcfs_cpu.c +++ b/libcfs/libcfs/libcfs_cpu.c @@ -1190,7 +1190,7 @@ void cfs_cpu_fini(void) #ifdef HAVE_HOTPLUG_STATE_MACHINE if (lustre_cpu_online > 0) cpuhp_remove_state_nocalls(lustre_cpu_online); - cpuhp_remove_state_nocalls(CPUHP_LUSTRE_CFS_DEAD); + cpuhp_remove_state_nocalls(CPUHP_BP_PREPARE_DYN); #else unregister_hotcpu_notifier(&cfs_cpu_notifier); #endif /* !HAVE_HOTPLUG_STATE_MACHINE */ @@ -1205,7 +1205,7 @@ int cfs_cpu_init(void) #ifdef CONFIG_HOTPLUG_CPU #ifdef HAVE_HOTPLUG_STATE_MACHINE - ret = cpuhp_setup_state_nocalls(CPUHP_LUSTRE_CFS_DEAD, + ret = cpuhp_setup_state_nocalls(CPUHP_BP_PREPARE_DYN, "fs/lustre/cfe:dead", NULL, cfs_cpu_dead); if (ret < 0) @@ -1260,7 +1260,7 @@ failed_alloc_table: if (lustre_cpu_online > 0) cpuhp_remove_state_nocalls(lustre_cpu_online); failed_cpu_online: - cpuhp_remove_state_nocalls(CPUHP_LUSTRE_CFS_DEAD); + cpuhp_remove_state_nocalls(CPUHP_AP_ONLINE_DYN); failed_cpu_dead: #else unregister_hotcpu_notifier(&cfs_cpu_notifier); diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index c080cb0..8601384 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -4061,6 +4061,54 @@ AC_DEFUN([LC_HAVE_SHRINKER_ALLOC], [ ]) # LC_HAVE_SHRINKER_ALLOC # +# LC_HAVE_DENTRY_D_CHILDREN +# +# Linux commit v6.7-rc1-3-gda549bdd15c2 +# dentry: switch the lists of children to hlist +# +AC_DEFUN([LC_SRC_HAVE_DENTRY_D_CHILDREN], [ + LB2_LINUX_TEST_SRC([dentry_d_children], [ + #include + ],[ + struct dentry *dentry = NULL; + + return hlist_empty(&dentry->d_children); + ],[-Werror]) +]) +AC_DEFUN([LC_HAVE_DENTRY_D_CHILDREN], [ + AC_MSG_CHECKING([if sruct dentry has d_children member]) + LB2_LINUX_TEST_RESULT([dentry_d_children], [ + AC_DEFINE(HAVE_DENTRY_D_CHILDREN, 1, + [sruct dentry has d_children member]) + ]) +]) # LC_HAVE_DENTRY_D_CHILDREN + +# +# LC_HAVE_GENERIC_ERROR_REMOVE_FOLIO +# +# Linux commit v6.7-rc4-79-gaf7628d6ec19 +# fs: convert error_remove_page to error_remove_folio +# +AC_DEFUN([LC_SRC_HAVE_GENERIC_ERROR_REMOVE_FOLIO], [ + LB2_LINUX_TEST_SRC([generic_error_remove_folio], [ + #include + ],[ + struct address_space *mapping = NULL; + struct folio *folio = NULL; + int err = generic_error_remove_folio(mapping, folio); + + (void) err; + ],[-Werror]) +]) +AC_DEFUN([LC_HAVE_GENERIC_ERROR_REMOVE_FOLIO], [ + AC_MSG_CHECKING([if generic_error_remove_folio() exists]) + LB2_LINUX_TEST_RESULT([generic_error_remove_folio], [ + AC_DEFINE(HAVE_GENERIC_ERROR_REMOVE_FOLIO, 1, + [generic_error_remove_folio() exists]) + ]) +]) # LC_HAVE_GENERIC_ERROR_REMOVE_FOLIO + +# # LC_PROG_LINUX # # Lustre linux kernel checks @@ -4313,6 +4361,10 @@ AC_DEFUN([LC_PROG_LINUX_SRC], [ LC_SRC_HAVE_INODE_GET_MTIME_SEC LC_SRC_HAVE_SHRINKER_ALLOC + # 6.8 + LC_SRC_HAVE_DENTRY_D_CHILDREN + LC_SRC_HAVE_GENERIC_ERROR_REMOVE_FOLIO + # kernel patch to extend integrity interface LC_SRC_BIO_INTEGRITY_PREP_FN ]) @@ -4591,6 +4643,10 @@ AC_DEFUN([LC_PROG_LINUX_RESULTS], [ LC_HAVE_INODE_GET_MTIME_SEC LC_HAVE_SHRINKER_ALLOC + # 6.8 + LC_HAVE_DENTRY_D_CHILDREN + LC_HAVE_GENERIC_ERROR_REMOVE_FOLIO + # 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 b97d37b..8f31130 100644 --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -89,6 +89,16 @@ static inline int d_in_lookup(struct dentry *dentry) } #endif +#ifdef HAVE_DENTRY_D_CHILDREN +#define d_no_children(dentry) (hlist_empty(&(dentry)->d_children)) +#define d_for_each_child(child, dentry) \ + hlist_for_each_entry((child), &(dentry)->d_children, d_sib) +#else +#define d_no_children(dentry) (list_empty(&(dentry)->d_subdirs)) +#define d_for_each_child(child, dentry) \ + list_for_each_entry((child), &(dentry)->d_subdirs, d_child) +#endif + #ifndef HAVE_VM_FAULT_T #define vm_fault_t int #endif @@ -689,6 +699,30 @@ static inline void ll_security_release_secctx(char *secdata, u32 seclen, #define ll_set_acl(ns, inode, acl, type) ll_set_acl(inode, acl, type) #endif +#ifndef HAVE_GENERIC_ERROR_REMOVE_FOLIO +#ifdef HAVE_FOLIO_BATCH +#define generic_folio folio +#else +#define generic_folio page +#define folio_page(page, n) (page) +#define folio_nr_pages(page) (1) +#define page_folio(page) (page) +#endif +static inline int generic_error_remove_folio(struct address_space *mapping, + struct generic_folio *folio) +{ + int pg, npgs = folio_nr_pages(folio); + int err = 0; + + for (pg = 0; pg < npgs; pg++) { + err = generic_error_remove_page(mapping, folio_page(folio, pg)); + if (err) + break; + } + return err; +} +#endif + /** * delete_from_page_cache is not exported anymore */ @@ -704,7 +738,7 @@ static inline void cfs_delete_from_page_cache(struct page *page) unlock_page(page); /* on entry page is locked */ if (S_ISREG(page->mapping->host->i_mode)) { - generic_error_remove_page(page->mapping, page); + generic_error_remove_folio(page->mapping, page_folio(page)); } else { loff_t lstart = page->index << PAGE_SHIFT; loff_t lend = lstart + PAGE_SIZE - 1; diff --git a/lustre/llite/dcache.c b/lustre/llite/dcache.c index 5272445..b41c03d 100644 --- a/lustre/llite/dcache.c +++ b/lustre/llite/dcache.c @@ -131,7 +131,7 @@ static int ll_ddelete(const struct dentry *de) d_lustre_invalid((struct dentry *)de) ? "deleting" : "keeping", de, de, de->d_parent, de->d_inode, d_unhashed((struct dentry *)de) ? "" : "hashed,", - list_empty(&de->d_subdirs) ? "" : "subdirs"); + d_no_children(de) ? "" : "subdirs"); /* kernel >= 2.6.38 last refcount is decreased after this function. */ LASSERT(ll_d_count(de) == 1); diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index 9978dec..333cc84 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -179,7 +179,7 @@ restart: spin_lock(&dir->i_lock); hlist_for_each_entry(dentry, &dir->i_dentry, d_alias) { spin_lock(&dentry->d_lock); - list_for_each_entry(child, &dentry->d_subdirs, d_child) { + d_for_each_child(child, dentry) { if (child->d_inode) continue; diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c index 65a27e6..f0e3302 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -1616,7 +1616,7 @@ static int vvp_io_fault_start(const struct lu_env *env, LASSERT(PageLocked(vmpage)); if (OBD_FAIL_CHECK(OBD_FAIL_LLITE_FAULT_TRUNC_RACE)) - generic_error_remove_page(vmpage->mapping, vmpage); + generic_error_remove_folio(vmpage->mapping, page_folio(vmpage)); size = i_size_read(inode); /* Though we have already held a cl_lock upon this page, but diff --git a/lustre/llite/vvp_page.c b/lustre/llite/vvp_page.c index 50a456c..0e58bdc 100644 --- a/lustre/llite/vvp_page.c +++ b/lustre/llite/vvp_page.c @@ -184,7 +184,8 @@ static void vvp_page_completion_read(const struct lu_env *env, * because subpage would be from wrong osc when trying * to read from a new mirror */ - generic_error_remove_page(vmpage->mapping, vmpage); + generic_error_remove_folio(vmpage->mapping, + page_folio(vmpage)); } } diff --git a/lustre/obdclass/cl_page.c b/lustre/obdclass/cl_page.c index 368373b..411dda9 100644 --- a/lustre/obdclass/cl_page.c +++ b/lustre/obdclass/cl_page.c @@ -825,7 +825,7 @@ void cl_page_discard(const struct lu_env *env, vmpage = cp->cp_vmpage; LASSERT(vmpage != NULL); LASSERT(PageLocked(vmpage)); - generic_error_remove_page(vmpage->mapping, vmpage); + generic_error_remove_folio(vmpage->mapping, page_folio(vmpage)); } else { cl_page_delete(env, cp); } diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index a402104..b96e771 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -745,7 +745,8 @@ static struct page *osd_get_page(const struct lu_env *env, struct dt_object *dt, CDEBUG(D_SEC, "compression, found page at %llu, removing\n", offset); - generic_error_remove_page(inode->i_mapping, page); + generic_error_remove_folio(inode->i_mapping, + page_folio(page)); } } @@ -1667,8 +1668,8 @@ static int osd_write_commit(const struct lu_env *env, struct dt_object *dt, */ lnb[i].lnb_hole ? "because no data in page\n" : ""); LASSERT(lnb[i].lnb_page); - generic_error_remove_page(inode->i_mapping, - lnb[i].lnb_page); + generic_error_remove_folio(inode->i_mapping, + page_folio(lnb[i].lnb_page)); continue; } @@ -1719,8 +1720,8 @@ static int osd_write_commit(const struct lu_env *env, struct dt_object *dt, continue; if (!PagePrivate2(lnb[i].lnb_page)) { LASSERT(PageLocked(lnb[i].lnb_page)); - generic_error_remove_page(inode->i_mapping, - lnb[i].lnb_page); + generic_error_remove_folio(inode->i_mapping, + page_folio(lnb[i].lnb_page)); } } } -- 1.8.3.1