]> granicus.if.org Git - zfs/commitdiff
Add TASKQID_INVALID
authorBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 28 Oct 2016 22:40:14 +0000 (22:40 +0000)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 2 Nov 2016 19:14:45 +0000 (12:14 -0700)
Add the TASKQID_INVALID macros and update callers to use the macro
instead of testing against 0.  There is no functional change
even though the functions in zfs_ctldir.c incorrectly used -1
instead of 0.

Reviewed-by: Tom Caputi <tcaputi@datto.com>
Reviewed-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #5347

12 files changed:
include/sys/zfs_context.h
module/icp/core/kcf_sched.c
module/zfs/arc.c
module/zfs/dmu_objset.c
module/zfs/dmu_traverse.c
module/zfs/metaslab.c
module/zfs/vdev.c
module/zfs/vdev_file.c
module/zfs/zfs_ctldir.c
module/zfs/zfs_vnops.c
module/zfs/zio.c
module/zfs/zvol.c

index bc508755150da9954793c3d755727004082371c2..ed0a97c4523f246903cdb867794ca6ece10bd6b8 100644 (file)
@@ -495,6 +495,8 @@ typedef struct taskq {
 #define        TQ_NOQUEUE      0x02            /* Do not enqueue if can't dispatch */
 #define        TQ_FRONT        0x08            /* Queue in front */
 
+#define        TASKQID_INVALID         ((taskqid_t)0)
+
 extern taskq_t *system_taskq;
 
 extern taskq_t *taskq_create(const char *, int, pri_t, int, int, uint_t);
index 3b4cce4b5294a7f4d276f9d0aebf4b8c29c7b8ca..4161bb7e319c1b1c43bbd20b265147992e46aa72 100644 (file)
@@ -561,7 +561,7 @@ kcf_resubmit_request(kcf_areq_node_t *areq)
                taskq_t *taskq = new_pd->pd_sched_info.ks_taskq;
 
                if (taskq_dispatch(taskq, process_req_hwp, areq, TQ_NOSLEEP) ==
-                   (taskqid_t)0) {
+                   TASKQID_INVALID) {
                        error = CRYPTO_HOST_MEMORY;
                } else {
                        error = CRYPTO_QUEUED;
@@ -782,7 +782,7 @@ kcf_submit_request(kcf_provider_desc_t *pd, crypto_ctx_t *ctx,
 
                        if (taskq_dispatch(taskq,
                            process_req_hwp, areq, TQ_NOSLEEP) ==
-                           (taskqid_t)0) {
+                           TASKQID_INVALID) {
                                error = CRYPTO_HOST_MEMORY;
                                if (!(crq->cr_flag & CRYPTO_SKIP_REQID))
                                        kcf_reqid_delete(areq);
index 5825d3300bbecc4ae89bf0f32017d9e82a276836..b855c1c7140052f8f9721a48d9fe77a3d2f36445 100644 (file)
@@ -3479,7 +3479,7 @@ arc_prune_async(int64_t adjust)
                refcount_add(&ap->p_refcnt, ap->p_pfunc);
                ap->p_adjust = adjust;
                if (taskq_dispatch(arc_prune_taskq, arc_prune_task,
-                   ap, TQ_SLEEP) == 0) {
+                   ap, TQ_SLEEP) == TASKQID_INVALID) {
                        refcount_remove(&ap->p_refcnt, ap->p_pfunc);
                        continue;
                }
index ac60008a3a8029706763cbe7f7799e686a3a6dd0..c1f2d8430d2ffc9062a8b82fe8ff97457df131cb 100644 (file)
@@ -1118,7 +1118,7 @@ dmu_objset_upgrade(objset_t *os, dmu_objset_upgrade_cb_t cb)
                os->os_upgrade_id = taskq_dispatch(
                    os->os_spa->spa_upgrade_taskq,
                    dmu_objset_upgrade_task_cb, os, TQ_SLEEP);
-               if (os->os_upgrade_id == 0)
+               if (os->os_upgrade_id == TASKQID_INVALID)
                        os->os_upgrade_status = ENOMEM;
        }
        mutex_exit(&os->os_upgrade_lock);
index a2566ced3211eac30eafa7ae5a3743b4a3950a20..c78228d7458876a2bd64f0bb0707225cfbea353f 100644 (file)
@@ -615,8 +615,8 @@ traverse_impl(spa_t *spa, dsl_dataset_t *ds, uint64_t objset, blkptr_t *rootbp,
        }
 
        if (!(flags & TRAVERSE_PREFETCH_DATA) ||
-           0 == taskq_dispatch(system_taskq, traverse_prefetch_thread,
-           td, TQ_NOQUEUE))
+           taskq_dispatch(system_taskq, traverse_prefetch_thread,
+           td, TQ_NOQUEUE) == TASKQID_INVALID)
                pd->pd_exited = B_TRUE;
 
        err = traverse_visitbp(td, NULL, rootbp, czb);
index e54eeeae266c2d7912d14f7660e50405c8e52edc..37fa9a7a3c320dc7535b1a0ad30c107ac50d233d 100644 (file)
@@ -1724,7 +1724,7 @@ metaslab_group_preload(metaslab_group_t *mg)
                 */
                mutex_exit(&mg->mg_lock);
                VERIFY(taskq_dispatch(mg->mg_taskq, metaslab_preload,
-                   msp, TQ_SLEEP) != 0);
+                   msp, TQ_SLEEP) != TASKQID_INVALID);
                mutex_enter(&mg->mg_lock);
                msp = msp_next;
        }
