]> granicus.if.org Git - zfs/commitdiff
Linux 4.13 compat: wait queues
authorBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 24 Jul 2017 02:32:14 +0000 (19:32 -0700)
committerGitHub <noreply@github.com>
Mon, 24 Jul 2017 02:32:14 +0000 (19:32 -0700)
Commit torvalds/linux@ac6424b9
- Renamed struct wait_queue -> struct wait_queue_entry.

Commit torvalds/linux@2055da97
- Renamed wait_queue_head::task_list -> wait_queue_head::head
- Renamed wait_queue_entry::task_list -> wait_queue_entry::entry

Reviewed-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #629

config/spl-build.m4
include/linux/wait_compat.h
include/sys/condvar.h
include/sys/kmem_cache.h
include/sys/taskq.h
module/spl/spl-proc.c
module/splat/splat-atomic.c
module/splat/splat-kmem.c
module/splat/splat-rwlock.c
module/splat/splat-thread.c

index 698d51a87f276c45650607cee5d3750503bd0004..630d67c2d5daad0fa5c09e6ea82c82e026874f90 100644 (file)
@@ -53,6 +53,8 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
        SPL_AC_INODE_LOCK
        SPL_AC_GROUP_INFO_GID
        SPL_AC_KMEM_CACHE_CREATE_USERCOPY
+       SPL_AC_WAIT_QUEUE_ENTRY_T
+       SPL_AC_WAIT_QUEUE_HEAD_ENTRY
 ])
 
 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
@@ -1670,3 +1672,56 @@ AC_DEFUN([SPL_AC_KMEM_CACHE_CREATE_USERCOPY], [
        ])
        EXTRA_KCFLAGS="$tmp_flags"
 ])
