From owner-svn-src-projects@freebsd.org Thu Mar 21 23:31:12 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 07C971552B73 for ; Thu, 21 Mar 2019 23:31:12 +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 988E985A63; Thu, 21 Mar 2019 23:31:11 +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 74067181B5; Thu, 21 Mar 2019 23:31:11 +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 x2LNVBEj081708; Thu, 21 Mar 2019 23:31:11 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2LNVAlG081704; Thu, 21 Mar 2019 23:31:10 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201903212331.x2LNVAlG081704@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Thu, 21 Mar 2019 23:31:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345399 - in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs X-SVN-Commit-Revision: 345399 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 988E985A63 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.96)[-0.963,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] 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: Thu, 21 Mar 2019 23:31:12 -0000 Author: asomers Date: Thu Mar 21 23:31:10 2019 New Revision: 345399 URL: https://svnweb.freebsd.org/changeset/base/345399 Log: fusefs: correctly handle cacheable negative LOOKUP responses The FUSE protocol allows for LOOKUP to return a cacheable negative response, which means that the file doesn't exist and the kernel can cache its nonexistence. As of this commit fusefs doesn't cache the nonexistence, but it does correctly handle such responses. Prior to this commit attempting to create a file, even with O_CREAT would fail with ENOENT if the daemon returned a cacheable negative response. PR: 236231 Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/sys/fs/fuse/fuse_vnops.c projects/fuse2/tests/sys/fs/fusefs/create.cc projects/fuse2/tests/sys/fs/fusefs/mkdir.cc projects/fuse2/tests/sys/fs/fusefs/rename.cc Modified: projects/fuse2/sys/fs/fuse/fuse_vnops.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_vnops.c Thu Mar 21 23:01:56 2019 (r345398) +++ projects/fuse2/sys/fs/fuse/fuse_vnops.c Thu Mar 21 23:31:10 2019 (r345399) @@ -747,6 +747,7 @@ calldaemon: * but it's also cacheable (which we keep * keep on doing not as of writing this) */ + fdi.answ_stat = ENOENT; lookup_err = ENOENT; } else if (nid == FUSE_ROOT_ID) { lookup_err = EINVAL; Modified: projects/fuse2/tests/sys/fs/fusefs/create.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/create.cc Thu Mar 21 23:01:56 2019 (r345398) +++ projects/fuse2/tests/sys/fs/fusefs/create.cc Thu Mar 21 23:31:10 2019 (r345399) @@ -185,8 +185,7 @@ TEST_F(Create, DISABLED_Enosys) /* * Creating a new file after FUSE_LOOKUP returned a negative cache entry */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236231 */ -TEST_F(Create, DISABLED_entry_cache_negative) +TEST_F(Create, entry_cache_negative) { const char FULLPATH[] = "mountpoint/some_file.txt"; const char RELPATH[] = "some_file.txt"; @@ -240,8 +239,7 @@ TEST_F(Create, DISABLED_entry_cache_negative) /* * Creating a new file should purge any negative namecache entries */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236231 */ -TEST_F(Create, DISABLED_entry_cache_negative_purge) +TEST_F(Create, entry_cache_negative_purge) { const char FULLPATH[] = "mountpoint/some_file.txt"; const char RELPATH[] = "some_file.txt"; Modified: projects/fuse2/tests/sys/fs/fusefs/mkdir.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/mkdir.cc Thu Mar 21 23:01:56 2019 (r345398) +++ projects/fuse2/tests/sys/fs/fusefs/mkdir.cc Thu Mar 21 23:31:10 2019 (r345399) @@ -69,8 +69,7 @@ TEST_F(Mkdir, emlink) /* * Creating a new directory after FUSE_LOOKUP returned a negative cache entry */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236231 */ -TEST_F(Mkdir, DISABLED_entry_cache_negative) +TEST_F(Mkdir, entry_cache_negative) { const char FULLPATH[] = "mountpoint/some_file.txt"; const char RELPATH[] = "some_file.txt"; @@ -109,8 +108,7 @@ TEST_F(Mkdir, DISABLED_entry_cache_negative) /* * Creating a new directory should purge any negative namecache entries */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236231 */ -TEST_F(Mkdir, DISABLED_entry_cache_negative_purge) +TEST_F(Mkdir, entry_cache_negative_purge) { const char FULLPATH[] = "mountpoint/some_file.txt"; const char RELPATH[] = "some_file.txt"; Modified: projects/fuse2/tests/sys/fs/fusefs/rename.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/rename.cc Thu Mar 21 23:01:56 2019 (r345398) +++ projects/fuse2/tests/sys/fs/fusefs/rename.cc Thu Mar 21 23:31:10 2019 (r345399) @@ -86,8 +86,7 @@ TEST_F(Rename, enoent) /* * Renaming a file after FUSE_LOOKUP returned a negative cache entry for dst */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236231 */ -TEST_F(Rename, DISABLED_entry_cache_negative) +TEST_F(Rename, entry_cache_negative) { const char FULLDST[] = "mountpoint/dst"; const char RELDST[] = "dst"; @@ -126,8 +125,7 @@ TEST_F(Rename, DISABLED_entry_cache_negative) /* * Renaming a file should purge any negative namecache entries for the dst */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236231 */ -TEST_F(Rename, DISABLED_entry_cache_negative_purge) +TEST_F(Rename, entry_cache_negative_purge) { const char FULLDST[] = "mountpoint/dst"; const char RELDST[] = "dst"; @@ -136,12 +134,7 @@ TEST_F(Rename, DISABLED_entry_cache_negative_purge) // FUSE hardcodes the mountpoint to inode 1 uint64_t dst_dir_ino = 1; uint64_t ino = 42; - /* - * Set entry_valid = 0 because this test isn't concerned with whether - * or not we actually cache negative entries, only with whether we - * interpret negative cache responses correctly. - */ - struct timespec entry_valid = {.tv_sec = 0, .tv_nsec = 0}; + struct timespec entry_valid = {.tv_sec = TIME_T_MAX, .tv_nsec = 0}; expect_lookup(RELSRC, ino, S_IFREG | 0644, 0, 1); /* LOOKUP returns a negative cache entry for dst */ @@ -164,7 +157,7 @@ TEST_F(Rename, DISABLED_entry_cache_negative_purge) ASSERT_EQ(0, rename(FULLSRC, FULLDST)) << strerror(errno); /* Finally, a subsequent lookup should query the daemon */ - expect_lookup(RELSRC, ino, S_IFREG | 0644, 0, 1); + expect_lookup(RELDST, ino, S_IFREG | 0644, 0, 1); ASSERT_EQ(0, access(FULLDST, F_OK)) << strerror(errno); }