From patchwork Fri Apr 5 06:07:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13618558 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE2A3208AD for ; Fri, 5 Apr 2024 06:07:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712297237; cv=none; b=s+qpg/F0VIdE/KnOoT8vfEyxUCAsedQb3WiVRLy4UtLLMtZKzktxKYjIr0c3uzNALUwWT9NMqK+IrvqIYaiErYQteS6BgJLJGQ+7pOsKSgOpItj4nVp9dyE6k/2/HQmS1zzf9Bnzd0Q4F5RNQEg70RbDhVQHONy6qQVid/hy4m8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712297237; c=relaxed/simple; bh=xkRUW8MqgDkKxGHbh0wJM7gxP0Cnv1EVLGQapHLYSEU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XxBe9Ef80Z1u+ybGb+fhNZ8IrZiRcTzT+Z3uEorSAgmswek/JztwEViafv6rdYISVBeF9zyCjEQnxE5YV30CxwvPv8YVV6/GEnoEWmHZyGRdBcKquGbeIW3OPKDtTbrCVUsAeF1BMLPainIEqECezND6fi3QR02e9qN42hAyLjg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=fBuqqoY1; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="fBuqqoY1" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=xGhh8sHPIUV5QpirSnWndrxPwB/0DuOq0uLOamLC9oU=; b=fBuqqoY1jtQ18fMyKC4vL6INhQ dFpf9iCpQKm0k5lXKBj1eDTLyKJUfUqwKbW4tF/CQbTYCAwgrls8H8mhJ1UE2wPNTN+woQwl+7TdT 1jzin879WmyGV4GdHVhFfl5ytAtcx4FwsJmoso0jCp2MVCrOu9FzScjuBuCxadzo+yb1X0rh46E9o SdBECf83Y3o2frilIQpKwt64Vz+aO4AzQNuaXvdPi66gidm9rFHetuXPzggD6r5Br7fa03HP9nJ5A Tv8tfgasb6Yy6+8BNLFRInjZ7RuJePAigc+o32gu/7vccC7fDSzipOOLjDW0NLsWuNj1wSHliTCis cc3hzBNQ==; Received: from [2001:4bb8:199:60a5:d0:35b2:c2d9:a57a] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rscjK-00000005OMx-2kX7; Fri, 05 Apr 2024 06:07:15 +0000 From: Christoph Hellwig To: Chandan Babu R Cc: "Darrick J. Wong" , Dave Chinner , linux-xfs@vger.kernel.org Subject: [PATCH 1/3] xfs: move more logic into xfs_extent_busy_clear_one Date: Fri, 5 Apr 2024 08:07:08 +0200 Message-Id: <20240405060710.227096-2-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240405060710.227096-1-hch@lst.de> References: <20240405060710.227096-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Move the handling of discarded entries into xfs_extent_busy_clear_one to reuse the length check and tidy up the logic in the caller. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_extent_busy.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/fs/xfs/xfs_extent_busy.c b/fs/xfs/xfs_extent_busy.c index 56cfa1498571e3..6fbffa46e5e94b 100644 --- a/fs/xfs/xfs_extent_busy.c +++ b/fs/xfs/xfs_extent_busy.c @@ -518,20 +518,26 @@ xfs_extent_busy_trim( goto out; } -STATIC void +static bool xfs_extent_busy_clear_one( - struct xfs_mount *mp, struct xfs_perag *pag, - struct xfs_extent_busy *busyp) + struct xfs_extent_busy *busyp, + bool do_discard) { if (busyp->length) { - trace_xfs_extent_busy_clear(mp, busyp->agno, busyp->bno, - busyp->length); + if (do_discard && + !(busyp->flags & XFS_EXTENT_BUSY_SKIP_DISCARD)) { + busyp->flags = XFS_EXTENT_BUSY_DISCARDED; + return false; + } + trace_xfs_extent_busy_clear(pag->pag_mount, busyp->agno, + busyp->bno, busyp->length); rb_erase(&busyp->rb_node, &pag->pagb_tree); } list_del_init(&busyp->list); kfree(busyp); + return true; } static void @@ -575,13 +581,8 @@ xfs_extent_busy_clear( wakeup = false; } - if (do_discard && busyp->length && - !(busyp->flags & XFS_EXTENT_BUSY_SKIP_DISCARD)) { - busyp->flags = XFS_EXTENT_BUSY_DISCARDED; - } else { - xfs_extent_busy_clear_one(mp, pag, busyp); + if (xfs_extent_busy_clear_one(pag, busyp, do_discard)) wakeup = true; - } } if (pag) From patchwork Fri Apr 5 06:07:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13618559 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28E0D1EB2B for ; Fri, 5 Apr 2024 06:07:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712297239; cv=none; b=ru+/F/0r1r8IBzT01Fg8WBGCMzRLWuFHzq0dE5G5fImfTbpnF8YN6CfN+V4CdvltOrmV83eqHYZTjLKwLR0AnNBW+JkA7lDwdgG1Z7l8pj3ZAV3y+cn8d++um6HIPBGOAWw4mlDa7h4JGu8g6iS/EAA1nDbPcDSlXbdISzYOsYE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712297239; c=relaxed/simple; bh=GrjfQ//OMwzUSVx6mkzlR2qidWMTpxka32/y3c9tBJk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JWfhT7NBqdQ57si1UHisIgbBcNI+VBWBYRrkSbWRytfxq/raOENkZFChovgxIg6+HUYtyOhj+/18pCxPtLtMEP8aShxWiHJ/cmK5hhFXRHie6LXtWLG28LitAn43EZCDzbAoOlr5ioFzDyyJRzOY3bnXeRmx5eqmkfS7737ZfpI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=Iu2dfTb6; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Iu2dfTb6" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=0ejniRSIDGKKpe0V9DXbr01vQ7Uoo6I5RAcU91/joZ4=; b=Iu2dfTb6g7Pufkxh6m7k0yL1kg 4PP8Y/xyUW/EVDS/qc3zXRr9y4wtcxm9UkpwImRAnwXc9LOnowBM8wH+WqPXC2dtfxEnnOP/ctHyn miPYQwLDVy3n0R3vPQWkqvAGkukTSIAkkdYsiDdknxX4p4rb2N1XXyKlWARnt5s9yYg18Tqv567Zx uFWosilihRxlb8jdfPYyqOH4PmzUyq5xQOD5yCOtCXxaXZgpDpLIvAV7Y3lpT6BMj0UEmIixmvHg+ ZeeZALNWtUzsq1LV2tpnSXBqKKdV7RDRpxALZvHre4TNtc4/yoann8SDbDc82/D2+zpp53GjZJU2e w9x7miLA==; Received: from [2001:4bb8:199:60a5:d0:35b2:c2d9:a57a] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rscjN-00000005ONH-1ouA; Fri, 05 Apr 2024 06:07:17 +0000 From: Christoph Hellwig To: Chandan Babu R Cc: "Darrick J. Wong" , Dave Chinner , linux-xfs@vger.kernel.org Subject: [PATCH 2/3] xfs: unwind xfs_extent_busy_clear Date: Fri, 5 Apr 2024 08:07:09 +0200 Message-Id: <20240405060710.227096-3-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240405060710.227096-1-hch@lst.de> References: <20240405060710.227096-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html The current structure of xfs_extent_busy_clear that locks the first busy extent in each AG and unlocks when switching to a new AG makes sparse unhappy as the lock critical section tracking can't cope with taking the lock conditionally and inside a loop. Rewrite xfs_extent_busy_clear so that it has an outer loop only advancing when moving to a new AG, and an inner loop that consumes busy extents for the given AG to make life easier for sparse and to also make this logic more obvious to humans. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_extent_busy.c | 59 +++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/fs/xfs/xfs_extent_busy.c b/fs/xfs/xfs_extent_busy.c index 6fbffa46e5e94b..a73e7c73b664c6 100644 --- a/fs/xfs/xfs_extent_busy.c +++ b/fs/xfs/xfs_extent_busy.c @@ -540,21 +540,6 @@ xfs_extent_busy_clear_one( return true; } -static void -xfs_extent_busy_put_pag( - struct xfs_perag *pag, - bool wakeup) - __releases(pag->pagb_lock) -{ - if (wakeup) { - pag->pagb_gen++; - wake_up_all(&pag->pagb_wait); - } - - spin_unlock(&pag->pagb_lock); - xfs_perag_put(pag); -} - /* * Remove all extents on the passed in list from the busy extents tree. * If do_discard is set skip extents that need to be discarded, and mark @@ -566,27 +551,33 @@ xfs_extent_busy_clear( struct list_head *list, bool do_discard) { - struct xfs_extent_busy *busyp, *n; - struct xfs_perag *pag = NULL; - xfs_agnumber_t agno = NULLAGNUMBER; - bool wakeup = false; - - list_for_each_entry_safe(busyp, n, list, list) { - if (busyp->agno != agno) { - if (pag) - xfs_extent_busy_put_pag(pag, wakeup); - agno = busyp->agno; - pag = xfs_perag_get(mp, agno); - spin_lock(&pag->pagb_lock); - wakeup = false; - } + struct xfs_extent_busy *busyp, *next; - if (xfs_extent_busy_clear_one(pag, busyp, do_discard)) - wakeup = true; - } + busyp = list_first_entry_or_null(list, typeof(*busyp), list); + if (!busyp) + return; + + do { + bool wakeup = false; + struct xfs_perag *pag; - if (pag) - xfs_extent_busy_put_pag(pag, wakeup); + pag = xfs_perag_get(mp, busyp->agno); + spin_lock(&pag->pagb_lock); + do { + next = list_next_entry(busyp, list); + if (xfs_extent_busy_clear_one(pag, busyp, do_discard)) + wakeup = true; + busyp = next; + } while (!list_entry_is_head(busyp, list, list) && + busyp->agno == pag->pag_agno); + + if (wakeup) { + pag->pagb_gen++; + wake_up_all(&pag->pagb_wait); + } + spin_unlock(&pag->pagb_lock); + xfs_perag_put(pag); + } while (!list_entry_is_head(busyp, list, list)); } /* From patchwork Fri Apr 5 06:07:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13618560 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EDA191EB2B for ; Fri, 5 Apr 2024 06:07:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712297242; cv=none; b=SlqFIMd0Dh64fW+TQkCf/FcsT0dYrZIUyJOirKDx97xoR1ljEevBaxj33ICdkoJjWPeNV0aMsHG/zX7KUuy5f/5d+SwXMmLRp9h2A5RL6W/z3KWVEIUqPBTxy4N2cFPoTVDOEtRD4IDwjNF19I/A17CH4XjlHKHLO6rkPLCQiQw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712297242; c=relaxed/simple; bh=d5fyDJEbqQOMR32EjRpKxGP23Uu/ubzBqAt3gbfNqGI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Yid+o94BO7Gz+V09ndm04iURNZbY9K3XQA56vT/ucPeuOChhZh9YOxduCMCYO1rMx1Roy63QqAdNrEg3sLp1JNmdEqK+Cyq7zMmsH9qagQfKVrzikjcORU11olkygcH/ugNKhojKD2/2yHfISGEJZcW+nDbMrjAhOI6yaz1dE3c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=FZlLlRzr; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="FZlLlRzr" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=bBuSofmK5kcFULFHUV9RZL5kWmHFWLF1LwoqpMG2NgA=; b=FZlLlRzrF7e6GnAVa/qwwpwidK vQi4Z1G/qOBB3loZGIjEUTzMtTXSI72nh25aYE89uAdCTrRE+q7feoGjjP2agYRqYWlQjwqxM1Fkv YU0IfP/FnvyHvmpwbq2M+kCo/3/z7bbLUnCEo+wwo7Xsp1Y/TdmaCeGQWUIBV64VjgSIvhsuxvqx/ SzpznI//QQ/1zZLEBjOyAqMoVveoSnFFmJ5FwUI3kOBligpBiDkWnMw3LzC411ctBnt8Ozf9eQkeK gOHoKHIsU4GbffsBop0KJCDEcuHtTiypnobBXO01ZBsJe97L3j/B0uuArQ/yloqgmkPWK2Bj66Wp2 ebSpDjsw==; Received: from [2001:4bb8:199:60a5:d0:35b2:c2d9:a57a] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rscjQ-00000005ONX-06Dz; Fri, 05 Apr 2024 06:07:20 +0000 From: Christoph Hellwig To: Chandan Babu R Cc: "Darrick J. Wong" , Dave Chinner , linux-xfs@vger.kernel.org Subject: [PATCH 3/3] xfs: remove the unused xfs_extent_busy_enomem trace event Date: Fri, 5 Apr 2024 08:07:10 +0200 Message-Id: <20240405060710.227096-4-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240405060710.227096-1-hch@lst.de> References: <20240405060710.227096-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_trace.h | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index aea97fc074f8de..62ef0888398b09 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -1654,7 +1654,6 @@ DEFINE_EVENT(xfs_extent_busy_class, name, \ xfs_agblock_t agbno, xfs_extlen_t len), \ TP_ARGS(mp, agno, agbno, len)) DEFINE_BUSY_EVENT(xfs_extent_busy); -DEFINE_BUSY_EVENT(xfs_extent_busy_enomem); DEFINE_BUSY_EVENT(xfs_extent_busy_force); DEFINE_BUSY_EVENT(xfs_extent_busy_reuse); DEFINE_BUSY_EVENT(xfs_extent_busy_clear);