From nobody Wed Jul 6 12:33:51 2022 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 7BEE41D10226; Wed, 6 Jul 2022 12:33:52 +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 4LdJr00ytFz3tZD; Wed, 6 Jul 2022 12:33:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657110832; 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=QKw3MWDfukJIfQXovwzwr1qJBXlXF1uJ6FJ+BV79Z3o=; b=GXytaBAUV7dXrGxCUua2+WhJV/T6EjbYkdXH+0UkMZCS12VVcsngmpxmRqRF9rJPkp1DLM lOd21AatADohNkZPlk79nSCcvVJFXvOSNIxCzVprvpOlK/IRmsEnVueMJ8JQhb1S4sqHmw PFI3nfN0H7hlb7/dcdXbQdCsDVpREHURY6af95q5sdwAYAes0zGbx4oMugWC85YV00aZbA eq5zQyj0EMFIeC83Oyvsj9B1glxYkDlByNzEJwZiWlYQXWMAs2aQd/tPjJhzft36hjRwnK wUI7spZVXw9Aku6zJQeZfCSI/O6CqM1CWPl0RA+577wyjZHris0maV8F7lsa7w== 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 EDE561A998; Wed, 6 Jul 2022 12:33:51 +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 266CXpnP017897; Wed, 6 Jul 2022 12:33:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 266CXpjW017896; Wed, 6 Jul 2022 12:33:51 GMT (envelope-from git) Date: Wed, 6 Jul 2022 12:33:51 GMT Message-Id: <202207061233.266CXpjW017896@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 36960099a008 - stable/13 - vfs_mount.c: convert explicit panics and KASSERTs to MPASSERT/MPPASS 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 36960099a008f6fbdfee1b6c43e0226832da2cbf Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657110832; 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=QKw3MWDfukJIfQXovwzwr1qJBXlXF1uJ6FJ+BV79Z3o=; b=OrIciKQolBEcbzZUovbM305KN8qaUp5sHI06HomlDyvcqIVGjB9rM9Fhx/CjvsDsdjkBr0 f+aPNXrilWI5dk9uP0yGrIlPpIaOwNjoQBwKWN1sT88maxT85fM8WOdFbdIO3LZDSXICLN lRC+YxiIUoV5zmiR8xxke0Cqtz6m1VNH3qXk0uDCNpXAzQadMDwSmjy826ZJmL7ylkzbX6 ZqagravTigZvMdjpUqSCP6PBdMKAU1XBdUhxQo2YeGfxosKAJHUt3QY9/nmunKldNxOChT gCkoT+UffEtGy75KV5diLBCRIBXiGspUjkcc2a98kDMJWmO/oRqtbP2vwqll8w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657110832; a=rsa-sha256; cv=none; b=CFSp1GvTKIhCOnLsPAUr5fxLyFTQMNrHjciDkt65oc0xBf5A9Cd0eFMUIpewHf7L/jB2dt ZKfd8ZttOjpVSHELyGY7yqwVYvDo1rtETVvDhrFaeCHbjNgpcGHZEURPEEKh9tQGdMu2AN GsJ6LmIHxb8XecGy+4z/j9ozISKLFbgIROS6lOs0bW7X52BgiZj7B6XUZkdxipZ2Kfn+CH WXRwa7EOLjMAM2Pk6Ehmm1SmMSSd8jeQKy6OnX1SwCdRPsP+TcIGyj2vFrYj2Pb6kd3USE 5w3FlWqtS23KgNm/bvpONzHDEWxbKGZ2QbE3yLmnVxZtxCQtT5j8Vq3j3KadhQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=36960099a008f6fbdfee1b6c43e0226832da2cbf commit 36960099a008f6fbdfee1b6c43e0226832da2cbf Author: Konstantin Belousov AuthorDate: 2022-06-29 11:37:58 +0000 Commit: Konstantin Belousov CommitDate: 2022-07-06 12:33:30 +0000 vfs_mount.c: convert explicit panics and KASSERTs to MPASSERT/MPPASS (cherry picked from commit ad175a107b4e0fdc0128c98c3ca9d6cf8006aba7) --- sys/kern/vfs_mount.c | 57 +++++++++++++++++++++------------------------------- 1 file changed, 23 insertions(+), 34 deletions(-) diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index e14b1e882501..6e2945c91e1c 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -542,12 +542,10 @@ vfs_mount_alloc(struct vnode *vp, struct vfsconf *vfsp, const char *fspath, mp->mnt_nvnodelistsize = 0; TAILQ_INIT(&mp->mnt_lazyvnodelist); mp->mnt_lazyvnodelistsize = 0; - if (mp->mnt_ref != 0 || mp->mnt_lockref != 0 || - mp->mnt_writeopcount != 0) - panic("%s: non-zero counters on new mp %p\n", __func__, mp); - if (mp->mnt_vfs_ops != 1) - panic("%s: vfs_ops should be 1 but %d found\n", __func__, - mp->mnt_vfs_ops); + MPPASS(mp->mnt_ref == 0 && mp->mnt_lockref == 0 && + mp->mnt_writeopcount == 0, mp); + MPASSERT(mp->mnt_vfs_ops == 1, mp, + ("vfs_ops should be 1 but %d found", mp->mnt_vfs_ops)); (void) vfs_busy(mp, MBF_NOWAIT); atomic_add_acq_int(&vfsp->vfc_refcount, 1); mp->mnt_op = vfsp->vfc_vfsops; @@ -576,8 +574,7 @@ void vfs_mount_destroy(struct mount *mp) { - if (mp->mnt_vfs_ops == 0) - panic("%s: entered with zero vfs_ops\n", __func__); + MPPASS(mp->mnt_vfs_ops != 0, mp); vfs_assert_mount_counters(mp); @@ -592,10 +589,8 @@ vfs_mount_destroy(struct mount *mp) KASSERT(mp->mnt_ref == 0, ("%s: invalid refcount in the drain path @ %s:%d", __func__, __FILE__, __LINE__)); - if (mp->mnt_writeopcount != 0) - panic("vfs_mount_destroy: nonzero writeopcount"); - if (mp->mnt_secondary_writes != 0) - panic("vfs_mount_destroy: nonzero secondary_writes"); + MPPASS(mp->mnt_writeopcount == 0, mp); + MPPASS(mp->mnt_secondary_writes == 0, mp); atomic_subtract_rel_int(&mp->mnt_vfc->vfc_refcount, 1); if (!TAILQ_EMPTY(&mp->mnt_nvnodelist)) { struct vnode *vp; @@ -605,21 +600,16 @@ vfs_mount_destroy(struct mount *mp) panic("unmount: dangling vnode"); } KASSERT(TAILQ_EMPTY(&mp->mnt_uppers), ("mnt_uppers")); - if (mp->mnt_nvnodelistsize != 0) - panic("vfs_mount_destroy: nonzero nvnodelistsize"); - if (mp->mnt_lazyvnodelistsize != 0) - panic("vfs_mount_destroy: nonzero lazyvnodelistsize"); - if (mp->mnt_lockref != 0) - panic("vfs_mount_destroy: nonzero lock refcount"); + MPPASS(mp->mnt_nvnodelistsize == 0, mp); + MPPASS(mp->mnt_lazyvnodelistsize == 0, mp); + MPPASS(mp->mnt_lockref == 0, mp); MNT_IUNLOCK(mp); - if (mp->mnt_vfs_ops != 1) - panic("%s: vfs_ops should be 1 but %d found\n", __func__, - mp->mnt_vfs_ops); + MPASSERT(mp->mnt_vfs_ops == 1, mp, + ("vfs_ops should be 1 but %d found", mp->mnt_vfs_ops)); - if (mp->mnt_rootvnode != NULL) - panic("%s: mount point still has a root vnode %p\n", __func__, - mp->mnt_rootvnode); + MPASSERT(mp->mnt_rootvnode == NULL, mp, + ("mount point still has a root vnode %p", mp->mnt_rootvnode)); if (mp->mnt_vnodecovered != NULL) vrele(mp->mnt_vnodecovered); @@ -1589,9 +1579,10 @@ vfs_op_enter(struct mount *mp) mp->mnt_writeopcount += mpcpu->mntp_writeopcount; mpcpu->mntp_writeopcount = 0; } - if (mp->mnt_ref <= 0 || mp->mnt_lockref < 0 || mp->mnt_writeopcount < 0) - panic("%s: invalid count(s) on mp %p: ref %d lockref %d writeopcount %d\n", - __func__, mp, mp->mnt_ref, mp->mnt_lockref, mp->mnt_writeopcount); + MPASSERT(mp->mnt_ref > 0 && mp->mnt_lockref >= 0 && + mp->mnt_writeopcount >= 0, mp, + ("invalid count(s): ref %d lockref %d writeopcount %d", + mp->mnt_ref, mp->mnt_lockref, mp->mnt_writeopcount)); MNT_IUNLOCK(mp); vfs_assert_mount_counters(mp); } @@ -1602,13 +1593,11 @@ vfs_op_exit_locked(struct mount *mp) mtx_assert(MNT_MTX(mp), MA_OWNED); - if (mp->mnt_vfs_ops <= 0) - panic("%s: invalid vfs_ops count %d for mp %p\n", - __func__, mp->mnt_vfs_ops, mp); - KASSERT(mp->mnt_vfs_ops > 1 || - (mp->mnt_kern_flag & (MNTK_UNMOUNT | MNTK_SUSPEND)) == 0, - ("%s: vfs_ops too low (%d) for mp %p in unmount or suspend", - __func__, mp->mnt_vfs_ops, mp)); + MPASSERT(mp->mnt_vfs_ops > 0, mp, + ("invalid vfs_ops count %d", mp->mnt_vfs_ops)); + MPASSERT(mp->mnt_vfs_ops > 1 || + (mp->mnt_kern_flag & (MNTK_UNMOUNT | MNTK_SUSPEND)) == 0, mp, + ("vfs_ops too low %d in unmount or suspend", mp->mnt_vfs_ops)); mp->mnt_vfs_ops--; }