index e3a9da2d5d7b8a585dcd9f5babc3cd801dea6dbc..c51ed43e62e55a800a90e5e7fbbcbe3bd2141eff 100644 (file)
@@ -1191,7 +1191,7 @@ retry_sync:
 
                for (c = 0; c < children; c++)
                        VERIFY(taskq_dispatch(tq, vdev_open_child,
-                           vd->vdev_child[c], TQ_SLEEP) != 0);
+                           vd->vdev_child[c], TQ_SLEEP) != TASKQID_INVALID);
 
                taskq_destroy(tq);
        }
index bca4175a6ff414f7332e23b9433187a2e6584d76..a0a23598be60593b2f0d296895c1989a8eb256f6 100644 (file)
@@ -202,7 +202,8 @@ vdev_file_io_start(zio_t *zio)
                         */
                        if (spl_fstrans_check()) {
                                VERIFY3U(taskq_dispatch(system_taskq,
-                                   vdev_file_io_fsync, zio, TQ_SLEEP), !=, 0);
+                                   vdev_file_io_fsync, zio, TQ_SLEEP), !=,
+                                   TASKQID_INVALID);
                                return;
                        }
 
@@ -220,7 +221,7 @@ vdev_file_io_start(zio_t *zio)
        zio->io_target_timestamp = zio_handle_io_delay(zio);
 
        VERIFY3U(taskq_dispatch(system_taskq, vdev_file_io_strategy, zio,
-           TQ_SLEEP), !=, 0);
+           TQ_SLEEP), !=, TASKQID_INVALID);
 }
 
 /* ARGSUSED */
index 44003a5a625706ef6b7e7a2edc3cd6ec2c72d612..78bc7974001ab1a90b81b21cf1094cda7ef0097e 100644 (file)
@@ -147,7 +147,7 @@ zfsctl_snapshot_alloc(char *full_name, char *full_path, spa_t *spa,
        se->se_spa = spa;
        se->se_objsetid = objsetid;
        se->se_root_dentry = root_dentry;
-       se->se_taskqid = -1;
+       se->se_taskqid = TASKQID_INVALID;
 
        refcount_create(&se->se_refcount);
 
@@ -339,7 +339,7 @@ snapentry_expire(void *data)
                return;
        }
 
