History log of /freebsd-current/tests/sys/fs/fusefs/read.cc
Revision Date Author Comments
# e9b411d2 06-May-2024 Gleb Smirnoff <glebius@FreeBSD.org>

tests/fusefs: fix all tests that depend on kern.maxphys

The tests try to read kern.maxphys sysctl into int value, while
unsigned long is required. Not sure when this was broken, seems like
since cd8537910406e.

Reviewed by: asomers
Differential Revision: https://reviews.freebsd.org/D45053


# 8bae22bb 15-Jan-2024 Alan Somers <asomers@FreeBSD.org>

fusefs: prefer new/delete over malloc/free

MFC after: 2 weeks
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D43464


# e5236d25 21-Sep-2023 Alan Somers <asomers@FreeBSD.org>

fusefs: fix unused variables from fb619c94c67

PR: 270749
Reported by: cy
MFC after: 1 week
MFC with: fb619c94c679e939496fe0cf94b8d2cba95e6e63
Sponsored by: Axcient


# fb619c94 20-Sep-2023 Alan Somers <asomers@FreeBSD.org>

fusefs: fix some bugs updating atime during close

When using cached attributes, we must update a file's atime during
close, if it has been read since the last attribute refresh. But,

* Don't update atime if we lack write permissions to the file or if the
file system is readonly.
* If the daemon fails our atime update request for any reason, don't
report this as a failure for VOP_CLOSE.

PR: 270749
Reported by: Jamie Landeg-Jones <jamie@catflap.org>
MFC after: 1 week
Sponsored by: Axcient
Reviewed by: pfg
Differential Revision: https://reviews.freebsd.org/D41925


# b3e76948 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: two-line .h pattern

Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/


# 811e0a31 08-Aug-2023 Enji Cooper <ngie@FreeBSD.org>

fusefs tests: handle -Wdeprecated* issues with GoogleTest 1.14.0

`INSTANTIATE_TEST_CASE_P` has been replaced with `INSTANTIATE_TEST_SUITE_P`.
Replace all uses of the former macro with the latter macro.

While here, address the fact that the latter macro doesn't permit some
of the constructions that the former macro did, e.g., empty parameters,
etc.

MFC after: 2 weeks
Reviewed by: asomers
Differential Revision: https://reviews.freebsd.org/D41398


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 0b6a34ac 12-Feb-2022 Alan Somers <asomers@FreeBSD.org>

[skip ci] fusefs: delete a stray comment from 91972cfcddf

MFC after: 3 days


# d109559d 28-Nov-2021 Alan Somers <asomers@FreeBSD.org>

fusefs: fix 32-bit build of the tests after 91972cfcddf

MFC after: 2 weeks
MFC with: 91972cfcddf950d7a9c33df5a9171ada1805a144


# 91972cfc 28-Nov-2021 Alan Somers <asomers@FreeBSD.org>

fusefs: update atime on reads when using cached attributes

When using cached attributes, whether or not the data cache is enabled,
fusefs must update a file's atime whenever it reads from it, so long as
it wasn't mounted with -o noatime. Update it in-kernel, and flush it to
the server on close or during the next setattr operation.

The downside is that close() will now frequently trigger a FUSE_SETATTR
upcall. But if you care about performance, you should be using
-o noatime anyway.

MFC after: 2 weeks
Reviewed by: pfg
Differential Revision: https://reviews.freebsd.org/D33145


# 3fcbde5e 22-Sep-2021 Konstantin Belousov <kib@FreeBSD.org>

tests/sys/fs/fusefs/read.cc: fix build on powerpc64

There sig_atomic_t is shorter than void *.
As result, it cannot keep pointer.

Assigning to void * is actually safe for us in a signal handler.

Reviewed by: asomers
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Fixes: 4f917847c9037d
Differential revision: https://reviews.freebsd.org/D32064


# 4f917847 16-Sep-2021 Alan Somers <asomers@FreeBSD.org>

