diff -ur lustre-2.16.1/libcfs/include/libcfs/libcfs.h lustre-2.16.1a/libcfs/include/libcfs/libcfs.h --- lustre-2.16.1/libcfs/include/libcfs/libcfs.h 2024-11-16 09:28:42.000000000 +0800 +++ lustre-2.16.1a/libcfs/include/libcfs/libcfs.h 2025-12-19 19:47:16.757020811 +0800 @@ -77,7 +77,7 @@ 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 -ur lustre-2.16.1/libcfs/libcfs/module.c lustre-2.16.1a/libcfs/libcfs/module.c --- lustre-2.16.1/libcfs/libcfs/module.c 2024-11-16 09:28:42.000000000 +0800 +++ lustre-2.16.1a/libcfs/libcfs/module.c 2025-12-19 19:47:16.801021658 +0800 @@ -100,7 +100,7 @@ EXPORT_SYMBOL(libcfs_ioctl); #endif -static int proc_dobitmasks(struct ctl_table *table, int write, +static int proc_dobitmasks(const struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { const int tmpstrlen = 512; @@ -143,7 +143,7 @@ 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, +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,7 +154,7 @@ return cfs_trace_dump_debug_buffer_usrstr(buffer, nob); } -static int proc_daemon_file(struct ctl_table *table, int write, +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; @@ -173,7 +173,7 @@ return cfs_trace_daemon_command_usrstr(buffer, nob); } -static int libcfs_force_lbug(struct ctl_table *table, int write, +static int libcfs_force_lbug(const struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { @@ -182,7 +182,7 @@ return 0; } -static int proc_fail_loc(struct ctl_table *table, int write, +static int proc_fail_loc(const struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { int rc; @@ -220,7 +220,7 @@ return rc; } -static int libcfs_debug_marker(struct ctl_table *table, int write, +static int libcfs_debug_marker(const struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { @@ -250,7 +250,7 @@ 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 +293,7 @@ } 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,7 +331,7 @@ return rc; } -static int debugfs_dostring(struct ctl_table *table, int write, +static int debugfs_dostring(const struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { int len = *lenp; diff -ur lustre-2.16.1/lnet/lnet/lnet_debugfs.c lustre-2.16.1a/lnet/lnet/lnet_debugfs.c --- lustre-2.16.1/lnet/lnet/lnet_debugfs.c 2024-11-16 09:28:42.000000000 +0800 +++ lustre-2.16.1a/lnet/lnet/lnet_debugfs.c 2025-12-19 19:47:16.517016189 +0800 @@ -60,7 +60,7 @@ #define LNET_PROC_VERSION(v) ((unsigned int)((v) & LNET_PROC_VER_MASK)) -static int proc_cpt_table(struct ctl_table *table, int write, +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; @@ -100,7 +100,7 @@ return rc; } -static int proc_cpt_distance(struct ctl_table *table, int write, +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; @@ -140,7 +140,7 @@ return rc; } -static int proc_lnet_stats(struct ctl_table *table, int write, +static int proc_lnet_stats(const struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { int rc; @@ -189,7 +189,7 @@ } static int -proc_lnet_routes(struct ctl_table *table, int write, void __user *buffer, +proc_lnet_routes(const struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { const int tmpsiz = 256; @@ -315,7 +315,7 @@ } static int -proc_lnet_routers(struct ctl_table *table, int write, void __user *buffer, +proc_lnet_routers(const struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { int rc = 0; @@ -420,7 +420,7 @@ /* 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, +proc_lnet_peers(const struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { const int tmpsiz = 256; @@ -597,7 +597,7 @@ return rc; } -static int proc_lnet_buffers(struct ctl_table *table, int write, +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; @@ -658,7 +658,7 @@ } static int -proc_lnet_nis(struct ctl_table *table, int write, void __user *buffer, +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; @@ -837,7 +837,7 @@ }, }; -static int proc_lnet_portal_rotor(struct ctl_table *table, int write, +static int proc_lnet_portal_rotor(const struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { diff -ur lustre-2.16.1/lustre/llite/dir.c lustre-2.16.1a/lustre/llite/dir.c --- lustre-2.16.1/lustre/llite/dir.c 2024-11-16 09:28:42.000000000 +0800 +++ lustre-2.16.1a/lustre/llite/dir.c 2025-12-19 19:47:16.317012338 +0800 @@ -2932,7 +2932,7 @@ else lfd->lfd_pos = offset; file->f_pos = offset; - file->f_version = 0; +// file->f_version = 0; } ret = offset; } diff -ur lustre-2.16.1/lustre/llite/llite_lib.c lustre-2.16.1a/lustre/llite/llite_lib.c --- lustre-2.16.1/lustre/llite/llite_lib.c 2024-11-16 09:28:42.000000000 +0800 +++ lustre-2.16.1a/lustre/llite/llite_lib.c 2025-12-19 19:47:16.313012261 +0800 @@ -3105,8 +3105,12 @@ unsigned long nrpages; unsigned long flags; +// LASSERTF((inode->i_state & I_FREEING) || inode_is_locked(inode), +// DFID ":inode %px state %#lx, lli_flags %#lx\n", +// PFID(ll_inode2fid(inode)), inode, inode->i_state, +// ll_i2info(inode)->lli_flags); LASSERTF((inode->i_state & I_FREEING) || inode_is_locked(inode), - DFID ":inode %px state %#lx, lli_flags %#lx\n", + DFID ":inode %px state %d, lli_flags %#lx\n", PFID(ll_inode2fid(inode)), inode, inode->i_state, ll_i2info(inode)->lli_flags); @@ -3133,7 +3137,8 @@ XA_STATE(xas, &mapping->i_pages, 0); struct page *page; #endif - CWARN("%s: inode="DFID"(%p) nrpages=%lu state %#lx, lli_flags %#lx, see https://jira.whamcloud.com/browse/LU-118\n", +// CWARN("%s: inode="DFID"(%p) nrpages=%lu state %#lx, lli_flags %#lx, see https://jira.whamcloud.com/browse/LU-118\n", + CWARN("%s: inode="DFID"(%p) nrpages=%lu state %d, lli_flags %#lx, see https://jira.whamcloud.com/browse/LU-118\n", ll_i2sbi(inode)->ll_fsname, PFID(ll_inode2fid(inode)), inode, nrpages, inode->i_state, ll_i2info(inode)->lli_flags); diff -ur lustre-2.16.1/lustre/llite/rw26.c lustre-2.16.1a/lustre/llite/rw26.c --- lustre-2.16.1/lustre/llite/rw26.c 2024-11-16 09:28:42.000000000 +0800 +++ lustre-2.16.1a/lustre/llite/rw26.c 2025-12-19 19:47:16.293011876 +0800 @@ -799,7 +799,8 @@ #ifdef HAVE_GRAB_CACHE_PAGE_WRITE_BEGIN_WITH_FLAGS unsigned int flags, #endif - struct page **pagep, void **fsdata) +// struct page **pagep, void **fsdata) + struct folio **pagefoliop, void **fsdata) { struct ll_cl_context *lcc = NULL; const struct lu_env *env = NULL; @@ -940,7 +941,8 @@ if (io) io->ci_result = result; } else { - *pagep = vmpage; +// *pagep = vmpage; + *pagefoliop = page_folio(vmpage); *fsdata = lcc; } RETURN(result); @@ -989,18 +991,21 @@ static int ll_write_end(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned copied, - struct page *vmpage, void *fsdata) + struct folio *pagefolio, void *fsdata) +// struct page *vmpage, void *fsdata) { struct ll_cl_context *lcc = fsdata; const struct lu_env *env; struct cl_io *io; struct vvp_io *vio; struct cl_page *page; + struct page *vmpage; unsigned from = pos & (PAGE_SIZE - 1); bool unplug = false; int result = 0; ENTRY; + vmpage = folio_page(pagefolio, 0); put_page(vmpage); CDEBUG(D_VFSTRACE, "pos %llu, len %u, copied %u\n", pos, len, copied); diff -ur lustre-2.16.1/lustre/llite/rw.c lustre-2.16.1a/lustre/llite/rw.c --- lustre-2.16.1/lustre/llite/rw.c 2024-11-16 09:28:42.000000000 +0800 +++ lustre-2.16.1a/lustre/llite/rw.c 2025-12-19 19:47:16.309012184 +0800 @@ -1503,7 +1503,8 @@ * but not in case when IO has actually * occurred and completed with an error. */ - if (!PageError(vmpage)) { +// if (!PageError(vmpage)) { + if (!IS_ERR(vmpage)) { redirty_page_for_writepage(wbc, vmpage); result = 0; redirtied = true; @@ -1545,7 +1546,7 @@ if (result < 0) { if (!lli->lli_async_rc) lli->lli_async_rc = result; - SetPageError(vmpage); +// SetPageError(vmpage); if (!unlocked) unlock_page(vmpage); } diff -ur lustre-2.16.1/lustre/llite/vvp_dev.c lustre-2.16.1a/lustre/llite/vvp_dev.c --- lustre-2.16.1/lustre/llite/vvp_dev.c 2024-11-16 09:28:42.000000000 +0800 +++ lustre-2.16.1a/lustre/llite/vvp_dev.c 2025-12-19 19:47:16.301012030 +0800 @@ -487,7 +487,7 @@ page_count(vmpage)); has_flags = 0; seq_page_flag(seq, vmpage, locked, has_flags); - seq_page_flag(seq, vmpage, error, has_flags); +// seq_page_flag(seq, vmpage, error, has_flags); seq_page_flag(seq, vmpage, referenced, has_flags); seq_page_flag(seq, vmpage, uptodate, has_flags); seq_page_flag(seq, vmpage, dirty, has_flags); diff -ur lustre-2.16.1/lustre/llite/vvp_io.c lustre-2.16.1a/lustre/llite/vvp_io.c --- lustre-2.16.1/lustre/llite/vvp_io.c 2024-11-16 09:28:42.000000000 +0800 +++ lustre-2.16.1a/lustre/llite/vvp_io.c 2025-12-19 19:47:16.293011876 +0800 @@ -993,9 +993,12 @@ struct address_space *mapping) { #ifndef HAVE_RADIX_TREE_TAG_SET - __xa_set_mark(&mapping->i_pages, page_index(page), PAGECACHE_TAG_DIRTY); +// __xa_set_mark(&mapping->i_pages, page_index(page), PAGECACHE_TAG_DIRTY); + __xa_set_mark(&mapping->i_pages, page->index, PAGECACHE_TAG_DIRTY); #else - radix_tree_tag_set(&mapping->page_tree, page_index(page), +// radix_tree_tag_set(&mapping->page_tree, page_index(page), +// PAGECACHE_TAG_DIRTY); + radix_tree_tag_set(&mapping->page_tree, page->index, PAGECACHE_TAG_DIRTY); #endif } diff -ur lustre-2.16.1/lustre/llite/vvp_page.c lustre-2.16.1a/lustre/llite/vvp_page.c --- lustre-2.16.1/lustre/llite/vvp_page.c 2024-11-16 09:28:42.000000000 +0800 +++ lustre-2.16.1a/lustre/llite/vvp_page.c 2025-12-19 19:47:16.321012415 +0800 @@ -113,10 +113,10 @@ struct vvp_object *obj = cl_inode2vvp(inode); if (ioret == 0) { - ClearPageError(vmpage); +// ClearPageError(vmpage); obj->vob_discard_page_warned = 0; } else { - SetPageError(vmpage); +// SetPageError(vmpage); if (CFS_FAIL_CHECK(OBD_FAIL_LLITE_PANIC_ON_ESTALE)) LASSERTF(ioret == -ENOSPC, "%s:"DFID" got a stale page %p: rc = %d.\n", diff -ur lustre-2.16.1/lustre/mdc/mdc_locks.c lustre-2.16.1a/lustre/mdc/mdc_locks.c --- lustre-2.16.1/lustre/mdc/mdc_locks.c 2024-11-16 09:28:42.000000000 +0800 +++ lustre-2.16.1a/lustre/mdc/mdc_locks.c 2025-12-19 19:47:14.776982685 +0800 @@ -98,8 +98,13 @@ lock->l_resource->lr_lvb_inode != data) { struct inode *old_inode = lock->l_resource->lr_lvb_inode; +// LASSERTF(old_inode->i_state & I_FREEING, +// "Found existing inode %px/%lu/%u state %lu in lock: setting data to %px/%lu/%u\n", +// old_inode, old_inode->i_ino, old_inode->i_generation, +// old_inode->i_state, +// new_inode, new_inode->i_ino, new_inode->i_generation); LASSERTF(old_inode->i_state & I_FREEING, - "Found existing inode %px/%lu/%u state %lu in lock: setting data to %px/%lu/%u\n", + "Found existing inode %px/%lu/%u state %d in lock: setting data to %px/%lu/%u\n", old_inode, old_inode->i_ino, old_inode->i_generation, old_inode->i_state, new_inode, new_inode->i_ino, new_inode->i_generation); diff -ur lustre-2.16.1/lustre/mdc/mdc_request.c lustre-2.16.1a/lustre/mdc/mdc_request.c --- lustre-2.16.1/lustre/mdc/mdc_request.c 2024-11-16 09:28:42.000000000 +0800 +++ lustre-2.16.1a/lustre/mdc/mdc_request.c 2025-12-19 19:47:14.784982838 +0800 @@ -1509,7 +1509,9 @@ } if (!PageChecked(page)) SetPageChecked(page); - if (PageError(page)) { +// if (PageError(page)) { + + if (IS_ERR(page)) { CERROR("%s: page error: "DFID" at %llu: rc %d\n", exp->exp_obd->obd_name, PFID(&op_data->op_fid1), rp_param.rp_off, -5); diff -ur lustre-2.16.1/lustre/obdclass/cl_page.c lustre-2.16.1a/lustre/obdclass/cl_page.c --- lustre-2.16.1/lustre/obdclass/cl_page.c 2024-11-16 09:28:42.000000000 +0800 +++ lustre-2.16.1a/lustre/obdclass/cl_page.c 2025-12-19 19:47:16.097008102 +0800 @@ -1083,6 +1083,19 @@ } EXPORT_SYMBOL(cl_page_header_print); +static inline int folio_precise_page_mapcount(struct folio *folio, + struct page *page) +{ + int mapcount = atomic_read(&page->_mapcount) + 1; + + if (page_mapcount_is_type(mapcount)) + mapcount = 0; + if (folio_test_large(folio)) + mapcount += folio_entire_mapcount(folio); + + return mapcount; +} + /* Prints human readable representation of \a cl_page to the \a f. */ void cl_page_print(const struct lu_env *env, void *cookie, lu_printer_t printer, const struct cl_page *cp) @@ -1097,10 +1110,17 @@ (*printer)(env, cookie, "vmpage @%p", vmpage); 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), +// list_empty(&vmpage->lru) ? "not-" : ""); (*printer)(env, cookie, " %lx %d:%d %lx %lu %slru", (long)vmpage->flags, page_count(vmpage), - page_mapcount(vmpage), vmpage->private, - page_index(vmpage), + folio_precise_page_mapcount(page_folio(vmpage), + vmpage), + vmpage->private, + vmpage->index, list_empty(&vmpage->lru) ? "not-" : ""); } diff -ur lustre-2.16.1/lustre/osc/osc_page.c lustre-2.16.1a/lustre/osc/osc_page.c --- lustre-2.16.1/lustre/osc/osc_page.c 2024-11-16 09:28:42.000000000 +0800 +++ lustre-2.16.1a/lustre/osc/osc_page.c 2025-12-19 19:47:14.988986766 +0800 @@ -515,6 +515,19 @@ * for recovery so we need to check vmpage refcount as well; otherwise, * even we can destroy cl_page but the corresponding vmpage can't be reused. */ +static inline int folio_precise_page_mapcount(struct folio *folio, + struct page *page) +{ + int mapcount = atomic_read(&page->_mapcount) + 1; + + if (page_mapcount_is_type(mapcount)) + mapcount = 0; + if (folio_test_large(folio)) + mapcount += folio_entire_mapcount(folio); + + return mapcount; +} + static inline bool lru_page_busy(struct client_obd *cli, struct cl_page *page) { if (cl_page_in_use_noref(page)) @@ -524,7 +537,10 @@ 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) - page_mapcount(vmpage) > 2) + + if (page_count(vmpage) - + folio_precise_page_mapcount(page_folio(vmpage), vmpage) > 2) return true; } return false; @@ -535,7 +551,13 @@ */ static inline bool lru_page_unevictable(struct cl_page *clpage) { - return PageMlocked(cl_page_vmpage(clpage)); +// return PageMlocked(cl_page_vmpage(clpage)); + + struct folio *folio = page_folio(cl_page_vmpage(clpage)); + bool ret; + ret = !mapping_unevictable(folio_mapping(folio)) && + !folio_test_mlocked(folio); + return !ret; } enum shrink_action { diff -ur lustre-2.16.1/lustre/tests/lutf/swig_templates/typemap.template lustre-2.16.1a/lustre/tests/lutf/swig_templates/typemap.template --- lustre-2.16.1/lustre/tests/lutf/swig_templates/typemap.template 2024-11-16 09:28:42.000000000 +0800 +++ lustre-2.16.1a/lustre/tests/lutf/swig_templates/typemap.template 2025-12-19 19:47:15.372994161 +0800 @@ -120,7 +120,7 @@ if (*$1 == NULL) goto fail; obj = PyUnicode_FromString(*$1); - $result = SWIG_Python_AppendOutput($result,obj); + $result = SWIG_Python_AppendOutput($result,obj,0); %} /* The malloc'ed pointer is no longer needed, so make sure it is freed. */ diff -ur lustre-2.16.1/lustre/utils/obd.c lustre-2.16.1a/lustre/utils/obd.c --- lustre-2.16.1/lustre/utils/obd.c 2024-11-16 09:28:42.000000000 +0800 +++ lustre-2.16.1a/lustre/utils/obd.c 2025-12-19 19:47:16.021006639 +0800 @@ -5090,7 +5090,8 @@ return -ENAMETOOLONG; } - strncpy(fsname, param, fsname_len); +// strncpy(fsname, param, fsname_len); + strncpy(fsname, param, LUSTRE_MAXFSNAME); fsname[fsname_len] = '\0'; if (!ptr) return 0;