From 6d27c2c8c72e853a238fd3fc7f42d658188ca02f Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Sun, 24 Mar 2024 15:33:15 +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. 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/fs/lustre-release/+/54229 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Jian Yu Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- libcfs/autoconf/lustre-libcfs.m4 | 19 +++++++++++--- lnet/lnet/lib-cpt.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 | 8 +++--- 10 files changed, 120 insertions(+), 16 deletions(-) diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4 index ba0c8d1..b8c47cd 100644 --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -1009,14 +1009,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/lnet/lnet/lib-cpt.c b/lnet/lnet/lib-cpt.c index 5e4d2ab..c86f566 100644 --- a/lnet/lnet/lib-cpt.c +++ b/lnet/lnet/lib-cpt.c @@ -1253,7 +1253,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 */ @@ -1268,7 +1268,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) @@ -1323,7 +1323,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 5afeb19..f139924 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -4386,6 +4386,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], [ + LB2_MSG_LINUX_TEST_RESULT([if sruct dentry has d_children member], + [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], [ + LB2_MSG_LINUX_TEST_RESULT([if generic_error_remove_folio() exists], + [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 @@ -4669,6 +4717,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 ]) @@ -4973,6 +5025,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 8cf7e5b..4969b39 100644 --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -124,6 +124,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 @@ -777,6 +787,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 */ @@ -792,7 +826,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 60299c9..3d285f7 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(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"); if (d_lustre_invalid(de)) RETURN(1); diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index 79e9e29..f5c9177 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -178,7 +178,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 a04ad8c..393167a 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -1565,7 +1565,7 @@ static int vvp_io_fault_start(const struct lu_env *env, LASSERT(PageLocked(vmpage)); if (CFS_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 a91a176..f92c9de 100644 --- a/lustre/llite/vvp_page.c +++ b/lustre/llite/vvp_page.c @@ -159,7 +159,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 6a05aad..7a501f5 100644 --- a/lustre/obdclass/cl_page.c +++ b/lustre/obdclass/cl_page.c @@ -784,7 +784,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 b3375b0..7d7a609 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -1476,8 +1476,8 @@ static int osd_write_commit(const struct lu_env *env, struct dt_object *dt, CDEBUG(D_INODE, "Skipping [%d] == %d\n", i, lnb[i].lnb_rc); 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; } @@ -1528,8 +1528,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