fusefs: don't panic if FUSE_GETATTR fails durint VOP_GETPAGES

During VOP_GETPAGES, fusefs needs to determine the file's length, which
could require a FUSE_GETATTR operation. If that fails, it's better to
SIGBUS than panic.

MFC after: 1 week
Sponsored by: Axcient
Reviewed by: markj, kib
Differential Revision: https://reviews.freebsd.org/D31994


# 7ee7e409 12-Feb-2020 Alan Somers <asomers@FreeBSD.org>

fusefs: fix some memory leaks in the tests.

Oddly, most of these were not detected by Coverity.

Reported by: Coverity (one of them, anyway)
Coverity CID: 1404490
MFC after: 2 weeks


# 8e765737 06-Sep-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: coverity cleanup in the tests

Address the following defects reported by Coverity:

* Structurally dead code (CID 1404366): set m_quit before FAIL, not after

* Unchecked return value of sysctlbyname (CID 1404321)

* Unchecked return value of stat(2) (CID 1404471)

* Unchecked return value of open(2) (CID 1404402, 1404529)

* Unchecked return value of dup(2) (CID 1404478)

* Buffer overflows. These are all false positives caused by the fact that
Coverity thinks I'm using a buffer to store strings, when in fact I'm
really just using it to store a byte array that happens to be initialized
with a string. I'm changing the type from char to uint8_t in the hopes
that it will placate Coverity. (CID 1404338, 1404350, 1404367, 1404376,
1404379, 1404381, 1404388, 1404403, 1404425, 1404433, 1404434, 1404474,
1404480, 1404484, 1404503, 1404505)

* False positive file descriptor leak. I'm going to try to fix this with
Coverity modeling, but I'll also change an EXPECT to ASSERT so we don't
perform meaningless assertions after the failure. (CID 1404320, 1404324,
1404440, 1404445).

* Unannotated file descriptor leak. This will be followed up by a Coverity
modeling change. (CID 1404326, 1404334, 1404336, 1404357, 1404361,
1404372, 1404391, 1404395, 1404409, 1404430, 1404448, 1404451, 1404455,
1404457, 1404458, 1404460)

* Uninitialized variables in C++ constructors (CID 1404327, 1404346). In the
case of m_maxphys, this actually led to part of the FUSE_INIT's response
being set to stack garbage during the WriteCluster::clustering test.

* Uninitialized sun_len field in struct sockaddr_un (CID 1404330, 1404371,
1404429).

Reported by: Coverity
Reviewed by: emaste
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21457


# 1fa8ebfb 13-Aug-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: add SVN Keywords to the test files

Reported by: SVN pre-commit hooks
MFC after: 15 days
MFC-With: r350665
Sponsored by: The FreeBSD Foundation


# c2265ae7 12-Aug-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: skip some tests when unsafe aio is disabled

MFC after: 16 days
MFC-With: r350665
Sponsored by: The FreeBSD Foundation


# 5a0b9a27 19-Jul-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: fix warnings in the tests reported by GCC

Sponsored by: The FreeBSD Foundation


# fca79580 19-Jul-2019 Alan Somers <asomers@FreeBSD.org>

sendfile: don't panic when VOP_GETPAGES_ASYNC returns an error

PR: 236466
Sponsored by: The FreeBSD Foundation


# f74b33d9 26-Jun-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: tighten expectations in mmap tests

In r349378 I fixed mmap's habit of reading more data than was available.

Sponsored by: The FreeBSD Foundation


# 7fc0921d 26-Jun-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: annotate deliberate file descriptor leaks in the tests

closing a file descriptor causes FUSE activity that is superfluous to the
purpose of most tests, but would nonetheless require matching expectations.
Rather than do that, most tests deliberately leak file descriptors instead.
This commit moves the leakage from each test into two trivial functions:
leak and leakdir. Hopefully Coverity will only complain about those
functions and not all of their callers.

Sponsored by: The FreeBSD Foundation


