From f0cce1c6cacc85f658b4d5abb84bc5fbd8306a38 Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Sat, 25 May 2024 17:20:38 -0600 Subject: [PATCH] LU-17878 build: compatibility updates for kernel 6.9 Linux v6.8-2-ga8922f79671f ceph: remove SLAB_MEM_SPREAD flag usage Provide a replacement for older kernels when SLAB_MEM_SPREAD is not defined. Linux v6.8-rc1-47-gc69ff4071935 filelock: split leases out of struct file_lock Provide abstractions for: flc_type, flc_pid, flc_file, flc_flags, and flc_owner Test-Parameters: trivial HPE-bug-id: LUS-12363 Signed-off-by: Shaun Tancheff Change-Id: Ide457ba29fc2d3537f074fe9a66cf0c8567f7621 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55201 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Jian Yu Reviewed-by: Oleg Drokin --- lustre/autoconf/lustre-core.m4 | 29 +++++++++++++++++++++++++++++ lustre/include/lustre_compat.h | 18 ++++++++++++++++++ lustre/ldlm/ldlm_flock.c | 14 +++++++------- lustre/llite/file.c | 36 ++++++++++++++++++------------------ 4 files changed, 72 insertions(+), 25 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 3edf81e..1070ce6 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -4541,6 +4541,29 @@ AC_DEFUN([LC_HAVE_GENERIC_ERROR_REMOVE_FOLIO], [ ]) # LC_HAVE_GENERIC_ERROR_REMOVE_FOLIO # +# LC_HAVE_STRUCT_FILE_LOCK_CORE +# +# Linux commit v6.7-rc4-79-gaf7628d6ec19 +# fs: convert error_remove_page to error_remove_folio +# +AC_DEFUN([LC_SRC_HAVE_STRUCT_FILE_LOCK_CORE], [ + LB2_LINUX_TEST_SRC([struct_file_lock_core], [ + #include + ],[ + struct file_lock_core *flc = NULL; + + flc->flc_flags = 0; + ],[-Werror]) +]) +AC_DEFUN([LC_HAVE_STRUCT_FILE_LOCK_CORE], [ + LB2_MSG_LINUX_TEST_RESULT([if struct file_lock_core exists], + [struct_file_lock_core], [ + AC_DEFINE(HAVE_STRUCT_FILE_LOCK_CORE, 1, + [struct file_lock_core exists]) + ]) +]) # LC_HAVE_STRUCT_FILE_LOCK_CORE + +# # LC_PROG_LINUX # # Lustre linux kernel checks @@ -4831,6 +4854,9 @@ AC_DEFUN([LC_PROG_LINUX_SRC], [ LC_SRC_HAVE_GENERIC_ERROR_REMOVE_FOLIO LC_SRC_LSMCONTEXT_HAS_ID + # 6.9 + LC_SRC_HAVE_STRUCT_FILE_LOCK_CORE + # kernel patch to extend integrity interface LC_SRC_BIO_INTEGRITY_PREP_FN ]) @@ -5142,6 +5168,9 @@ AC_DEFUN([LC_PROG_LINUX_RESULTS], [ LC_HAVE_GENERIC_ERROR_REMOVE_FOLIO LC_LSMCONTEXT_HAS_ID + # 6.9 + LC_HAVE_STRUCT_FILE_LOCK_CORE + # 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 7c547a7..f9140a7 100644 --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -96,6 +96,24 @@ #define bi_opf bi_rw #endif +#ifndef SLAB_MEM_SPREAD +#define SLAB_MEM_SPREAD 0 +#endif + +#ifdef HAVE_STRUCT_FILE_LOCK_CORE +#define C_FLC_TYPE c.flc_type +#define C_FLC_PID c.flc_pid +#define C_FLC_FILE c.flc_file +#define C_FLC_FLAGS c.flc_flags +#define C_FLC_OWNER c.flc_owner +#else +#define C_FLC_TYPE fl_type +#define C_FLC_PID fl_pid +#define C_FLC_FILE fl_file +#define C_FLC_FLAGS fl_flags +#define C_FLC_OWNER fl_owner +#endif + static inline struct bio *cfs_bio_alloc(struct block_device *bdev, unsigned short nr_vecs, __u32 op, gfp_t gfp_mask) diff --git a/lustre/ldlm/ldlm_flock.c b/lustre/ldlm/ldlm_flock.c index 14a182b..a289ee0 100644 --- a/lustre/ldlm/ldlm_flock.c +++ b/lustre/ldlm/ldlm_flock.c @@ -818,7 +818,7 @@ granted: LASSERT(ldlm_is_test_lock(lock)); if (ldlm_is_test_lock(lock) || ldlm_is_flock_deadlock(lock)) - mode = getlk->fl_type; + mode = getlk->C_FLC_TYPE; else mode = lock->l_req_mode; @@ -844,22 +844,22 @@ granted: if (flags & LDLM_FL_TEST_LOCK) { /* * fcntl(F_GETLK) request - * The old mode was saved in getlk->fl_type so that if the mode + * The old mode was saved in getlk->C_FLC_TYPE so that if the mode * in the lock changes we can decref the appropriate refcount. */ LASSERT(ldlm_is_test_lock(lock)); - ldlm_flock_destroy(lock, getlk->fl_type, LDLM_FL_WAIT_NOREPROC); + ldlm_flock_destroy(lock, getlk->C_FLC_TYPE, LDLM_FL_WAIT_NOREPROC); switch (lock->l_granted_mode) { case LCK_PR: - getlk->fl_type = F_RDLCK; + getlk->C_FLC_TYPE = F_RDLCK; break; case LCK_PW: - getlk->fl_type = F_WRLCK; + getlk->C_FLC_TYPE = F_WRLCK; break; default: - getlk->fl_type = F_UNLCK; + getlk->C_FLC_TYPE = F_UNLCK; } - getlk->fl_pid = (pid_t)lock->l_policy_data.l_flock.pid; + getlk->C_FLC_PID = (pid_t)lock->l_policy_data.l_flock.pid; getlk->fl_start = (loff_t)lock->l_policy_data.l_flock.start; getlk->fl_end = (loff_t)lock->l_policy_data.l_flock.end; } else { diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 222026c..8ca7720 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -5225,7 +5225,7 @@ ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) struct lustre_handle lockh = { 0 }; union ldlm_policy_data flock = { { 0 } }; struct file_lock flbuf = *file_lock; - int fl_type = file_lock->fl_type; + int fl_type = file_lock->C_FLC_TYPE; ktime_t kstart = ktime_get(); __u64 flags = 0; int rc; @@ -5235,20 +5235,20 @@ ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID" file_lock=%p\n", PFID(ll_inode2fid(inode)), file_lock); - if (file_lock->fl_flags & FL_FLOCK) { + if (file_lock->C_FLC_FLAGS & FL_FLOCK) { LASSERT((cmd == F_SETLKW) || (cmd == F_SETLK)); /* flocks are whole-file locks */ flock.l_flock.end = OFFSET_MAX; /* For flocks owner is determined by the local file desctiptor*/ - flock.l_flock.owner = (unsigned long)file_lock->fl_file; - } else if (file_lock->fl_flags & FL_POSIX) { - flock.l_flock.owner = (unsigned long)file_lock->fl_owner; + flock.l_flock.owner = (unsigned long)file_lock->C_FLC_FILE; + } else if (file_lock->C_FLC_FLAGS & FL_POSIX) { + flock.l_flock.owner = (unsigned long)file_lock->C_FLC_OWNER; flock.l_flock.start = file_lock->fl_start; flock.l_flock.end = file_lock->fl_end; } else { RETURN(-EINVAL); } - flock.l_flock.pid = file_lock->fl_pid; + flock.l_flock.pid = file_lock->C_FLC_PID; #if defined(HAVE_LM_COMPARE_OWNER) || defined(lm_compare_owner) /* Somewhat ugly workaround for svc lockd. @@ -5259,7 +5259,7 @@ ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) * conflict with normal locks is unlikely since pid space and * pointer space for current->files are not intersecting */ if (file_lock->fl_lmops && file_lock->fl_lmops->lm_compare_owner) - flock.l_flock.owner = (unsigned long)file_lock->fl_pid; + flock.l_flock.owner = (unsigned long)file_lock->C_FLC_PID; #endif switch (fl_type) { @@ -5320,7 +5320,7 @@ ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) /* Save the old mode so that if the mode in the lock changes we * can decrement the appropriate reader or writer refcount. */ - file_lock->fl_type = einfo.ei_mode; + file_lock->C_FLC_TYPE = einfo.ei_mode; op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); @@ -5337,23 +5337,23 @@ ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) /* Restore the file lock type if not TEST lock. */ if (!(flags & LDLM_FL_TEST_LOCK)) - file_lock->fl_type = fl_type; + file_lock->C_FLC_TYPE = fl_type; #ifdef HAVE_LOCKS_LOCK_FILE_WAIT - if ((rc == 0 || file_lock->fl_type == F_UNLCK) && + if ((rc == 0 || file_lock->C_FLC_TYPE == F_UNLCK) && !(flags & LDLM_FL_TEST_LOCK)) rc2 = locks_lock_file_wait(file, file_lock); #else - if ((file_lock->fl_flags & FL_FLOCK) && - (rc == 0 || file_lock->fl_type == F_UNLCK)) + if ((file_lock->C_FLC_FLAGS & FL_FLOCK) && + (rc == 0 || file_lock->C_FLC_TYPE == F_UNLCK)) rc2 = flock_lock_file_wait(file, file_lock); - if ((file_lock->fl_flags & FL_POSIX) && - (rc == 0 || file_lock->fl_type == F_UNLCK) && + if ((file_lock->C_FLC_FLAGS & FL_POSIX) && + (rc == 0 || file_lock->C_FLC_TYPE == F_UNLCK) && !(flags & LDLM_FL_TEST_LOCK)) rc2 = posix_lock_file_wait(file, file_lock); #endif /* HAVE_LOCKS_LOCK_FILE_WAIT */ - if (rc2 && file_lock->fl_type != F_UNLCK) { + if (rc2 && file_lock->C_FLC_TYPE != F_UNLCK) { einfo.ei_mode = LCK_NL; md_enqueue(sbi->ll_md_exp, &einfo, &flock, op_data, &lockh, flags); @@ -5363,14 +5363,14 @@ ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) ll_finish_md_op_data(op_data); if (rc == 0 && (flags & LDLM_FL_TEST_LOCK) && - flbuf.fl_type != file_lock->fl_type) { /* Verify local & remote */ + flbuf.C_FLC_TYPE != file_lock->C_FLC_TYPE) { /* Verify local & remote */ CERROR("Flock LR mismatch! inode="DFID", flags=%#llx, mode=%u, " "pid=%u/%u, start=%llu/%llu, end=%llu/%llu,type=%u/%u\n", PFID(ll_inode2fid(inode)), flags, einfo.ei_mode, - file_lock->fl_pid, flbuf.fl_pid, + file_lock->C_FLC_PID, flbuf.C_FLC_PID, file_lock->fl_start, flbuf.fl_start, file_lock->fl_end, flbuf.fl_end, - file_lock->fl_type, flbuf.fl_type); + file_lock->C_FLC_TYPE, flbuf.C_FLC_TYPE); /* return local */ *file_lock = flbuf; } -- 1.8.3.1