From nobody Mon Dec 1 03:48:30 2025 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 4dKVHf3zj7z6HtMD for ; Mon, 01 Dec 2025 03:48:30 +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 4dKVHf0ndPz3mfR for ; Mon, 01 Dec 2025 03:48:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1764560910; 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=7sEJWtFeBwrSYERgLHXlLPZuvhDqEzrHZNU8wqBY8Ic=; b=tnU+s3tQlIIC3+TFNHFpqbMN+JgUdVKYag9a/GGP78/yTIvcmuSjlTheJZzp8i9gJOWifE pKamQsAwvaydb1vz7Ggjz9vz8AYBTQd9lCbSxZzMMlf0VHp1JSSnrI5OUuRHZYOzoFV285 gkFv6dhcBnbzduirTJ5u8PA8cRcnNsFkYvrzX71j/XKW2Ob9xZWxsRRNbMk9Ety1WSMhHg 8abc0uzI3rJgNmY+dBDpOc19H26uDEQRj9gl2D6LTPE19h2WzlFdCQ3+XW84F3zh4vMA1G 8R5DyUg7mXM4cZ3UZMmdo1kzexBl/RHsGw/LjgVaxBjdZ7EMY9XFHHyYoUyYJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1764560910; 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=7sEJWtFeBwrSYERgLHXlLPZuvhDqEzrHZNU8wqBY8Ic=; b=fnYXwuC6HrMWp7gye4jYfBYfOl3Ya2mWN/mifQDv7QLY7uLyIOFM4TWlHnvc8S8pVYIgfa R7+Ayfn2P4PwMHESJ4kq0JKQsIQ/LuyqgYh9IJmZ2n6HWE14VLqrt8R1Qldoho1TJN2zGX DaJ5bH63Ju9sDQtG44L01OqqMlDN+3zozBwerjVNIICP7IsSJ14GETM9k57kM/zzpFaHCu j6G2XSS1jIFKr6M9TWVoilFG02CPcnPh/21FjpBDq3JFBBLSH5aC0IBi8CNJzeyxdU5hSC H4kkYlKCCGlVLSai+eA5xGZ/+s9DqLHHNGQlhz9DGLmATC1nOR3CEwVadN7Hxg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1764560910; a=rsa-sha256; cv=none; b=aJrHCIHWD79hWP2+A5EyIQ2aWVptO2Z5uvhxVgPrakbbONbAZABZ8HWRr/Zpzl0tK4H2Ip qqfrX8nb6nKqrdbohDZNli9MSzDqavkv0qbczFNn/5fxaA2qPSvePJLde4r0Xxu89uIxXs kAL515XyI/uQxixL31Irqkq9JPnGvhxnM/sEjpguqP62N+4lhZMH+G81Yt2wEnynASDsgA k/iikaLi62hsC49Ag5i5kEMaze3b9hkQMsRN3wEz3JGNfy0g4Bz9h/DB1Sumfdxmwl//xM 5HGeKcREcfS0c33eIExM309+cEoSybi8sBj3N8NATX62hGwf9/WfqfUU2jj9Lg== 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 4dKVHf0CpFz14Gj for ; Mon, 01 Dec 2025 03:48:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 30c2e by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 01 Dec 2025 03:48:30 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: a0e349258479 - stable/15 - exterror.9: explain buffers and bios usage of extended errors List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: a0e349258479583219d32e5c54a54db78db6e934 Auto-Submitted: auto-generated Date: Mon, 01 Dec 2025 03:48:30 +0000 Message-Id: <692d100e.30c2e.2b00216b@gitrepo.freebsd.org> The branch stable/15 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a0e349258479583219d32e5c54a54db78db6e934 commit a0e349258479583219d32e5c54a54db78db6e934 Author: Konstantin Belousov AuthorDate: 2025-11-18 04:23:41 +0000 Commit: Konstantin Belousov CommitDate: 2025-12-01 03:40:55 +0000 exterror.9: explain buffers and bios usage of extended errors (cherry picked from commit c0a38339fec37a5b6367f138f059a12d6d716fd4) --- share/man/man9/exterror.9 | 82 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/share/man/man9/exterror.9 b/share/man/man9/exterror.9 index 79197e4a187d..fd4b732b8213 100644 --- a/share/man/man9/exterror.9 +++ b/share/man/man9/exterror.9 @@ -17,8 +17,15 @@ #define EXTERR_CATEGORY EXTERR_CAT_MYCATEGORY .Ed .In sys/exterrvar.h +.Vt struct kexterr; +.Ft void +.Fn exterr_clear "struct kexterr *ke" +.Ft int +.Fn exterr_set_from "const struct kexterr *ke" .Ft int .Fn EXTERROR "int error" "const char *msg" ... +.Ft void +.Fn EXTERROR_KE "struct kexterr *ke" "int error" "const char *msg" ... .Sh DESCRIPTION The .Nm @@ -102,6 +109,33 @@ Additionally, use of .Fn EXTERROR in kernel threads is not sensible as there is no userspace to retrieve the extended error data. +.Pp +The +.Fn EXTERROR_KE +macro is similar to +.Fn EXTERROR , +but it takes an explicit pointer +.Fa kep +to the +.Vt struct kexterr +to fill with the extended error information. +The macro expression value is +.Vt void . +See below for description of the asynchronous i/o error facilities. +.Pp +The +.Fn exterr_clear +function clears the content of the +.Vt struct kexterr +pointed to by the argument +.Fa ke . +.Pp +The +.Fn exterr_set_from +function sets the current thread extended error data from the +.Fa struct kexterr +pointed to by the argument +.Fa ke . .Sh USERSPACE ACCESS TO EXTENDED ERROR DATA There is no syscall overhead for using .Nm @@ -127,6 +161,54 @@ were modified to print the extended information if it is available in addition to the usual .Va errno decoding. +.Sh ASYNCHRONOUS INPUT/OUTPUT +Due to the nature of the +.Fx +i/o subsystem, most input/output requests, presented as buffers (as in +.Vt struct buf ) +and geom bio's ( +.Vt struct bio ) +are processed asynchronously in filesystem- and geom-private threads. +This makes it challenging to pass any extended error information +from the geom providers and drivers, where an error typically occurs, +back to the thread that initiated the request, and is the consumer of +the result. +.Pp +To alleviate the mismatch, both +.Vt struct buf +and +.Vt struct bio +have member of the +.Vt struct kexterr +type. +For buffers, the +.Va b_exterr +for +.Vt struct buf , +and +.Va bio_exterr +for +.Vt struct bio . +Asynchronous i/o code can use the +.Fn EXTERROR_KE +macro, passing the pointer to the current request's embedded +.Vt struct kexterr , +to record the extended error. +In both cases, the +.Va BIO_EXTERR +flag should be set to indicate that whole extended error is valid, +not only the +.Va b_error +or +.Va bio_error +values. +.Pp +Both VFS and geom generic layers, and several geom providers that generate +subordinate bio's from the original request, are aware of the extended +errors. +They pass +.Vt kexterr +from the failed request back to the thread that create the request. .Sh SEE ALSO .Xr errno 3 , .Xr err 3