From nobody Thu Jan 27 15:15:04 2022 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 B2ADF19872D1; Thu, 27 Jan 2022 15:15:05 +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 4Jl3zs2Pmfz4dVH; Thu, 27 Jan 2022 15:15:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643296505; 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=cgbcn26NjlJ1jh0ptRaoO5k2pYeXD5KQN7pPArdjI9g=; b=xrDj5tTozqWoqtDXQSjbL1hw1uKYgT2v3nEFYxznLim5X6aF7BtXtx+CRoyHiwoKELGque 06D+0lYy65x4JfT11qOCTZQJ66U2bmHsyRUQ6WYyemwvC2HlgE50KWYViCdNwOr2N3IQgC 5C4XQ1sIu2JWy9Y18tTlbOsIziKe8BHXpBjCvVjrens7KEZRWtLXQDws8KPhpmTkqql3u7 DFTe/LyCaM0w5D1Jr5lkbZedbGTXhR7lJxfQ1BD/HIU3y5gib810iNVsj1R5iWdzIB5+nH q1DiteqoFWdWFHbEVcqOeVBUL2YLXubnfo/FaWxiVwDe9p5AuqqpiD/zHEoGpg== 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 1C3501887B; Thu, 27 Jan 2022 15:15:05 +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 20RFF5Qw006058; Thu, 27 Jan 2022 15:15:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20RFF4km006057; Thu, 27 Jan 2022 15:15:04 GMT (envelope-from git) Date: Thu, 27 Jan 2022 15:15:04 GMT Message-Id: <202201271515.20RFF4km006057@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: a2dfffb98917 - main - shsec: Allocate data blocks only for BIO_READ/WRITE requests 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a2dfffb98917a57bfacb155b9d7d423c3e8ff792 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643296505; 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=cgbcn26NjlJ1jh0ptRaoO5k2pYeXD5KQN7pPArdjI9g=; b=fVVSYnooGQfoYEgV+uJjM/iOlytu9E2lO+5VSYqFrgp7ajdARSOrcktr/9+N7P9pQnIl9J e2s7Zy9dJe2kAFjtac09GTXSEJKdLIj0xY/mPTaN/m61V2dXP3NB79+NJQgRVhyG0lpkEc kcq5zrImCBRFOvIvcZ3m8J5Nt9qhUOAUKqASWjuvDxkUTIlzFzxrr5/MGPOxAWaHifdK1z MhQseZd7oUKcSaaU5Ur5i3Ij2Jj4QnN47IpqA5ZU0Qqbc4Mi1OSD6sRVoslm4KtJka4CDo 3Hd87iKxpEvmi1fJ6fyqcp5g2AkeHyavfTdO0Ges8JxD+u6JFPFzROBCtp5BQw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1643296505; a=rsa-sha256; cv=none; b=fEIRwGS6OxuwSOtQmy70lCG3Eeq1fMFGvXEcygwToj0kZElLHnXnCObhMwGHY3jMEpfIMD Vt2SVNgZb3lX24bagyIpy7GVDg0/k4u4EuNqOZrxNzJ3oCQwqWFqfNv15duuDPBnwopWKU meBKjpt8ENvSS/tLPN/fLi/JAvx85KQbONEEXX1VwhgfNtgblPdCj6fdohZCgd7VcsN5Yb RTyYCrFENTi9miQF+BqiY8Zv3e0Y4PEVREjfkBYIYtnCDIk14FAvEvd0twyB4/9zu9WppZ IdyHXkoDfb35kP668+eN3mBWcvMTkQ8BPNxqbhNgbjDbUEg5AL//mpi0D11uvA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=a2dfffb98917a57bfacb155b9d7d423c3e8ff792 commit a2dfffb98917a57bfacb155b9d7d423c3e8ff792 Author: Mark Johnston AuthorDate: 2022-01-27 14:53:02 +0000 Commit: Mark Johnston CommitDate: 2022-01-27 14:56:07 +0000 shsec: Allocate data blocks only for BIO_READ/WRITE requests In particular, there is no need to allocate a data block when passing BIO_FLUSH requests to child providers, and g_io_request() asserts that bp->bio_data == NULL for such requests. PR: 255131 Reported and tested by: nvass@gmx.com MFC after: 2 weeks Sponsored by: The FreeBSD Foundation --- sys/geom/shsec/g_shsec.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/sys/geom/shsec/g_shsec.c b/sys/geom/shsec/g_shsec.c index 65bfbc6681dd..88add59f6d26 100644 --- a/sys/geom/shsec/g_shsec.c +++ b/sys/geom/shsec/g_shsec.c @@ -270,8 +270,10 @@ g_shsec_done(struct bio *bp) (ssize_t)pbp->bio_length); } } - explicit_bzero(bp->bio_data, bp->bio_length); - uma_zfree(g_shsec_zone, bp->bio_data); + if (bp->bio_data != NULL) { + explicit_bzero(bp->bio_data, bp->bio_length); + uma_zfree(g_shsec_zone, bp->bio_data); + } g_destroy_bio(bp); pbp->bio_inbed++; if (pbp->bio_children == pbp->bio_inbed) { @@ -349,20 +351,22 @@ g_shsec_start(struct bio *bp) * Fill in the component buf structure. */ cbp->bio_done = g_shsec_done; - cbp->bio_data = uma_zalloc(g_shsec_zone, M_NOWAIT); - if (cbp->bio_data == NULL) { - g_shsec_alloc_failed++; - error = ENOMEM; - goto failure; - } cbp->bio_caller2 = sc->sc_disks[no]; - if (bp->bio_cmd == BIO_WRITE) { - if (no == 0) { - dst = (uint32_t *)cbp->bio_data; - bcopy(bp->bio_data, dst, len); - } else { - g_shsec_xor2((uint32_t *)cbp->bio_data, dst, - len); + if (bp->bio_cmd == BIO_READ || bp->bio_cmd == BIO_WRITE) { + cbp->bio_data = uma_zalloc(g_shsec_zone, M_NOWAIT); + if (cbp->bio_data == NULL) { + g_shsec_alloc_failed++; + error = ENOMEM; + goto failure; + } + if (bp->bio_cmd == BIO_WRITE) { + if (no == 0) { + dst = (uint32_t *)cbp->bio_data; + bcopy(bp->bio_data, dst, len); + } else { + g_shsec_xor2((uint32_t *)cbp->bio_data, + dst, len); + } } } }