Add TASKQID_INVALID

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
This commit is contained in:
Brian Behlendorf 2016-10-28 22:40:14 +00:00
parent b3c159fee4
commit 48d3eb40c7
12 changed files with 22 additions and 19 deletions

View File

@ -495,6 +495,8 @@ typedef struct taskq {
#define TQ_NOQUEUE 0x02 /* Do not enqueue if can't dispatch */ #define TQ_NOQUEUE 0x02 /* Do not enqueue if can't dispatch */
#define TQ_FRONT 0x08 /* Queue in front */ #define TQ_FRONT 0x08 /* Queue in front */
#define TASKQID_INVALID ((taskqid_t)0)
extern taskq_t *system_taskq; extern taskq_t *system_taskq;
extern taskq_t *taskq_create(const char *, int, pri_t, int, int, uint_t); extern taskq_t *taskq_create(const char *, int, pri_t, int, int, uint_t);

View File

@ -561,7 +561,7 @@ kcf_resubmit_request(kcf_areq_node_t *areq)
taskq_t *taskq = new_pd->pd_sched_info.ks_taskq; taskq_t *taskq = new_pd->pd_sched_info.ks_taskq;
if (taskq_dispatch(taskq, process_req_hwp, areq, TQ_NOSLEEP) == if (taskq_dispatch(taskq, process_req_hwp, areq, TQ_NOSLEEP) ==
(taskqid_t)0) { TASKQID_INVALID) {
error = CRYPTO_HOST_MEMORY; error = CRYPTO_HOST_MEMORY;
} else { } else {
error = CRYPTO_QUEUED; error = CRYPTO_QUEUED;
@ -782,7 +782,7 @@ kcf_submit_request(kcf_provider_desc_t *pd, crypto_ctx_t *ctx,
if (taskq_dispatch(taskq, if (taskq_dispatch(taskq,
process_req_hwp, areq, TQ_NOSLEEP) == process_req_hwp, areq, TQ_NOSLEEP) ==
(taskqid_t)0) { TASKQID_INVALID) {
error = CRYPTO_HOST_MEMORY; error = CRYPTO_HOST_MEMORY;
if (!(crq->cr_flag & CRYPTO_SKIP_REQID)) if (!(crq->cr_flag & CRYPTO_SKIP_REQID))
kcf_reqid_delete(areq); kcf_reqid_delete(areq);

View File

@ -3479,7 +3479,7 @@ arc_prune_async(int64_t adjust)
refcount_add(&ap->p_refcnt, ap->p_pfunc); refcount_add(&ap->p_refcnt, ap->p_pfunc);
ap->p_adjust = adjust; ap->p_adjust = adjust;
if (taskq_dispatch(arc_prune_taskq, arc_prune_task, 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); refcount_remove(&ap->p_refcnt, ap->p_pfunc);
continue; continue;
} }

View 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_upgrade_id = taskq_dispatch(
os->os_spa->spa_upgrade_taskq, os->os_spa->spa_upgrade_taskq,
dmu_objset_upgrade_task_cb, os, TQ_SLEEP); 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; os->os_upgrade_status = ENOMEM;
} }
mutex_exit(&os->os_upgrade_lock); mutex_exit(&os->os_upgrade_lock);

View 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) || if (!(flags & TRAVERSE_PREFETCH_DATA) ||
0 == taskq_dispatch(system_taskq, traverse_prefetch_thread, taskq_dispatch(system_taskq, traverse_prefetch_thread,
td, TQ_NOQUEUE)) td, TQ_NOQUEUE) == TASKQID_INVALID)
pd->pd_exited = B_TRUE; pd->pd_exited = B_TRUE;
err = traverse_visitbp(td, NULL, rootbp, czb); err = traverse_visitbp(td, NULL, rootbp, czb);

View File

@ -1724,7 +1724,7 @@ metaslab_group_preload(metaslab_group_t *mg)
*/ */
mutex_exit(&mg->mg_lock); mutex_exit(&mg->mg_lock);
VERIFY(taskq_dispatch(mg->mg_taskq, metaslab_preload, VERIFY(taskq_dispatch(mg->mg_taskq, metaslab_preload,
msp, TQ_SLEEP) != 0); msp, TQ_SLEEP) != TASKQID_INVALID);
mutex_enter(&mg->mg_lock); mutex_enter(&mg->mg_lock);
msp = msp_next; msp = msp_next;
} }

View File

@ -1191,7 +1191,7 @@ retry_sync:
for (c = 0; c < children; c++) for (c = 0; c < children; c++)
VERIFY(taskq_dispatch(tq, vdev_open_child, 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); taskq_destroy(tq);
} }

