From nobody Tue Nov 17 21:11:25 2026 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 4jTcq21cXdz71sjq for ; Tue, 17 Nov 2026 21:11:26 +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 4jTcq16SpMz4Fxp for ; Tue, 17 Nov 2026 21:11:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794949885; 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=O+g43VBpanDuFukT26hmI9EwUm2SlVJa5/BU9J+ILLg=; b=seVVQpETRpXDAp94S9tdg0ReHfJmLz+2ERGA60tlMiwYqH5Dp7UiAsqVdH+SIur0H/rOgC xt6G7w9gpWr0AEvZEq5pHDFZek4inOQdrWqT/TmnMi7A6gEkA7q37UgF50Qky23TOrXqMD masvfyCL0802QXye1Wm8aYssSSoC3e2vkT18KFK3vMLflO6vV3Zb5qVNiBK3x0zp2XzpmP a9kRqOfgbpQptLu46XbH5yonGDfPw/NVI5wkd5zhdqcYFHpTIgHqZlIqjL1N+REMMViNM8 VEDBZU5bZOzr7DcRAxGaOPkAF6NZw0SdVNzgHNJddHE+gI60Aruejkm0McN/UA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794949885; b=MIlQ60PqlnFvrl52A3gjBU1YXY0P0VPPS1OekByK2k/b9nhXcvKGeeu6QklHMSQOncA1u0 dtQje+rc2RfMqLVRD7A7q4+avcQyz4ax69Yx0OpjfI9M+iWhd42ogoyzZN7gzMLvj/q3Sg SGynKwecaV5+LbI/1JTq3gWPRvLDF8AzY2D9avQk/M+PvjPp7hYUBuRpukMeDaqYOZCSIO zULM3+58+TB1DmceuSFwjpkQ7Dwlq/ShT0Q5ucSWVE73g2gV/zUbfWjwtRhr8LCDWYs4Iw euW8enCp36+Y0BdSdM3ed/rvdsJQmiZLXCUOs6i3zlHdeUqFf5CU99h84KW7Sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794949885; 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=O+g43VBpanDuFukT26hmI9EwUm2SlVJa5/BU9J+ILLg=; b=uao+DL8dCqf4L6lVol2Debn917bXfwGx2xmBk3wmO6DxkGHQXfFK0aIdYF3PB2TXMtHTGP DQYNzkqK6bFpEifGNfmMnOXHnaKcxsIzScsEJ0Er4NoyS4Lrt7fX1dG/yaS/C0O1Med3F5 KV3Do5NcMPW8vsSfaqBmoe9VEJz9XH8mOo6K5RFvYhfw/CMH3tpUxSbquacKRYKcgfXWk6 rbTUr3r3VGQkuz12C6v/+9ijvatnAUZv5SsdQSuBlI1T7/ntP+AiLIHeW9gj3JBZjefYJh Qta/a0H1Tdm0aG2HJ8VIm5k0vXTN6QUFrSIzZmfYhgBWA1faqV20jx+gHWpVzw== 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 4jTcq167Mqz1040 for ; Tue, 17 Nov 2026 21:11:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 18de2 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 17 Nov 2026 21:11:25 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: 95c7b9eaa9ec - main - vfs: fail VOP_DEALLOCATE passes that make no progress List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main X-BeenThere: dev-commits-src-main@freebsd.org List-Id: Commit messages for the main branch 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: 95c7b9eaa9ecc874333ff4cc97ad1c4d816223e4 Auto-Submitted: auto-generated Date: Tue, 17 Nov 2026 21:11:25 +0000 Message-Id: <6afcc2fd.18de2.12d92fda@gitrepo.freebsd.org> The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=95c7b9eaa9ecc874333ff4cc97ad1c4d816223e4 commit 95c7b9eaa9ecc874333ff4cc97ad1c4d816223e4 Author: Kyle Evans AuthorDate: 2026-11-17 21:10:38 +0000 Commit: Kyle Evans CommitDate: 2026-11-17 21:11:05 +0000 vfs: fail VOP_DEALLOCATE passes that make no progress VOP_DEALLOCATE(9) permits a filesystem to return a partial result, and vn_deallocate_impl() simply loops until the range is consumed. If a filesystem returns success without shrinking the remaining length, we spin forever with the rangelock held and no way to interrupt the thread. Return EIO if a pass doesn't make progress so that a buggy filesystem doesn't wedge the caller. Document the progress requirement in VOP_DEALLOCATE(9) and the new EIO condition in fspacectl(2). I did wonder if this should be made interruptible for, e.g., slow I/O over NFS, but I've declined to touch it for now. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D61496 --- lib/libc/gen/exterr_cat_filenames.h | 1 + lib/libsys/fspacectl.2 | 4 +++- share/man/man9/VOP_DEALLOCATE.9 | 9 +++++++-- sys/kern/vfs_vnops.c | 18 ++++++++++++++++-- sys/sys/exterr_cat.h | 1 + 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/lib/libc/gen/exterr_cat_filenames.h b/lib/libc/gen/exterr_cat_filenames.h index 690d5d33fbf8..9e5eddc39d9d 100644 --- a/lib/libc/gen/exterr_cat_filenames.h +++ b/lib/libc/gen/exterr_cat_filenames.h @@ -20,6 +20,7 @@ [EXTERR_CAT_VFSBIO] = "kern/vfs_bio.c", [EXTERR_CAT_INOTIFY] = "kern/vfs_inotify.c", [EXTERR_CAT_VFSSYSCALL] = "kern/vfs_syscalls.c", + [EXTERR_CAT_VFSVNOPS] = "kern/vfs_vnops.c", [EXTERR_CAT_BRIDGE] = "net/if_bridge.c", [EXTERR_CAT_SWAP] = "vm/swap_pager.c", [EXTERR_CAT_MMAP] = "vm/vm_mmap.c", diff --git a/lib/libsys/fspacectl.2 b/lib/libsys/fspacectl.2 index 911c24101785..84775e5f8158 100644 --- a/lib/libsys/fspacectl.2 +++ b/lib/libsys/fspacectl.2 @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 25, 2021 +.Dd November 12, 2026 .Dt FSPACECTL 2 .Os .Sh NAME @@ -169,6 +169,8 @@ or a non-NULL argument point outside the process' allocated address space. .It Bq Er EIO An I/O error occurred while reading from or writing to a file system. +.It Bq Er EIO +The file system failed to make progress on the requested operation range. .It Bq Er EINTEGRITY Corrupted data was detected while reading from the file system. .It Bq Er ENODEV diff --git a/share/man/man9/VOP_DEALLOCATE.9 b/share/man/man9/VOP_DEALLOCATE.9 index 0db4d07ad2f0..8c6a2f01c710 100644 --- a/share/man/man9/VOP_DEALLOCATE.9 +++ b/share/man/man9/VOP_DEALLOCATE.9 @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 25, 2021 +.Dd November 12, 2026 .Dt VOP_DEALLOCATE 9 .Os .Sh NAME @@ -73,7 +73,12 @@ and .Fa *len are updated to reflect the portion of the range that still needs to be zeroed/deallocated on return. -Partial result is considered a successful operation. +Partial result is considered a successful operation, provided that some +progress was made: +a successful return must decrease +.Fa *len , +or the caller will fail the request with +.Er EIO . For a non-partial successful completion, .Fa *len is updated to be the value 0, and diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 88de7ac5b4c0..fa579de2b83a 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -43,11 +43,13 @@ #include "opt_hwpmc_hooks.h" #include "opt_hwt_hooks.h" +#define EXTERR_CATEGORY EXTERR_CAT_VFSVNOPS #include #include #include #include #include +#include #include #include #include @@ -4008,7 +4010,7 @@ vn_deallocate_impl(struct vnode *vp, off_t *offset, off_t *length, int flags, { struct mount *mp; void *rl_cookie; - off_t off, len; + off_t len, off, olen; int error; #ifdef AUDIT bool audited_vnode1 = false; @@ -4049,10 +4051,22 @@ vn_deallocate_impl(struct vnode *vp, off_t *offset, off_t *length, int flags, error = mac_vnode_check_write(active_cred, file_cred, vp); #endif - if (error == 0) + if (error == 0) { + olen = len; error = VOP_DEALLOCATE(vp, &off, &len, flags, ioflag, cred); + /* + * A partial result is permitted, but each pass must + * make some progress or we would spin here forever. + */ + if (error == 0 && len >= olen) { + error = EXTERROR(EIO, + "no progress on vp %p (off %jd)", + vp, (intmax_t)off); + } + } + if ((ioflag & IO_NODELOCKED) == 0) { VOP_UNLOCK(vp); if (mp != NULL) { diff --git a/sys/sys/exterr_cat.h b/sys/sys/exterr_cat.h index 235238a562ec..6b716b41448e 100644 --- a/sys/sys/exterr_cat.h +++ b/sys/sys/exterr_cat.h @@ -58,5 +58,6 @@ #define EXTERR_CAT_HWPMC_MOD 21 #define EXTERR_CAT_TTY 22 #define EXTERR_CAT_GEOMZONED 23 +#define EXTERR_CAT_VFSVNOPS 24 #endif