From nobody Mon Feb 13 22:31:39 2023 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 4PFzbH717Cz3qVhS; Mon, 13 Feb 2023 22:31:39 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PFzbH6Z2Bz3F6B; Mon, 13 Feb 2023 22:31:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676327499; 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=Hm1VMOzPLKqQJAHbOuuNH59UB1ZbYqVewTCAVbVaL20=; b=r0AUooJpY8Ln1gY2B4hE+ty9dnxrtRnCRy7C89BcGpYhkzTk1tfK8JU3yZVGGMRJ1iqSzL Cp0m9JmpmebQa5tSnBN/oqoALMkU6yXX/6lOL0kKkKqh7kwGB7aMAFX+uKpxEguXCu7XB1 rSn1QikvTI4RRJI+pv+EISM22ETAzYbeADGqOLQeYYYXTCMcMfSFw1HJHLJN31SvYNCq/V 1DeNrKVPtymVkV7eljHon7NIKne3TZ/yAaAIfFRL5yo1eSTot0M5kCYBkKFYVvsgJHvs/q aRriXB+utkWP8eMh8BuheXPk78sC3nDlMJjmxsM3UIC3JVvRaXmVKsdzHEhTdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676327499; 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=Hm1VMOzPLKqQJAHbOuuNH59UB1ZbYqVewTCAVbVaL20=; b=MrT4kIOi6ZBM8Bt0wwfSqLWoagezXOkiicJs4zydUmQR1fA3yiWwLiD7m2/ihLvF8UnHaB XvJJLxAc5lb6liOXo7PsIyvOHXxwSyvlWQ+vmmo3n8foElAd8+TxQcuDo1d5QQJuvIty9a ECmNxluFGivofEyUmJkuFlpiykbTIDjGqEgLRjoKg8yjBwmD4feVf/N0GDYIYLnHquBjPD uJS+bxeuT/GOSN12eaYrbMbwk/exOVlNSPf3lThkPz1Qf/lBBvWmcsER6h99pZFzbhOEZK tXhv+no5HVDzp11X1h6NgYeyBZlkz+aSWcDMNtz0g6w+WCZIUiMfJSmHlmonSA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676327499; a=rsa-sha256; cv=none; b=srYBvTensLovCPFiwki5IGUbeawyLQu1MRunnS9JKLG4sk9+FFNh0e0SdbxRnMaLi9sOjx +euQHCHgO/HJgpSJbKXza01H6avKPhdlpLOxdpk1jk4gXpC5/oy/jFdqdyfbHC8uTw3JNs rvPCbdObPbM//5T+95mSVJHMgs4anxN68MeOhOXfZikahfklNvlU9DtG7pwa2OSrmnBsvW soJj10kTOuvqW9B1IOXDgN268ECzJ35VHKdKSOJFmTp2X39kk+roJYmZYskMKaTZCEEr8N JmxJCB+aaQ5Qx5vJuB3Np+2gx/ZuCIZymz8R0p4QRc7XctZfFRFrWKno3M3cRQ== 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 4PFzbH5chCzbjt; Mon, 13 Feb 2023 22:31:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 31DMVdMW080688; Mon, 13 Feb 2023 22:31:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31DMVddp080687; Mon, 13 Feb 2023 22:31:39 GMT (envelope-from git) Date: Mon, 13 Feb 2023 22:31:39 GMT Message-Id: <202302132231.31DMVddp080687@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: 020e8a4d0609 - main - allocbuf(): convert direct panic() calls to KASSERT()s 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: 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/main X-Git-Reftype: branch X-Git-Commit: 020e8a4d0609d56cb49a9f35258ff07815d5e478 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=020e8a4d0609d56cb49a9f35258ff07815d5e478 commit 020e8a4d0609d56cb49a9f35258ff07815d5e478 Author: Konstantin Belousov AuthorDate: 2023-02-11 18:03:22 +0000 Commit: Konstantin Belousov CommitDate: 2023-02-13 22:28:42 +0000 allocbuf(): convert direct panic() calls to KASSERT()s Also do minor style adjustments. Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D38549 --- sys/kern/vfs_bio.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 3a5afec88a02..abc3eea9be4e 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -4363,8 +4363,9 @@ allocbuf(struct buf *bp, int size) if (bp->b_bcount == size) return (1); - if (bp->b_kvasize != 0 && bp->b_kvasize < size) - panic("allocbuf: buffer too small"); + KASSERT(bp->b_kvasize == 0 || bp->b_kvasize >= size, + ("allocbuf: buffer too small %p %#x %#x", + bp, bp->b_kvasize, size)); newbsize = roundup2(size, DEV_BSIZE); if ((bp->b_flags & B_VMIO) == 0) { @@ -4381,11 +4382,12 @@ allocbuf(struct buf *bp, int size) } else { int desiredpages; - desiredpages = (size == 0) ? 0 : + desiredpages = size == 0 ? 0 : num_pages((bp->b_offset & PAGE_MASK) + newbsize); - if (bp->b_flags & B_MALLOC) - panic("allocbuf: VMIO buffer can't be malloced"); + KASSERT((bp->b_flags & B_MALLOC) == 0, + ("allocbuf: VMIO buffer can't be malloced %p", bp)); + /* * Set B_CACHE initially if buffer is 0 length or will become * 0-length.