From nobody Sat Nov 07 01:20:27 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jLysX51HYz70NxW for ; Sat, 07 Nov 2026 01:20:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jLysX4C6Mz4Wty for ; Sat, 07 Nov 2026 01:20:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794014432; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CT1y93JLzPDU3zLTju9bJt4vJSlFI+DrP2V7HpvkFkU=; b=AQKX761+/wNG3fVj1JgEiE2m2hWqwtviSP1LeuCISrSQfR11v4zTUJ347q71R3lXqY9GU6 hKo6MEIXgkp8CrdVCik5nK9qLc9nSJKpNinGZMQ98asngKmNj9g1y7KfiXpG4026DmxcSf 6RTPmM/lYcmFa6Zw0HEUs+8zRL2PXTMDltHwlwg6PJjV+Ofs7lQYyyxQ1VcqoWJUkhs5oZ b00MDgN1G1ao2L7XXZHlMQZlU6JPdfTbc3PzOVQXxB0GR8Jo/rnb8PPZjd0YZkKK+RofQb Mej7NA/wgszIsOhy+IDIW+a/L91Xwe5BqsF28sV3O1b2QjPQg6FtWsQ4yedHPw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794014432; b=gtQ49yodkt7BZ5rjkvUHQ6PMMTiF35jNk9TzYSj1gzf0kF3CAKDt/QOAylOPUe/91C78Ir 7RsuaToAg1/81IsiH4qptHMlkTVyc4NcSP3riNadGfA/upwQ7HRMfcEk+kGRVrFKOFDMTK uBT+lfdqpPffQm5TYdbM5oh1k4aDtK+WFbPfNoMStUH9AJyb3ag9YjAc/MyxxORkjPGP+c XXB9swvM/BEMc36tcqK8gdJja/mwMTARjdNhQV56pLAIrfs+/34uyGdaEdCpM6F4MMhuTh e3MOn+uklH06/XIrSmPnTcU5jPvO52EhFrhYcXbYzcz9ewvpby6tNFwvMJNWYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794014432; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CT1y93JLzPDU3zLTju9bJt4vJSlFI+DrP2V7HpvkFkU=; b=NDQEgPatMTFbKMSJ7g13p8OiSYh/W//oVkU3jXtbTh40YCDx00UlApHpgofrPR7WfuHDxd QBBQANZW1wkMIKg6JHPRbRUy0AA242LNyBEDFB4AtrSDrl8sMfsLY8OzCx2QBivjlvOsm1 tHceVQGJId0uJFjfCklkvj9oFPaZTAbGtIgxgESpPBwI0WmSfl9BbHObs24akAJi0/MFYw WVBG5oq7yar6cvK5Ejx3nJRb/EkJhNXVR1w8QzOJBskRUGuZ+iBxLH9hRdjaHvS4zmHeVD YC9aiY/TwpSAKdWdp4dkkJcKjTadybgsHDKl/ot0/NgSrI9dyUJWICEUkknDvg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jLysX3bnMz12JB for ; Sat, 07 Nov 2026 01:20:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 18b09 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 07 Nov 2026 01:20:27 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Hayzam Sherif From: Kenneth D. Merry Subject: git: c17aa0984de8 - main - camdd: Fix the worker startup race List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ken X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c17aa0984de83a1079cda81b5cce521e73c7a64d Auto-Submitted: auto-generated Date: Sat, 07 Nov 2026 01:20:27 +0000 Message-Id: <6aee7cdb.18b09.1d80ca@gitrepo.freebsd.org> The branch main has been updated by ken: URL: https://cgit.FreeBSD.org/src/commit/?id=c17aa0984de83a1079cda81b5cce521e73c7a64d commit c17aa0984de83a1079cda81b5cce521e73c7a64d Author: Hayzam Sherif AuthorDate: 2026-11-07 01:19:07 +0000 Commit: Kenneth D. Merry CommitDate: 2026-11-07 01:19:07 +0000 camdd: Fix the worker startup race The reader can hand off its first buffer before the writer sets CAMDD_DEV_FLAG_ACTIVE. camdd_queue_peer_buf() then mistakes the writer for an exited peer and releases the buffer instead of queueing it. This can make a copy fail with bytes read but nothing written, without an error message. Mark both devices active before creating either worker, leaving the workers to clear the flag on exit. The work queues and EVFILT_USER events are already initialized, so queued buffers and their notification can wait for the writer to start without a startup barrier. Treat pthread_create() failure as fatal. Returning through the normal cleanup path can free devices that an already-started worker is still using, and an unstarted peer cannot consume any queued buffers. Reviewed by: imp, markj, ken MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D61277 --- usr.sbin/camdd/camdd.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/usr.sbin/camdd/camdd.c b/usr.sbin/camdd/camdd.c index 3f36704646e3..8b1385bf880d 100644 --- a/usr.sbin/camdd/camdd.c +++ b/usr.sbin/camdd/camdd.c @@ -1684,8 +1684,6 @@ camdd_worker(void *arg) pthread_mutex_lock(&dev->mutex); - dev->flags |= CAMDD_DEV_FLAG_ACTIVE; - for (;;) { struct kevent ke; int retval = 0; @@ -3343,13 +3341,18 @@ camdd_rw(struct camdd_io_opts *io_opts, camdd_argmask arglist, int num_io_opts, goto bailout; } + /* + * Mark both devices active before starting either worker so that the + * reader can queue buffers before the writer starts running. + */ + for (i = 0; i < num_io_opts; i++) + devs[i]->flags |= CAMDD_DEV_FLAG_ACTIVE; + for (i = 0; i < num_io_opts; i++) { error = pthread_create(&threads[i], NULL, camdd_worker, (void *)devs[i]); - if (error != 0) { - warnc(error, "pthread_create() failed"); - goto bailout; - } + if (error != 0) + errc(1, error, "pthread_create() failed"); } for (;;) {