+
+dnl #
+dnl # 4.13 API change
+dnl # Renamed struct wait_queue -> struct wait_queue_entry.
+dnl #
+AC_DEFUN([SPL_AC_WAIT_QUEUE_ENTRY_T], [
+       AC_MSG_CHECKING([whether wait_queue_entry_t exists])
+       SPL_LINUX_TRY_COMPILE([
+               #include <linux/wait.h>
+       ],[
+               wait_queue_entry_t *entry __attribute__ ((unused));
+       ],[
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY_T, 1,
+                   [wait_queue_entry_t exists])
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+])
+
+dnl #
+dnl # 4.13 API change
+dnl # Renamed wait_queue_head::task_list -> wait_queue_head::head
+dnl # Renamed wait_queue_entry::task_list -> wait_queue_entry::entry
+dnl #
+AC_DEFUN([SPL_AC_WAIT_QUEUE_HEAD_ENTRY], [
+       AC_MSG_CHECKING([whether wq_head->head and wq_entry->entry exist])
+       SPL_LINUX_TRY_COMPILE([
+               #include <linux/wait.h>
+
+               #ifdef HAVE_WAIT_QUEUE_ENTRY_T
+               typedef wait_queue_head_t       spl_wait_queue_head_t;
+               typedef wait_queue_entry_t      spl_wait_queue_entry_t;
+               #else
+               typedef wait_queue_head_t       spl_wait_queue_head_t;
+               typedef wait_queue_t            spl_wait_queue_entry_t;
+               #endif
+       ],[
+               spl_wait_queue_head_t wq_head;
+               spl_wait_queue_entry_t wq_entry;
+               struct list_head *head __attribute__ ((unused));
+               struct list_head *entry __attribute__ ((unused));
+
+               head = &wq_head.head;
+               entry = &wq_entry.entry;
+       ],[
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_WAIT_QUEUE_HEAD_ENTRY, 1,
+                   [wq_head->head and wq_entry->entry exist])
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+])
index d8cd09b9eb08431f6a425fbd740c2e4baff8dc55..445a73c68fa15c6d6b461e4b74dc266b0f09026b 100644 (file)
@@ -26,6 +26,7 @@
 #define _SPL_WAIT_COMPAT_H
 
 #include <linux/sched.h>
+#include <linux/wait.h>
 
 #ifndef HAVE_WAIT_ON_BIT_ACTION
 #  define spl_wait_on_bit(word, bit, mode) wait_on_bit(word, bit, mode)
@@ -43,4 +44,12 @@ spl_bit_wait(void *word)
 
 #endif /* HAVE_WAIT_ON_BIT_ACTION */
 
+#ifdef HAVE_WAIT_QUEUE_ENTRY_T
+typedef wait_queue_head_t      spl_wait_queue_head_t;
+typedef wait_queue_entry_t     spl_wait_queue_entry_t;
+#else
+typedef wait_queue_head_t      spl_wait_queue_head_t;
+typedef wait_queue_t           spl_wait_queue_entry_t;
+#endif
+
 #endif /* SPL_WAIT_COMPAT_H */
index 9b55449ae555d2b2ece52c57730b76de78b2c9e2..5479e75ad652ccae08899a72cc93384962affd73 100644 (file)
@@ -26,7 +26,7 @@
 #define        _SPL_CONDVAR_H
 
 #include <linux/module.h>
-#include <linux/wait.h>
+#include <linux/wait_compat.h>
 #include <linux/delay_compat.h>
 #include <sys/kmem.h>
 #include <sys/mutex.h>
@@ -41,8 +41,8 @@
 
 typedef struct {
        int cv_magic;
-       wait_queue_head_t cv_event;
-       wait_queue_head_t cv_destroy;
+       spl_wait_queue_head_t cv_event;
+       spl_wait_queue_head_t cv_destroy;
        atomic_t cv_refs;
        atomic_t cv_waiters;
        kmutex_t *cv_mutex;
index e971c2b0d9522679b5aff50223f5c188cd044fbb..8fa14f67e73fe563babd542a85164c2a927340fe 100644 (file)
@@ -193,7 +193,7 @@ typedef struct spl_kmem_cache {
        struct list_head        skc_partial_list;  /* Partially alloc'ed */
        struct rb_root          skc_emergency_tree; /* Min sized objects */
        spinlock_t              skc_lock;       /* Cache lock */
-       wait_queue_head_t       skc_waitq;      /* Allocation waiters */
+       spl_wait_queue_head_t   skc_waitq;      /* Allocation waiters */
        uint64_t                skc_slab_fail;  /* Slab alloc failures */
        uint64_t                skc_slab_create;  /* Slab creates */
        uint64_t                skc_slab_destroy; /* Slab destroys */
index 5adda882725cd691896d77099b5eab5b9cc2f072..c5ccec715be62380c9b33e7a6ce18273611f3186 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/kthread.h>
+#include <linux/wait_compat.h>
 #include <sys/types.h>
 #include <sys/thread.h>
 #include <sys/rwlock.h>
@@ -96,14 +97,14 @@ typedef struct taskq {
        struct list_head        tq_prio_list;   /* priority pending taskq_ent_t's */
        struct list_head        tq_delay_list;  /* delayed taskq_ent_t's */
        struct list_head        tq_taskqs;      /* all taskq_t's */
-       wait_queue_head_t       tq_work_waitq;  /* new work waitq */
-       wait_queue_head_t       tq_wait_waitq;  /* wait waitq */
+       spl_wait_queue_head_t   tq_work_waitq;  /* new work waitq */
+       spl_wait_queue_head_t   tq_wait_waitq;  /* wait waitq */
        tq_lock_role_t          tq_lock_class;  /* class when taking tq_lock */
 } taskq_t;
 
 typedef struct taskq_ent {
        spinlock_t              tqent_lock;
-       wait_queue_head_t       tqent_waitq;
+       spl_wait_queue_head_t   tqent_waitq;
        struct timer_list       tqent_timer;
        struct list_head        tqent_list;
        taskqid_t               tqent_id;
index bffbcc607579d9dc3e49ced11c229265fd840ed7..05c1a5dbc2209b577928f4b9838eb0795ccd8685 100644 (file)
@@ -244,7 +244,7 @@ taskq_seq_show_impl(struct seq_file *f, void *p, boolean_t allflag)
 {
        taskq_t *tq = p;
        taskq_thread_t *tqt;
-       wait_queue_t *wq;
+       spl_wait_queue_entry_t *wq;
        struct task_struct *tsk;
        taskq_ent_t *tqe;
        char name[100];
@@ -261,7 +261,11 @@ taskq_seq_show_impl(struct seq_file *f, void *p, boolean_t allflag)
        lheads[LHEAD_PEND] = &tq->tq_pend_list;
        lheads[LHEAD_PRIO] = &tq->tq_prio_list;
        lheads[LHEAD_DELAY] = &tq->tq_delay_list;
+#ifdef HAVE_WAIT_QUEUE_HEAD_ENTRY
+       lheads[LHEAD_WAIT] = &tq->tq_wait_waitq.head;
+#else
        lheads[LHEAD_WAIT] = &tq->tq_wait_waitq.task_list;
+#endif
        lheads[LHEAD_ACTIVE] = &tq->tq_active_list;
 
        for (i = 0; i < LHEAD_SIZE; ++i) {
@@ -320,7 +324,13 @@ taskq_seq_show_impl(struct seq_file *f, void *p, boolean_t allflag)
                                }
                                /* show the wait waitq list */
                                if (i == LHEAD_WAIT) {
-                                       wq = list_entry(lh, wait_queue_t, task_list);
+#ifdef HAVE_WAIT_QUEUE_HEAD_ENTRY
+                                       wq = list_entry(lh,
+                                           spl_wait_queue_entry_t, entry);
+#else
+                                       wq = list_entry(lh,
+                                           spl_wait_queue_entry_t, task_list);
+#endif
                                        if (j == 0)
                                                seq_printf(f, "\t%s:",
                                                    list_names[i]);
index f6ed80fb8228e59ab7818e4b2fc0f67386d246cd..b8759e01f29b52fde188ce768f2aa78db576146f 100644 (file)
@@ -28,6 +28,7 @@
 #include <sys/thread.h>
 #include <sys/mutex.h>
 #include <linux/mm_compat.h>
+#include <linux/wait_compat.h>
 #include <linux/slab.h>
 #include "splat-internal.h"
 
@@ -55,7 +56,7 @@ typedef struct atomic_priv {
         unsigned long ap_magic;
         struct file *ap_file;
        kmutex_t ap_lock;
-        wait_queue_head_t ap_waitq;
+        spl_wait_queue_head_t ap_waitq;
        volatile uint64_t ap_atomic;
        volatile uint64_t ap_atomic_exited;
        atomic_op_t ap_op;
index 8946b06713a5dfd0d1de1307bfe234f6eaddd73c..d0649ad9a058467d117246561d94a8fc9331e996 100644 (file)
@@ -275,8 +275,8 @@ typedef struct kmem_cache_priv {
        struct file *kcp_file;
        kmem_cache_t *kcp_cache;
        spinlock_t kcp_lock;
-       wait_queue_head_t kcp_ctl_waitq;
-       wait_queue_head_t kcp_thr_waitq;
+       spl_wait_queue_head_t kcp_ctl_waitq;
+       spl_wait_queue_head_t kcp_thr_waitq;
        int kcp_flags;
        int kcp_kct_count;
        kmem_cache_thread_t *kcp_kct[SPLAT_KMEM_THREADS];
index d7626b2364ee6f7c6c763d075e72a6df10e6fd80..5d3ffb195115a9aec4cf090fabd8123ffb663dda 100644 (file)
@@ -76,7 +76,7 @@ typedef struct rw_priv {
        struct file *rw_file;
        krwlock_t rw_rwlock;
        spinlock_t rw_lock;
-       wait_queue_head_t rw_waitq;
+       spl_wait_queue_head_t rw_waitq;
        int rw_completed;
        int rw_holders;
        int rw_waiters;
index a043fc74f821ad64ee6fd4a6b1255228ebd75e4d..e99d691013c3caa053cb441fe96f9b034462c949 100644 (file)
@@ -28,6 +28,7 @@
 #include <sys/random.h>
 #include <linux/delay.h>
 #include <linux/mm_compat.h>
+#include <linux/wait_compat.h>
 #include <linux/slab.h>
 #include "splat-internal.h"
 
@@ -54,7 +55,7 @@ typedef struct thread_priv {
         unsigned long tp_magic;
         struct file *tp_file;
         spinlock_t tp_lock;
-        wait_queue_head_t tp_waitq;
+        spl_wait_queue_head_t tp_waitq;
        uint_t tp_keys[SPLAT_THREAD_TEST_KEYS];
        int tp_rc;
        int tp_count;