From nobody Sat Jan 1 03:39:04 2022 X-Original-To: dev-commits-src-main@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 C5DFF191F2DA; Sat, 1 Jan 2022 03:39:04 +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 4JQnmm2nt6z3sQN; Sat, 1 Jan 2022 03:39:04 +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 4114717A44; Sat, 1 Jan 2022 03:39:04 +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 2013d4px095750; Sat, 1 Jan 2022 03:39:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2013d4n8095749; Sat, 1 Jan 2022 03:39:04 GMT (envelope-from git) Date: Sat, 1 Jan 2022 03:39:04 GMT Message-Id: <202201010339.2013d4n8095749@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alan Somers Subject: git: 8d99a6b91b78 - main - fusefs: move common code from forget.cc to utils.cc List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 8d99a6b91b788b7ddf88f975f288f7c6479f4be3 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641008344; 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=F2xZDW8jxKhq+Lj05bB7oAVhGBDm2+Th2E3FsXPDuKY=; b=MlTtN2vwJUcgd/RNnRUM/feSexvOcwefeazdeMbJvKXu58yPfhFt8kYegL7rm38qaLx198 Tw3I7wUa12f45K2GdC46JQDy71VhwkWU+V6fLtVFyWFIrADczIVQYyfbaAsP7B35iiyAv+ lR2M5SN/vhpYe8r/yh/MPE0nb+0a4WihYBRd3PDqcEID6KW74bLBkegDOhaOeOLv+2EdEb 02Krr0dyR5BFL4/ChGCcoNbWcByXcOfL174AUZMHbdLEyQLW7UmNXc6hJgqkPsegGeCBtr fvOcareUKkLlnyE4azsyruSwWQGVBl2pqmeLlMutreJ3MHGgMfj48TWAQEZ54g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641008344; a=rsa-sha256; cv=none; b=KWknduu0SFQs+Cbj1GCfK8RTRcKuzi4b6G5ZxNOu7z52b6uY3HKOPxljHPdmmjPY1UyjaI t9Vyc7f4+tSzm9BQxQDj7hGQqbYQEGmrn5h3NZ0OSdbhLd4jv02XHLBu79dYy3DeZ9Jn3k wACh/jAatICmUbuO8lHeI7u1YcWTIvjSJYOnZx/kMI3WZWVne/IUADLSrNhCteG/mk3VLw U9GXf6dZowdxuANTLv556ohlvFmOk7/t3EOtlaBDnQb+W59U8LZLLxzEqErBgQ8tUSg1WG MHBaAghHSzbxmYzWPhriJea/+KuqI6Lq4eVhIL6Su+INQdn/OYoVbb4VZ1/ycQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=8d99a6b91b788b7ddf88f975f288f7c6479f4be3 commit 8d99a6b91b788b7ddf88f975f288f7c6479f4be3 Author: Alan Somers AuthorDate: 2021-12-02 02:50:26 +0000 Commit: Alan Somers CommitDate: 2022-01-01 03:38:20 +0000 fusefs: move common code from forget.cc to utils.cc MFC after: 2 weeks --- tests/sys/fs/fusefs/forget.cc | 10 ++-------- tests/sys/fs/fusefs/utils.cc | 9 +++++++++ tests/sys/fs/fusefs/utils.hh | 4 ++++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/tests/sys/fs/fusefs/forget.cc b/tests/sys/fs/fusefs/forget.cc index 2041d20efae4..84fc271df57c 100644 --- a/tests/sys/fs/fusefs/forget.cc +++ b/tests/sys/fs/fusefs/forget.cc @@ -44,8 +44,6 @@ extern "C" { using namespace testing; -const char reclaim_mib[] = "debug.try_reclaim_vnode"; - class Forget: public FuseTest { public: void SetUp() { @@ -67,7 +65,6 @@ TEST_F(Forget, ok) uint64_t ino = 42; mode_t mode = S_IFREG | 0755; sem_t sem; - int err; ASSERT_EQ(0, sem_init(&sem, 0, 0)) << strerror(errno); @@ -90,8 +87,7 @@ TEST_F(Forget, ok) ASSERT_EQ(0, access(FULLPATH, F_OK)) << strerror(errno); ASSERT_EQ(0, access(FULLPATH, F_OK)) << strerror(errno); - err = sysctlbyname(reclaim_mib, NULL, 0, FULLPATH, sizeof(FULLPATH)); - ASSERT_EQ(0, err) << strerror(errno); + reclaim_vnode(FULLPATH); sem_wait(&sem); sem_destroy(&sem); @@ -109,7 +105,6 @@ TEST_F(Forget, invalidate_names) const char FNAME[] = "some_file.txt"; uint64_t dir_ino = 42; uint64_t file_ino = 43; - int err; EXPECT_LOOKUP(FUSE_ROOT_ID, DNAME) .Times(2) @@ -145,8 +140,7 @@ TEST_F(Forget, invalidate_names) ASSERT_EQ(0, access(FULLFPATH, F_OK)) << strerror(errno); /* Reclaim the directory, invalidating its children from namecache */ - err = sysctlbyname(reclaim_mib, NULL, 0, FULLDPATH, sizeof(FULLDPATH)); - ASSERT_EQ(0, err) << strerror(errno); + reclaim_vnode(FULLDPATH); /* Access the file again, causing another lookup */ ASSERT_EQ(0, access(FULLFPATH, F_OK)) << strerror(errno); diff --git a/tests/sys/fs/fusefs/utils.cc b/tests/sys/fs/fusefs/utils.cc index f733fef7ebe0..fb2109e1e9c4 100644 --- a/tests/sys/fs/fusefs/utils.cc +++ b/tests/sys/fs/fusefs/utils.cc @@ -623,6 +623,15 @@ out: return; } +void +FuseTest::reclaim_vnode(const char *path) +{ + int err; + + err = sysctlbyname(reclaim_mib, NULL, 0, path, strlen(path) + 1); + ASSERT_EQ(0, err) << strerror(errno); +} + static void usage(char* progname) { fprintf(stderr, "Usage: %s [-v]\n\t-v increase verbosity\n", progname); exit(2); diff --git a/tests/sys/fs/fusefs/utils.hh b/tests/sys/fs/fusefs/utils.hh index 6f1f91b02c97..610d2126fa52 100644 --- a/tests/sys/fs/fusefs/utils.hh +++ b/tests/sys/fs/fusefs/utils.hh @@ -73,6 +73,7 @@ class FuseTest : public ::testing::Test { unsigned m_time_gran; MockFS *m_mock = NULL; const static uint64_t FH = 0xdeadbeef1a7ebabe; + const char *reclaim_mib = "debug.try_reclaim_vnode"; public: int m_maxbcachebuf; @@ -256,4 +257,7 @@ class FuseTest : public ::testing::Test { * See comments for FuseTest::leak */ static void leakdir(DIR* dirp __unused) {} + + /* Manually reclaim a vnode. Requires root privileges. */ + void reclaim_vnode(const char *fullpath); };