]) # 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.
#
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
#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);
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 */
]) # 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()
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
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;
#include <linux/uidgid.h>
#include <linux/device.h>
#include <linux/xarray.h>
+#include <linux/idr.h>
#include <lustre_errno.h>