Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F111111594
D26759.id78189.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D26759.id78189.diff
View Options
Index: head/sys/contrib/openzfs/module/os/freebsd/spl/spl_taskq.c
===================================================================
--- head/sys/contrib/openzfs/module/os/freebsd/spl/spl_taskq.c
+++ head/sys/contrib/openzfs/module/os/freebsd/spl/spl_taskq.c
@@ -67,7 +67,7 @@
static unsigned long tqenthashlock;
static struct sx *tqenthashtbl_lock;
-static uint32_t tqidnext = 1;
+static taskqid_t tqidnext;
#define TQIDHASH(tqid) (&tqenthashtbl[(tqid) & tqenthash])
#define TQIDHASHLOCK(tqid) (&tqenthashtbl_lock[((tqid) & tqenthashlock)])
@@ -90,7 +90,6 @@
M_TASKQ, M_WAITOK | M_ZERO);
for (i = 0; i < tqenthashlock + 1; i++)
sx_init_flags(&tqenthashtbl_lock[i], "tqenthash", SX_DUPOK);
- tqidnext = 1;
taskq_zone = uma_zcreate("taskq_zone", sizeof (taskq_ent_t),
NULL, NULL, NULL, NULL,
UMA_ALIGN_CACHE, 0);
@@ -121,6 +120,28 @@
SYSUNINIT(system_taskq_fini, SI_SUB_CONFIGURE, SI_ORDER_ANY, system_taskq_fini,
NULL);
+#ifdef __LP64__
+static taskqid_t
+__taskq_genid(void)
+{
+
+ return (atomic_fetchadd_long(&tqidnext, 1) + 1);
+}
+#else
+static taskqid_t
+__taskq_genid(void)
+{
+ taskqid_t tqid;
+
+ for (;;) {
+ tqid = atomic_fetchadd_int(&tqidnext, 1) + 1;
+ if (__predict_true(tqid != 0))
+ break;
+ }
+ return (tqid);
+}
+#endif
+
static taskq_ent_t *
taskq_lookup(taskqid_t tqid)
{
@@ -140,8 +161,10 @@
static taskqid_t
taskq_insert(taskq_ent_t *ent)
{
- taskqid_t tqid = atomic_fetchadd_int(&tqidnext, 1);
+ taskqid_t tqid;
+ tqid = __taskq_genid();
+ VERIFY(tqid);
ent->tqent_id = tqid;
ent->tqent_registered = B_TRUE;
sx_xlock(TQIDHASHLOCK(tqid));
@@ -289,7 +312,7 @@
uint_t flags, clock_t expire_time)
{
taskq_ent_t *task;
- taskqid_t tid;
+ taskqid_t tqid;
clock_t timo;
int mflag;
@@ -310,13 +333,13 @@
task->tqent_type = TIMEOUT_TASK;
task->tqent_cancelled = B_FALSE;
refcount_init(&task->tqent_rc, 1);
- tid = taskq_insert(task);
+ tqid = taskq_insert(task);
TIMEOUT_TASK_INIT(tq->tq_queue, &task->tqent_timeout_task, 0,
taskq_run, task);
taskqueue_enqueue_timeout(tq->tq_queue, &task->tqent_timeout_task,
timo);
- return (tid);
+ return (tqid);
}
taskqid_t
@@ -324,7 +347,7 @@
{
taskq_ent_t *task;
int mflag, prio;
- taskqid_t tid;
+ taskqid_t tqid;
if ((flags & (TQ_SLEEP | TQ_NOQUEUE)) == TQ_SLEEP)
mflag = M_WAITOK;
@@ -344,11 +367,10 @@
task->tqent_arg = arg;
task->tqent_cancelled = B_FALSE;
task->tqent_type = NORMAL_TASK;
- tid = taskq_insert(task);
+ tqid = taskq_insert(task);
TASK_INIT(&task->tqent_task, prio, taskq_run, task);
taskqueue_enqueue(tq->tq_queue, &task->tqent_task);
- VERIFY(tid);
- return (tid);
+ return (tqid);
}
static void
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Feb 28, 2:15 PM (5 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16886335
Default Alt Text
D26759.id78189.diff (2 KB)
Attached To
Mode
D26759: zfs: fix panic due to tqid overflow
Attached
Detach File
Event Timeline
Log In to Comment