Whamcloud - gitweb
LU-14195 obdclass: change list_sort to use const pointers 19/45219/2
authorJian Yu <yujian@whamcloud.com>
Wed, 13 Oct 2021 07:12:03 +0000 (00:12 -0700)
committerOleg Drokin <green@whamcloud.com>
Wed, 27 Oct 2021 00:38:17 +0000 (00:38 +0000)
Kernel 5.10.70 commit 4f0f586bf0c898233d8f316f471a21db2abd522d
defines the list_cmp_func_t type and changes the comparison
function types of all list_sort() callers to use const pointers
to avoid type mismatches.

Change-Id: I40d37ec0f0d485d0deebaa9dc3493f2865f76ec9
Signed-off-by: Jian Yu <yujian@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/45219
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/autoconf/lustre-libcfs.m4
lustre/obdclass/cl_io.c

index 07c4de9..64ade1b 100644 (file)
@@ -1684,6 +1684,26 @@ LB_CHECK_LINUX_HEADER([crypto/sha2.h], [
                [crypto/sha2.h is present])])
 ]) # LIBCFS_HAVE_CRYPTO_SHA2_HEADER
 
                [crypto/sha2.h is present])])
 ]) # LIBCFS_HAVE_CRYPTO_SHA2_HEADER
 
+#
+# LIBCFS_HAVE_LIST_CMP_FUNC_T
+#
+# kernel 5.10.70 commit 4f0f586bf0c898233d8f316f471a21db2abd522d
+# treewide: Change list_sort to use const pointers
+AC_DEFUN([LIBCFS_HAVE_LIST_CMP_FUNC_T], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror -Wno-unused-variable"
+LB_CHECK_COMPILE([if list_cmp_func_t type is defined],
+list_cmp_func_t, [
+       #include <linux/list_sort.h>
+],[
+       list_cmp_func_t cmp;
+],[
+       AC_DEFINE(HAVE_LIST_CMP_FUNC_T, 1,
+               [list_cmp_func_t type is defined])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LIBCFS_HAVE_LIST_CMP_FUNC_T
+
 AC_DEFUN([LIBCFS_PROG_LINUX_SRC], [
        LIBCFS_SRC_HAVE_PROC_OPS
 
 AC_DEFUN([LIBCFS_PROG_LINUX_SRC], [
        LIBCFS_SRC_HAVE_PROC_OPS
 
@@ -1825,6 +1845,7 @@ LIBCFS_SEC_RELEASE_SECCTX
 # 5.10
 LIBCFS_HAVE_KFREE_SENSITIVE
 LIBCFS_HAVE_CRYPTO_SHA2_HEADER
 # 5.10
 LIBCFS_HAVE_KFREE_SENSITIVE
 LIBCFS_HAVE_CRYPTO_SHA2_HEADER
+LIBCFS_HAVE_LIST_CMP_FUNC_T
 ]) # LIBCFS_PROG_LINUX
 
 #
 ]) # LIBCFS_PROG_LINUX
 
 #
index caf4701..dc2be4a 100644 (file)
@@ -221,8 +221,14 @@ int cl_io_rw_init(const struct lu_env *env, struct cl_io *io,
 }
 EXPORT_SYMBOL(cl_io_rw_init);
 
 }
 EXPORT_SYMBOL(cl_io_rw_init);
 
+#ifdef HAVE_LIST_CMP_FUNC_T
+static int cl_lock_descr_cmp(void *priv,
+                            const struct list_head *a,
+                            const struct list_head *b)
+#else /* !HAVE_LIST_CMP_FUNC_T */
 static int cl_lock_descr_cmp(void *priv,
                             struct list_head *a, struct list_head *b)
 static int cl_lock_descr_cmp(void *priv,
                             struct list_head *a, struct list_head *b)
+#endif /* HAVE_LIST_CMP_FUNC_T */
 {
        const struct cl_io_lock_link *l0 = list_entry(a, struct cl_io_lock_link,
                                                      cill_linkage);
 {
        const struct cl_io_lock_link *l0 = list_entry(a, struct cl_io_lock_link,
                                                      cill_linkage);