From nobody Fri Nov 03 04:50:57 2023 X-Original-To: dev-commits-src-branches@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 4SM7c20mQkz4yvRM; Fri, 3 Nov 2023 04:50:58 +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 4SM7c20GwXz4YDV; Fri, 3 Nov 2023 04:50:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698987058; 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=Df4X3t8I65b/NYF2XdhW/RcsoC5fJIyBTnsZ2OuSkaA=; b=VOItdPoyM+rMWLKHd9Gr8y1RMS/r6vePFCukP45U5nFCYujBzSdh7qJTa1eHfA2gCfWUSL qEBauA7Ceews608YUhgi4rnIkAgdkxH3dy58O7o7DAb5wzxu4MsLoBnsiwK8w+puUor5bQ 9w7xED74nL+9E9eNdrKdl6dQXbBfq3mJdB0H0Xq52HdknZpZOlvrP3ygcv46/X8DnYbbcU KpBfLQd9DqCseUfPTivt9wp4cwnh25YERGN2m3FGnjNXDfXP8mFEF0cMlWvrhJ8bEOIa+E ZunM2QDzW69pmkNLBYspAc7jgANYIPyyOAb4KV+vPU0OSm5B+T2ey4tJKIVDyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698987058; 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=Df4X3t8I65b/NYF2XdhW/RcsoC5fJIyBTnsZ2OuSkaA=; b=GINqn3e+Yt3LpJxUhtnuOWQa99XmASoBtHRDn9ZK3b2a2gsKg4xGb6HqNeZVnpoVKEeWOh GzjKiJbAVtBUi5GVc3x6toarGrB8+QXnq+cSiLHQXW2bp4tw4YLwfQwc07I11c3MyQxAt5 QJopGZipP8prA9Gi60r5AwTeoEVIT49lhJVBHdb+yB1YOMTFohJTdZLBSOEYmqMt7vtLbR UcMN3b/cHRWwcdpoVyDTsGZnnur+ZvWnrMQPTdX/dOT+ZbK3ihzldHGFVIYy4eIJGtit+g 4mTs7M4OhouUQZmAk+BgOhV7FndX8DczzP2pV0ARwptxUnk9mQayk2UHRmi3rw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1698987058; a=rsa-sha256; cv=none; b=kOtFon/q/2a+XvmaiRVPKiOjmzA+HdQ0UycI5/JF2MXQ0njFt37M5HlufdZgObzVA0bQ9r y76ErmjDsKty0FpxTyfZvqNGWP9sUOV8p8/B7uBbJQgZzukLqUxWsC3soA8woXdVLnM5GX ywMXJEEJKskYp/655BjfVbL9XjoKa3lLTlwKNbAqColsLFufle47Tr+vC0vT7rVJYFoZ+D JNxPWcvA2dCNwvZcR9HlMLdSyVvp1q4dC1RNZveVV6NpJ8sbXnIZ/6kyzvgkzOijlVjVzN 1EQoOdbU2j2CGr5q8MLxJw9B7+J18oAy7UJ0+dU7qxR/krr4n4YhwTHBLC5a0A== 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 4SM7c16RQ3zyFw; Fri, 3 Nov 2023 04:50:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3A34ovAW057093; Fri, 3 Nov 2023 04:50:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3A34ovm8057090; Fri, 3 Nov 2023 04:50:57 GMT (envelope-from git) Date: Fri, 3 Nov 2023 04:50:57 GMT Message-Id: <202311030450.3A34ovm8057090@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: ee4bdd4b0db5 - stable/12 - libbe: bail out early if the zfs kmod isn't loaded List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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/stable/12 X-Git-Reftype: branch X-Git-Commit: ee4bdd4b0db5b9d64e64490fc84a395344862aed Auto-Submitted: auto-generated The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=ee4bdd4b0db5b9d64e64490fc84a395344862aed commit ee4bdd4b0db5b9d64e64490fc84a395344862aed Author: Kyle Evans AuthorDate: 2023-07-07 00:41:14 +0000 Commit: Kyle Evans CommitDate: 2023-11-03 04:50:46 +0000 libbe: bail out early if the zfs kmod isn't loaded As noted in the comment, we already know the rest of libbe_init() will fail because there's no pool imported. Avoid the side effect by checking beforehand and bailing out early. With this, freebsd-update(8) should no longer trigger a load of the zfs kmod just because it runs `bectl check`. Reviewed by: jwmaag_gmail.com, rew (cherry picked from commit 2f700ca965a04c4a03b6f760da6a210b6ca4df4b) --- lib/libbe/be.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/libbe/be.c b/lib/libbe/be.c index 6c7bf1b2ae45..e86ceccee74e 100644 --- a/lib/libbe/be.c +++ b/lib/libbe/be.c @@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include @@ -115,6 +116,16 @@ libbe_init(const char *root) lbh = NULL; poolname = pos = NULL; + /* + * If the zfs kmod's not loaded then the later libzfs_init() will load + * the module for us, but that's not desirable for a couple reasons. If + * the module's not loaded, there's no pool imported and we're going to + * fail anyways. We also don't really want libbe consumers to have that + * kind of side-effect (module loading) in the general case. + */ + if (modfind("zfs") < 0) + goto err; + if ((lbh = calloc(1, sizeof(libbe_handle_t))) == NULL) goto err;