From nobody Tue Nov 18 05:35:14 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 4d9YGp2gc7z6GRSb; Tue, 18 Nov 2025 05:35:14 +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 4d9YGp1wYTz3qrF; Tue, 18 Nov 2025 05:35:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1763444114; 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=JMJQNAaBrwCb5cx6frrCHPLSt0bhsReiL8wMvzrG4ZI=; b=CHdWbv3R8w9icQMyZY6REk3tt9ziCgyzK970reYc+6FZjZVodR3x8hqHflwvE6V4ejhFPx OeI0CLiQBBcgo/OrerHqVTN8rAPtRYmQSVUVkQZHKUEOAWSHFX+EW6RuIOk5U1V4/w/8O9 Bd44qym3adJrKPMO64JqwYi4PJbKKnfs5pgOLpQZd7ZAogJtZWXrTwn6yLPAMdKqhJGlZr 08GLk6lBABoJZmAT5icBUn5y400iGJxHSX1BZ4efCAT/C9vccxKd5qB2tYKAaSn0HQaVYc YqtLSFKC4z0aQfcv5patRNchzjKMN5Ce0p9eh2OMVuwrzemDlJW6fwIifH1ANQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1763444114; 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=JMJQNAaBrwCb5cx6frrCHPLSt0bhsReiL8wMvzrG4ZI=; b=SHMqCugNCkNEb+5q9eKiN/kNMdYeYKuHE8M6MaFQJ9gA+eUBB52o7wmpaBGY7wbuz+4Fys gKvlzJA8Q/MA/29K6DCk5JAMQv/wqfG2uDPKu2gCK5cd6WhQ25eiRkL9KbzbLIpYmItERP KsrTngeuOpZvgeejpBjEW2nLVNynlh1VFNjtxQBmjrcjhSzqH/ElQYv8v+sOu6dFZmzz0C aAHonhI7qrjfrgNdC39MglvukXdo3vQlgz34nzbHMJ7DflE0nQ02+cCsBNccBZJpl58byn o7B3B2WxgUIZFYFArcV5JCG3w8ljekyGZmmXrhqd5RAFLgAANQnRwyKNvMXqLQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1763444114; a=rsa-sha256; cv=none; b=bnQOPjJBZNkgMZ+OKYDCygBQT4jL6uj+dXYm5Bad9NtQnEuXgxzHILYh/IMcXASjHfaMFH wGDT+TNGNgI10eOsP9u+uAN0bcH5kPU7V43Vj6VQOCbg86NNH4t+jgTjkjQaMe3YUlzomM Q0MBWquQDIFeczTO/yi/pPYqzy1fv8Xa5FJQ+9L8rGbAcqtyuZfTuXn6kCfabS39LWjxCj XCjcauGHFz1oppOwV21rm/e9GsdygQMyqFufdJOc3sWCtUst5myIc/BwgDVih9z8jzhkpQ R7wbLu8qWPTQMP5rMsYj2zILVL/wY9RM/DzSC6ElwK3yfeQ2buQLbemA7y6M+Q== 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 4d9YGp1SDKzhtV; Tue, 18 Nov 2025 05:35:14 +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 5AI5ZEnS080109; Tue, 18 Nov 2025 05:35:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5AI5ZE5Z080106; Tue, 18 Nov 2025 05:35:14 GMT (envelope-from git) Date: Tue, 18 Nov 2025 05:35:14 GMT Message-Id: <202511180535.5AI5ZE5Z080106@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: c0a38339fec3 - main - exterror.9: explain buffers and bios usage of extended errors 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c0a38339fec37a5b6367f138f059a12d6d716fd4 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c0a38339fec37a5b6367f138f059a12d6d716fd4 commit c0a38339fec37a5b6367f138f059a12d6d716fd4 Author: Konstantin Belousov AuthorDate: 2025-11-18 04:23:41 +0000 Commit: Konstantin Belousov CommitDate: 2025-11-18 05:34:56 +0000 exterror.9: explain buffers and bios usage of extended errors Reviewed by: pauamma_gundo.com Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D53798 --- 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