From nobody Tue Dec 14 21:48:13 2021 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 E903318E832D; Tue, 14 Dec 2021 21:48:13 +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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JDBnn4rPfz3qpv; Tue, 14 Dec 2021 21:48:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8200610682; Tue, 14 Dec 2021 21:48:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BELmDPi096674; Tue, 14 Dec 2021 21:48:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BELmDtY096673; Tue, 14 Dec 2021 21:48:13 GMT (envelope-from git) Date: Tue, 14 Dec 2021 21:48:13 GMT Message-Id: <202112142148.1BELmDtY096673@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: 0a44675ba50a - stable/13 - fusefs: fix intermittency in the dev_fuse_poll test List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0a44675ba50a9e440ded268bb2a728c044a4f20c Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639518493; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DupLUj4n/claAL7MmtZdjVRGi4RqHHOIyQzKLcdJ0YM=; b=aEwT4dJ1PxW00FYlKktkM17tOguVWqy2beSAXx39Tg6paS6QRPIM2p4F/3EBvdCiaEVzlm WBKu7fOw6Tf6enb6DLnHjMzzqRuOWVrNIZio7UQq5R7BaH0GX7Gwjb5rE/wbvdQLeNsT6d S/lki2EdNHN7hDLD7w1swUuAV8/8iNmKY1yIRxBbe/TguxicyWqNn1T2WjbPRxpWPWD8hx JWW2ppByHPvvQWajvgpUxJnyrPEeaahYOEYJ8+OaXwOtoVdz19g121kYbvML2X8PZNaM1Z UOYcppSS7k+fqxYcV9F+kr3Pphfp6SyvFTqRSmKfLKxN/d7nUcSmAPmI/52DHQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639518493; a=rsa-sha256; cv=none; b=ssR7GKsTYJhy6qCSKJWJPnykFx8LcRdKYl2S0xZlzE2z7nu7JoHjQt4FXheG5vDRJQnhyL pkAdcC7+NeZaPqH27OWxjL5zE8ZUIiRZ++jjjQM7ptY/gfbrDQpeMJZ+nkA3LmLGFa4vWB 13J9CiLXLljmlUXNCqEPAA8scu+mskzqe97y5YEluVZCpU/KdLe5u70PosNXS0IDn3swk3 gvywG5IK1Qm8/VfTlHk6mKtvdA21D12wp9l5bZFK8F9h1WHkNkQKp6ZYKCZ6AH2BWGuBbL TT8GrLiLKi+S0qLNWSFOUtw4fkEfdf5nTLrmbXSZxqdKt5HSluISwsoOr4PeNA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=0a44675ba50a9e440ded268bb2a728c044a4f20c commit 0a44675ba50a9e440ded268bb2a728c044a4f20c Author: Alan Somers AuthorDate: 2021-09-25 16:16:20 +0000 Commit: Alan Somers CommitDate: 2021-12-14 21:47:32 +0000 fusefs: fix intermittency in the dev_fuse_poll test The DevFusePoll::access/select test would occasionally segfault. The cause was a file descriptor that was shared between two threads. The first thread would kill the second and close the file descriptor. But it was possible that the second would read the file descriptor before it shut down. That did not cause problems for kqueue, poll, or blocking operation, but it triggered segfaults in select's macros. Differential Revision: https://reviews.freebsd.org/D32142 (cherry picked from commit f44a448709d3b77508fd59ee28201ae1666387c2) --- tests/sys/fs/fusefs/mockfs.cc | 10 +++++++--- tests/sys/fs/fusefs/mockfs.hh | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/sys/fs/fusefs/mockfs.cc b/tests/sys/fs/fusefs/mockfs.cc index 4d0724b9c227..99f7ccc61273 100644 --- a/tests/sys/fs/fusefs/mockfs.cc +++ b/tests/sys/fs/fusefs/mockfs.cc @@ -870,6 +870,7 @@ void MockFS::read_request(mockfs_buf_in &in, ssize_t &res) { struct timeval timeout_tv; const int timeout_ms = 999; int timeout_int, nfds; + int fuse_fd; switch (m_pm) { case BLOCKING: @@ -906,19 +907,22 @@ void MockFS::read_request(mockfs_buf_in &in, ssize_t &res) { ASSERT_TRUE(fds[0].revents & POLLIN); break; case SELECT: + fuse_fd = m_fuse_fd; + if (fuse_fd < 0) + break; timeout_tv.tv_sec = 0; timeout_tv.tv_usec = timeout_ms * 1'000; - nfds = m_fuse_fd + 1; + nfds = fuse_fd + 1; while (nready == 0) { FD_ZERO(&readfds); - FD_SET(m_fuse_fd, &readfds); + FD_SET(fuse_fd, &readfds); nready = select(nfds, &readfds, NULL, NULL, &timeout_tv); if (m_quit) return; } ASSERT_LE(0, nready) << strerror(errno); - ASSERT_TRUE(FD_ISSET(m_fuse_fd, &readfds)); + ASSERT_TRUE(FD_ISSET(fuse_fd, &readfds)); break; default: FAIL() << "not yet implemented"; diff --git a/tests/sys/fs/fusefs/mockfs.hh b/tests/sys/fs/fusefs/mockfs.hh index 24ca017dcdb1..600a4b4292c0 100644 --- a/tests/sys/fs/fusefs/mockfs.hh +++ b/tests/sys/fs/fusefs/mockfs.hh @@ -284,7 +284,7 @@ class MockFS { pthread_t m_daemon_id; /* file descriptor of /dev/fuse control device */ - int m_fuse_fd; + volatile int m_fuse_fd; /* The minor version of the kernel API that this mock daemon targets */ uint32_t m_kernel_minor_version;