# f8ebf1cd 26-Jun-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: implement protocol 7.23's FUSE_WRITEBACK_CACHE option

As of protocol 7.23, fuse file systems can specify their cache behavior on a
per-mountpoint basis. If they set FUSE_WRITEBACK_CACHE in
fuse_init_out.flags, then they'll get the writeback cache. If not, then
they'll get the writethrough cache. If they set FOPEN_DIRECT_IO in every
FUSE_OPEN response, then they'll get no cache at all.

The old vfs.fusefs.data_cache_mode sysctl is ignored for servers that use
protocol 7.23 or later. However, it's retained for older servers,
especially for those running in jails that lack access to the new protocol.

This commit also fixes two other minor test bugs:
* WriteCluster:SetUp was using an uninitialized variable.
* Read.direct_io_pread wasn't verifying that the cache was actually
bypassed.

Sponsored by: The FreeBSD Foundation


# f2704f05 25-Jun-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: fix the tests for non-default values of MAXPHYS

Sponsored by: The FreeBSD Foundation


# 6ca3b02b 25-Jun-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: fix the tests for nondefault values of vfs.maxbcachebuf

Sponsored by: The FreeBSD Foundation


# b9e20197 25-Jun-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: rewrite vop_getpages and vop_putpages

Use the standard facilities for getpages and putpages instead of bespoke
implementations that don't work well with the writeback cache. This has
several corollaries:

* Change the way we handle short reads _again_. vfs_bio_getpages doesn't
provide any way to handle unexpected short reads. Plus, I found some more
lock-order problems. So now when the short read is detected we'll just
clear the vnode's attribute cache, forcing the file size to be requeried
the next time it's needed. VOP_GETPAGES doesn't have any way to indicate
a short read to the "caller", so we just bzero the rest of the page
whenever a short read happens.

* Change the way we decide when to set the FUSE_WRITE_CACHE bit. We now set
it for clustered writes even when the writeback cache is not in use.

Sponsored by: The FreeBSD Foundation


# aef22f2d 21-Jun-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: correctly handle short reads

A fuse server may return a short read for three reasons:

* The file is opened with FOPEN_DIRECT_IO. In this case, the short read
should be returned directly to userland. We already handled this case
correctly.

* The file was truncated server-side, and the read hit EOF. In this case,
the kernel should update the file size. Fixed in the case of VOP_READ.
Fixing this for VOP_GETPAGES is TODO.

* The file is opened in writeback mode, there are dirty buffers past what
the server thinks is the file's EOF, and the read hit what the server
thinks is the file's EOF. In this case, the client is trying to read a
hole, and should zero-fill it. We already handled this case, and I added
a test for it.

Sponsored by: The FreeBSD Foundation


# a1c9f4ad 20-Jun-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: implement VOP_BMAP

If the fuse daemon supports FUSE_BMAP, then use that for the block mapping.
Otherwise, use the same technique used by vop_stdbmap. Report large values
for runp and runb in order to maximize read clustering and minimize upcalls,
even if we don't know the true layout.

The major result of this change is that sequential reads to FUSE files will
now usually happen 128KB at a time instead of 64KB.

Sponsored by: The FreeBSD Foundation


# 402b609c 17-Jun-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: use cluster_read for more readahead

fusefs will now use cluster_read. This allows readahead of more than one
cache block. However, it won't yet actually cluster the reads because that
requires VOP_BMAP, which fusefs does not yet implement.

Sponsored by: The FreeBSD Foundation


# d569012f 17-Jun-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: implement non-clustered readahead

fusefs will now read ahead at most one cache block at a time (usually 64
KB). Clustered reads are still TODO. Individual file systems may disable
read ahead by setting fuse_init_out.max_readahead=0 during initialization.

Sponsored by: The FreeBSD Foundation


# eadd12d3 17-Jun-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: rename the ReadCacheable.default_readahead test

The test didn't actually have anything to do with readahead. Rename it to
"ReadCacheable.cache_block"

Sponsored by: The FreeBSD Foundation


