From nobody Thu Oct 10 10:46:05 2024 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 4XPRHy0QFYz5YqTq; Thu, 10 Oct 2024 10:46:06 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XPRHx6f6Tz41nV; Thu, 10 Oct 2024 10:46:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728557165; 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=1WU01Kifeucip1D2DcYYkLzqrteJR5lCtZKONs/7iWU=; b=PrJAGKy/+vN598nB8nNbRKi72Kmt5W20yvWsZMmYQ+/LMomzY2z33SQF+5aUOEKx3wc4m2 wGJJih6nQ3ekRirdxskbXyYDlp0DTWW8l2OzNc8gvy/k58KMo/hWbPusd564SaCuqD3q+3 ToKB5H+3HgW+/3WTc1JLs+aiIvaY9Uk8zUdS1ygB0iXEZYmLjzlQit0qwNCYc8ghYONZzI DvjmQt00+pJPdPD6X+O10sWVLMmNvBWNi91PagTuQY326QIAanal3GwCPjY5LGaV7epHnI 82LjWnbxvPk3s7onme6WaAsd83NrLnssvTD6ZLZvhJQDLfXyrFPzplVZwMFzbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728557165; 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=1WU01Kifeucip1D2DcYYkLzqrteJR5lCtZKONs/7iWU=; b=olOzzmrWFVRl7MXthVMDWLtMw6gOy4pgwOvf7kqhpKPjalwWO3Lx8E4KRRD0c1J6C45CYj Xlic1OXFoaXSJvcWLpa6YLzzvbJYzMnMp+BFB/8U+AP9K0afuDPVcaBdVpsfQ1ylEUKz1p /rIXJtj81LWFh0IkkPdDBSKmLyijY7fJRK7LZ61xv73q4X77ImRffBM3zXFkB4ZfeXwEQO MAHi/jprZdPrn5Mru4NeovUx6Kcgpup4a9o58E5REfXnxPY0LAf4ySsh58g+W75TLIpz0i lY0SjM8WN3xdQ0OPJFe29sRtbu576/gtEW4sSZEggD846gZIA+iD61MuVk/vkg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728557165; a=rsa-sha256; cv=none; b=UXQIAq9WhFQtZH3u0vEi+a0YM28EIzP+eRpM61lPOTrAmLd9JxCjBkmQIc3LVhSSVipP8n 8QlIYO20G4UjwRGFv1kOEr+1dX+xh0ysIsX1EYoAfVUwt6R+nDz3uWGASzRA9Bn1+i37+2 GL0dmBp8FK5FIoi069n8uJUp8g9pcHh8IKZE/s+H270VR5TbnMFJSrb+eo8NC+V/hRedJ8 /ryXSgYZBWSsYxWRp+eG/YFpfPLFHFSTfmIXHnGCKe2aDOAGJFG4kBHx9mAKCHEXE3egCk w4u5AfUB2X+JE5oimuAOywAqVf9qN9pS7XIn2mZStHv38uw2R+qTFHinupGUyQ== 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 4XPRHx67LHzvVK; Thu, 10 Oct 2024 10:46:05 +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 49AAk5ll020039; Thu, 10 Oct 2024 10:46:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49AAk5dE020036; Thu, 10 Oct 2024 10:46:05 GMT (envelope-from git) Date: Thu, 10 Oct 2024 10:46:05 GMT Message-Id: <202410101046.49AAk5dE020036@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Doug Moore Subject: git: ff2263469ad0 - main - Revert "vfs_subr: optimize inval_buf_range" 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dougm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ff2263469ad0f304b2e5f44f1a62c9b20c0306a3 Auto-Submitted: auto-generated The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=ff2263469ad0f304b2e5f44f1a62c9b20c0306a3 commit ff2263469ad0f304b2e5f44f1a62c9b20c0306a3 Author: Doug Moore AuthorDate: 2024-10-10 10:43:40 +0000 Commit: Doug Moore CommitDate: 2024-10-10 10:45:43 +0000 Revert "vfs_subr: optimize inval_buf_range" @pho has reported that this change leads to a failure of the mmap28.sh stress test, and I have confirmed it, so I withdraw it for further study. This reverts commit af4cd5e7b5b50502922b5d2bb42daa7fc66545bb. --- sys/kern/vfs_subr.c | 49 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 328507efd1fd..f192c6798858 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -2616,24 +2616,17 @@ static int v_inval_buf_range_locked(struct vnode *vp, struct bufobj *bo, daddr_t startlbn, daddr_t endlbn) { - struct bufv *bv; struct buf *bp, *nbp; - uint8_t anyfreed; - bool clean; + bool anyfreed; ASSERT_VOP_LOCKED(vp, "v_inval_buf_range_locked"); ASSERT_BO_LOCKED(bo); - anyfreed = 1; - clean = true; do { - bv = clean ? &bo->bo_clean : &bo->bo_dirty; - bp = BUF_PCTRIE_LOOKUP_GE(&bv->bv_root, startlbn); - if (bp == NULL) - continue; - TAILQ_FOREACH_FROM_SAFE(bp, &bv->bv_hd, b_bobufs, nbp) { - if (bp->b_lblkno >= endlbn) - break; + anyfreed = false; + TAILQ_FOREACH_SAFE(bp, &bo->bo_clean.bv_hd, b_bobufs, nbp) { + if (bp->b_lblkno < startlbn || bp->b_lblkno >= endlbn) + continue; if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_SLEEPFAIL | LK_INTERLOCK, BO_LOCKPTR(bo)) == ENOLCK) { @@ -2645,17 +2638,39 @@ v_inval_buf_range_locked(struct vnode *vp, struct bufobj *bo, bp->b_flags |= B_INVAL | B_RELBUF; bp->b_flags &= ~B_ASYNC; brelse(bp); - anyfreed = 2; + anyfreed = true; BO_LOCK(bo); if (nbp != NULL && - (((nbp->b_xflags & - (clean ? BX_VNCLEAN : BX_VNDIRTY)) == 0) || + (((nbp->b_xflags & BX_VNCLEAN) == 0) || nbp->b_vp != vp || - (nbp->b_flags & B_DELWRI) == (clean? B_DELWRI: 0))) + (nbp->b_flags & B_DELWRI) != 0)) + return (EAGAIN); + } + + TAILQ_FOREACH_SAFE(bp, &bo->bo_dirty.bv_hd, b_bobufs, nbp) { + if (bp->b_lblkno < startlbn || bp->b_lblkno >= endlbn) + continue; + if (BUF_LOCK(bp, + LK_EXCLUSIVE | LK_SLEEPFAIL | LK_INTERLOCK, + BO_LOCKPTR(bo)) == ENOLCK) { + BO_LOCK(bo); + return (EAGAIN); + } + bremfree(bp); + bp->b_flags |= B_INVAL | B_RELBUF; + bp->b_flags &= ~B_ASYNC; + brelse(bp); + anyfreed = true; + + BO_LOCK(bo); + if (nbp != NULL && + (((nbp->b_xflags & BX_VNDIRTY) == 0) || + (nbp->b_vp != vp) || + (nbp->b_flags & B_DELWRI) == 0)) return (EAGAIN); } - } while (clean = !clean, anyfreed-- > 0); + } while (anyfreed); return (0); }