fusefs: standardize on OPNOTSUPP for posix_fallocate(2)

POSIX Issue 7 had allowed EINVAL for this case, but issue 8 moves it
to ENOTSUP instead.  ZFS uses the latter and we have some software in
ports already that's wanting to use that to detect the filesystem not
supporting it, so let's standardize on it.

Reviewed by:	imp (previous version), asomers, kib
Differential Revision:	https://reviews.freebsd.org/D53535
This commit is contained in:
Kyle Evans 2025-11-04 18:30:58 -06:00
parent 90314c04f1
commit fa393807c5
2 changed files with 11 additions and 11 deletions

View file

@ -625,7 +625,7 @@ fuse_vnop_allocate(struct vop_allocate_args *ap)
return (EROFS);
if (fsess_not_impl(mp, FUSE_FALLOCATE))
return (EXTERROR(EINVAL, "This server does not implement "
return (EXTERROR(EOPNOTSUPP, "This server does not implement "
"FUSE_FALLOCATE"));
io.uio_offset = *offset;
@ -656,14 +656,14 @@ fuse_vnop_allocate(struct vop_allocate_args *ap)
if (err == ENOSYS) {
fsess_set_notimpl(mp, FUSE_FALLOCATE);
err = EXTERROR(EINVAL, "This server does not implement "
err = EXTERROR(EOPNOTSUPP, "This server does not implement "
"FUSE_ALLOCATE");
} else if (err == EOPNOTSUPP) {
/*
* The file system server does not support FUSE_FALLOCATE with
* the supplied mode for this particular file.
*/
err = EXTERROR(EINVAL, "This file can't be pre-allocated");
err = EXTERROR(EOPNOTSUPP, "This file can't be pre-allocated");
} else if (!err) {
*offset += *len;
*len = 0;

View file

@ -205,7 +205,7 @@ TEST_F(Fspacectl, enosys)
EXPECT_EQ(0, fspacectl(fd, SPACECTL_DEALLOC, &rqsr, 0, NULL));
/* Neither should posix_fallocate query the daemon */
EXPECT_EQ(EINVAL, posix_fallocate(fd, off1, len1));
EXPECT_EQ(EOPNOTSUPP, posix_fallocate(fd, off1, len1));
leak(fd);
}
@ -548,7 +548,7 @@ INSTANTIATE_TEST_SUITE_P(FspacectlCache, FspacectlCache,
/*
* If the server returns ENOSYS, it indicates that the server does not support
* FUSE_FALLOCATE. This and future calls should return EINVAL.
* FUSE_FALLOCATE. This and future calls should return EOPNOTSUPP.
*/
TEST_F(PosixFallocate, enosys)
{
@ -570,10 +570,10 @@ TEST_F(PosixFallocate, enosys)
fd = open(FULLPATH, O_RDWR);
ASSERT_LE(0, fd) << strerror(errno);
EXPECT_EQ(EINVAL, posix_fallocate(fd, off0, len0));
EXPECT_EQ(EOPNOTSUPP, posix_fallocate(fd, off0, len0));
/* Subsequent calls shouldn't query the daemon*/
EXPECT_EQ(EINVAL, posix_fallocate(fd, off0, len0));
EXPECT_EQ(EOPNOTSUPP, posix_fallocate(fd, off0, len0));
/* Neither should VOP_DEALLOCATE query the daemon */
EXPECT_EQ(0, fspacectl(fd, SPACECTL_DEALLOC, &rqsr, 0, NULL));
@ -607,10 +607,10 @@ TEST_F(PosixFallocate, eopnotsupp)
fd = open(FULLPATH, O_RDWR);
ASSERT_LE(0, fd) << strerror(errno);
EXPECT_EQ(EINVAL, posix_fallocate(fd, fsize, length));
EXPECT_EQ(EOPNOTSUPP, posix_fallocate(fd, fsize, length));
/* Subsequent calls should still query the daemon*/
EXPECT_EQ(EINVAL, posix_fallocate(fd, offset, length));
EXPECT_EQ(EOPNOTSUPP, posix_fallocate(fd, offset, length));
/* And subsequent VOP_DEALLOCATE calls should also query the daemon */
rqsr.r_len = length;
@ -759,7 +759,7 @@ TEST_F(PosixFallocate, rlimit_fsize)
}
/* With older servers, no FUSE_FALLOCATE should be attempted */
TEST_F(PosixFallocate_7_18, einval)
TEST_F(PosixFallocate_7_18, eopnotsupp)
{
const char FULLPATH[] = "mountpoint/some_file.txt";
const char RELPATH[] = "some_file.txt";
@ -773,7 +773,7 @@ TEST_F(PosixFallocate_7_18, einval)
fd = open(FULLPATH, O_RDWR);
ASSERT_LE(0, fd) << strerror(errno);
EXPECT_EQ(EINVAL, posix_fallocate(fd, offset, length));
EXPECT_EQ(EOPNOTSUPP, posix_fallocate(fd, offset, length));
leak(fd);
}