From 68ec6a2b6fca5dcdd02b871b95b1c763b63b6272 Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Sat, 21 Sep 2024 11:01:42 +0700 Subject: [PATCH] LU-18190 build: compatibility updates for kernel 6.11 Linux commit v6.10-12269-g78eb4ea25cd5 sysctl: treewide: constify the ctl_table argument of proc_handlers Constify ctl_table and cast away const for older kernels Linux commit v5.15-rc3-13-g9257e1567738 mm/filemap: Add folio_index(), folio_file_page() and folio_contains() Linux commit v6.10-rc6-27-g05b0c7edad9b mm: drop page_index and simplify folio_index Removed page_index() in favor of folio_index() provide a wrapper folio_index_page() to call the correct function with a page. Linux commit v6.1-rc4-186-gcb67f4282bf9 mm,thp,rmap: simplify compound page mapcount handling Adds folio_mapcount() Linux commit v6.10-rc6-100-gcdd9a571b7d8 fs/proc: move page_mapcount() to fs/proc/internal.h Removed page_mapcount() in favor of folio_mapcount() provide folio_mapcount_page() to call page_mapcount() or calculate mapcount as done by folio_precise_page_mapcount() Linux commit v6.10-rc3-19-ge9f5f44ad372 block: remove the blk_integrity_profile structure Linux commit v6.10-rc3-25-g9f4aa46f2a74 block: invert the BLK_INTEGRITY_{GENERATE,VERIFY} flags Invert the checks for BLK_INTEGRITY_NO{GENERATE,VERIFY} when BLK_INTEGRITY_NOVERIFY is present and remove checks that require bi->profile->{verify_fn,generate_fn} Also resolve a gcc-14 issue with -Werror=stringop-truncation in lustre/utils/obd.c HPE-bug-id: LUS-12519 Test-Parameters: trivial Signed-off-by: Shaun Tancheff Change-Id: Ifda4da9716108129bb59634612940d61abe69aa2 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56283 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger Reviewed-by: Jian Yu --- libcfs/autoconf/lustre-libcfs.m4 | 57 ++++++++++++++++++++++++++++ libcfs/include/libcfs/libcfs.h | 20 ++++++++-- libcfs/libcfs/module.c | 79 +++++++++++++++++++++------------------ lnet/lnet/lnet_debugfs.c | 60 +++++++++++++++-------------- lustre/autoconf/lustre-core.m4 | 23 ++++++++++++ lustre/include/lustre_compat.h | 24 ++++++++++++ lustre/llite/vvp_io.c | 2 +- lustre/obdclass/cl_page.c | 4 +- lustre/osc/osc_page.c | 2 +- lustre/osd-ldiskfs/osd_internal.h | 37 +++++++++++++----- lustre/utils/obd.c | 3 +- 11 files changed, 227 insertions(+), 84 deletions(-) diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4 index a79e451..356c9aa 100644 --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -2453,6 +2453,57 @@ AC_DEFUN([LIBCFS_TIMER_DELETE],[ ]) ]) # LIBCFS_TIMER_DELETE +# +# LIBCFS_CONSTIFY_CTR_TABLE +# +# Linux commit v6.10-12269-g78eb4ea25cd5 +# sysctl: treewide: constify the ctl_table argument of proc_handlers +# +AC_DEFUN([LIBCFS_SRC_CONSTIFY_CTR_TABLE],[ + LB2_LINUX_TEST_SRC([constify_struct_ctl_table], [ + #include + + static int handler(const struct ctl_table *table, int write, + void __user *buf, size_t *lenp, loff_t *ppos) + { + return 0; + } + ],[ + static struct ctl_table ctl_tbl __attribute__ ((unused)) = { + .proc_handler = &handler, + }; + ],[-Werror]) +]) +AC_DEFUN([LIBCFS_CONSTIFY_CTR_TABLE],[ + LB2_MSG_LINUX_TEST_RESULT( + [if struct ctl_table argument to proc_handler() is const], + [constify_struct_ctl_table], [ + AC_DEFINE(HAVE_CONST_CTR_TABLE, 1, + [struct ctl_table argument to proc_handler() is const]) + ]) +]) # LIBCFS_CONSTIFY_CTR_TABLE + +# +# LIBCFS_BLK_INTEGRITY_NOVERIFY +# +# Linux commit v6.10-rc3-25-g9f4aa46f2a74 +# block: invert the BLK_INTEGRITY_{GENERATE,VERIFY} flags +# +AC_DEFUN([LIBCFS_SRC_BLK_INTEGRITY_NOVERIFY], [ + LB2_LINUX_TEST_SRC([blk_integrity_noverify], [ + #include + ],[ + int flag __attribute__ ((unused)) = BLK_INTEGRITY_NOVERIFY; + ],[-Werror]) +]) +AC_DEFUN([LIBCFS_BLK_INTEGRITY_NOVERIFY], [ + LB2_MSG_LINUX_TEST_RESULT([if BLK_INTEGRITY_NOVERIFY is available], + [blk_integrity_noverify], [ + AC_DEFINE(HAVE_BLK_INTEGRITY_NOVERIFY, 1, + [BLK_INTEGRITY_NOVERIFY is available]) + ]) +]) # LIBCFS_BLK_INTEGRITY_NOVERIFY + dnl # dnl # Generate and compile all of the kernel API test cases to determine dnl # which interfaces are available. By invoking the kernel build system @@ -2606,6 +2657,9 @@ AC_DEFUN([LIBCFS_PROG_LINUX_SRC], [ # 6.2 LIBCFS_SRC_TIMER_DELETE_SYNC LIBCFS_SRC_TIMER_DELETE + # 6.11 + LIBCFS_SRC_CONSTIFY_CTR_TABLE + LIBCFS_SRC_BLK_INTEGRITY_NOVERIFY ]) dnl # @@ -2759,6 +2813,9 @@ AC_DEFUN([LIBCFS_PROG_LINUX_RESULTS], [ # 6.2 LIBCFS_TIMER_DELETE_SYNC LIBCFS_TIMER_DELETE + # 6.11 + LIBCFS_CONSTIFY_CTR_TABLE + LIBCFS_BLK_INTEGRITY_NOVERIFY ]) # diff --git a/libcfs/include/libcfs/libcfs.h b/libcfs/include/libcfs/libcfs.h index 84138760..e599e9f 100644 --- a/libcfs/include/libcfs/libcfs.h +++ b/libcfs/include/libcfs/libcfs.h @@ -71,13 +71,25 @@ int libcfs_ioctl(unsigned int cmd, struct libcfs_ioctl_data *data); extern struct workqueue_struct *cfs_rehash_wq; -void lnet_insert_debugfs(struct ctl_table *table, struct module *mod, - void **statep); -void lnet_remove_debugfs(struct ctl_table *table); +#ifdef HAVE_CONST_CTR_TABLE +#define DEFINE_CTL_TABLE_INIT(__name, init)\ + const struct ctl_table *__name = init +#define cfs_proc_handler(h) (h) +#else +#define DEFINE_CTL_TABLE_INIT(__name, init)\ + struct ctl_table *__name = init +typedef int (*cfs_ctl_table_handler_t)(struct ctl_table *, + int, void __user *, size_t *, loff_t *); +#define cfs_proc_handler(h) ((cfs_ctl_table_handler_t)(h)) +#endif + +void lnet_insert_debugfs(const struct ctl_table *table, + struct module *mod, void **statep); +void lnet_remove_debugfs(const struct ctl_table *table); void lnet_debugfs_fini(void **statep); /* helper for sysctl handlers */ -int debugfs_doint(struct ctl_table *table, int write, +int debugfs_doint(const struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos); /* diff --git a/libcfs/libcfs/module.c b/libcfs/libcfs/module.c index b1cbbe3..642b9ce 100644 --- a/libcfs/libcfs/module.c +++ b/libcfs/libcfs/module.c @@ -100,8 +100,9 @@ int libcfs_ioctl(unsigned int cmd, struct libcfs_ioctl_data *data) EXPORT_SYMBOL(libcfs_ioctl); #endif -static int proc_dobitmasks(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) +static int proc_dobitmasks(const struct ctl_table *table, + int write, void __user *buffer, size_t *lenp, + loff_t *ppos) { const int tmpstrlen = 512; char *tmpstr = NULL; @@ -143,8 +144,9 @@ static int proc_dobitmasks(struct ctl_table *table, int write, static int min_watchdog_ratelimit; /* disable ratelimiting */ static int max_watchdog_ratelimit = (24*60*60); /* limit to once per day */ -static int proc_dump_kernel(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) +static int proc_dump_kernel(const struct ctl_table *table, + int write, void __user *buffer, size_t *lenp, + loff_t *ppos) { size_t nob = *lenp; @@ -154,8 +156,9 @@ static int proc_dump_kernel(struct ctl_table *table, int write, return cfs_trace_dump_debug_buffer_usrstr(buffer, nob); } -static int proc_daemon_file(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) +static int proc_daemon_file(const struct ctl_table *table, + int write, void __user *buffer, size_t *lenp, + loff_t *ppos) { size_t nob = *lenp; loff_t pos = *ppos; @@ -173,17 +176,18 @@ static int proc_daemon_file(struct ctl_table *table, int write, return cfs_trace_daemon_command_usrstr(buffer, nob); } -static int libcfs_force_lbug(struct ctl_table *table, int write, - void __user *buffer, - size_t *lenp, loff_t *ppos) +static int libcfs_force_lbug(const struct ctl_table *table, + int write, void __user *buffer, size_t *lenp, + loff_t *ppos) { if (write) LBUG(); return 0; } -static int proc_fail_loc(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) +static int proc_fail_loc(const struct ctl_table *table, + int write, void __user *buffer, size_t *lenp, + loff_t *ppos) { int rc; long old_fail_loc = cfs_fail_loc; @@ -220,8 +224,8 @@ static int proc_fail_loc(struct ctl_table *table, int write, return rc; } -static int libcfs_debug_marker(struct ctl_table *table, int write, - void __user *buffer, +static int libcfs_debug_marker(const struct ctl_table *table, + int write, void __user *buffer, size_t *lenp, loff_t *ppos) { size_t len = min(*lenp, 4000UL); @@ -250,7 +254,7 @@ static int libcfs_debug_marker(struct ctl_table *table, int write, return *lenp > 4000 ? -EOVERFLOW : 0; } -int debugfs_doint(struct ctl_table *table, int write, +int debugfs_doint(const struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { int rc; @@ -293,7 +297,7 @@ int debugfs_doint(struct ctl_table *table, int write, } EXPORT_SYMBOL(debugfs_doint); -static int debugfs_dou64(struct ctl_table *table, int write, +static int debugfs_dou64(const struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { int rc; @@ -331,8 +335,9 @@ static int debugfs_dou64(struct ctl_table *table, int write, return rc; } -static int debugfs_dostring(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) +static int debugfs_dostring(const struct ctl_table *table, + int write, void __user *buffer, size_t *lenp, + loff_t *ppos) { int len = *lenp; char *kbuf = table->data; @@ -369,96 +374,96 @@ static struct ctl_table lnet_table[] = { .data = &libcfs_debug, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = &proc_dobitmasks, + .proc_handler = cfs_proc_handler(&proc_dobitmasks), }, { .procname = "subsystem_debug", .data = &libcfs_subsystem_debug, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = &proc_dobitmasks, + .proc_handler = cfs_proc_handler(&proc_dobitmasks), }, { .procname = "printk", .data = &libcfs_printk, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = &proc_dobitmasks, + .proc_handler = cfs_proc_handler(&proc_dobitmasks), }, { .procname = "debug_log_upcall", .data = lnet_debug_log_upcall, .maxlen = sizeof(lnet_debug_log_upcall), .mode = 0644, - .proc_handler = &debugfs_dostring, + .proc_handler = cfs_proc_handler(&debugfs_dostring), }, { .procname = "lnet_memused", .data = (u64 *)&libcfs_kmem.counter, .maxlen = sizeof(u64), .mode = 0444, - .proc_handler = &debugfs_dou64, + .proc_handler = cfs_proc_handler(&debugfs_dou64), }, { .procname = "catastrophe", .data = &libcfs_catastrophe, .maxlen = sizeof(int), .mode = 0444, - .proc_handler = &debugfs_doint, + .proc_handler = cfs_proc_handler(&debugfs_doint), }, { .procname = "dump_kernel", .maxlen = 256, .mode = 0200, - .proc_handler = &proc_dump_kernel, + .proc_handler = cfs_proc_handler(&proc_dump_kernel), }, { .procname = "daemon_file", .mode = 0644, .maxlen = 256, - .proc_handler = &proc_daemon_file, + .proc_handler = cfs_proc_handler(&proc_daemon_file), }, { .procname = "watchdog_ratelimit", .data = &libcfs_watchdog_ratelimit, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = &debugfs_doint, + .proc_handler = cfs_proc_handler(&debugfs_doint), .extra1 = &min_watchdog_ratelimit, .extra2 = &max_watchdog_ratelimit, }, { .procname = "debug_marker", .mode = 0200, - .proc_handler = &libcfs_debug_marker + .proc_handler = cfs_proc_handler(&libcfs_debug_marker) }, { .procname = "force_lbug", .data = NULL, .maxlen = 0, .mode = 0200, - .proc_handler = &libcfs_force_lbug + .proc_handler = cfs_proc_handler(&libcfs_force_lbug) }, { .procname = "fail_loc", .data = &cfs_fail_loc, .maxlen = sizeof(cfs_fail_loc), .mode = 0644, - .proc_handler = &proc_fail_loc + .proc_handler = cfs_proc_handler(&proc_fail_loc) }, { .procname = "fail_val", .data = &cfs_fail_val, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = &debugfs_doint + .proc_handler = cfs_proc_handler(&debugfs_doint) }, { .procname = "fail_err", .data = &cfs_fail_err, .maxlen = sizeof(cfs_fail_err), .mode = 0644, - .proc_handler = &debugfs_doint, + .proc_handler = cfs_proc_handler(&debugfs_doint), }, { } @@ -485,7 +490,7 @@ static const struct lnet_debugfs_symlink_def lnet_debugfs_symlinks[] = { static ssize_t lnet_debugfs_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos) { - struct ctl_table *table = filp->private_data; + DEFINE_CTL_TABLE_INIT(table, filp->private_data); loff_t old_pos = *ppos; ssize_t rc = -EINVAL; @@ -507,7 +512,7 @@ static ssize_t lnet_debugfs_read(struct file *filp, char __user *buf, static ssize_t lnet_debugfs_write(struct file *filp, const char __user *buf, size_t count, loff_t *ppos) { - struct ctl_table *table = filp->private_data; + DEFINE_CTL_TABLE_INIT(table, filp->private_data); loff_t old_pos = *ppos; ssize_t rc = -EINVAL; @@ -554,8 +559,8 @@ static const struct file_operations *lnet_debugfs_fops_select( return &state[2]; } -void lnet_insert_debugfs(struct ctl_table *table, struct module *mod, - void **statep) +void lnet_insert_debugfs(const struct ctl_table *table, + struct module *mod, void **statep) { struct file_operations *state = *statep; if (!lnet_debugfs_root) @@ -583,7 +588,7 @@ void lnet_insert_debugfs(struct ctl_table *table, struct module *mod, */ for (; table && table->procname; table++) debugfs_create_file(table->procname, table->mode, - lnet_debugfs_root, table, + lnet_debugfs_root, (void *)table, lnet_debugfs_fops_select(table->mode, (const struct file_operations *)state)); } @@ -604,7 +609,7 @@ static void lnet_insert_debugfs_links( symlinks->target); } -void lnet_remove_debugfs(struct ctl_table *table) +void lnet_remove_debugfs(const struct ctl_table *table) { for (; table && table->procname; table++) { struct qstr dname = QSTR_INIT(table->procname, diff --git a/lnet/lnet/lnet_debugfs.c b/lnet/lnet/lnet_debugfs.c index 4e53afa..9665893 100644 --- a/lnet/lnet/lnet_debugfs.c +++ b/lnet/lnet/lnet_debugfs.c @@ -60,8 +60,9 @@ #define LNET_PROC_VERSION(v) ((unsigned int)((v) & LNET_PROC_VER_MASK)) -static int proc_cpt_table(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) +static int proc_cpt_table(const struct ctl_table *table, + int write, void __user *buffer, size_t *lenp, + loff_t *ppos) { size_t nob = *lenp; loff_t pos = *ppos; @@ -100,8 +101,9 @@ out: return rc; } -static int proc_cpt_distance(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) +static int proc_cpt_distance(const struct ctl_table *table, + int write, void __user *buffer, size_t *lenp, + loff_t *ppos) { size_t nob = *lenp; loff_t pos = *ppos; @@ -140,8 +142,9 @@ out: return rc; } -static int proc_lnet_stats(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) +static int proc_lnet_stats(const struct ctl_table *table, + int write, void __user *buffer, size_t *lenp, + loff_t *ppos) { int rc; struct lnet_counters *ctrs; @@ -189,8 +192,8 @@ out_no_ctrs: } static int -proc_lnet_routes(struct ctl_table *table, int write, void __user *buffer, - size_t *lenp, loff_t *ppos) +proc_lnet_routes(const struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) { const int tmpsiz = 256; char *tmpstr; @@ -315,8 +318,8 @@ proc_lnet_routes(struct ctl_table *table, int write, void __user *buffer, } static int -proc_lnet_routers(struct ctl_table *table, int write, void __user *buffer, - size_t *lenp, loff_t *ppos) +proc_lnet_routers(const struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) { int rc = 0; char *tmpstr; @@ -420,8 +423,8 @@ proc_lnet_routers(struct ctl_table *table, int write, void __user *buffer, /* TODO: there should be no direct access to ptable. We should add a set * of APIs that give access to the ptable and its members */ static int -proc_lnet_peers(struct ctl_table *table, int write, void __user *buffer, - size_t *lenp, loff_t *ppos) +proc_lnet_peers(const struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) { const int tmpsiz = 256; struct lnet_peer_table *ptable; @@ -597,8 +600,9 @@ proc_lnet_peers(struct ctl_table *table, int write, void __user *buffer, return rc; } -static int proc_lnet_buffers(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) +static int proc_lnet_buffers(const struct ctl_table *table, + int write, void __user *buffer, size_t *lenp, + loff_t *ppos) { size_t nob = *lenp; loff_t pos = *ppos; @@ -658,8 +662,8 @@ static int proc_lnet_buffers(struct ctl_table *table, int write, } static int -proc_lnet_nis(struct ctl_table *table, int write, void __user *buffer, - size_t *lenp, loff_t *ppos) +proc_lnet_nis(const struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) { int tmpsiz = 128 * LNET_CPT_NUMBER; int rc = 0; @@ -837,8 +841,8 @@ static struct lnet_portal_rotors portal_rotors[] = { }, }; -static int proc_lnet_portal_rotor(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, +static int proc_lnet_portal_rotor(const struct ctl_table *table, + int write, void __user *buffer, size_t *lenp, loff_t *ppos) { const int buf_len = 128; @@ -912,55 +916,55 @@ static struct ctl_table lnet_table[] = { .procname = "cpu_partition_table", .maxlen = 128, .mode = 0444, - .proc_handler = &proc_cpt_table, + .proc_handler = cfs_proc_handler(&proc_cpt_table), }, { .procname = "cpu_partition_distance", .maxlen = 128, .mode = 0444, - .proc_handler = &proc_cpt_distance, + .proc_handler = cfs_proc_handler(&proc_cpt_distance), }, { .procname = "stats", .mode = 0644, - .proc_handler = &proc_lnet_stats, + .proc_handler = cfs_proc_handler(&proc_lnet_stats), }, { .procname = "routes", .mode = 0444, - .proc_handler = &proc_lnet_routes, + .proc_handler = cfs_proc_handler(&proc_lnet_routes), }, { .procname = "routers", .mode = 0444, - .proc_handler = &proc_lnet_routers, + .proc_handler = cfs_proc_handler(&proc_lnet_routers), }, { .procname = "peers", .mode = 0644, - .proc_handler = &proc_lnet_peers, + .proc_handler = cfs_proc_handler(&proc_lnet_peers), }, { .procname = "buffers", .mode = 0444, - .proc_handler = &proc_lnet_buffers, + .proc_handler = cfs_proc_handler(&proc_lnet_buffers), }, { .procname = "nis", .mode = 0644, - .proc_handler = &proc_lnet_nis, + .proc_handler = cfs_proc_handler(&proc_lnet_nis), }, { .procname = "portal_rotor", .mode = 0644, - .proc_handler = &proc_lnet_portal_rotor, + .proc_handler = cfs_proc_handler(&proc_lnet_portal_rotor), }, { .procname = "lnet_lnd_timeout", .data = &lnet_lnd_timeout, .maxlen = sizeof(lnet_lnd_timeout), .mode = 0444, - .proc_handler = &debugfs_doint, + .proc_handler = cfs_proc_handler(&debugfs_doint), }, { .procname = NULL } }; diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index c81541e..d955dc2 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -4162,6 +4162,27 @@ AC_DEFUN([LC_IOP_GET_INODE_ACL], [ ]) # LC_IOP_GET_INODE_ACL # +# LC_HAVE_FOLIO_MAPCOUNT +# +# linux kernel v6.1-rc4-186-gcb67f4282bf9 +# mm,thp,rmap: simplify compound page mapcount handling +# +AC_DEFUN([LC_SRC_HAVE_FOLIO_MAPCOUNT], [ + LB2_LINUX_TEST_SRC([folio_mapcount], [ + #include + ],[ + (void)folio_mapcount((const struct folio *)NULL); + ],[-Werror]) +]) +AC_DEFUN([LC_HAVE_FOLIO_MAPCOUNT], [ + LB2_MSG_LINUX_TEST_RESULT([if 'folio_mapcount()' is available], + [folio_mapcount], [ + AC_DEFINE(HAVE_FOLIO_MAPCOUNT, 1, + ['folio_mapcount()' is available]) + ]) +]) # LC_HAVE_FOLIO_MAPCOUNT + +# # LC_HAVE_U64_CAPABILITY # # linux kernel v6.2-13111-gf122a08b197d @@ -4950,6 +4971,7 @@ AC_DEFUN([LC_PROG_LINUX_SRC], [ # 6.2 LC_SRC_HAVE_GET_RANDOM_U32_BELOW LC_SRC_HAVE_ACL_WITH_DENTRY + LC_SRC_HAVE_FOLIO_MAPCOUNT # 6.3 LC_SRC_HAVE_MNT_IDMAP_ARG @@ -5266,6 +5288,7 @@ AC_DEFUN([LC_PROG_LINUX_RESULTS], [ # 6.2 LC_HAVE_GET_RANDOM_U32_BELOW LC_HAVE_ACL_WITH_DENTRY + LC_HAVE_FOLIO_MAPCOUNT # 6.3 LC_HAVE_MNT_IDMAP_ARG diff --git a/lustre/include/lustre_compat.h b/lustre/include/lustre_compat.h index 9fa78b5..3ae12ff 100644 --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -880,6 +880,8 @@ static inline void folio_batch_reinit(struct folio_batch *fbatch) } # endif /* HAVE_FOLIO_BATCH_REINIT */ +# define folio_index_page(pg) folio_index(page_folio((pg))) + #else /* !HAVE_FOLIO_BATCH && !HAVE_FILEMAP_GET_FOLIOS */ # ifdef HAVE_PAGEVEC @@ -908,6 +910,8 @@ static inline void folio_batch_reinit(struct folio_batch *fbatch) # define fbatch_at(pvec, n) ((pvec)->pages[(n)]) # define fbatch_at_npgs(pvec, n) 1 # define fbatch_at_pg(pvec, n, pg) ((pvec)->pages[(n)]) +# define folio_index_page(pg) page_index((pg)) + #endif /* HAVE_FOLIO_BATCH && HAVE_FILEMAP_GET_FOLIOS */ #ifndef HAVE_FLUSH___WORKQUEUE @@ -965,4 +969,24 @@ static inline struct timespec64 inode_set_mtime(struct inode *inode, } #endif /* !HAVE_INODE_GET_MTIME_SEC */ +#ifdef HAVE_FOLIO_MAPCOUNT +/* clone of fs/proc/internal.h: + * folio_precise_page_mapcount(struct folio *folio, struct page *page) + */ +static inline int folio_mapcount_page(struct page *page) +{ + struct folio *folio = page_folio(page); + int mapcount = atomic_read(&page->_mapcount) + 1; + + if (mapcount < PAGE_MAPCOUNT_RESERVE + 1) + mapcount = 0; + if (folio_test_large(folio)) + mapcount += folio_entire_mapcount(folio); + + return mapcount; +} +#else /* !HAVE_FOLIO_MAPCOUNT */ +#define folio_mapcount_page(pg) page_mapcount((pg)) +#endif /* HAVE_FOLIO_MAPCOUNT */ + #endif /* _LUSTRE_COMPAT_H */ diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c index 18998b3..a292c08 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -995,7 +995,7 @@ static inline void ll_page_tag_dirty(struct page *page, #ifndef HAVE_RADIX_TREE_TAG_SET __xa_set_mark(&mapping->i_pages, page_index(page), PAGECACHE_TAG_DIRTY); #else - radix_tree_tag_set(&mapping->page_tree, page_index(page), + radix_tree_tag_set(&mapping->page_tree, folio_index_page(page), PAGECACHE_TAG_DIRTY); #endif } diff --git a/lustre/obdclass/cl_page.c b/lustre/obdclass/cl_page.c index a90316b..9cda63a 100644 --- a/lustre/obdclass/cl_page.c +++ b/lustre/obdclass/cl_page.c @@ -1099,8 +1099,8 @@ void cl_page_print(const struct lu_env *env, void *cookie, if (vmpage != NULL) { (*printer)(env, cookie, " %lx %d:%d %lx %lu %slru", (long)vmpage->flags, page_count(vmpage), - page_mapcount(vmpage), vmpage->private, - page_index(vmpage), + folio_mapcount_page(vmpage), vmpage->private, + folio_index_page(vmpage), list_empty(&vmpage->lru) ? "not-" : ""); } diff --git a/lustre/osc/osc_page.c b/lustre/osc/osc_page.c index 4da1adc..2ddac2b 100644 --- a/lustre/osc/osc_page.c +++ b/lustre/osc/osc_page.c @@ -524,7 +524,7 @@ static inline bool lru_page_busy(struct client_obd *cli, struct cl_page *page) struct page *vmpage = cl_page_vmpage(page); /* vmpage have two known users: cl_page and VM page cache */ - if (page_count(vmpage) - page_mapcount(vmpage) > 2) + if ((page_count(vmpage) - folio_mapcount_page(vmpage)) > 2) return true; } return false; diff --git a/lustre/osd-ldiskfs/osd_internal.h b/lustre/osd-ldiskfs/osd_internal.h index 09ebcef..0d5f39f 100644 --- a/lustre/osd-ldiskfs/osd_internal.h +++ b/lustre/osd-ldiskfs/osd_internal.h @@ -1640,7 +1640,9 @@ static inline unsigned short blk_integrity_interval(struct blk_integrity *bi) static inline const char *blk_integrity_name(struct blk_integrity *bi) { -#ifdef HAVE_INTERVAL_EXP_BLK_INTEGRITY +#ifdef HAVE_BLK_INTEGRITY_NOVERIFY + return blk_integrity_profile_name(bi); +#elif defined HAVE_INTERVAL_EXP_BLK_INTEGRITY return bi->profile->name; #else return bi->name; @@ -1649,7 +1651,9 @@ static inline const char *blk_integrity_name(struct blk_integrity *bi) static inline unsigned int bip_size(struct bio_integrity_payload *bip) { -#ifdef HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD +#ifdef HAVE_BLK_INTEGRITY_NOVERIFY + return bip->bip_iter.bi_size; +#elif defined HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD return bip->bip_iter.bi_size; #else return bip->bip_size; @@ -1667,6 +1671,12 @@ static inline const char *blk_integrity_name(struct blk_integrity *bi) } #endif /* !CONFIG_BLK_DEV_INTEGRITY */ +#ifdef HAVE_BLK_INTEGRITY_NOVERIFY +#define INTEGRITY_READ(flag) (!(BLK_INTEGRITY_NOVERIFY & (flag))) +#define INTEGRITY_WRITE(flag) (!(BLK_INTEGRITY_NOGENERATE & (flag))) + +#else /* !HAVE_BLK_INTEGRITY_NOVERIFY */ + #ifndef INTEGRITY_FLAG_READ #define INTEGRITY_FLAG_READ BLK_INTEGRITY_VERIFY #endif @@ -1675,6 +1685,10 @@ static inline const char *blk_integrity_name(struct blk_integrity *bi) #define INTEGRITY_FLAG_WRITE BLK_INTEGRITY_GENERATE #endif +#define INTEGRITY_READ(flag) (INTEGRITY_FLAG_READ & (flag)) +#define INTEGRITY_WRITE(flag) (INTEGRITY_FLAG_WRITE & (flag)) +#endif /* HAVE_BLK_INTEGRITY_NOVERIFY */ + static inline bool bdev_integrity_enabled(struct block_device *bdev, int rw) { #if IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY) @@ -1683,21 +1697,26 @@ static inline bool bdev_integrity_enabled(struct block_device *bdev, int rw) if (bi == NULL) return false; -#ifdef HAVE_INTERVAL_EXP_BLK_INTEGRITY +#ifdef HAVE_BLK_INTEGRITY_NOVERIFY + if (rw == 0 && INTEGRITY_READ(bi->flags)) + return true; + + if (rw == 1 && INTEGRITY_WRITE(bi->flags)) + return true; + +#elif defined HAVE_INTERVAL_EXP_BLK_INTEGRITY if (rw == 0 && bi->profile->verify_fn != NULL && - (bi->flags & INTEGRITY_FLAG_READ)) + INTEGRITY_READ(bi->flags)) return true; if (rw == 1 && bi->profile->generate_fn != NULL && - (bi->flags & INTEGRITY_FLAG_WRITE)) + INTEGRITY_WRITE(bi->flags)) return true; #else - if (rw == 0 && bi->verify_fn != NULL && - (bi->flags & INTEGRITY_FLAG_READ)) + if (rw == 0 && bi->verify_fn != NULL && INTEGRITY_READ(bi->flags)) return true; - if (rw == 1 && bi->generate_fn != NULL && - (bi->flags & INTEGRITY_FLAG_WRITE)) + if (rw == 1 && bi->generate_fn != NULL && INTEGRITY_WRITE(bi->flags)) return true; #endif /* !HAVE_INTERVAL_EXP_BLK_INTEGRITY */ #endif /* !CONFIG_BLK_DEV_INTEGRITY */ diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index b8cd40e..24870e4 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -5090,8 +5090,7 @@ int parse_pool_cmd_args(int argc, char **argv, bool *wait, return -ENAMETOOLONG; } - strncpy(fsname, param, fsname_len); - fsname[fsname_len] = '\0'; + snprintf(fsname, fsname_len + 1, "%s", param); if (!ptr) return 0; -- 1.8.3.1