-       se->se_taskqid = -1;
+       se->se_taskqid = TASKQID_INVALID;
        (void) zfsctl_snapshot_unmount(se->se_name, MNT_EXPIRE);
        zfsctl_snapshot_rele(se);
 
@@ -366,7 +366,7 @@ zfsctl_snapshot_unmount_cancel(zfs_snapentry_t *se)
        ASSERT(RW_LOCK_HELD(&zfs_snapshot_lock));
 
        if (taskq_cancel_id(zfs_expire_taskq, se->se_taskqid) == 0) {
-               se->se_taskqid = -1;
+               se->se_taskqid = TASKQID_INVALID;
                zfsctl_snapshot_rele(se);
        }
 }
@@ -377,7 +377,7 @@ zfsctl_snapshot_unmount_cancel(zfs_snapentry_t *se)
 static void
 zfsctl_snapshot_unmount_delay_impl(zfs_snapentry_t *se, int delay)
 {
-       ASSERT3S(se->se_taskqid, ==, -1);
+       ASSERT3S(se->se_taskqid, ==, TASKQID_INVALID);
 
        if (delay <= 0)
                return;
index 8ac14df0039f0916fff1b505b3bcb61bc7b0f3ba..5b2099efb4d3fed57c5765f6fdbf50db7c56b798 100644 (file)
@@ -952,7 +952,7 @@ zfs_iput_async(struct inode *ip)
 
        if (atomic_read(&ip->i_count) == 1)
                VERIFY(taskq_dispatch(dsl_pool_iput_taskq(dmu_objset_pool(os)),
-                   (task_func_t *)iput, ip, TQ_SLEEP) != 0);
+                   (task_func_t *)iput, ip, TQ_SLEEP) != TASKQID_INVALID);
        else
                iput(ip);
 }
index c149b4ff234970938aaaf5eb8ea575021adb6470..638e3d805a0ad7d936c1df9d0a266b2f7736badd 100644 (file)
@@ -1557,7 +1557,7 @@ zio_delay_interrupt(zio_t *zio)
                                tid = taskq_dispatch_delay(system_taskq,
                                    (task_func_t *) zio_interrupt,
                                    zio, TQ_NOSLEEP, expire_at_tick);
-                               if (!tid) {
+                               if (tid == TASKQID_INVALID) {
                                        /*
                                         * Couldn't allocate a task.  Just
                                         * finish the zio without a delay.
index 72a6bc5e24bb64ede1cfc1d2e2b471628d7c4d83..b5169baf48d0af31dc51863d3fe9f30b9eb7413a 100644 (file)
@@ -1895,7 +1895,7 @@ zvol_create_minors(spa_t *spa, const char *name, boolean_t async)
                return;
 
        id = taskq_dispatch(spa->spa_zvol_taskq, zvol_task_cb, task, TQ_SLEEP);
-       if ((async == B_FALSE) && (id != 0))
+       if ((async == B_FALSE) && (id != TASKQID_INVALID))
                taskq_wait_id(spa->spa_zvol_taskq, id);
 }
 
@@ -1910,7 +1910,7 @@ zvol_remove_minors(spa_t *spa, const char *name, boolean_t async)
                return;
 
        id = taskq_dispatch(spa->spa_zvol_taskq, zvol_task_cb, task, TQ_SLEEP);
-       if ((async == B_FALSE) && (id != 0))
+       if ((async == B_FALSE) && (id != TASKQID_INVALID))
                taskq_wait_id(spa->spa_zvol_taskq, id);
 }
 
@@ -1926,7 +1926,7 @@ zvol_rename_minors(spa_t *spa, const char *name1, const char *name2,
                return;
 
        id = taskq_dispatch(spa->spa_zvol_taskq, zvol_task_cb, task, TQ_SLEEP);
-       if ((async == B_FALSE) && (id != 0))
+       if ((async == B_FALSE) && (id != TASKQID_INVALID))
                taskq_wait_id(spa->spa_zvol_taskq, id);
 }