From nobody Tue Nov 17 21:11:23 2026 X-Original-To: dev-commits-src-all@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 4jTcpz6WZ0z71tB5 for ; Tue, 17 Nov 2026 21:11:23 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jTcpz5kqJz4Fvq for ; Tue, 17 Nov 2026 21:11:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794949883; 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=U1ICWFd8Ky7ULTcfNtDfpb3+PXp7roFES1QEh0HWWWU=; b=C3LnkqePJM7t+Aen1DFwaEpqHQxME+tApf+O0e0M0cQbrukCrpALDjm67JkFIiiTI8xV99 2US04IKZDDTs41XkIgOrLQYmSyVQPL2P+d+0paNEj1C8T93yM58UGP/Re+9Ou+OT6/oFbl OYb4N6fsPrnFBXyHLAPQfpOB27skx61aLQy6O8aXTH08gmmUbQtWiEr4p/b4djPVEPAOQl DbpQmPkkPfY4VONYR5lrI7SyJ1m4L0gSyWa9UXz9lmGh2+Zhi92tJzpsNm9k9BFR7BUOOl ccKiP5afbLUdVdr0cO/tWy/7jCPSUIusDlphsdZEiJfe6iWIqu9IMPgF/2RN8Q== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794949883; b=E4BEct6+mdlVjSOQ6lnN8yJyLdKc+N375ovTQ5+PXxGR9oIr+u/RX/nsg8oJTeCnxWpBqq UVh+Aq4zCmdA8G2D705k7x1ki0t7uZTUCUJGWnXuEO0FfEZ7Y437/J5pHTEZRgT+sMmDzw n8a1loUKBSNzECitU0WfcY8kmwVhZVXilA1Ce33HRr9KUhZdAdy5cIMp5O9QIeucKwIdS5 QHegjGnes7RobBMYGRdC63TieZ1eh6DORGcktq19zzenuHk9+widCkqXQ3hWfNBbi9tLEF ViainEDipIX+9UTGVCqLHGS3Y01hwKQaEMm/fojJIYFuvUF/nzqZ7wjhlJXHiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794949883; 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=U1ICWFd8Ky7ULTcfNtDfpb3+PXp7roFES1QEh0HWWWU=; b=Pgsi3MXEBbUwy7z7HUbDvHjRHedD9XqU8lAOg0seYGmuAmlCkG0Tegip3SDBYJ3aIa0XZl hTj4X3BSfHW49v0LZ3J5pqTDzW1pHBWdPFWUdxYRtJmKP5ReRf+cr/H1mkNG1ThlLzqxX2 XDt7FXE0YItOop+VRkk3wwz05fj4ubU2i2Uo1113UaPzI1U6XTzjqKkvDahdFb1oO0Y96s xbT/DiDMaEnfRi8yY1CUZnstdnqP3OKkUVft9AreunBba8OXsXIW0XZCjAv2m4q6D4OJp4 DwXkz1p5jTLY3wMsXTWmFkKs5fQ9Eeb87CJpY4/BXlr9ROqHfj+9eemVLcoizA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jTcpz5Npqz103t for ; Tue, 17 Nov 2026 21:11:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1a2c4 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 17 Nov 2026 21:11:23 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: 41e054033ed9 - main - tmpfs: fix a hang reachable through hole-punching List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 41e054033ed91099aaf0dd11c09db4f6752b95b6 Auto-Submitted: auto-generated Date: Tue, 17 Nov 2026 21:11:23 +0000 Message-Id: <6afcc2fb.1a2c4.e85bf20@gitrepo.freebsd.org> The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=41e054033ed91099aaf0dd11c09db4f6752b95b6 commit 41e054033ed91099aaf0dd11c09db4f6752b95b6 Author: Kyle Evans AuthorDate: 2026-11-17 21:10:38 +0000 Commit: Kyle Evans CommitDate: 2026-11-17 21:11:05 +0000 tmpfs: fix a hang reachable through hole-punching Deallocate requests that clip only the start of a single page need to be taken into account as well- it misses the first branch because startofs == 0, but then it also misses the last branch because the start and end are on the same page. Handling this case in either branch is equally valid, so I've arbitrarily chosen the first branch since it already has single-page logic. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D61490 --- sys/fs/tmpfs/tmpfs_subr.c | 10 +++++++--- tests/sys/file/fspacectl_test.c | 27 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c index cfdd5cd1f973..b29b555dedc2 100644 --- a/sys/fs/tmpfs/tmpfs_subr.c +++ b/sys/fs/tmpfs/tmpfs_subr.c @@ -1963,9 +1963,10 @@ tmpfs_reg_punch_hole(struct vnode *vp, off_t *offset, off_t *length) /* * If there is a partial page at the beginning of the hole-punching - * request, fill the partial page with zeroes. + * request or if we're only punching a hole within a single page, fill + * the partial page with zeroes. */ - if (startofs != 0) { + if (startofs != 0 || pistart == piend) { end = pistart != piend ? PAGE_SIZE : endofs; error = tmpfs_partial_page_invalidate(object, pistart, startofs, end, FALSE); @@ -1973,6 +1974,9 @@ tmpfs_reg_punch_hole(struct vnode *vp, off_t *offset, off_t *length) goto out; off += end - startofs; len -= end - startofs; + + if (pistart == piend) + goto out; } /* @@ -1988,7 +1992,7 @@ tmpfs_reg_punch_hole(struct vnode *vp, off_t *offset, off_t *length) * If there is a partial page at the end of the hole-punching request, * fill the partial page with zeroes. */ - if (endofs != 0 && pistart != piend) { + if (endofs != 0) { error = tmpfs_partial_page_invalidate(object, piend, 0, endofs, FALSE); if (error != 0) diff --git a/tests/sys/file/fspacectl_test.c b/tests/sys/file/fspacectl_test.c index 714474b76b05..b358e01f13d2 100644 --- a/tests/sys/file/fspacectl_test.c +++ b/tests/sys/file/fspacectl_test.c @@ -325,6 +325,32 @@ ATF_TC_BODY(unaligned_dealloc_eof, tc) ATF_REQUIRE(close(fd) == 0); } +/* + * Check deallocation of an aligned range that ends within its first block. + * tmpfs used to make no progress on such a range, leaving the caller + * spinning in vn_deallocate_impl() forever. + */ +ATF_TC_WITHOUT_HEAD(aligned_dealloc_partial); +ATF_TC_BODY(aligned_dealloc_partial, tc) +{ + struct spacectl_range range; + off_t offset, length; + blksize_t blocksize; + int fd; + + ATF_REQUIRE((blocksize = fd_get_blksize()) != -1); + range.r_offset = offset = blocksize; + range.r_len = length = blocksize / 2; + + ATF_REQUIRE((fd = open("sys_fspacectl_testfile", + O_CREAT | O_RDWR | O_TRUNC, 0600)) != -1); + ATF_REQUIRE(fill(fd, 0, file_max_blocks * blocksize) == 0); + ATF_CHECK(fspacectl(fd, SPACECTL_DEALLOC, &range, 0, &range) == 0); + ATF_CHECK(check_content_dealloc(fd, offset, length, + file_max_blocks * blocksize) == 0); + ATF_REQUIRE(close(fd) == 0); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, aligned_dealloc); @@ -333,6 +359,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, unaligned_dealloc_eof); ATF_TP_ADD_TC(tp, aligned_dealloc_offmax); ATF_TP_ADD_TC(tp, unaligned_dealloc_offmax); + ATF_TP_ADD_TC(tp, aligned_dealloc_partial); return atf_no_error(); }