# 29edc611 27-May-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: make the tests more cplusplusy

* Prefer std::unique_ptr to raw pointers
* Prefer pass-by-reference to pass-by-pointer
* Prefer static_cast to C-style cast, unless it's too much typing

Reported by: ngie
Sponsored by: The FreeBSD Foundation


# cc04566c 25-May-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: more build fixes

* Fix printf format strings on 32-bit OSes
* Fix -Wclass-memaccess violation on GCC-8 caused by using memset on an object
of non-trivial type.
* Fix memory leak in MockFS::init
* Fix -Wcast-align error on i386 in expect_readdir
* Fix some heterogenous comparison errors on 32-bit OSes.

Sponsored by: The FreeBSD Foundation


# e97ae4ad 23-May-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: implement FUSE_ASYNC_READ

If a daemon sets the FUSE_ASYNC_READ flag during initialization, then the
client is allowed to issue multiple concurrent reads for the same file
handle. Otherwise concurrent reads are not allowed. This commit implements
it. Previously we unconditionally disallowed concurrent reads.

Sponsored by: The FreeBSD Foundation


# 16bd2d47 16-May-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: Upgrade FUSE protocol to version 7.9.

This commit upgrades the FUSE API to protocol 7.9 and adds unit tests for
backwards compatibility with servers built for version 7.8. It doesn't
implement any of 7.9's new features yet.

Sponsored by: The FreeBSD Foundation


# a87257ac 09-May-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: shorten and consolidate sleeps

Some fusefs tests must sleep because they deliberately trigger a race, or
because they're testing the cache timeout functionality. Consolidate the
sleep interval in a single place so it will be easy to adjust. Shorten it
from either 500ms or 250ms to 100ms. From experiment I find that 10ms works
every time, so 100ms should be fairly safe.

Sponsored by: The FreeBSD Foundation


# df66475a 09-Apr-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: skip the Read.keep_cache test when cache is disabled

This should've been part of r345892

PR: 236560
Sponsored by: The FreeBSD Foundation


# cad67791 08-Apr-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: cache file attributes

FUSE_LOOKUP, FUSE_GETATTR, FUSE_SETATTR, FUSE_MKDIR, FUSE_LINK,
FUSE_SYMLINK, FUSE_MKNOD, and FUSE_CREATE all return file attributes with a
cache validity period. fusefs will now cache the attributes, if the server
returns a non-zero cache validity period.

This change does _not_ implement finite attr cache timeouts. That will
follow as part of PR 235773.

PR: 235775
Reported by: cem
Sponsored by: The FreeBSD Foundation


# a7e81cb3 04-Apr-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: properly handle FOPEN_KEEP_CACHE

If a fuse file system returne FOPEN_KEEP_CACHE in the open or create
response, then the client is supposed to _not_ clear its caches for that
file. I don't know why clearing the caches would be the default given that
there's a separate flag to bypass the cache altogether, but that's the way
it is. fusefs(5) will now honor this flag.

Our behavior is slightly different than Linux's because we reuse file
handles. That means that open(2) wont't clear the cache if there's a
reusable file handle, even if the file server wouldn't have sent
FOPEN_KEEP_CACHE had we opened a new file handle like Linux does.

PR: 236560
Sponsored by: The FreeBSD Foundation


# 4b97bb00 29-Mar-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: fix more tests when data caching is disabled

readahead is also disallowed when data_cache_mode=0. This should've been
part of r345720.

Sponsored by: The FreeBSD Foundation


# f3b5de29 29-Mar-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: fix tests when data caching is disabled

VOP_GETPAGES is disabled when vfs.fusefs.data_cache_mode=0, causing mmap to
return success but accessing the mapped memory will subsequently segfault.

Sponsored by: The FreeBSD Foundation


# 9821f1d3 20-Mar-2019 Alan Somers <asomers@FreeBSD.org>

fusefs: adapt the tests to the fuse => fusefs rename

Sponsored by: The FreeBSD Foundation