From owner-svn-src-projects@freebsd.org Mon Mar 4 19:10:24 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DE2A0151F3E5 for ; Mon, 4 Mar 2019 19:10:23 +0000 (UTC) (envelope-from asomers@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7D26082454; Mon, 4 Mar 2019 19:10:23 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 58BF58558; Mon, 4 Mar 2019 19:10:23 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x24JANSE003178; Mon, 4 Mar 2019 19:10:23 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x24JANP2003177; Mon, 4 Mar 2019 19:10:23 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201903041910.x24JANP2003177@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Mon, 4 Mar 2019 19:10:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r344775 - projects/fuse2/tests/sys/fs/fuse X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: projects/fuse2/tests/sys/fs/fuse X-SVN-Commit-Revision: 344775 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 7D26082454 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.980,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Mar 2019 19:10:24 -0000 Author: asomers Date: Mon Mar 4 19:10:22 2019 New Revision: 344775 URL: https://svnweb.freebsd.org/changeset/base/344775 Log: fuse(4): add tests for negative lookups PR: 236226 Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/tests/sys/fs/fuse/lookup.cc Modified: projects/fuse2/tests/sys/fs/fuse/lookup.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fuse/lookup.cc Mon Mar 4 19:06:51 2019 (r344774) +++ projects/fuse2/tests/sys/fs/fuse/lookup.cc Mon Mar 4 19:10:22 2019 (r344775) @@ -198,6 +198,65 @@ TEST_F(Lookup, entry_cache) ASSERT_EQ(0, access(FULLPATH, F_OK)) << strerror(errno); } +/* + * If the daemon returns an error of 0 and an inode of 0, that's a flag for + * "ENOENT and cache it" with the given entry_timeout + */ +/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236226 */ +TEST_F(Lookup, DISABLED_entry_cache_negative) +{ + EXPECT_CALL(*m_mock, process( + ResultOf([](auto in) { + return (in->header.opcode == FUSE_LOOKUP); + }, Eq(true)), + _) + ).Times(1) + .WillOnce(Invoke([](auto in, auto out) { + out->header.unique = in->header.unique; + out->header.error = 0; + out->body.entry.nodeid = 0; + out->body.entry.entry_valid = UINT64_MAX; + SET_OUT_HEADER_LEN(out, entry); + })); + EXPECT_NE(0, access("mountpoint/does_not_exist", F_OK)); + EXPECT_EQ(ENOENT, errno); + EXPECT_NE(0, access("mountpoint/does_not_exist", F_OK)); + EXPECT_EQ(ENOENT, errno); +} + +/* Negative entry caches should timeout, too */ +/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236226 */ +TEST_F(Lookup, DISABLED_entry_cache_negative_timeout) +{ + /* + * The timeout should be longer than the longest plausible time the + * daemon would take to complete a write(2) to /dev/fuse, but no longer. + */ + long timeout_ns = 250'000'000; + + EXPECT_CALL(*m_mock, process( + ResultOf([](auto in) { + return (in->header.opcode == FUSE_LOOKUP); + }, Eq(true)), + _) + ).Times(1) + .WillOnce(Invoke([=](auto in, auto out) { + out->header.unique = in->header.unique; + out->header.error = 0; + out->body.entry.nodeid = 0; + out->body.entry.entry_valid_nsec = timeout_ns; + SET_OUT_HEADER_LEN(out, entry); + })); + EXPECT_NE(0, access("mountpoint/does_not_exist", F_OK)); + EXPECT_EQ(ENOENT, errno); + + usleep(2 * timeout_ns / 1000); + + /* The cache has timed out; VOP_LOOKUP should requery the daemon*/ + EXPECT_NE(0, access("mountpoint/does_not_exist", F_OK)); + EXPECT_EQ(ENOENT, errno); +} + /* * If lookup returns a finite but non-zero entry cache timeout, then we should * discard the cached inode and requery the daemon