Whamcloud - gitweb
LU-16802 build: compatibility for 6.4 kernels 75/50875/14
authorShaun Tancheff <shaun.tancheff@hpe.com>
Fri, 27 Oct 2023 06:21:13 +0000 (01:21 -0500)
committerOleg Drokin <green@whamcloud.com>
Sat, 18 Nov 2023 21:43:25 +0000 (21:43 +0000)
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.

Test-Parameters: trivial
HPE-bug-id: LUS-11614
Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Change-Id: I765d6257eec8b5a9bf1bd5947f03370eb9df1625
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50875
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Petros Koutoupis <petros.koutoupis@hpe.com>
Reviewed-by: xinliang <xinliang.liu@linaro.org>
lustre/autoconf/lustre-core.m4
lustre/include/lustre_compat.h
lustre/llite/rw26.c
lustre/mdc/mdc_request.c
lustre/obdclass/cl_io.c
lustre/ofd/ofd_access_log.c
lustre/ptlrpc/gss/gss_svc_upcall.c

index d71694c..664419b 100644 (file)
@@ -3984,6 +3984,116 @@ AC_DEFUN([LC_HAVE_LOCKS_LOCK_FILE_WAIT_IN_FILELOCK], [
 ]) # LC_HAVE_LOCKS_LOCK_FILE_WAIT_IN_FILELOCK
 
 #
+# 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 <linux/uio.h>
+       ],[
+               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 <linux/uio.h>
+       ],[
+               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 <linux/device/class.h>
+       ],[
+               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 <linux/sunrpc/cache.h>
+       ],[
+               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
@@ -4242,6 +4352,12 @@ AC_DEFUN([LC_PROG_LINUX_SRC], [
        LC_SRC_HAVE_LOCKS_LOCK_FILE_WAIT_IN_FILELOCK
        LC_SRC_HAVE_U64_CAPABILITY
 
+       # 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
 ])
@@ -4521,6 +4637,12 @@ AC_DEFUN([LC_PROG_LINUX_RESULTS], [
        LC_HAVE_LOCKS_LOCK_FILE_WAIT_IN_FILELOCK
        LC_HAVE_U64_CAPABILITY
 
+       # 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
 ])
index 1d05e87..3c5c0a0 100644 (file)
@@ -336,20 +336,22 @@ static inline void iov_iter_truncate(struct iov_iter *i, u64 count)
 # define SB_KERNMOUNT MS_KERNMOUNT
 #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);                                            \
index 4b45abc..a28d328 100644 (file)
@@ -602,7 +602,7 @@ ll_direct_IO_impl(struct kiocb *iocb, struct iov_iter *iter, int rw)
                        count = result;
                } else {
                        /* same calculation used in ll_get_user_pages */
-                       count = min_t(size_t, count, iter->iov->iov_len);
+                       count = min_t(size_t, count, iter_iov(iter)->iov_len);
                        result = ll_allocate_dio_buffer(pvec, count);
                        /* allocate_dio_buffer returns number of pages or
                         * error, so do not set count = result
index 6e501d1..f17744a 100644 (file)
@@ -3071,7 +3071,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;
index 0cf0943..4035008 100644 (file)
@@ -1211,7 +1211,7 @@ static void cl_sub_dio_end(const struct lu_env *env, struct cl_sync_io *anchor)
                /* save the iovec pointer before it's modified by
                 * ll_dio_user_copy
                 */
-               struct iovec *tmp = (struct iovec *) sdio->csd_iter.iov;
+               struct iovec *tmp = (struct iovec *) sdio->csd_iter.__iov;
 
                CDEBUG(D_VFSTRACE,
                       "finishing unaligned dio %s aio->cda_bytes %ld\n",
@@ -1227,7 +1227,7 @@ static void cl_sub_dio_end(const struct lu_env *env, struct cl_sync_io *anchor)
                 * because we have the unmodified iovec pointer
                 */
                OBD_FREE_PTR(tmp);
-               sdio->csd_iter.iov = NULL;
+               sdio->csd_iter.__iov = NULL;
        } else {
                /* unaligned DIO does not get user pages, so it doesn't have to
                 * release them, but aligned I/O must
@@ -1306,13 +1306,13 @@ struct cl_sub_dio *cl_sub_dio_alloc(struct cl_dio_aio *ll_aio,
                         * separate thread requires a local copy of the iovec
                         */
                        memcpy(&sdio->csd_iter, iter, sizeof(struct iov_iter));
-                       OBD_ALLOC_PTR(sdio->csd_iter.iov);
-                       if (sdio->csd_iter.iov == NULL) {
+                       OBD_ALLOC_PTR(sdio->csd_iter.__iov);
+                       if (sdio->csd_iter.__iov == NULL) {
                                cl_sub_dio_free(sdio);
                                sdio = NULL;
                                goto out;
                        }
-                       memcpy((void *) sdio->csd_iter.iov, iter->iov,
+                       memcpy((void *) sdio->csd_iter.__iov, iter->__iov,
                               sizeof(struct iovec));
                }
        }
@@ -1335,7 +1335,7 @@ EXPORT_SYMBOL(cl_dio_aio_free);
 void cl_sub_dio_free(struct cl_sub_dio *sdio)
 {
        if (sdio) {
-               void *tmp = (void *)sdio->csd_iter.iov;
+               void *tmp = (void *)sdio->csd_iter.__iov;
 
                if (tmp) {
                        LASSERT(sdio->csd_unaligned);
index 088ec66..1024c08 100644 (file)
@@ -681,7 +681,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;
index dbd9efd..d7f2c8c 100644 (file)
 #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);
@@ -673,13 +682,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);
@@ -916,36 +925,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);
@@ -955,41 +966,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;
 
@@ -1033,23 +1044,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 = {