From 7f199fc3fb3a7cd24d140fa6878119c5d962f201 Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Mon, 13 Nov 2023 23:30:26 -0800 Subject: [PATCH] LU-16802 build: compatibility for 6.4 kernels linux kernel v6.3-rc4-32-g6eb203e1a868 iov_iter: remove iov_iter_iovec() Provide a replacement iov_iter_iovec() when one is not provided. linux kernel v6.3-rc4-34-g747b1f65d39a iov_iter: overlay struct iovec and ubuf/len This renames iov_iter member iov to __iov and provides the iov_iter() accessor. Define __iov as iov when __iov not present. Provide an iov_iter() for older kernels. linux kernel v6.3-rc1-13-g1aaba11da9aa driver core: class: remove module * from class_create() Provide an ll_class_create() to pass THIS_MODULE, or not, as needed by class_create(). Linux commit v6.2-rc1-20-gf861646a6562 quota: port to mnt_idmap Update osd_dquot_transfer to use mnt_idmap and fallback to user_ns, if needed, by dquot_transfer. Linux commit v6.3-rc7-2433-gcf64b9bce950 SUNRPC: return proper error from get_expiry() Updated get_expiry() requires a time64_t pointer to be passed to hold the expiry time. A non-zero return value indicates an error, nominally -EINVAL. Provide a wrapper for kernels that return a time64_t and return -EINVAL on error. Lustre-change: https://review.whamcloud.com/c/fs/lustre-release/+/50875 Lustre-commit: 2559c3a7a2c64b31baae1cba2ede6c4415ddc04d Test-Parameters: trivial HPE-bug-id: LUS-11614 Signed-off-by: Shaun Tancheff Change-Id: I765d6257eec8b5a9bf1bd5947f03370eb9df1625 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53128 Reviewed-by: Oleg Drokin Tested-by: jenkins Tested-by: Maloo --- lustre/autoconf/lustre-core.m4 | 124 +++++++++++++++++++++++++++- lustre/include/lustre_compat.h | 18 +++-- lustre/mdc/mdc_request.c | 2 +- lustre/ofd/ofd_access_log.c | 2 +- lustre/ptlrpc/gss/gss_svc_upcall.c | 161 ++++++++++++++++++++----------------- 5 files changed, 221 insertions(+), 86 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index aeac7e3..a1352cb 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -3250,7 +3250,7 @@ AC_DEFUN([LC_SRC_REGISTER_SHRINKER_FORMAT_NAMED], [ ]) AC_DEFUN([LC_REGISTER_SHRINKER_FORMAT_NAMED], [ AC_MSG_CHECKING([if register_shrinker() returns status]) - LB2_LINUX_TEST_RESULT([address_space_operations_migrate_folio], [ + LB2_LINUX_TEST_RESULT([register_shrinker_format], [ AC_DEFINE(HAVE_REGISTER_SHRINKER_FORMAT_NAMED, 1, [register_shrinker() returns status]) ]) @@ -3315,6 +3315,116 @@ AC_DEFUN([LC_HAVE_IOV_ITER_GET_PAGES_ALLOC2], [ ]) # LC_HAVE_IOV_ITER_GET_PAGES_ALLOC2 # +# LC_HAVE_IOV_ITER_IOVEC +# +# linux kernel v6.3-rc4-32-g6eb203e1a868 +# iov_iter: remove iov_iter_iovec() +# +AC_DEFUN([LC_SRC_HAVE_IOV_ITER_IOVEC], [ + LB2_LINUX_TEST_SRC([iov_iter_iovec_exists], [ + #include + ],[ + struct iovec iov __attribute__ ((unused)); + struct iov_iter i = { }; + + iov = iov_iter_iovec(&i); + ],[-Werror]) +]) +AC_DEFUN([LC_HAVE_IOV_ITER_IOVEC], [ + AC_MSG_CHECKING([if 'iov_iter_iovec' is available]) + LB2_LINUX_TEST_RESULT([iov_iter_iovec_exists], [ + AC_DEFINE(HAVE_IOV_ITER_IOVEC, 1, + ['iov_iter_iovec' is available]) + ]) +]) # LC_HAVE_IOV_ITER_IOVEC + +# +# LC_HAVE_IOVEC_WITH_IOV_MEMBER +# +# linux kernel v6.3-rc4-34-g747b1f65d39a +# iov_iter: overlay struct iovec and ubuf/len +# This renames iov_iter member iov to __iov and now __iov == __ubuf_iovec +# And provides the iov_iter() accessor to return __iov or __ubuf_iovec +# +AC_DEFUN([LC_SRC_HAVE_IOVEC_WITH_IOV_MEMBER], [ + LB2_LINUX_TEST_SRC([iov_iter_has___iov_member], [ + #include + ],[ + struct iov_iter iter = { }; + size_t len __attribute__ ((unused)); + + len = iter.__iov->iov_len; + ],[-Werror]) +]) +AC_DEFUN([LC_HAVE_IOVEC_WITH_IOV_MEMBER], [ + AC_MSG_CHECKING([if 'iov_iter_iovec' is available]) + LB2_LINUX_TEST_RESULT([iov_iter_has___iov_member], [ + AC_DEFINE(HAVE___IOV_MEMBER, __iov, + ['struct iov_iter' has '__iov' member]) + AC_DEFINE(HAVE_ITER_IOV, 1, + [iter_iov() is available]) + ],[ + AC_DEFINE(iter_iov(iter), (iter)->__iov, + ['iov_iter()' provides iov]) + AC_DEFINE(__iov, iov, + ['struct iov_iter' has 'iov' member]) + ]) +]) # LC_HAVE_IOVEC_WITH_IOV_MEMBER + +# +# LC_HAVE_CLASS_CREATE_MODULE_ARG +# +# linux kernel v6.3-rc1-13-g1aaba11da9aa +# driver core: class: remove module * from class_create() +# +AC_DEFUN([LC_SRC_HAVE_CLASS_CREATE_MODULE_ARG], [ + LB2_LINUX_TEST_SRC([class_create_without_module_arg], [ + #include + ],[ + struct class *class __attribute__ ((unused)); + + class = class_create("empty"); + if (IS_ERR(class)) + /* checked */; + ],[-Werror]) +]) +AC_DEFUN([LC_HAVE_CLASS_CREATE_MODULE_ARG], [ + AC_MSG_CHECKING([if 'class_create' does not have module arg]) + LB2_LINUX_TEST_RESULT([class_create_without_module_arg], [ + AC_DEFINE([ll_class_create(name)], + [class_create((name))], + ['class_create' does not have module arg]) + ],[ + AC_DEFINE([ll_class_create(name)], + [class_create(THIS_MODULE, (name))], + ['class_create' expects module arg]) + ]) +]) # LC_HAVE_CLASS_CREATE_MODULE_ARG + +# +# LC_HAVE_GET_EXPIRY_TIME64_T +# +# linux kernel v6.3-rc7-2433-gcf64b9bce950 +# SUNRPC: return proper error from get_expiry() +# +AC_DEFUN([LC_SRC_HAVE_GET_EXPIRY_TIME64_T], [ + LB2_LINUX_TEST_SRC([get_expiry_with_time64_t], [ + #include + ],[ + int err __attribute__ ((unused)); + + err = get_expiry((char **)NULL, (time64_t *)NULL); + ],[-Werror]) +]) +AC_DEFUN([LC_HAVE_GET_EXPIRY_TIME64_T], [ + AC_MSG_CHECKING([if 'get_expiry' needs a time64_t arg]) + LB2_LINUX_TEST_RESULT([get_expiry_with_time64_t], [ + AC_DEFINE(HAVE_GET_EXPIRY_2ARGS, 1, + ['get_expiry' takes time64_t]) + ]) +]) # LC_HAVE_GET_EXPIRY_TIME64_T + +# # LC_PROG_LINUX # # Lustre linux kernel checks @@ -3535,6 +3645,12 @@ AC_DEFUN([LC_PROG_LINUX_SRC], [ LC_SRC_HAVE_VFS_SETXATTR_NON_CONST_VALUE LC_SRC_HAVE_IOV_ITER_GET_PAGES_ALLOC2 + # 6.4 + LC_SRC_HAVE_IOV_ITER_IOVEC + LC_SRC_HAVE_IOVEC_WITH_IOV_MEMBER + LC_SRC_HAVE_CLASS_CREATE_MODULE_ARG + LC_SRC_HAVE_GET_EXPIRY_TIME64_T + # kernel patch to extend integrity interface LC_SRC_BIO_INTEGRITY_PREP_FN ]) @@ -3767,6 +3883,12 @@ AC_DEFUN([LC_PROG_LINUX_RESULTS], [ LC_HAVE_VFS_SETXATTR_NON_CONST_VALUE LC_HAVE_IOV_ITER_GET_PAGES_ALLOC2 + # 6.4 + LC_HAVE_IOV_ITER_IOVEC + LC_HAVE_IOVEC_WITH_IOV_MEMBER + LC_HAVE_CLASS_CREATE_MODULE_ARG + LC_HAVE_GET_EXPIRY_TIME64_T + # 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 e1d4e91..8169052 100644 --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -258,20 +258,22 @@ static inline void iov_iter_truncate(struct iov_iter *i, u64 count) # define SB_NODIRATIME MS_NODIRATIME #endif -#ifndef HAVE_FILE_OPERATIONS_READ_WRITE_ITER -static inline void iov_iter_reexpand(struct iov_iter *i, size_t count) -{ - i->count = count; -} - +#ifndef HAVE_IOV_ITER_IOVEC static inline struct iovec iov_iter_iovec(const struct iov_iter *iter) { return (struct iovec) { - .iov_base = iter->iov->iov_base + iter->iov_offset, + .iov_base = iter->__iov->iov_base + iter->iov_offset, .iov_len = min(iter->count, - iter->iov->iov_len - iter->iov_offset), + iter->__iov->iov_len - iter->iov_offset), }; } +#endif + +#ifndef HAVE_FILE_OPERATIONS_READ_WRITE_ITER +static inline void iov_iter_reexpand(struct iov_iter *i, size_t count) +{ + i->count = count; +} #define iov_for_each(iov, iter, start) \ for (iter = (start); \ diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 662a87c..5af81a4 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -3009,7 +3009,7 @@ static int __init mdc_init(void) if (rc) return rc; - mdc_changelog_class = class_create(THIS_MODULE, MDC_CHANGELOG_DEV_NAME); + mdc_changelog_class = ll_class_create(MDC_CHANGELOG_DEV_NAME); if (IS_ERR(mdc_changelog_class)) { rc = PTR_ERR(mdc_changelog_class); goto out_dev; diff --git a/lustre/ofd/ofd_access_log.c b/lustre/ofd/ofd_access_log.c index a1db9b2..ac7a8e1 100644 --- a/lustre/ofd/ofd_access_log.c +++ b/lustre/ofd/ofd_access_log.c @@ -679,7 +679,7 @@ int ofd_access_log_module_init(void) oal_log_major = MAJOR(dev); - oal_log_class = class_create(THIS_MODULE, LUSTRE_ACCESS_LOG_DIR_NAME); + oal_log_class = ll_class_create(LUSTRE_ACCESS_LOG_DIR_NAME); if (IS_ERR(oal_log_class)) { rc = PTR_ERR(oal_log_class); goto out_dev; diff --git a/lustre/ptlrpc/gss/gss_svc_upcall.c b/lustre/ptlrpc/gss/gss_svc_upcall.c index f5c83a2..e7608a5 100644 --- a/lustre/ptlrpc/gss/gss_svc_upcall.c +++ b/lustre/ptlrpc/gss/gss_svc_upcall.c @@ -71,6 +71,15 @@ #include "gss_api.h" #include "gss_crypto.h" +#ifndef HAVE_GET_EXPIRY_2ARGS +static inline int __get_expiry2(char **bpp, time64_t *rvp) +{ + *rvp = get_expiry(bpp); + return *rvp ? 0 : -EINVAL; +} +#define get_expiry(ps, pt) __get_expiry2((ps), (pt)) +#endif + #define GSS_SVC_UPCALL_TIMEOUT (20) static DEFINE_SPINLOCK(__ctx_index_lock); @@ -339,13 +348,13 @@ static int rsi_parse(struct cache_detail *cd, char *mesg, int mlen) * Directly return -EINVAL in this case. */ status = -EINVAL; - goto out; + goto out; } rsii.h.flags = 0; /* expiry */ - expiry = get_expiry(&mesg); - if (expiry == 0) + status = get_expiry(&mesg, &expiry); + if (status) goto out; len = qword_get(&mesg, buf, mlen); @@ -582,36 +591,38 @@ static struct cache_head * rsc_alloc(void) static int rsc_parse(struct cache_detail *cd, char *mesg, int mlen) { - char *buf = mesg; - int len, rv, tmp_int; - struct rsc rsci, *rscp = NULL; + char *buf = mesg; + int len, rv, tmp_int; + struct rsc rsci, *rscp = NULL; time64_t expiry; - int status = -EINVAL; - struct gss_api_mech *gm = NULL; + int status = -EINVAL; + struct gss_api_mech *gm = NULL; - memset(&rsci, 0, sizeof(rsci)); + memset(&rsci, 0, sizeof(rsci)); - /* context handle */ - len = qword_get(&mesg, buf, mlen); - if (len < 0) goto out; - status = -ENOMEM; - if (rawobj_alloc(&rsci.handle, buf, len)) - goto out; - - rsci.h.flags = 0; - /* expiry */ - expiry = get_expiry(&mesg); - status = -EINVAL; - if (expiry == 0) - goto out; - - /* remote flag */ - rv = get_int(&mesg, &tmp_int); - if (rv) { - CERROR("fail to get remote flag\n"); - goto out; - } - rsci.ctx.gsc_remote = (tmp_int != 0); + /* context handle */ + len = qword_get(&mesg, buf, mlen); + if (len < 0) + goto out; + + status = -ENOMEM; + if (rawobj_alloc(&rsci.handle, buf, len)) + goto out; + + rsci.h.flags = 0; + /* expiry */ + status = get_expiry(&mesg, &expiry); + if (status) + goto out; + + status = -EINVAL; + /* remote flag */ + rv = get_int(&mesg, &tmp_int); + if (rv) { + CERROR("fail to get remote flag\n"); + goto out; + } + rsci.ctx.gsc_remote = (tmp_int != 0); /* root user flag */ rv = get_int(&mesg, &tmp_int); @@ -621,41 +632,41 @@ static int rsc_parse(struct cache_detail *cd, char *mesg, int mlen) } rsci.ctx.gsc_usr_root = (tmp_int != 0); - /* mds user flag */ - rv = get_int(&mesg, &tmp_int); - if (rv) { - CERROR("fail to get mds user flag\n"); - goto out; - } - rsci.ctx.gsc_usr_mds = (tmp_int != 0); + /* mds user flag */ + rv = get_int(&mesg, &tmp_int); + if (rv) { + CERROR("fail to get mds user flag\n"); + goto out; + } + rsci.ctx.gsc_usr_mds = (tmp_int != 0); - /* oss user flag */ - rv = get_int(&mesg, &tmp_int); - if (rv) { - CERROR("fail to get oss user flag\n"); - goto out; - } - rsci.ctx.gsc_usr_oss = (tmp_int != 0); + /* oss user flag */ + rv = get_int(&mesg, &tmp_int); + if (rv) { + CERROR("fail to get oss user flag\n"); + goto out; + } + rsci.ctx.gsc_usr_oss = (tmp_int != 0); - /* mapped uid */ - rv = get_int(&mesg, (int *) &rsci.ctx.gsc_mapped_uid); - if (rv) { - CERROR("fail to get mapped uid\n"); - goto out; - } + /* mapped uid */ + rv = get_int(&mesg, (int *) &rsci.ctx.gsc_mapped_uid); + if (rv) { + CERROR("fail to get mapped uid\n"); + goto out; + } - rscp = rsc_lookup(&rsci); - if (!rscp) - goto out; - - /* uid, or NEGATIVE */ - rv = get_int(&mesg, (int *) &rsci.ctx.gsc_uid); - if (rv == -EINVAL) - goto out; - if (rv == -ENOENT) { - CERROR("NOENT? set rsc entry negative\n"); + rscp = rsc_lookup(&rsci); + if (!rscp) + goto out; + + /* uid, or NEGATIVE */ + rv = get_int(&mesg, (int *) &rsci.ctx.gsc_uid); + if (rv == -EINVAL) + goto out; + if (rv == -ENOENT) { + CERROR("NOENT? set rsc entry negative\n"); set_bit(CACHE_NEGATIVE, &rsci.h.flags); - } else { + } else { rawobj_t tmp_buf; time64_t ctx_expiry; @@ -699,23 +710,23 @@ static int rsc_parse(struct cache_detail *cd, char *mesg, int mlen) * We want just the number of seconds into the future. */ expiry += ctx_expiry - ktime_get_real_seconds(); - } + } - rsci.h.expiry_time = expiry; - rscp = rsc_update(&rsci, rscp); - status = 0; + rsci.h.expiry_time = expiry; + rscp = rsc_update(&rsci, rscp); + status = 0; out: - if (gm) - lgss_mech_put(gm); - rsc_free(&rsci); - if (rscp) - cache_put(&rscp->h, &rsc_cache); - else - status = -ENOMEM; + if (gm) + lgss_mech_put(gm); + rsc_free(&rsci); + if (rscp) + cache_put(&rscp->h, &rsc_cache); + else + status = -ENOMEM; - if (status) - CERROR("parse rsc error %d\n", status); - return status; + if (status) + CERROR("parse rsc error %d\n", status); + return status; } static struct cache_detail rsc_cache = { -- 1.8.3.1