Whamcloud - gitweb
DDN-3473 build: support kernel 3.10.0-693.el7
authorJian Yu <yujian@whamcloud.com>
Wed, 16 Nov 2022 05:54:26 +0000 (21:54 -0800)
committerAndreas Dilger <adilger@whamcloud.com>
Fri, 25 Nov 2022 22:59:48 +0000 (22:59 +0000)
This patch fixes the following build failures to support
kernel 3.10.0-693.el7 for Lustre client:

- error: implicit declaration of function 'idr_destroy'
- error: implicit declaration of function 'gfpflags_allow_blocking'
- error: implicit declaration of function ‘cdev_device_add’
- error: passing argument 1 of 'init_wait_var_entry' from
  incompatible pointer type

Test-Parameters: trivial
Signed-off-by: Jian Yu <yujian@whamcloud.com>
Change-Id: I4b5c5264fb102d3a825c92e7b1e92cf0c52540e5
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/49197
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/linux/linux-wait.h
libcfs/include/libcfs/linux/xarray.h
lustre/autoconf/lustre-core.m4
lustre/mdc/mdc_changelog.c
lustre/mdc/mdc_request.c

index 517f72f..30c82de 100644 (file)
@@ -488,6 +488,24 @@ topology_sibling_cpumask, [
 ]) # LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
 
 #
+# Kernel version 4.3 commit d0164adc89f6bb374d304ffcc375c6d2652fe67d
+# define gfpflags_allow_blocking() in include/linux/gfp.h
+#
+AC_DEFUN([LIBCFS_HAVE_GFPFLAGS_ALLOW_BLOCKING],[
+LB_CHECK_COMPILE([does function 'gfpflags_allow_blocking' exist in gfp.h],
+gfpflags_allow_blocking, [
+       #include <linux/gfp.h>
+],[
+       const gfp_t gfp_flags;
+
+       gfpflags_allow_blocking(gfp_flags);
+],[
+       AC_DEFINE(HAVE_GFPFLAGS_ALLOW_BLOCKING, 1,
+               ['gfpflags_allow_blocking' is available in gfp.h])
+])
+]) # LIBCFS_HAVE_GFPFLAGS_ALLOW_BLOCKING
+
+#
 # Kernel version 4.4 commit ef951599074ba4fad2d0efa0a977129b41e6d203
 # introduced kstrtobool and kstrtobool_from_user.
 #
@@ -1778,6 +1796,8 @@ LIBCFS_KTIME_MS_DELTA
 LIBCFS_KERNEL_PARAM_LOCK
 # 4.2
 LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
+# 4.3
+LIBCFS_HAVE_GFPFLAGS_ALLOW_BLOCKING
 # 4.4
 LIBCFS_KSTRTOBOOL_FROM_USER
 # 4.5
index f0f7f69..8ab89f0 100644 (file)
@@ -66,6 +66,12 @@ static inline void clear_and_wake_up_bit(int bit, void *word)
 
 #ifndef HAVE_WAIT_VAR_EVENT
 extern void __init wait_bit_init(void);
+
+#ifndef HAVE_WAIT_QUEUE_ENTRY
+#define wait_bit_queue_entry wait_bit_queue
+#define wq_entry wait
+#endif
+
 extern void init_wait_var_entry(struct wait_bit_queue_entry *wbq_entry,
                                void *var, int flags);
 extern void wake_up_var(void *var);
index 74397ab..b475412 100644 (file)
@@ -1761,6 +1761,14 @@ static inline void *xas_next(struct xa_state *xas)
        xas->xa_offset++;
        return xa_entry(xas->xa, node, xas->xa_offset);
 }
+
+#ifndef HAVE_GFPFLAGS_ALLOW_BLOCKING
+static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags)
+{
+        return !!(gfp_flags & __GFP_WAIT);
+}
+#endif /* !HAVE_GFPFLAGS_ALLOW_BLOCKING */
+
 #endif /* !HAVE_XARRAY_SUPPORT */
 
 #endif /* _LINUX_XARRAY_H */
index c8a6164..5d61829 100644 (file)
@@ -1999,6 +1999,27 @@ crypto_max_alg_name, [
 ]) # LC_HAVE_CRYPTO_MAX_ALG_NAME_128
 
 #