View File

@ -202,7 +202,8 @@ vdev_file_io_start(zio_t *zio)
*/ */
if (spl_fstrans_check()) { if (spl_fstrans_check()) {
VERIFY3U(taskq_dispatch(system_taskq, VERIFY3U(taskq_dispatch(system_taskq,
vdev_file_io_fsync, zio, TQ_SLEEP), !=, 0); vdev_file_io_fsync, zio, TQ_SLEEP), !=,
TASKQID_INVALID);
return; return;
} }
@ -220,7 +221,7 @@ vdev_file_io_start(zio_t *zio)
zio->io_target_timestamp = zio_handle_io_delay(zio); zio->io_target_timestamp = zio_handle_io_delay(zio);
VERIFY3U(taskq_dispatch(system_taskq, vdev_file_io_strategy, zio, VERIFY3U(taskq_dispatch(system_taskq, vdev_file_io_strategy, zio,
TQ_SLEEP), !=, 0); TQ_SLEEP), !=, TASKQID_INVALID);
} }
/* ARGSUSED */ /* ARGSUSED */

View File

@ -147,7 +147,7 @@ zfsctl_snapshot_alloc(char *full_name, char *full_path, spa_t *spa,
se->se_spa = spa; se->se_spa = spa;
se->se_objsetid = objsetid; se->se_objsetid = objsetid;
se->se_root_dentry = root_dentry; se->se_root_dentry = root_dentry;
se->se_taskqid = -1; se->se_taskqid = TASKQID_INVALID;
refcount_create(&se->se_refcount); refcount_create(&se->se_refcount);
@ -339,7 +339,7 @@ snapentry_expire(void *data)
return; return;
} }
se->se_taskqid = -1; se->se_taskqid = TASKQID_INVALID;
(void) zfsctl_snapshot_unmount(se->se_name, MNT_EXPIRE); (void) zfsctl_snapshot_unmount(se->se_name, MNT_EXPIRE);
zfsctl_snapshot_rele(se); zfsctl_snapshot_rele(se);
@ -366,7 +366,7 @@ zfsctl_snapshot_unmount_cancel(zfs_snapentry_t *se)
ASSERT(RW_LOCK_HELD(&zfs_snapshot_lock)); ASSERT(RW_LOCK_HELD(&zfs_snapshot_lock));
if (taskq_cancel_id(zfs_expire_taskq, se->se_taskqid) == 0) { if (taskq_cancel_id(zfs_expire_taskq, se->se_taskqid) == 0) {
se->se_taskqid = -1; se->se_taskqid = TASKQID_INVALID;
zfsctl_snapshot_rele(se); zfsctl_snapshot_rele(se);
} }
} }
@ -377,7 +377,7 @@ zfsctl_snapshot_unmount_cancel(zfs_snapentry_t *se)
static void static void
zfsctl_snapshot_unmount_delay_impl(zfs_snapentry_t *se, int delay) 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) if (delay <= 0)
return; return;

View File

@ -952,7 +952,7 @@ zfs_iput_async(struct inode *ip)
if (atomic_read(&ip->i_count) == 1) if (atomic_read(&ip->i_count) == 1)
VERIFY(taskq_dispatch(dsl_pool_iput_taskq(dmu_objset_pool(os)), 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 else
iput(ip); iput(ip);
} }

View File

@ -1557,7 +1557,7 @@ zio_delay_interrupt(zio_t *zio)
tid = taskq_dispatch_delay(system_taskq, tid = taskq_dispatch_delay(system_taskq,
(task_func_t *) zio_interrupt, (task_func_t *) zio_interrupt,
zio, TQ_NOSLEEP, expire_at_tick); zio, TQ_NOSLEEP, expire_at_tick);
if (!tid) { if (tid == TASKQID_INVALID) {
/* /*
* Couldn't allocate a task. Just * Couldn't allocate a task. Just
* finish the zio without a delay. * finish the zio without a delay.

View File

@ -1895,7 +1895,7 @@ zvol_create_minors(spa_t *spa, const char *name, boolean_t async)
return; return;
id = taskq_dispatch(spa->spa_zvol_taskq, zvol_task_cb, task, TQ_SLEEP); 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); 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; return;
id = taskq_dispatch(spa->spa_zvol_taskq, zvol_task_cb, task, TQ_SLEEP); 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); 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; return;
id = taskq_dispatch(spa->spa_zvol_taskq, zvol_task_cb, task, TQ_SLEEP); 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); taskq_wait_id(spa->spa_zvol_taskq, id);
} }