From nobody Thu Oct 23 13:41:05 2025 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 4csnHP6F9Cz6DWqR; Thu, 23 Oct 2025 13:41:05 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4csnHP5bCvz3JhV; Thu, 23 Oct 2025 13:41:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761226865; 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=UtJ5/sRBR4jWyvNGA5/40of16N0iI/52HB0mXb6K5Vw=; b=YFhWZdJyzbyJgI3jQaiHW6jUub9nnsnws3IggLFcZwfkFal87vkBx+y6xzTG0qNWqRNLzp CoW9vLmg/JI3iX//IRg7E2Xv64bUcSe+YlhLleWp8nAaFB1CTtpT95nv2e6ZLZXGNCLoAO Oe2YTZDvUCvmrGzXQn1uh42Dq3qs7hY8XJ4Ya8WWDmev5O7NVocpLbBEjARG8IMEAcU5Xc +b5gSGffGCms/2ZbuLnfeuILUtVEJ6TXYaqFWUy3cfIz1MSm0dvl3vWLOBFZ5OlFlFvWNz YrXZzWw+twQI7mAKPt1RJUrQmnj936g1cBJjoBgDUxj8NTKOozY2BfT/gFpi1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761226865; 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=UtJ5/sRBR4jWyvNGA5/40of16N0iI/52HB0mXb6K5Vw=; b=g5UtxaZ0r7QHySNKEUaYw+oHIzzithuYFIV0Ggs2hfXIzSmV3tWQimFpXMSPFqb915Ke2S ZHD8a8sWMPzDnc+PBG7Ivn6HY7QDShkLuA/ydb6uNW8q4Gmiaef4kCkElC31+Bh06ndjS0 Xp6u+UlEJykuXnCcz72fNfwK5xkW8YxHE8NdvMh89j4uXFAVrCkM0DT+R3tJQC52IUKPsc 69tXBeoYjwO8WnbtlZ16d0651VINwAMgkbO+S6zGpUAJNYsNV4qIAfMnQs+n0zdT+/PtIH 4mqQ3XSFFEvzE7RMoubwk+NXYa1sz7U2cXYDodSxfV6+C5OX1DvHrEYEBlIq9w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1761226865; a=rsa-sha256; cv=none; b=d8ioKBtb7uA9hMQYrhOrK7lUO4CODzWGc4G3ztFSZS/2bPN/1Z9fBqchELud6b8JxDG721 6tWzsV2OCAUXjfcYjYxpVR/SPNtnRjhj3Vg1on4VQ+lq8VjK4CJnZkkPZzC2w1pBzTIDAx jb1/wouDOTfora91O0RCSoLLkcvkW+vPZyX8Sp/iyyuIHB4kQW+LYcsw7Anfgtsn+x4V9O 6Ifhl7UJHxIZG7sh+81wg5hDzqqPCRjRBQHVG/UcfrQcEyuQmoFqXnp0QE9eieolu00Weu M9tck7oaiibJmd4Glb/7yde5VI5whz1Cug9JQxCYLRstwiFSw0NIyhZvvdRa2g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4csnHP4wyRz2Bp; Thu, 23 Oct 2025 13:41:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 59NDf5HT007413; Thu, 23 Oct 2025 13:41:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59NDf5as007410; Thu, 23 Oct 2025 13:41:05 GMT (envelope-from git) Date: Thu, 23 Oct 2025 13:41:05 GMT Message-Id: <202510231341.59NDf5as007410@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: 6d408ac49073 - main - fusefs: add a regression test for a cluster_read bug 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-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: 6d408ac490730614b3ed0ebd3caffcd23f303fb4 Auto-Submitted: auto-generated The branch main has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=6d408ac490730614b3ed0ebd3caffcd23f303fb4 commit 6d408ac490730614b3ed0ebd3caffcd23f303fb4 Author: Alan Somers AuthorDate: 2025-10-23 13:40:56 +0000 Commit: Alan Somers CommitDate: 2025-10-23 13:40:56 +0000 fusefs: add a regression test for a cluster_read bug VOP_BMAP is purely advisory. If VOP_BMAP returns an error during readahead, cluster_read should still succeed, because the actual data was still read just fine. Add a regression test for PR 264196, wherein cluster_read would fail if VOP_BMAP did. PR: 264196 MFC with: 62aef3f73f38db9fb68bffc12cc8900fecd58f0e Reported by: danfe Reviewed by: arrowd Differential Revision: https://reviews.freebsd.org/D51316 --- tests/sys/fs/fusefs/bmap.cc | 87 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/tests/sys/fs/fusefs/bmap.cc b/tests/sys/fs/fusefs/bmap.cc index 30612079657d..e61dadb6d79e 100644 --- a/tests/sys/fs/fusefs/bmap.cc +++ b/tests/sys/fs/fusefs/bmap.cc @@ -177,6 +177,93 @@ TEST_F(Bmap, default_) leak(fd); } +/* + * The server returns an error for some reason for FUSE_BMAP. fusefs should + * faithfully report that error up to the caller. + */ +TEST_F(Bmap, einval) +{ + struct fiobmap2_arg arg; + const off_t filesize = 1 << 30; + int64_t lbn = 100; + const ino_t ino = 42; + int fd; + + expect_lookup(RELPATH, 42, filesize); + expect_open(ino, 0, 1); + EXPECT_CALL(*m_mock, process( + ResultOf([=](auto in) { + return (in.header.opcode == FUSE_BMAP && + in.header.nodeid == ino); + }, Eq(true)), + _) + ).WillOnce(Invoke(ReturnErrno(EINVAL))); + + fd = open(FULLPATH, O_RDWR); + ASSERT_LE(0, fd) << strerror(errno); + + arg.bn = lbn; + arg.runp = -1; + arg.runb = -1; + ASSERT_EQ(-1, ioctl(fd, FIOBMAP2, &arg)); + EXPECT_EQ(EINVAL, errno); + + leak(fd); +} + +/* + * Even if the server returns EINVAL during VOP_BMAP, we should still be able + * to successfully read a block. This is a regression test for + * https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=264196 . The bug did not + * lie in fusefs, but this is a convenient place for a regression test. + */ +TEST_F(Bmap, spurious_einval) +{ + const off_t filesize = 4ull << 30; + const ino_t ino = 42; + int fd, r; + char buf[1]; + + expect_lookup(RELPATH, 42, filesize); + expect_open(ino, 0, 1); + EXPECT_CALL(*m_mock, process( + ResultOf([=](auto in) { + return (in.header.opcode == FUSE_BMAP && + in.header.nodeid == ino); + }, Eq(true)), + _) + ).WillRepeatedly(Invoke(ReturnErrno(EINVAL))); + EXPECT_CALL(*m_mock, process( + ResultOf([=](auto in) { + return (in.header.opcode == FUSE_READ && + in.header.nodeid == ino && + in.body.read.offset == 0 && + in.body.read.size == (uint64_t)m_maxbcachebuf); + }, Eq(true)), + _) + ).WillOnce(Invoke(ReturnImmediate([=](auto in, auto& out) { + size_t osize = in.body.read.size; + + assert(osize < sizeof(out.body.bytes)); + out.header.len = sizeof(struct fuse_out_header) + osize; + bzero(out.body.bytes, osize); + }))); + + fd = open(FULLPATH, O_RDWR); + ASSERT_LE(0, fd) << strerror(errno); + + /* + * Read the same block multiple times. On a system affected by PR + * 264196 , the second read will fail. + */ + r = read(fd, buf, sizeof(buf)); + EXPECT_EQ(r, 1) << strerror(errno); + r = read(fd, buf, sizeof(buf)); + EXPECT_EQ(r, 1) << strerror(errno); + r = read(fd, buf, sizeof(buf)); + EXPECT_EQ(r, 1) << strerror(errno); +} + /* * VOP_BMAP should not query the server for the file's size, even if its cached * attributes have expired.