+# LC_HAVE_CDEV_DEVICE_ADD
+#
+# Kernel version 4.11 commit 233ed09d7fdacf592ee91e6c97ce5f4364fbe7c0
+# This patch introduce cdev_device_add and cdev_device_del which
+# replaces a common pattern including setting the kobj parent, calling
+# cdev_add and then calling device_add. It also introduces cdev_set_parent
+# for the few cases that set the kobject parent without using device_add.
+#
+AC_DEFUN([LC_HAVE_CDEV_DEVICE_ADD], [
+LB_CHECK_COMPILE([if 'cdev_device_add' exists],
+cdev_device_add, [
+       #include <linux/cdev.h>
+],[
+       cdev_device_add(NULL, NULL);
+], [
+       AC_DEFINE(HAVE_CDEV_DEVICE_ADD, 1,
+               ['cdev_device_add' exists])
+])
+]) # LC_HAVE_CDEV_DEVICE_ADD
+
+#
 # Kernel version 4.12 commit 47f38c539e9a42344ff5a664942075bd4df93876
 # CURRENT_TIME is not 64 bit time safe so it was replaced with
 # current_time()
@@ -2750,6 +2771,7 @@ AC_DEFUN([LC_PROG_LINUX], [
        LC_VM_OPERATIONS_REMOVE_VMF_ARG
        LC_HAVE_KEY_USAGE_REFCOUNT
        LC_HAVE_CRYPTO_MAX_ALG_NAME_128
+       LC_HAVE_CDEV_DEVICE_ADD
 
        # 4.12
        LC_CURRENT_TIME
index 51e53de..09f03c5 100644 (file)
@@ -117,6 +117,87 @@ enum {
 DEFINE_IDR(mdc_changelog_minor_idr);
 static DEFINE_SPINLOCK(chlg_minor_lock);
 
+#ifndef HAVE_CDEV_DEVICE_ADD
+/**
+ * cdev_set_parent() - set the parent kobject for a char device
+ * @p: the cdev structure
+ * @kobj: the kobject to take a reference to
+ *
+ * cdev_set_parent() sets a parent kobject which will be referenced
+ * appropriately so the parent is not freed before the cdev. This
+ * should be called before cdev_add.
+ */
+static void cdev_set_parent(struct cdev *p, struct kobject *kobj)
+{
+       WARN_ON(!kobj->state_initialized);
+       p->kobj.parent = kobj;
+}
+
+/**
+ * cdev_device_add() - add a char device and it's corresponding
+ *     struct device, linkink
+ * @dev: the device structure
+ * @cdev: the cdev structure
+ *
+ * cdev_device_add() adds the char device represented by @cdev to the system,
+ * just as cdev_add does. It then adds @dev to the system using device_add
+ * The dev_t for the char device will be taken from the struct device which
+ * needs to be initialized first. This helper function correctly takes a
+ * reference to the parent device so the parent will not get released until
+ * all references to the cdev are released.
+ *
+ * This helper uses dev->devt for the device number. If it is not set
+ * it will not add the cdev and it will be equivalent to device_add.
+ *
+ * This function should be used whenever the struct cdev and the
+ * struct device are members of the same structure whose lifetime is
+ * managed by the struct device.
+ *
+ * NOTE: Callers must assume that userspace was able to open the cdev and
+ * can call cdev fops callbacks at any time, even if this function fails.
+ */
+static int cdev_device_add(struct cdev *cdev, struct device *dev)
+{
+       int rc = 0;
+
+       if (dev->devt) {
+               cdev_set_parent(cdev, &dev->kobj);
+
+               rc = cdev_add(cdev, dev->devt, 1);
+               if (rc)
+                       return rc;
+       }
+
+       rc = device_add(dev);
+       if (rc)
+               cdev_del(cdev);
+
+       return rc;
+}
+
+/**
+ * cdev_device_del() - inverse of cdev_device_add
+ * @dev: the device structure
+ * @cdev: the cdev structure
+ *
+ * cdev_device_del() is a helper function to call cdev_del and device_del.
+ * It should be used whenever cdev_device_add is used.
+ *
+ * If dev->devt is not set it will not remove the cdev and will be equivalent
+ * to device_del.
+ *
+ * NOTE: This guarantees that associated sysfs callbacks are not running
+ * or runnable, however any cdevs already open will remain and their fops
+ * will still be callable even after this function returns.
+ */
+static void cdev_device_del(struct cdev *cdev, struct device *dev)
+{
+       device_del(dev);
+       if (dev->devt)
+               cdev_del(cdev);
+}
+#endif /* !HAVE_CDEV_DEVICE_ADD */
+
 static int chlg_minor_alloc(int *pminor)
 {
        void *minor_allocated = (void *)-1;
index f4620c5..b2d1e9a 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/uidgid.h>
 #include <linux/device.h>
 #include <linux/xarray.h>
+#include <linux/idr.h>
 
 #include <lustre_errno.h>