From patchwork Thu Jun 20 23:09:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13706514 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 41FCF14374E for ; Thu, 20 Jun 2024 23:09:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718924977; cv=none; b=kgxTvjjp67zZlVZFYOCRK31WEhnjPohIZPlfwDlGxkeIL3ctJFBzC672fPvBC2iCinQBx8PFYt+jePagQhoeO1I8okSXam0ilpkIN5uZAsEDZbXjjGCvb6DK7H4aJ+obP0sAO9+46im55Pb4LSnceiCQjJvl1p4UNoeEoEE49hw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718924977; c=relaxed/simple; bh=ewCa1J3LyrlI7RMBaGjs0mySdd48RYz4HveQ3PQZ00Q=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=i0/RfXbg7xoMnLnWUAk3y+KRVUVZzh7ho8cLp1sDklW8Sn0KOOQmj8j85E6KIYwb+cCp1547wVAgDfxYMs/paCtkSZYc22hunL+pazLGBfNinIRXpQXcLXyj3rJ1PhpLddtYm4ALfXSvZ/NG5VOOfMVoXoyu9+Xx6EvjFVsRgk0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FXrNaM6j; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FXrNaM6j" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A0CFC2BD10; Thu, 20 Jun 2024 23:09:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718924977; bh=ewCa1J3LyrlI7RMBaGjs0mySdd48RYz4HveQ3PQZ00Q=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=FXrNaM6jPESxrMIwyvOjILevqcFCAEdQ/4SHxxYlvDbODAIQha8wpuQJ7CqszOOzr w9D/Zm5l+yHlf7187cuc+6wnyZZUNjmI2sEkmOVqWed6ZKgiPpHwpbPLbrBfK7fAWP 0vFUpQvfdRPR5U841O71y27tKLCFqnfKy73KRoRgL0T2KaCO07YcbpoEtY9ado5QI5 PROwIpJsAd8ThZS4NrpiifZPPEOcGofOIav8flYXw0DsVTmdcDe/Hv9o3yJAt8jdm9 7CF5y16AVvXnv9ZQdmlHIq5C2ocMMfM706byEWcImFwrfHLH2rhbABXcBxseyDWoNv BqsxZxQBwcUhg== Date: Thu, 20 Jun 2024 16:09:36 -0700 Subject: [PATCH 01/10] xfs: give refcount btree cursor error tracepoints their own class From: "Darrick J. Wong" To: djwong@kernel.org Cc: linux-xfs@vger.kernel.org, hch@lst.de Message-ID: <171892419788.3184748.13995968067171093141.stgit@frogsfrogsfrogs> In-Reply-To: <171892419746.3184748.6406153597005839426.stgit@frogsfrogsfrogs> References: <171892419746.3184748.6406153597005839426.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Convert all the refcount tracepoints to use the btree error tracepoint class. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/xfs/libxfs/xfs_refcount.c | 42 ++++++++++++++---------------------------- fs/xfs/xfs_trace.h | 26 +++++++++++++------------- 2 files changed, 27 insertions(+), 41 deletions(-) diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c index 4d8bb760c7235..77acd311aa55c 100644 --- a/fs/xfs/libxfs/xfs_refcount.c +++ b/fs/xfs/libxfs/xfs_refcount.c @@ -211,8 +211,7 @@ xfs_refcount_update( error = xfs_btree_update(cur, &rec); if (error) - trace_xfs_refcount_update_error(cur->bc_mp, - cur->bc_ag.pag->pag_agno, error, _RET_IP_); + trace_xfs_refcount_update_error(cur, error, _RET_IP_); return error; } @@ -247,8 +246,7 @@ xfs_refcount_insert( out_error: if (error) - trace_xfs_refcount_insert_error(cur->bc_mp, - cur->bc_ag.pag->pag_agno, error, _RET_IP_); + trace_xfs_refcount_insert_error(cur, error, _RET_IP_); return error; } @@ -288,8 +286,7 @@ xfs_refcount_delete( &found_rec); out_error: if (error) - trace_xfs_refcount_delete_error(cur->bc_mp, - cur->bc_ag.pag->pag_agno, error, _RET_IP_); + trace_xfs_refcount_delete_error(cur, error, _RET_IP_); return error; } @@ -438,8 +435,7 @@ xfs_refcount_split_extent( return error; out_error: - trace_xfs_refcount_split_extent_error(cur->bc_mp, - cur->bc_ag.pag->pag_agno, error, _RET_IP_); + trace_xfs_refcount_split_extent_error(cur, error, _RET_IP_); return error; } @@ -522,8 +518,7 @@ xfs_refcount_merge_center_extents( return error; out_error: - trace_xfs_refcount_merge_center_extents_error(cur->bc_mp, - cur->bc_ag.pag->pag_agno, error, _RET_IP_); + trace_xfs_refcount_merge_center_extents_error(cur, error, _RET_IP_); return error; } @@ -589,8 +584,7 @@ xfs_refcount_merge_left_extent( return error; out_error: - trace_xfs_refcount_merge_left_extent_error(cur->bc_mp, - cur->bc_ag.pag->pag_agno, error, _RET_IP_); + trace_xfs_refcount_merge_left_extent_error(cur, error, _RET_IP_); return error; } @@ -658,8 +652,7 @@ xfs_refcount_merge_right_extent( return error; out_error: - trace_xfs_refcount_merge_right_extent_error(cur->bc_mp, - cur->bc_ag.pag->pag_agno, error, _RET_IP_); + trace_xfs_refcount_merge_right_extent_error(cur, error, _RET_IP_); return error; } @@ -753,8 +746,7 @@ xfs_refcount_find_left_extents( return error; out_error: - trace_xfs_refcount_find_left_extent_error(cur->bc_mp, - cur->bc_ag.pag->pag_agno, error, _RET_IP_); + trace_xfs_refcount_find_left_extent_error(cur, error, _RET_IP_); return error; } @@ -848,8 +840,7 @@ xfs_refcount_find_right_extents( return error; out_error: - trace_xfs_refcount_find_right_extent_error(cur->bc_mp, - cur->bc_ag.pag->pag_agno, error, _RET_IP_); + trace_xfs_refcount_find_right_extent_error(cur, error, _RET_IP_); return error; } @@ -1254,8 +1245,7 @@ xfs_refcount_adjust_extents( return error; out_error: - trace_xfs_refcount_modify_extent_error(cur->bc_mp, - cur->bc_ag.pag->pag_agno, error, _RET_IP_); + trace_xfs_refcount_modify_extent_error(cur, error, _RET_IP_); return error; } @@ -1315,8 +1305,7 @@ xfs_refcount_adjust( return 0; out_error: - trace_xfs_refcount_adjust_error(cur->bc_mp, cur->bc_ag.pag->pag_agno, - error, _RET_IP_); + trace_xfs_refcount_adjust_error(cur, error, _RET_IP_); return error; } @@ -1630,8 +1619,7 @@ xfs_refcount_find_shared( out_error: if (error) - trace_xfs_refcount_find_shared_error(cur->bc_mp, - cur->bc_ag.pag->pag_agno, error, _RET_IP_); + trace_xfs_refcount_find_shared_error(cur, error, _RET_IP_); return error; } @@ -1786,8 +1774,7 @@ xfs_refcount_adjust_cow_extents( return error; out_error: - trace_xfs_refcount_modify_extent_error(cur->bc_mp, - cur->bc_ag.pag->pag_agno, error, _RET_IP_); + trace_xfs_refcount_modify_extent_error(cur, error, _RET_IP_); return error; } @@ -1833,8 +1820,7 @@ xfs_refcount_adjust_cow( return 0; out_error: - trace_xfs_refcount_adjust_cow_error(cur->bc_mp, cur->bc_ag.pag->pag_agno, - error, _RET_IP_); + trace_xfs_refcount_adjust_cow_error(cur, error, _RET_IP_); return error; } diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index 3ca4605927068..ffaf5d7382363 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -3432,9 +3432,9 @@ DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_get); DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_update); DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_insert); DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_delete); -DEFINE_AG_ERROR_EVENT(xfs_refcount_insert_error); -DEFINE_AG_ERROR_EVENT(xfs_refcount_delete_error); -DEFINE_AG_ERROR_EVENT(xfs_refcount_update_error); +DEFINE_BTREE_ERROR_EVENT(xfs_refcount_insert_error); +DEFINE_BTREE_ERROR_EVENT(xfs_refcount_delete_error); +DEFINE_BTREE_ERROR_EVENT(xfs_refcount_update_error); /* refcount adjustment tracepoints */ DEFINE_AG_EXTENT_EVENT(xfs_refcount_increase); @@ -3449,20 +3449,20 @@ DEFINE_REFCOUNT_DOUBLE_EXTENT_EVENT(xfs_refcount_merge_left_extent); DEFINE_REFCOUNT_DOUBLE_EXTENT_EVENT(xfs_refcount_merge_right_extent); DEFINE_REFCOUNT_DOUBLE_EXTENT_AT_EVENT(xfs_refcount_find_left_extent); DEFINE_REFCOUNT_DOUBLE_EXTENT_AT_EVENT(xfs_refcount_find_right_extent); -DEFINE_AG_ERROR_EVENT(xfs_refcount_adjust_error); -DEFINE_AG_ERROR_EVENT(xfs_refcount_adjust_cow_error); -DEFINE_AG_ERROR_EVENT(xfs_refcount_merge_center_extents_error); -DEFINE_AG_ERROR_EVENT(xfs_refcount_modify_extent_error); -DEFINE_AG_ERROR_EVENT(xfs_refcount_split_extent_error); -DEFINE_AG_ERROR_EVENT(xfs_refcount_merge_left_extent_error); -DEFINE_AG_ERROR_EVENT(xfs_refcount_merge_right_extent_error); -DEFINE_AG_ERROR_EVENT(xfs_refcount_find_left_extent_error); -DEFINE_AG_ERROR_EVENT(xfs_refcount_find_right_extent_error); +DEFINE_BTREE_ERROR_EVENT(xfs_refcount_adjust_error); +DEFINE_BTREE_ERROR_EVENT(xfs_refcount_adjust_cow_error); +DEFINE_BTREE_ERROR_EVENT(xfs_refcount_merge_center_extents_error); +DEFINE_BTREE_ERROR_EVENT(xfs_refcount_modify_extent_error); +DEFINE_BTREE_ERROR_EVENT(xfs_refcount_split_extent_error); +DEFINE_BTREE_ERROR_EVENT(xfs_refcount_merge_left_extent_error); +DEFINE_BTREE_ERROR_EVENT(xfs_refcount_merge_right_extent_error); +DEFINE_BTREE_ERROR_EVENT(xfs_refcount_find_left_extent_error); +DEFINE_BTREE_ERROR_EVENT(xfs_refcount_find_right_extent_error); /* reflink helpers */ DEFINE_AG_EXTENT_EVENT(xfs_refcount_find_shared); DEFINE_AG_EXTENT_EVENT(xfs_refcount_find_shared_result); -DEFINE_AG_ERROR_EVENT(xfs_refcount_find_shared_error); +DEFINE_BTREE_ERROR_EVENT(xfs_refcount_find_shared_error); DECLARE_EVENT_CLASS(xfs_refcount_deferred_class, TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, From patchwork Thu Jun 20 23:09:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13706515 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1FCD913CF82 for ; Thu, 20 Jun 2024 23:09:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718924993; cv=none; b=GsflEjTWf91izxGeiZyyj8tVq8wDcI+Vh34Vnzr6GP4eRnhH3KR5A3zdrkAmwXe1DeHGvO2gxgAsxPT4UNAg8PY3IBAY1aU9uSugzwucEec+fNXqMqv2p6sjTv6rydtS0YiKtwp1+P1Cwmtz9gFWTPgxQs5r4r7ULkGs56YGPQI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718924993; c=relaxed/simple; bh=VRTAqEfBP7a+PnSAMt4Xct8Wt7PHuMUvMAkgSHFFyEQ=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iUlTii4ZhyGGeFg5j9F5a0rofQe/Mgf+0flV8u9lyO66mNn+Ggtz+MhpILg/blxffDQ79G8frSsLQG9nKUaKvSvvNCm+lLSD1n+6KG3AKsniiLiZzmTz3bD2k0Mu1xq8UV0ZTa8a3mx5bKI47501/pHLLdPfpyI/8uTNmNXdc5M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uwjnArFD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uwjnArFD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6B95C2BD10; Thu, 20 Jun 2024 23:09:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718924992; bh=VRTAqEfBP7a+PnSAMt4Xct8Wt7PHuMUvMAkgSHFFyEQ=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=uwjnArFD/5br6NT6XofML6tnEYRbkLy0kdRevPFi4S4Sf48s93SZTVK2Oiv+eDIRZ t0OUJjUb8gR850fAVsiCpB7007FKYx7A+ljyTtpypb4Gx7t1Tx37MSHZLR6ytos4F3 eAuDf1RMeu522ut7vLOAXiYhMUKI1ijJ4/G5lBoZN09vYXg+G6LkA8CP89UC0zORZT 4MAE4gRLTpZkjJxpyRx32yENtciATf9xUVygnIPf2aOgKVxJoFIXJ5FvXE4Ud+bMKp 6BjkaLeH3yRkivXSK5+iRrKEUBm91lZHXRkeHWLQHAihYIAxM/0DTM3rNjbIjAF3PT 2kXNt59qtE8Hg== Date: Thu, 20 Jun 2024 16:09:52 -0700 Subject: [PATCH 02/10] xfs: create specialized classes for refcount tracepoints From: "Darrick J. Wong" To: djwong@kernel.org Cc: linux-xfs@vger.kernel.org, hch@lst.de Message-ID: <171892419806.3184748.4482333777418540364.stgit@frogsfrogsfrogs> In-Reply-To: <171892419746.3184748.6406153597005839426.stgit@frogsfrogsfrogs> References: <171892419746.3184748.6406153597005839426.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong The only user of the "ag" tracepoint event classes is the refcount btree, so rename them to make that obvious and make them take the btree cursor to simplify the arguments. This will save us a lot of trouble later on. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/xfs/libxfs/xfs_refcount.c | 24 ++++++----------- fs/xfs/xfs_trace.h | 61 +++++++++++++++++++++++++++--------------- 2 files changed, 48 insertions(+), 37 deletions(-) diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c index 77acd311aa55c..1916f8281450e 100644 --- a/fs/xfs/libxfs/xfs_refcount.c +++ b/fs/xfs/libxfs/xfs_refcount.c @@ -51,7 +51,7 @@ xfs_refcount_lookup_le( xfs_agblock_t bno, int *stat) { - trace_xfs_refcount_lookup(cur->bc_mp, cur->bc_ag.pag->pag_agno, + trace_xfs_refcount_lookup(cur, xfs_refcount_encode_startblock(bno, domain), XFS_LOOKUP_LE); cur->bc_rec.rc.rc_startblock = bno; @@ -71,7 +71,7 @@ xfs_refcount_lookup_ge( xfs_agblock_t bno, int *stat) { - trace_xfs_refcount_lookup(cur->bc_mp, cur->bc_ag.pag->pag_agno, + trace_xfs_refcount_lookup(cur, xfs_refcount_encode_startblock(bno, domain), XFS_LOOKUP_GE); cur->bc_rec.rc.rc_startblock = bno; @@ -91,7 +91,7 @@ xfs_refcount_lookup_eq( xfs_agblock_t bno, int *stat) { - trace_xfs_refcount_lookup(cur->bc_mp, cur->bc_ag.pag->pag_agno, + trace_xfs_refcount_lookup(cur, xfs_refcount_encode_startblock(bno, domain), XFS_LOOKUP_LE); cur->bc_rec.rc.rc_startblock = bno; @@ -1262,11 +1262,9 @@ xfs_refcount_adjust( int error; if (adj == XFS_REFCOUNT_ADJUST_INCREASE) - trace_xfs_refcount_increase(cur->bc_mp, - cur->bc_ag.pag->pag_agno, *agbno, *aglen); + trace_xfs_refcount_increase(cur, *agbno, *aglen); else - trace_xfs_refcount_decrease(cur->bc_mp, - cur->bc_ag.pag->pag_agno, *agbno, *aglen); + trace_xfs_refcount_decrease(cur, *agbno, *aglen); /* * Ensure that no rcextents cross the boundary of the adjustment range. @@ -1526,8 +1524,7 @@ xfs_refcount_find_shared( int have; int error; - trace_xfs_refcount_find_shared(cur->bc_mp, cur->bc_ag.pag->pag_agno, - agbno, aglen); + trace_xfs_refcount_find_shared(cur, agbno, aglen); /* By default, skip the whole range */ *fbno = NULLAGBLOCK; @@ -1614,8 +1611,7 @@ xfs_refcount_find_shared( } done: - trace_xfs_refcount_find_shared_result(cur->bc_mp, - cur->bc_ag.pag->pag_agno, *fbno, *flen); + trace_xfs_refcount_find_shared_result(cur, *fbno, *flen); out_error: if (error) @@ -1833,8 +1829,7 @@ __xfs_refcount_cow_alloc( xfs_agblock_t agbno, xfs_extlen_t aglen) { - trace_xfs_refcount_cow_increase(rcur->bc_mp, rcur->bc_ag.pag->pag_agno, - agbno, aglen); + trace_xfs_refcount_cow_increase(rcur, agbno, aglen); /* Add refcount btree reservation */ return xfs_refcount_adjust_cow(rcur, agbno, aglen, @@ -1850,8 +1845,7 @@ __xfs_refcount_cow_free( xfs_agblock_t agbno, xfs_extlen_t aglen) { - trace_xfs_refcount_cow_decrease(rcur->bc_mp, rcur->bc_ag.pag->pag_agno, - agbno, aglen); + trace_xfs_refcount_cow_decrease(rcur, agbno, aglen); /* Remove refcount btree reservation */ return xfs_refcount_adjust_cow(rcur, agbno, aglen, diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index ffaf5d7382363..23bf9193a7afd 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -3147,17 +3147,41 @@ DEFINE_AG_ERROR_EVENT(xfs_ag_resv_init_error); /* refcount tracepoint classes */ -/* reuse the discard trace class for agbno/aglen-based traces */ -#define DEFINE_AG_EXTENT_EVENT(name) DEFINE_DISCARD_EVENT(name) +DECLARE_EVENT_CLASS(xfs_refcount_class, + TP_PROTO(struct xfs_btree_cur *cur, xfs_agblock_t agbno, + xfs_extlen_t len), + TP_ARGS(cur, agbno, len), + TP_STRUCT__entry( + __field(dev_t, dev) + __field(xfs_agnumber_t, agno) + __field(xfs_agblock_t, agbno) + __field(xfs_extlen_t, len) + ), + TP_fast_assign( + __entry->dev = cur->bc_mp->m_super->s_dev; + __entry->agno = cur->bc_ag.pag->pag_agno; + __entry->agbno = agbno; + __entry->len = len; + ), + TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x", + MAJOR(__entry->dev), MINOR(__entry->dev), + __entry->agno, + __entry->agbno, + __entry->len) +); +#define DEFINE_REFCOUNT_EVENT(name) \ +DEFINE_EVENT(xfs_refcount_class, name, \ + TP_PROTO(struct xfs_btree_cur *cur, xfs_agblock_t agbno, \ + xfs_extlen_t len), \ + TP_ARGS(cur, agbno, len)) -/* ag btree lookup tracepoint class */ TRACE_DEFINE_ENUM(XFS_LOOKUP_EQi); TRACE_DEFINE_ENUM(XFS_LOOKUP_LEi); TRACE_DEFINE_ENUM(XFS_LOOKUP_GEi); -DECLARE_EVENT_CLASS(xfs_ag_btree_lookup_class, - TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, - xfs_agblock_t agbno, xfs_lookup_t dir), - TP_ARGS(mp, agno, agbno, dir), +TRACE_EVENT(xfs_refcount_lookup, + TP_PROTO(struct xfs_btree_cur *cur, xfs_agblock_t agbno, + xfs_lookup_t dir), + TP_ARGS(cur, agbno, dir), TP_STRUCT__entry( __field(dev_t, dev) __field(xfs_agnumber_t, agno) @@ -3165,8 +3189,8 @@ DECLARE_EVENT_CLASS(xfs_ag_btree_lookup_class, __field(xfs_lookup_t, dir) ), TP_fast_assign( - __entry->dev = mp->m_super->s_dev; - __entry->agno = agno; + __entry->dev = cur->bc_mp->m_super->s_dev; + __entry->agno = cur->bc_ag.pag->pag_agno; __entry->agbno = agbno; __entry->dir = dir; ), @@ -3178,12 +3202,6 @@ DECLARE_EVENT_CLASS(xfs_ag_btree_lookup_class, __entry->dir) ) -#define DEFINE_AG_BTREE_LOOKUP_EVENT(name) \ -DEFINE_EVENT(xfs_ag_btree_lookup_class, name, \ - TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \ - xfs_agblock_t agbno, xfs_lookup_t dir), \ - TP_ARGS(mp, agno, agbno, dir)) - /* single-rcext tracepoint class */ DECLARE_EVENT_CLASS(xfs_refcount_extent_class, TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, @@ -3427,7 +3445,6 @@ DEFINE_EVENT(xfs_refcount_triple_extent_class, name, \ TP_ARGS(mp, agno, i1, i2, i3)) /* refcount btree tracepoints */ -DEFINE_AG_BTREE_LOOKUP_EVENT(xfs_refcount_lookup); DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_get); DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_update); DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_insert); @@ -3437,10 +3454,10 @@ DEFINE_BTREE_ERROR_EVENT(xfs_refcount_delete_error); DEFINE_BTREE_ERROR_EVENT(xfs_refcount_update_error); /* refcount adjustment tracepoints */ -DEFINE_AG_EXTENT_EVENT(xfs_refcount_increase); -DEFINE_AG_EXTENT_EVENT(xfs_refcount_decrease); -DEFINE_AG_EXTENT_EVENT(xfs_refcount_cow_increase); -DEFINE_AG_EXTENT_EVENT(xfs_refcount_cow_decrease); +DEFINE_REFCOUNT_EVENT(xfs_refcount_increase); +DEFINE_REFCOUNT_EVENT(xfs_refcount_decrease); +DEFINE_REFCOUNT_EVENT(xfs_refcount_cow_increase); +DEFINE_REFCOUNT_EVENT(xfs_refcount_cow_decrease); DEFINE_REFCOUNT_TRIPLE_EXTENT_EVENT(xfs_refcount_merge_center_extents); DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_modify_extent); DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_recover_extent); @@ -3460,8 +3477,8 @@ DEFINE_BTREE_ERROR_EVENT(xfs_refcount_find_left_extent_error); DEFINE_BTREE_ERROR_EVENT(xfs_refcount_find_right_extent_error); /* reflink helpers */ -DEFINE_AG_EXTENT_EVENT(xfs_refcount_find_shared); -DEFINE_AG_EXTENT_EVENT(xfs_refcount_find_shared_result); +DEFINE_REFCOUNT_EVENT(xfs_refcount_find_shared); +DEFINE_REFCOUNT_EVENT(xfs_refcount_find_shared_result); DEFINE_BTREE_ERROR_EVENT(xfs_refcount_find_shared_error); DECLARE_EVENT_CLASS(xfs_refcount_deferred_class, From patchwork Thu Jun 20 23:10:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13706516 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7C0441422B6 for ; Thu, 20 Jun 2024 23:10:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718925008; cv=none; b=NYTHu15Y8lyDy25ytyuYROXR/FNZP5rKMAj/5C+/ZUcUZMx8qYWnATm228Fu3HFBVZb5IvoXUx+tANNo/JbeSALEjutQIWOHwHUqrsNCIs4DaOX3+k9NsSRClsgXjMu0eodJZMmxIF8FvRU/9O14VlMmscILLqAS471w9jDsRWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718925008; c=relaxed/simple; bh=B2u88H7yyxwV4B1MC3Xfa1TlyLNqeI471PSZsuq+Wmo=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FDo7449GVUluUbiGg+nJI5z/hax9o1n3g+Qj37FrBkrrmm1Tu/6KYsaFb+p78glByFGAfWjF2uD3LGp3BjK7T+EEQC2FuarAhOgyfeFPuNcCkz4Mmzmjm2JPzt5oLfjjDphlAUHVCeLGAelDdMs9f18vA5kpz2+m/gCDC9JFAkU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eC99Xccf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eC99Xccf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5589CC2BD10; Thu, 20 Jun 2024 23:10:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718925008; bh=B2u88H7yyxwV4B1MC3Xfa1TlyLNqeI471PSZsuq+Wmo=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=eC99XccfGo1aamrRC8u1St+Yy/RnagtcT4xxZBeAHo3gbELzCQuQBaRKDZwgMORnn Tj2TCrzbRgNjms1jMtyVazUYkCkkhx2qXWKGsmR7KAoQUvCSo5xgzaJwxBDnZWItHr WmqBunIb8en+JOrPvnK/IF2PA8rzO8z9FUvQs8jteORi9/YmUNdCoWouCLR7Lyzlnh upw97C3cdYqryZDeKNczETheoR+QlpPQI9LDZXf4tY2pJ4Nc9+na3cfoArlqXueWam tyTF6mh7Wd8y/KSaZHsqZdMIqJCnjQv5n5QqY15JNzTKYmzfm/Dar5o29ngIGDzCd9 yavNo5oVcG8Jw== Date: Thu, 20 Jun 2024 16:10:07 -0700 Subject: [PATCH 03/10] xfs: prepare refcount btree tracepoints for widening From: "Darrick J. Wong" To: djwong@kernel.org Cc: linux-xfs@vger.kernel.org, hch@lst.de Message-ID: <171892419823.3184748.515502742943442450.stgit@frogsfrogsfrogs> In-Reply-To: <171892419746.3184748.6406153597005839426.stgit@frogsfrogsfrogs> References: <171892419746.3184748.6406153597005839426.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Prepare the rest of refcount btree tracepoints for use with realtime reflink by making them take the btree cursor object as a parameter. This will save us a lot of trouble later on. Remove the xfs_refcount_recover_extent tracepoint since it's already covered by other refcount tracepoints. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/xfs/libxfs/xfs_refcount.c | 42 ++++++++------------- fs/xfs/xfs_trace.h | 83 +++++++++++++++++++----------------------- 2 files changed, 53 insertions(+), 72 deletions(-) diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c index 1916f8281450e..b777762494e7f 100644 --- a/fs/xfs/libxfs/xfs_refcount.c +++ b/fs/xfs/libxfs/xfs_refcount.c @@ -183,7 +183,7 @@ xfs_refcount_get_rec( if (fa) return xfs_refcount_complain_bad_rec(cur, fa, irec); - trace_xfs_refcount_get(cur->bc_mp, cur->bc_ag.pag->pag_agno, irec); + trace_xfs_refcount_get(cur, irec); return 0; } @@ -201,7 +201,7 @@ xfs_refcount_update( uint32_t start; int error; - trace_xfs_refcount_update(cur->bc_mp, cur->bc_ag.pag->pag_agno, irec); + trace_xfs_refcount_update(cur, irec); start = xfs_refcount_encode_startblock(irec->rc_startblock, irec->rc_domain); @@ -228,7 +228,7 @@ xfs_refcount_insert( { int error; - trace_xfs_refcount_insert(cur->bc_mp, cur->bc_ag.pag->pag_agno, irec); + trace_xfs_refcount_insert(cur, irec); cur->bc_rec.rc.rc_startblock = irec->rc_startblock; cur->bc_rec.rc.rc_blockcount = irec->rc_blockcount; @@ -273,7 +273,7 @@ xfs_refcount_delete( error = -EFSCORRUPTED; goto out_error; } - trace_xfs_refcount_delete(cur->bc_mp, cur->bc_ag.pag->pag_agno, &irec); + trace_xfs_refcount_delete(cur, &irec); error = xfs_btree_delete(cur, i); if (XFS_IS_CORRUPT(cur->bc_mp, *i != 1)) { xfs_btree_mark_sick(cur); @@ -410,8 +410,7 @@ xfs_refcount_split_extent( return 0; *shape_changed = true; - trace_xfs_refcount_split_extent(cur->bc_mp, cur->bc_ag.pag->pag_agno, - &rcext, agbno); + trace_xfs_refcount_split_extent(cur, &rcext, agbno); /* Establish the right extent. */ tmp = rcext; @@ -454,8 +453,7 @@ xfs_refcount_merge_center_extents( int error; int found_rec; - trace_xfs_refcount_merge_center_extents(cur->bc_mp, - cur->bc_ag.pag->pag_agno, left, center, right); + trace_xfs_refcount_merge_center_extents(cur, left, center, right); ASSERT(left->rc_domain == center->rc_domain); ASSERT(right->rc_domain == center->rc_domain); @@ -536,8 +534,7 @@ xfs_refcount_merge_left_extent( int error; int found_rec; - trace_xfs_refcount_merge_left_extent(cur->bc_mp, - cur->bc_ag.pag->pag_agno, left, cleft); + trace_xfs_refcount_merge_left_extent(cur, left, cleft); ASSERT(left->rc_domain == cleft->rc_domain); @@ -601,8 +598,7 @@ xfs_refcount_merge_right_extent( int error; int found_rec; - trace_xfs_refcount_merge_right_extent(cur->bc_mp, - cur->bc_ag.pag->pag_agno, cright, right); + trace_xfs_refcount_merge_right_extent(cur, cright, right); ASSERT(right->rc_domain == cright->rc_domain); @@ -741,8 +737,7 @@ xfs_refcount_find_left_extents( cleft->rc_refcount = 1; cleft->rc_domain = domain; } - trace_xfs_refcount_find_left_extent(cur->bc_mp, cur->bc_ag.pag->pag_agno, - left, cleft, agbno); + trace_xfs_refcount_find_left_extent(cur, left, cleft, agbno); return error; out_error: @@ -835,8 +830,8 @@ xfs_refcount_find_right_extents( cright->rc_refcount = 1; cright->rc_domain = domain; } - trace_xfs_refcount_find_right_extent(cur->bc_mp, cur->bc_ag.pag->pag_agno, - cright, right, agbno + aglen); + trace_xfs_refcount_find_right_extent(cur, cright, right, + agbno + aglen); return error; out_error: @@ -1139,8 +1134,7 @@ xfs_refcount_adjust_extents( tmp.rc_refcount = 1 + adj; tmp.rc_domain = XFS_REFC_DOMAIN_SHARED; - trace_xfs_refcount_modify_extent(cur->bc_mp, - cur->bc_ag.pag->pag_agno, &tmp); + trace_xfs_refcount_modify_extent(cur, &tmp); /* * Either cover the hole (increment) or @@ -1205,8 +1199,7 @@ xfs_refcount_adjust_extents( if (ext.rc_refcount == MAXREFCOUNT) goto skip; ext.rc_refcount += adj; - trace_xfs_refcount_modify_extent(cur->bc_mp, - cur->bc_ag.pag->pag_agno, &ext); + trace_xfs_refcount_modify_extent(cur, &ext); cur->bc_refc.nr_ops++; if (ext.rc_refcount > 1) { error = xfs_refcount_update(cur, &ext); @@ -1721,8 +1714,7 @@ xfs_refcount_adjust_cow_extents( tmp.rc_refcount = 1; tmp.rc_domain = XFS_REFC_DOMAIN_COW; - trace_xfs_refcount_modify_extent(cur->bc_mp, - cur->bc_ag.pag->pag_agno, &tmp); + trace_xfs_refcount_modify_extent(cur, &tmp); error = xfs_refcount_insert(cur, &tmp, &found_tmp); @@ -1753,8 +1745,7 @@ xfs_refcount_adjust_cow_extents( } ext.rc_refcount = 0; - trace_xfs_refcount_modify_extent(cur->bc_mp, - cur->bc_ag.pag->pag_agno, &ext); + trace_xfs_refcount_modify_extent(cur, &ext); error = xfs_refcount_delete(cur, &found_rec); if (error) goto out_error; @@ -1990,9 +1981,6 @@ xfs_refcount_recover_cow_leftovers( if (error) goto out_free; - trace_xfs_refcount_recover_extent(mp, pag->pag_agno, - &rr->rr_rrec); - /* Free the orphan record */ fsb = XFS_AGB_TO_FSB(mp, pag->pag_agno, rr->rr_rrec.rc_startblock); diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index 23bf9193a7afd..f1f2f661d64db 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -3204,9 +3204,8 @@ TRACE_EVENT(xfs_refcount_lookup, /* single-rcext tracepoint class */ DECLARE_EVENT_CLASS(xfs_refcount_extent_class, - TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, - struct xfs_refcount_irec *irec), - TP_ARGS(mp, agno, irec), + TP_PROTO(struct xfs_btree_cur *cur, struct xfs_refcount_irec *irec), + TP_ARGS(cur, irec), TP_STRUCT__entry( __field(dev_t, dev) __field(xfs_agnumber_t, agno) @@ -3216,8 +3215,8 @@ DECLARE_EVENT_CLASS(xfs_refcount_extent_class, __field(xfs_nlink_t, refcount) ), TP_fast_assign( - __entry->dev = mp->m_super->s_dev; - __entry->agno = agno; + __entry->dev = cur->bc_mp->m_super->s_dev; + __entry->agno = cur->bc_ag.pag->pag_agno; __entry->domain = irec->rc_domain; __entry->startblock = irec->rc_startblock; __entry->blockcount = irec->rc_blockcount; @@ -3234,15 +3233,14 @@ DECLARE_EVENT_CLASS(xfs_refcount_extent_class, #define DEFINE_REFCOUNT_EXTENT_EVENT(name) \ DEFINE_EVENT(xfs_refcount_extent_class, name, \ - TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \ - struct xfs_refcount_irec *irec), \ - TP_ARGS(mp, agno, irec)) + TP_PROTO(struct xfs_btree_cur *cur, struct xfs_refcount_irec *irec), \ + TP_ARGS(cur, irec)) /* single-rcext and an agbno tracepoint class */ DECLARE_EVENT_CLASS(xfs_refcount_extent_at_class, - TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, - struct xfs_refcount_irec *irec, xfs_agblock_t agbno), - TP_ARGS(mp, agno, irec, agbno), + TP_PROTO(struct xfs_btree_cur *cur, struct xfs_refcount_irec *irec, + xfs_agblock_t agbno), + TP_ARGS(cur, irec, agbno), TP_STRUCT__entry( __field(dev_t, dev) __field(xfs_agnumber_t, agno) @@ -3253,8 +3251,8 @@ DECLARE_EVENT_CLASS(xfs_refcount_extent_at_class, __field(xfs_agblock_t, agbno) ), TP_fast_assign( - __entry->dev = mp->m_super->s_dev; - __entry->agno = agno; + __entry->dev = cur->bc_mp->m_super->s_dev; + __entry->agno = cur->bc_ag.pag->pag_agno; __entry->domain = irec->rc_domain; __entry->startblock = irec->rc_startblock; __entry->blockcount = irec->rc_blockcount; @@ -3273,15 +3271,15 @@ DECLARE_EVENT_CLASS(xfs_refcount_extent_at_class, #define DEFINE_REFCOUNT_EXTENT_AT_EVENT(name) \ DEFINE_EVENT(xfs_refcount_extent_at_class, name, \ - TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \ - struct xfs_refcount_irec *irec, xfs_agblock_t agbno), \ - TP_ARGS(mp, agno, irec, agbno)) + TP_PROTO(struct xfs_btree_cur *cur, struct xfs_refcount_irec *irec, \ + xfs_agblock_t agbno), \ + TP_ARGS(cur, irec, agbno)) /* double-rcext tracepoint class */ DECLARE_EVENT_CLASS(xfs_refcount_double_extent_class, - TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, - struct xfs_refcount_irec *i1, struct xfs_refcount_irec *i2), - TP_ARGS(mp, agno, i1, i2), + TP_PROTO(struct xfs_btree_cur *cur, struct xfs_refcount_irec *i1, + struct xfs_refcount_irec *i2), + TP_ARGS(cur, i1, i2), TP_STRUCT__entry( __field(dev_t, dev) __field(xfs_agnumber_t, agno) @@ -3295,8 +3293,8 @@ DECLARE_EVENT_CLASS(xfs_refcount_double_extent_class, __field(xfs_nlink_t, i2_refcount) ), TP_fast_assign( - __entry->dev = mp->m_super->s_dev; - __entry->agno = agno; + __entry->dev = cur->bc_mp->m_super->s_dev; + __entry->agno = cur->bc_ag.pag->pag_agno; __entry->i1_domain = i1->rc_domain; __entry->i1_startblock = i1->rc_startblock; __entry->i1_blockcount = i1->rc_blockcount; @@ -3322,16 +3320,15 @@ DECLARE_EVENT_CLASS(xfs_refcount_double_extent_class, #define DEFINE_REFCOUNT_DOUBLE_EXTENT_EVENT(name) \ DEFINE_EVENT(xfs_refcount_double_extent_class, name, \ - TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \ - struct xfs_refcount_irec *i1, struct xfs_refcount_irec *i2), \ - TP_ARGS(mp, agno, i1, i2)) + TP_PROTO(struct xfs_btree_cur *cur, struct xfs_refcount_irec *i1, \ + struct xfs_refcount_irec *i2), \ + TP_ARGS(cur, i1, i2)) /* double-rcext and an agbno tracepoint class */ DECLARE_EVENT_CLASS(xfs_refcount_double_extent_at_class, - TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, - struct xfs_refcount_irec *i1, struct xfs_refcount_irec *i2, - xfs_agblock_t agbno), - TP_ARGS(mp, agno, i1, i2, agbno), + TP_PROTO(struct xfs_btree_cur *cur, struct xfs_refcount_irec *i1, + struct xfs_refcount_irec *i2, xfs_agblock_t agbno), + TP_ARGS(cur, i1, i2, agbno), TP_STRUCT__entry( __field(dev_t, dev) __field(xfs_agnumber_t, agno) @@ -3346,8 +3343,8 @@ DECLARE_EVENT_CLASS(xfs_refcount_double_extent_at_class, __field(xfs_agblock_t, agbno) ), TP_fast_assign( - __entry->dev = mp->m_super->s_dev; - __entry->agno = agno; + __entry->dev = cur->bc_mp->m_super->s_dev; + __entry->agno = cur->bc_ag.pag->pag_agno; __entry->i1_domain = i1->rc_domain; __entry->i1_startblock = i1->rc_startblock; __entry->i1_blockcount = i1->rc_blockcount; @@ -3375,17 +3372,15 @@ DECLARE_EVENT_CLASS(xfs_refcount_double_extent_at_class, #define DEFINE_REFCOUNT_DOUBLE_EXTENT_AT_EVENT(name) \ DEFINE_EVENT(xfs_refcount_double_extent_at_class, name, \ - TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \ - struct xfs_refcount_irec *i1, struct xfs_refcount_irec *i2, \ - xfs_agblock_t agbno), \ - TP_ARGS(mp, agno, i1, i2, agbno)) + TP_PROTO(struct xfs_btree_cur *cur, struct xfs_refcount_irec *i1, \ + struct xfs_refcount_irec *i2, xfs_agblock_t agbno), \ + TP_ARGS(cur, i1, i2, agbno)) /* triple-rcext tracepoint class */ DECLARE_EVENT_CLASS(xfs_refcount_triple_extent_class, - TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, - struct xfs_refcount_irec *i1, struct xfs_refcount_irec *i2, - struct xfs_refcount_irec *i3), - TP_ARGS(mp, agno, i1, i2, i3), + TP_PROTO(struct xfs_btree_cur *cur, struct xfs_refcount_irec *i1, + struct xfs_refcount_irec *i2, struct xfs_refcount_irec *i3), + TP_ARGS(cur, i1, i2, i3), TP_STRUCT__entry( __field(dev_t, dev) __field(xfs_agnumber_t, agno) @@ -3403,8 +3398,8 @@ DECLARE_EVENT_CLASS(xfs_refcount_triple_extent_class, __field(xfs_nlink_t, i3_refcount) ), TP_fast_assign( - __entry->dev = mp->m_super->s_dev; - __entry->agno = agno; + __entry->dev = cur->bc_mp->m_super->s_dev; + __entry->agno = cur->bc_ag.pag->pag_agno; __entry->i1_domain = i1->rc_domain; __entry->i1_startblock = i1->rc_startblock; __entry->i1_blockcount = i1->rc_blockcount; @@ -3439,10 +3434,9 @@ DECLARE_EVENT_CLASS(xfs_refcount_triple_extent_class, #define DEFINE_REFCOUNT_TRIPLE_EXTENT_EVENT(name) \ DEFINE_EVENT(xfs_refcount_triple_extent_class, name, \ - TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \ - struct xfs_refcount_irec *i1, struct xfs_refcount_irec *i2, \ - struct xfs_refcount_irec *i3), \ - TP_ARGS(mp, agno, i1, i2, i3)) + TP_PROTO(struct xfs_btree_cur *cur, struct xfs_refcount_irec *i1, \ + struct xfs_refcount_irec *i2, struct xfs_refcount_irec *i3), \ + TP_ARGS(cur, i1, i2, i3)) /* refcount btree tracepoints */ DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_get); @@ -3460,7 +3454,6 @@ DEFINE_REFCOUNT_EVENT(xfs_refcount_cow_increase); DEFINE_REFCOUNT_EVENT(xfs_refcount_cow_decrease); DEFINE_REFCOUNT_TRIPLE_EXTENT_EVENT(xfs_refcount_merge_center_extents); DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_modify_extent); -DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_recover_extent); DEFINE_REFCOUNT_EXTENT_AT_EVENT(xfs_refcount_split_extent); DEFINE_REFCOUNT_DOUBLE_EXTENT_EVENT(xfs_refcount_merge_left_extent); DEFINE_REFCOUNT_DOUBLE_EXTENT_EVENT(xfs_refcount_merge_right_extent); From patchwork Thu Jun 20 23:10:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13706517 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 0F1D8147C74 for ; Thu, 20 Jun 2024 23:10:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718925024; cv=none; b=pOVHBSLctznTHOKmItjTUgY5ve8Hz9tnd2Gz4cqU4ne4uiMDmFTeA/nFfdVepxJZcu/xwMPOkbqfMQFkkS46UIdLT4v1iZqpVZBoFW62SPb3eNwM5wiXaJEgqO5mc3pNKTEIFkQAXbvumoNFK7pxRz8yGoWfiqJUmYVsHgwqoSw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718925024; c=relaxed/simple; bh=aGOv23waCZGm+eo3tnji7q0liNVjNxlYQMD6w3O9uPQ=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Q31jk58DrrG32lBYRIvyGKQ3Yr/tnnBdTvw+QAbwfZyFXaTYXlL9ttMCjqDJ/eI4yQ1x1xbqQGMNRrV8LMiDxDGlm2mvhDNMbuhYka9OIZ5iJBBP74T7Lk7nyJpXxtREe/aYbbb6I19GcrRFL+FTl4bq5TGxqimawkOq0I3uw8U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BalZ7Dxm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BalZ7Dxm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1348C4AF08; Thu, 20 Jun 2024 23:10:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718925023; bh=aGOv23waCZGm+eo3tnji7q0liNVjNxlYQMD6w3O9uPQ=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=BalZ7Dxm1cxl3Gfq1U8HFlbiNyryVjXkric3bKnAORoNBa3RW6B9IDDz0qgOf+E+a TKqj8OqZQheaxBhWHgS5KgFVyVLEz8kOSvvMzyS6eH9N7JEjk3W+sCHrYoJm3aUBgw DhYLkYsVhLP4yMKj1o1NoXDxy+T3ew70z19Yl59tydS5sXdDk/xg/kA9sc1Ir41qXq 4BLksVhz+w7BQDa2OJlBXhzivaMAreGvCjFAb/teWyN3Ea7gZXQVvC30uiYbaaanez m3Jng7mSZLsMa/EtWeoaC5jqul/YHhIe6P5yYFbUnq7OIpQ8exwOrMdvEMrY4XLYz1 JThq2V2Bb7+vQ== Date: Thu, 20 Jun 2024 16:10:23 -0700 Subject: [PATCH 04/10] xfs: clean up refcount log intent item tracepoint callsites From: "Darrick J. Wong" To: djwong@kernel.org Cc: linux-xfs@vger.kernel.org, hch@lst.de Message-ID: <171892419841.3184748.9309858987645162456.stgit@frogsfrogsfrogs> In-Reply-To: <171892419746.3184748.6406153597005839426.stgit@frogsfrogsfrogs> References: <171892419746.3184748.6406153597005839426.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Pass the incore refcount intent structure to the tracepoints instead of open-coding the argument passing. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/xfs/libxfs/xfs_refcount.c | 14 +++------- fs/xfs/libxfs/xfs_refcount.h | 6 ++++ fs/xfs/xfs_trace.c | 1 + fs/xfs/xfs_trace.h | 59 +++++++++++++----------------------------- 4 files changed, 29 insertions(+), 51 deletions(-) diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c index b777762494e7f..c0572bb86cdb8 100644 --- a/fs/xfs/libxfs/xfs_refcount.c +++ b/fs/xfs/libxfs/xfs_refcount.c @@ -1367,9 +1367,7 @@ xfs_refcount_finish_one( bno = XFS_FSB_TO_AGBNO(mp, ri->ri_startblock); - trace_xfs_refcount_deferred(mp, XFS_FSB_TO_AGNO(mp, ri->ri_startblock), - ri->ri_type, XFS_FSB_TO_AGBNO(mp, ri->ri_startblock), - ri->ri_blockcount); + trace_xfs_refcount_deferred(mp, ri); if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_REFCOUNT_FINISH_ONE)) return -EIO; @@ -1432,8 +1430,7 @@ xfs_refcount_finish_one( return -EFSCORRUPTED; } if (!error && ri->ri_blockcount > 0) - trace_xfs_refcount_finish_one_leftover(mp, ri->ri_pag->pag_agno, - ri->ri_type, bno, ri->ri_blockcount); + trace_xfs_refcount_finish_one_leftover(mp, ri); return error; } @@ -1449,11 +1446,6 @@ __xfs_refcount_add( { struct xfs_refcount_intent *ri; - trace_xfs_refcount_defer(tp->t_mountp, - XFS_FSB_TO_AGNO(tp->t_mountp, startblock), - type, XFS_FSB_TO_AGBNO(tp->t_mountp, startblock), - blockcount); - ri = kmem_cache_alloc(xfs_refcount_intent_cache, GFP_KERNEL | __GFP_NOFAIL); INIT_LIST_HEAD(&ri->ri_list); @@ -1461,6 +1453,8 @@ __xfs_refcount_add( ri->ri_startblock = startblock; ri->ri_blockcount = blockcount; + trace_xfs_refcount_defer(tp->t_mountp, ri); + xfs_refcount_update_get_group(tp->t_mountp, ri); xfs_defer_add(tp, &ri->ri_list, &xfs_refcount_update_defer_type); } diff --git a/fs/xfs/libxfs/xfs_refcount.h b/fs/xfs/libxfs/xfs_refcount.h index 9b56768a590c0..01a20621192ed 100644 --- a/fs/xfs/libxfs/xfs_refcount.h +++ b/fs/xfs/libxfs/xfs_refcount.h @@ -48,6 +48,12 @@ enum xfs_refcount_intent_type { XFS_REFCOUNT_FREE_COW, }; +#define XFS_REFCOUNT_INTENT_STRINGS \ + { XFS_REFCOUNT_INCREASE, "incr" }, \ + { XFS_REFCOUNT_DECREASE, "decr" }, \ + { XFS_REFCOUNT_ALLOC_COW, "alloc_cow" }, \ + { XFS_REFCOUNT_FREE_COW, "free_cow" } + struct xfs_refcount_intent { struct list_head ri_list; struct xfs_perag *ri_pag; diff --git a/fs/xfs/xfs_trace.c b/fs/xfs/xfs_trace.c index 9bf95c9f7942a..dd0ce46089194 100644 --- a/fs/xfs/xfs_trace.c +++ b/fs/xfs/xfs_trace.c @@ -43,6 +43,7 @@ #include "xfs_exchrange.h" #include "xfs_parent.h" #include "xfs_rmap.h" +#include "xfs_refcount.h" /* * We include this last to have the helpers above available for the trace diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index f1f2f661d64db..654ad6f574680 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -92,6 +92,7 @@ struct xfs_parent_irec; struct xfs_attrlist_cursor_kern; struct xfs_extent_free_item; struct xfs_rmap_intent; +struct xfs_refcount_intent; #define XFS_ATTR_FILTER_FLAGS \ { XFS_ATTR_ROOT, "ROOT" }, \ @@ -3474,66 +3475,42 @@ DEFINE_REFCOUNT_EVENT(xfs_refcount_find_shared); DEFINE_REFCOUNT_EVENT(xfs_refcount_find_shared_result); DEFINE_BTREE_ERROR_EVENT(xfs_refcount_find_shared_error); +TRACE_DEFINE_ENUM(XFS_REFCOUNT_INCREASE); +TRACE_DEFINE_ENUM(XFS_REFCOUNT_DECREASE); +TRACE_DEFINE_ENUM(XFS_REFCOUNT_ALLOC_COW); +TRACE_DEFINE_ENUM(XFS_REFCOUNT_FREE_COW); + DECLARE_EVENT_CLASS(xfs_refcount_deferred_class, - TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, - int type, xfs_agblock_t agbno, xfs_extlen_t len), - TP_ARGS(mp, agno, type, agbno, len), + TP_PROTO(struct xfs_mount *mp, struct xfs_refcount_intent *refc), + TP_ARGS(mp, refc), TP_STRUCT__entry( __field(dev_t, dev) __field(xfs_agnumber_t, agno) - __field(int, type) + __field(int, op) __field(xfs_agblock_t, agbno) __field(xfs_extlen_t, len) ), TP_fast_assign( __entry->dev = mp->m_super->s_dev; - __entry->agno = agno; - __entry->type = type; - __entry->agbno = agbno; - __entry->len = len; + __entry->agno = XFS_FSB_TO_AGNO(mp, refc->ri_startblock); + __entry->op = refc->ri_type; + __entry->agbno = XFS_FSB_TO_AGBNO(mp, refc->ri_startblock); + __entry->len = refc->ri_blockcount; ), - TP_printk("dev %d:%d op %d agno 0x%x agbno 0x%x fsbcount 0x%x", + TP_printk("dev %d:%d op %s agno 0x%x agbno 0x%x fsbcount 0x%x", MAJOR(__entry->dev), MINOR(__entry->dev), - __entry->type, + __print_symbolic(__entry->op, XFS_REFCOUNT_INTENT_STRINGS), __entry->agno, __entry->agbno, __entry->len) ); #define DEFINE_REFCOUNT_DEFERRED_EVENT(name) \ DEFINE_EVENT(xfs_refcount_deferred_class, name, \ - TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \ - int type, \ - xfs_agblock_t bno, \ - xfs_extlen_t len), \ - TP_ARGS(mp, agno, type, bno, len)) + TP_PROTO(struct xfs_mount *mp, struct xfs_refcount_intent *refc), \ + TP_ARGS(mp, refc)) DEFINE_REFCOUNT_DEFERRED_EVENT(xfs_refcount_defer); DEFINE_REFCOUNT_DEFERRED_EVENT(xfs_refcount_deferred); - -TRACE_EVENT(xfs_refcount_finish_one_leftover, - TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, - int type, xfs_agblock_t agbno, xfs_extlen_t len), - TP_ARGS(mp, agno, type, agbno, len), - TP_STRUCT__entry( - __field(dev_t, dev) - __field(xfs_agnumber_t, agno) - __field(int, type) - __field(xfs_agblock_t, agbno) - __field(xfs_extlen_t, len) - ), - TP_fast_assign( - __entry->dev = mp->m_super->s_dev; - __entry->agno = agno; - __entry->type = type; - __entry->agbno = agbno; - __entry->len = len; - ), - TP_printk("dev %d:%d type %d agno 0x%x agbno 0x%x fsbcount 0x%x", - MAJOR(__entry->dev), MINOR(__entry->dev), - __entry->type, - __entry->agno, - __entry->agbno, - __entry->len) -); +DEFINE_REFCOUNT_DEFERRED_EVENT(xfs_refcount_finish_one_leftover); /* simple inode-based error/%ip tracepoint class */ DECLARE_EVENT_CLASS(xfs_inode_error_class, From patchwork Thu Jun 20 23:10:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13706518 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 0F98213CF82 for ; Thu, 20 Jun 2024 23:10:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718925040; cv=none; b=IeyMrOUEFfWKnXvdHycftoKXRFcao9S9pLiQsDQqzWiow/2FT94GM1SU+J7enzFJsQNd2E3XGKv1wqzw63XtWBJNUK3Ae137ri8TH7TxhKMzRsPI3H8+MmIUOdxVWU49NimFbgsYDVts8EyvCkReRs9YTlPNUFsFKMFlBOUnaKw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718925040; c=relaxed/simple; bh=pcnBdEwWM43otL8ou6ouqTId7SjwnMUUr4Rkrg3d6hM=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EozcqLk9N8rSGWBAvsTJxCf1/zbLPxeMiapvqFfobfUkQJdHutmiZz6wVtpxXf2QF64VAdysZ6a+76mXh3dQ04+HunRQetMTLfie0yuZs00HDTkpBHZFfRlXfIaLSYcZyp01Zqx2MEXsfDfKWWB9ZrUNMPo+LvHPK3wi/Ia3omE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EbB/gW7Z; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EbB/gW7Z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F646C2BD10; Thu, 20 Jun 2024 23:10:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718925039; bh=pcnBdEwWM43otL8ou6ouqTId7SjwnMUUr4Rkrg3d6hM=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=EbB/gW7ZbOah2kPCAM/87DH2G4hel9kkFzgdXt7enKyrXLAK9s2wpqe1weY4a6mu5 Y4ctBjz9soZm1WQCLb/0SAdo9EkyHyNkbardUE8ZLu7sfAGJcAiSy/3TqT/Q+imK+u dbLDHOY5oweYq9/iAtfV4MgQBy0ZR9jsybsav3GkZZ5C3r7obOOFqt16PExs4Rk4Dp nsMCQE/udZUPIHK9fIwtBdgoe7nybs8nY1SWfwSFxXD07qEgW2kt7jnzFK7siIn9o4 nQgJIzawYM5NK35daLummB5XMU0Z1c6COZ8L4JGGzxNUPXGq85dlaVCj3/iTGmASSV tEmkrYvZfqhyA== Date: Thu, 20 Jun 2024 16:10:39 -0700 Subject: [PATCH 05/10] xfs: remove xfs_trans_set_refcount_flags From: "Darrick J. Wong" To: djwong@kernel.org Cc: linux-xfs@vger.kernel.org, hch@lst.de Message-ID: <171892419858.3184748.8956724086429567211.stgit@frogsfrogsfrogs> In-Reply-To: <171892419746.3184748.6406153597005839426.stgit@frogsfrogsfrogs> References: <171892419746.3184748.6406153597005839426.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Remove this single-use helper. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_refcount_item.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c index 78e106d05aa20..deb8b4aaa9541 100644 --- a/fs/xfs/xfs_refcount_item.c +++ b/fs/xfs/xfs_refcount_item.c @@ -243,25 +243,6 @@ xfs_refcount_update_diff_items( return ra->ri_pag->pag_agno - rb->ri_pag->pag_agno; } -/* Set the phys extent flags for this reverse mapping. */ -static void -xfs_trans_set_refcount_flags( - struct xfs_phys_extent *pmap, - enum xfs_refcount_intent_type type) -{ - pmap->pe_flags = 0; - switch (type) { - case XFS_REFCOUNT_INCREASE: - case XFS_REFCOUNT_DECREASE: - case XFS_REFCOUNT_ALLOC_COW: - case XFS_REFCOUNT_FREE_COW: - pmap->pe_flags |= type; - break; - default: - ASSERT(0); - } -} - /* Log refcount updates in the intent item. */ STATIC void xfs_refcount_update_log_item( @@ -282,7 +263,18 @@ xfs_refcount_update_log_item( pmap = &cuip->cui_format.cui_extents[next_extent]; pmap->pe_startblock = ri->ri_startblock; pmap->pe_len = ri->ri_blockcount; - xfs_trans_set_refcount_flags(pmap, ri->ri_type); + + pmap->pe_flags = 0; + switch (ri->ri_type) { + case XFS_REFCOUNT_INCREASE: + case XFS_REFCOUNT_DECREASE: + case XFS_REFCOUNT_ALLOC_COW: + case XFS_REFCOUNT_FREE_COW: + pmap->pe_flags |= ri->ri_type; + break; + default: + ASSERT(0); + } } static struct xfs_log_item * From patchwork Thu Jun 20 23:10:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13706519 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 816A982D83 for ; Thu, 20 Jun 2024 23:10:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718925055; cv=none; b=QWoFg07O1hGqfM+rcaQ2QfQEd754la0IeuhrNPNTFrNecDxeFqfS28UKWwOWVZayzJ4fqSewM3Y90sR3c7TFU6uz4CthozqrpFTG9YBVTcmjhnEYPTtl3HNAvt9GO999x0BJo8Y1erRN+9wPuTrLjlxlgRBpGzYjCXlOIL7Z16A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718925055; c=relaxed/simple; bh=Z3MNSrDiG4xk1nM2nQnFzgQkowaVM57ciMCklPD6Xd0=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TdCanLa70x38b/btDrDgAFW6nL7jN0sBRLJqaUC2TxXDA1Ogbzq9LJMSrHuaEizzxOy2heQniNl/V4EpU6ruFNr0yP39ywh/vdlzFRVEjXEpchhSmmV/lUQokZlu87w9z4DyG3zl3SdPe4js0ESKrxU5nec/7viZCkDGXSDd6Ug= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cUdOV714; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cUdOV714" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4EE10C32781; Thu, 20 Jun 2024 23:10:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718925055; bh=Z3MNSrDiG4xk1nM2nQnFzgQkowaVM57ciMCklPD6Xd0=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=cUdOV714YkwIQ88y7rYFr20Q4gMW7IPC3j3jylfB3cRU44uXQDbd9udBIQzKHvU9Q q+zd9uNDAccJn4CPgmIVK+ZEzfKI37DtV6C2uwN5aK0blpt6yBRV8atLPqkM2hGzSF y2bQ/uXSTpz4r/TrWWBJ8BEyFlTLQwgFXbKEhleGdqoBz9kPYacNniI74dFyxmZGH5 C02EZ9kET7mgRYA6HRoYcKc4JQX3fxDwMT19z4lmBo2BdYyt5nZpK34qIOMW1uqYEj Jve7PJgnmUKemFUPgsZMitutv+KXYRbMu01jTgBWwlrw0RByyRbHpCg4152naCwQW4 GCB/HpeYUZa9w== Date: Thu, 20 Jun 2024 16:10:54 -0700 Subject: [PATCH 06/10] xfs: add a ci_entry helper From: "Darrick J. Wong" To: djwong@kernel.org Cc: linux-xfs@vger.kernel.org, hch@lst.de Message-ID: <171892419875.3184748.10263305750216565433.stgit@frogsfrogsfrogs> In-Reply-To: <171892419746.3184748.6406153597005839426.stgit@frogsfrogsfrogs> References: <171892419746.3184748.6406153597005839426.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Add a helper to translate from the item list head to the refcount_intent_item structure and use it so shorten assignments and avoid the need for extra local variables. Inspired-by: Christoph Hellwig Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_refcount_item.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c index deb8b4aaa9541..cc53c733bef1b 100644 --- a/fs/xfs/xfs_refcount_item.c +++ b/fs/xfs/xfs_refcount_item.c @@ -227,6 +227,11 @@ static const struct xfs_item_ops xfs_cud_item_ops = { .iop_intent = xfs_cud_item_intent, }; +static inline struct xfs_refcount_intent *ci_entry(const struct list_head *e) +{ + return list_entry(e, struct xfs_refcount_intent, ri_list); +} + /* Sort refcount intents by AG. */ static int xfs_refcount_update_diff_items( @@ -234,11 +239,8 @@ xfs_refcount_update_diff_items( const struct list_head *a, const struct list_head *b) { - struct xfs_refcount_intent *ra; - struct xfs_refcount_intent *rb; - - ra = container_of(a, struct xfs_refcount_intent, ri_list); - rb = container_of(b, struct xfs_refcount_intent, ri_list); + struct xfs_refcount_intent *ra = ci_entry(a); + struct xfs_refcount_intent *rb = ci_entry(b); return ra->ri_pag->pag_agno - rb->ri_pag->pag_agno; } @@ -341,11 +343,9 @@ xfs_refcount_update_finish_item( struct list_head *item, struct xfs_btree_cur **state) { - struct xfs_refcount_intent *ri; + struct xfs_refcount_intent *ri = ci_entry(item); int error; - ri = container_of(item, struct xfs_refcount_intent, ri_list); - /* Did we run out of reservation? Requeue what we didn't finish. */ error = xfs_refcount_finish_one(tp, ri, state); if (!error && ri->ri_blockcount > 0) { @@ -372,9 +372,7 @@ STATIC void xfs_refcount_update_cancel_item( struct list_head *item) { - struct xfs_refcount_intent *ri; - - ri = container_of(item, struct xfs_refcount_intent, ri_list); + struct xfs_refcount_intent *ri = ci_entry(item); xfs_refcount_update_put_group(ri); kmem_cache_free(xfs_refcount_intent_cache, ri); From patchwork Thu Jun 20 23:11:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13706520 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 288D182D83 for ; Thu, 20 Jun 2024 23:11:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718925071; cv=none; b=XR5qOObd2uIP6Fh4shv40J/DJ9HIWms4zMj6xAvA8zORCtCdS24st8hk504RyRWNizaPyfZ8J93IZzHmKTJIkf7Czt8UMTS1BepM49stTpU2AOVBO+lieHu6okEzzn8HQWatuI5gNuxZ2gTOWrWonpa1Kpzq9WC87hFqyO0nKE0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718925071; c=relaxed/simple; bh=/h8cWPffz9nZ4VBRdOPAI2egf2fVQFsGwPIWcni1xNg=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KoFnniVSJNdoTcOVCW2YQh4OjIVz+SrIH3/mp6rIkkTsq8dkJfQjvEAsJveJowycVL+0Uj82H5snP54fG3awXGasVNghuhbpAPeBT4593fEoHuS7DEy418l5om+2C2v2itkpp2TQEUs8W+ZzKVgi0XA7YUtYVlomaqB9s/hj1lA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rKveCZ9T; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rKveCZ9T" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 058ACC2BD10; Thu, 20 Jun 2024 23:11:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718925071; bh=/h8cWPffz9nZ4VBRdOPAI2egf2fVQFsGwPIWcni1xNg=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=rKveCZ9TdWAfcGY4sjezrn3v3EI48ed/DX93FM9SITTcJP5x/zEu2thMyBp3SSlNo LLGI9eeKyHs9rQHkAzON4o1sfwCq7+ehXOqSVohPdeQTaw1EuizmC31Sg1/71/BJF/ W8oySdLzX02pnM7gbPDQ3PehJ74Z6Ml66O+ofJ/BanrXpXtYXCnkxeHOg64ycby/lb OBGvwAzU74GmRzmHwqGVEwI3yIL/adf2/SB4Q6mTupStiww0XhJqrbw7Buf5sEDEFR GS5f+e0fEfm1PiPfNhvolJvm+V/7cEixNiVhFKg2SvWWq99BYUterL0/EU+nYJJpFU GOghesuArI4AA== Date: Thu, 20 Jun 2024 16:11:10 -0700 Subject: [PATCH 07/10] xfs: reuse xfs_refcount_update_cancel_item From: "Darrick J. Wong" To: djwong@kernel.org Cc: linux-xfs@vger.kernel.org, hch@lst.de Message-ID: <171892419892.3184748.5587189586405596401.stgit@frogsfrogsfrogs> In-Reply-To: <171892419746.3184748.6406153597005839426.stgit@frogsfrogsfrogs> References: <171892419746.3184748.6406153597005839426.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Reuse xfs_refcount_update_cancel_item to put the AG/RTG and free the item in a few places that currently open code the logic. Inspired-by: Christoph Hellwig Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_refcount_item.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c index cc53c733bef1b..90a019ddcc1f4 100644 --- a/fs/xfs/xfs_refcount_item.c +++ b/fs/xfs/xfs_refcount_item.c @@ -335,6 +335,17 @@ xfs_refcount_update_put_group( xfs_perag_intent_put(ri->ri_pag); } +/* Cancel a deferred refcount update. */ +STATIC void +xfs_refcount_update_cancel_item( + struct list_head *item) +{ + struct xfs_refcount_intent *ri = ci_entry(item); + + xfs_refcount_update_put_group(ri); + kmem_cache_free(xfs_refcount_intent_cache, ri); +} + /* Process a deferred refcount update. */ STATIC int xfs_refcount_update_finish_item( @@ -354,8 +365,7 @@ xfs_refcount_update_finish_item( return -EAGAIN; } - xfs_refcount_update_put_group(ri); - kmem_cache_free(xfs_refcount_intent_cache, ri); + xfs_refcount_update_cancel_item(item); return error; } @@ -367,17 +377,6 @@ xfs_refcount_update_abort_intent( xfs_cui_release(CUI_ITEM(intent)); } -/* Cancel a deferred refcount update. */ -STATIC void -xfs_refcount_update_cancel_item( - struct list_head *item) -{ - struct xfs_refcount_intent *ri = ci_entry(item); - - xfs_refcount_update_put_group(ri); - kmem_cache_free(xfs_refcount_intent_cache, ri); -} - /* Is this recovered CUI ok? */ static inline bool xfs_cui_validate_phys( From patchwork Thu Jun 20 23:11:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13706521 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D40A382D83 for ; Thu, 20 Jun 2024 23:11:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718925086; cv=none; b=duKSdE3G60r88Kb5dVPwfcTq19wq3lp6+2sTX7hdVYiRZ48d4yXra3hlr+cMM+0FOo6mY5hngHcUcDEzwX1qsJXWktMjHOB1nKuDKQxZIJRbNkOZCAQqJqrlLG+uxm9F2OhvCi6az3OOlu7nHgE3DsSRD3znv8a7SRSWuYwGg6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718925086; c=relaxed/simple; bh=/Q1OwaAfuVGdlUoqHTbnrKABYbiBYOT+F40/JVBzEGE=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=W58LNsdJ+g7J9BhScW0lSpSdcZ0xcAFAJZNQ0mgnxPX5C/BezoerhDtCnO9YqQDyTmhLinbHTCu75ZWvOCJuncTn8rUeqhx9sA1Hhg0npScZ6kaJAUtepgLSfb3xHEL6h3uYwsAF+bYQKHGY+gZrhQFeUl4wEuMRMj95TQaFVFk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rRnDwVLP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rRnDwVLP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA7DCC2BD10; Thu, 20 Jun 2024 23:11:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718925086; bh=/Q1OwaAfuVGdlUoqHTbnrKABYbiBYOT+F40/JVBzEGE=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=rRnDwVLPmU30SJBMGeqIHFKokQC3f0oC0gvJI81Qljm49XLvsx0kPtokHbUTfvEZ0 omAYdXiGvNMyebyWdDePgHA4FY2oOLqwLKEPXuFBUrzck1VdFjcwPr6EMCJLfGfmKt dvA4RVVmy9NY2hoiuoMbG5ZgnsPv98sBsZqN/CTQqODikv5k+mDzZP4rkmAk9qsH7F IQ0dbbx24R5Rj0icWMzPgWuUjEbkbjR7V7cZsJP9bgOKeHp4kASxO5wuwJn1DPC6mH noYhg+Kd339ZyNWT2WZgUHqlkGqf2MT7bGwBquVydOcPeIDpgoFHdsKSWCRbswzG8+ wMZwojy/2y9yA== Date: Thu, 20 Jun 2024 16:11:26 -0700 Subject: [PATCH 08/10] xfs: don't bother calling xfs_refcount_finish_one_cleanup in xfs_refcount_finish_one From: "Darrick J. Wong" To: djwong@kernel.org Cc: linux-xfs@vger.kernel.org, hch@lst.de Message-ID: <171892419908.3184748.15491155401473010232.stgit@frogsfrogsfrogs> In-Reply-To: <171892419746.3184748.6406153597005839426.stgit@frogsfrogsfrogs> References: <171892419746.3184748.6406153597005839426.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong In xfs_refcount_finish_one we know the cursor is non-zero when calling xfs_refcount_finish_one_cleanup and we pass a 0 error variable. This means xfs_refcount_finish_one_cleanup is just doing a xfs_btree_del_cursor. Open code that and move xfs_refcount_finish_one_cleanup to fs/xfs/xfs_refcount_item.c. Inspired-by: Christoph Hellwig Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/xfs/libxfs/xfs_refcount.c | 19 +------------------ fs/xfs/libxfs/xfs_refcount.h | 2 -- fs/xfs/xfs_refcount_item.c | 18 ++++++++++++++++++ 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c index c0572bb86cdb8..10a16635d93f2 100644 --- a/fs/xfs/libxfs/xfs_refcount.c +++ b/fs/xfs/libxfs/xfs_refcount.c @@ -1300,23 +1300,6 @@ xfs_refcount_adjust( return error; } -/* Clean up after calling xfs_refcount_finish_one. */ -void -xfs_refcount_finish_one_cleanup( - struct xfs_trans *tp, - struct xfs_btree_cur *rcur, - int error) -{ - struct xfs_buf *agbp; - - if (rcur == NULL) - return; - agbp = rcur->bc_ag.agbp; - xfs_btree_del_cursor(rcur, error); - if (error) - xfs_trans_brelse(tp, agbp); -} - /* * Set up a continuation a deferred refcount operation by updating the intent. * Checks to make sure we're not going to run off the end of the AG. @@ -1380,7 +1363,7 @@ xfs_refcount_finish_one( if (rcur != NULL && rcur->bc_ag.pag != ri->ri_pag) { nr_ops = rcur->bc_refc.nr_ops; shape_changes = rcur->bc_refc.shape_changes; - xfs_refcount_finish_one_cleanup(tp, rcur, 0); + xfs_btree_del_cursor(rcur, 0); rcur = NULL; *pcur = NULL; } diff --git a/fs/xfs/libxfs/xfs_refcount.h b/fs/xfs/libxfs/xfs_refcount.h index 01a20621192ed..c94b8f71d407b 100644 --- a/fs/xfs/libxfs/xfs_refcount.h +++ b/fs/xfs/libxfs/xfs_refcount.h @@ -82,8 +82,6 @@ void xfs_refcount_increase_extent(struct xfs_trans *tp, void xfs_refcount_decrease_extent(struct xfs_trans *tp, struct xfs_bmbt_irec *irec); -extern void xfs_refcount_finish_one_cleanup(struct xfs_trans *tp, - struct xfs_btree_cur *rcur, int error); extern int xfs_refcount_finish_one(struct xfs_trans *tp, struct xfs_refcount_intent *ri, struct xfs_btree_cur **pcur); diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c index 90a019ddcc1f4..4e06cadb924d3 100644 --- a/fs/xfs/xfs_refcount_item.c +++ b/fs/xfs/xfs_refcount_item.c @@ -21,6 +21,7 @@ #include "xfs_log_priv.h" #include "xfs_log_recover.h" #include "xfs_ag.h" +#include "xfs_btree.h" struct kmem_cache *xfs_cui_cache; struct kmem_cache *xfs_cud_cache; @@ -369,6 +370,23 @@ xfs_refcount_update_finish_item( return error; } +/* Clean up after calling xfs_refcount_finish_one. */ +STATIC void +xfs_refcount_finish_one_cleanup( + struct xfs_trans *tp, + struct xfs_btree_cur *rcur, + int error) +{ + struct xfs_buf *agbp; + + if (rcur == NULL) + return; + agbp = rcur->bc_ag.agbp; + xfs_btree_del_cursor(rcur, error); + if (error) + xfs_trans_brelse(tp, agbp); +} + /* Abort all pending CUIs. */ STATIC void xfs_refcount_update_abort_intent( From patchwork Thu Jun 20 23:11:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13706529 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B122514374E for ; Thu, 20 Jun 2024 23:11:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718925102; cv=none; b=Fr/c4f5tisMAv/g0fDZlRx1+oaPYO+tatfgHjsZg1IYLzsDpnJxVky1ROOOvieSQD8ntECLhcoon/bhypu1BRw51UitfHxZhwqMbk1/xSbGQAvkr6CK35tUy2OXf7Q/x5AQpDozbWQeyPcZJ46D3Zb4nkIPRXjaRvUDLvsqxEyc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718925102; c=relaxed/simple; bh=eR2jrI5Q9F2z0pcvj2CigA1FRfkeZRMFnOa+Zez2BJw=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XMcCJ5gVxUEBBYa5qBe8K7NpqWbqcRwm26d9jSPgRZ7vQIjsF3+cUzUeyDDcx1asgM5tELuLwrv7AbjqHncK7alWShYPy0cMi1UIDY8dE/WsIJjD9ReSAtIxEjOq+qZtulycYvQw6Q+z/ABTI5upl7Nz9LWUqsrtdkPYR0CM/dM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ITL2G88c; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ITL2G88c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46E99C2BD10; Thu, 20 Jun 2024 23:11:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718925102; bh=eR2jrI5Q9F2z0pcvj2CigA1FRfkeZRMFnOa+Zez2BJw=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=ITL2G88cVuNTKZzzKLKLTUYX5TUz7U/K/SBclInPxL4RqSKKbzxtUK8noLg+Ih9++ stYnN9HSm7QqeM5t+z85YE3eWeFp1WB3XuTRtTCazoK/60oTJMnwGo8qFKhZBzhsG2 ptWYSNLcFyoHJCz7exleVQ+iL5tziAcQtrgYvhEORgJZasLTPIgLu0pVqPppJZNtSK h0SJ8qcQD/HkAUkL7ZyUmI6yVJYwdYePNytKcN9jVuTLC8BunZ0HASDRTfRGuS6LO3 xif3qOfLou0aJ+X+p+dkA5ss9ONGC0ID8mOOaRcCxJR0VlAjLa8cqZEibKW13pKcfM 8IG40ZW7CTufw== Date: Thu, 20 Jun 2024 16:11:41 -0700 Subject: [PATCH 09/10] xfs: simplify usage of the rcur local variable in xfs_refcount_finish_one From: "Darrick J. Wong" To: djwong@kernel.org Cc: linux-xfs@vger.kernel.org, hch@lst.de Message-ID: <171892419926.3184748.7669666442192075027.stgit@frogsfrogsfrogs> In-Reply-To: <171892419746.3184748.6406153597005839426.stgit@frogsfrogsfrogs> References: <171892419746.3184748.6406153597005839426.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Only update rcur when we know the final *pcur value. Inspired-by: Christoph Hellwig [djwong: don't leave the caller with a dangling ref] Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/xfs/libxfs/xfs_refcount.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c index 10a16635d93f2..4137a8d1ac13d 100644 --- a/fs/xfs/libxfs/xfs_refcount.c +++ b/fs/xfs/libxfs/xfs_refcount.c @@ -1341,7 +1341,7 @@ xfs_refcount_finish_one( struct xfs_btree_cur **pcur) { struct xfs_mount *mp = tp->t_mountp; - struct xfs_btree_cur *rcur; + struct xfs_btree_cur *rcur = *pcur; struct xfs_buf *agbp = NULL; int error = 0; xfs_agblock_t bno; @@ -1359,7 +1359,6 @@ xfs_refcount_finish_one( * If we haven't gotten a cursor or the cursor AG doesn't match * the startblock, get one now. */ - rcur = *pcur; if (rcur != NULL && rcur->bc_ag.pag != ri->ri_pag) { nr_ops = rcur->bc_refc.nr_ops; shape_changes = rcur->bc_refc.shape_changes; @@ -1373,11 +1372,11 @@ xfs_refcount_finish_one( if (error) return error; - rcur = xfs_refcountbt_init_cursor(mp, tp, agbp, ri->ri_pag); + *pcur = rcur = xfs_refcountbt_init_cursor(mp, tp, agbp, + ri->ri_pag); rcur->bc_refc.nr_ops = nr_ops; rcur->bc_refc.shape_changes = shape_changes; } - *pcur = rcur; switch (ri->ri_type) { case XFS_REFCOUNT_INCREASE: From patchwork Thu Jun 20 23:11:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13706530 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6210A13CF82 for ; Thu, 20 Jun 2024 23:11:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718925118; cv=none; b=gHBOsXgfP4Vw4XasVyQjJcQjB3ZG6iy/DBuuKllX0KQi6ioFcROlaqIUVH1F672gLC996myMuI4LMmSoVjTwXK86gFPDKK7jeCxt+PaA9hW3BSnldLx5sxLf80SIEs78VIHvZgKizrQXqHBfcRnZRc3LHPnSQUIGqFHfAIO2PX8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718925118; c=relaxed/simple; bh=DNNNGnFqCL+cOB5HVzSLTxtJ7OHMgnpm0ncoi7oxuMI=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XLY82UQvw0yJKiHizfp5etM/AjPadSXQbApliVVsGTSvb6RcQxKN/jN2SfeO2TsPKcDyWn8reP47JPlBl7FhUuYPZ1W+GXVNskAfSneiYdNHJQ3rYn3+k9/JtG9MiyrQfPwNa7EciC7EnE1yX3GprYJqPQ+sAsY/E9yBwMEYXfk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=U/lWl9uy; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="U/lWl9uy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E231DC2BD10; Thu, 20 Jun 2024 23:11:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718925118; bh=DNNNGnFqCL+cOB5HVzSLTxtJ7OHMgnpm0ncoi7oxuMI=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=U/lWl9uyWKshz6CxEsVYEKQ+IVV17pS24DJbrKpBlnG5ziUEl/+8HTotaYQOhN05i Y5mmMGGEEJogCk1EGlnKFvecXAN69T7sEfOpPKn/lrgD7xOJw+V8YWwa+RImh0OkzM moybzEMRiLdz1rjbgUv9rr5Z0YB2TACvcC+EWJUYiOLvKMEb2+Ep6LySK2IViIzI2L bR2ylica0dqXJ5EMqhlly8XBa3Tai0sbCAYAyhi9aihywqVT0Mu9vM6izk7Jdd3ciV VSXm6axmrjBERhFDjgXIhmp6NFSXGZcuPgKAar+1TA/h/1OeoqV+7fzETx2MS4eroB 5y94psdDI8tEA== Date: Thu, 20 Jun 2024 16:11:57 -0700 Subject: [PATCH 10/10] xfs: move xfs_refcount_update_defer_add to xfs_refcount_item.c From: "Darrick J. Wong" To: djwong@kernel.org Cc: linux-xfs@vger.kernel.org, hch@lst.de Message-ID: <171892419943.3184748.2162208276846925919.stgit@frogsfrogsfrogs> In-Reply-To: <171892419746.3184748.6406153597005839426.stgit@frogsfrogsfrogs> References: <171892419746.3184748.6406153597005839426.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Move the code that adds the incore xfs_refcount_update_item deferred work data to a transaction live with the CUI log item code. This means that the refcount code no longer has to know about the inner workings of the CUI log items. As a consequence, we can get rid of the _{get,put}_group helpers. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/xfs/libxfs/xfs_refcount.c | 6 ++---- fs/xfs/libxfs/xfs_refcount.h | 3 --- fs/xfs/xfs_refcount_item.c | 24 +++++++++++------------- fs/xfs/xfs_refcount_item.h | 5 +++++ 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c index 4137a8d1ac13d..198b84117df13 100644 --- a/fs/xfs/libxfs/xfs_refcount.c +++ b/fs/xfs/libxfs/xfs_refcount.c @@ -24,6 +24,7 @@ #include "xfs_rmap.h" #include "xfs_ag.h" #include "xfs_health.h" +#include "xfs_refcount_item.h" struct kmem_cache *xfs_refcount_intent_cache; @@ -1435,10 +1436,7 @@ __xfs_refcount_add( ri->ri_startblock = startblock; ri->ri_blockcount = blockcount; - trace_xfs_refcount_defer(tp->t_mountp, ri); - - xfs_refcount_update_get_group(tp->t_mountp, ri); - xfs_defer_add(tp, &ri->ri_list, &xfs_refcount_update_defer_type); + xfs_refcount_defer_add(tp, ri); } /* diff --git a/fs/xfs/libxfs/xfs_refcount.h b/fs/xfs/libxfs/xfs_refcount.h index c94b8f71d407b..68acb0b1b4a87 100644 --- a/fs/xfs/libxfs/xfs_refcount.h +++ b/fs/xfs/libxfs/xfs_refcount.h @@ -74,9 +74,6 @@ xfs_refcount_check_domain( return true; } -void xfs_refcount_update_get_group(struct xfs_mount *mp, - struct xfs_refcount_intent *ri); - void xfs_refcount_increase_extent(struct xfs_trans *tp, struct xfs_bmbt_irec *irec); void xfs_refcount_decrease_extent(struct xfs_trans *tp, diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c index 4e06cadb924d3..27398512b179b 100644 --- a/fs/xfs/xfs_refcount_item.c +++ b/fs/xfs/xfs_refcount_item.c @@ -22,6 +22,7 @@ #include "xfs_log_recover.h" #include "xfs_ag.h" #include "xfs_btree.h" +#include "xfs_trace.h" struct kmem_cache *xfs_cui_cache; struct kmem_cache *xfs_cud_cache; @@ -319,21 +320,18 @@ xfs_refcount_update_create_done( return &cudp->cud_item; } -/* Take a passive ref to the AG containing the space we're refcounting. */ +/* Add this deferred CUI to the transaction. */ void -xfs_refcount_update_get_group( - struct xfs_mount *mp, +xfs_refcount_defer_add( + struct xfs_trans *tp, struct xfs_refcount_intent *ri) { + struct xfs_mount *mp = tp->t_mountp; + + trace_xfs_refcount_defer(mp, ri); + ri->ri_pag = xfs_perag_intent_get(mp, ri->ri_startblock); -} - -/* Release a passive AG ref after finishing refcounting work. */ -static inline void -xfs_refcount_update_put_group( - struct xfs_refcount_intent *ri) -{ - xfs_perag_intent_put(ri->ri_pag); + xfs_defer_add(tp, &ri->ri_list, &xfs_refcount_update_defer_type); } /* Cancel a deferred refcount update. */ @@ -343,7 +341,7 @@ xfs_refcount_update_cancel_item( { struct xfs_refcount_intent *ri = ci_entry(item); - xfs_refcount_update_put_group(ri); + xfs_perag_intent_put(ri->ri_pag); kmem_cache_free(xfs_refcount_intent_cache, ri); } @@ -433,7 +431,7 @@ xfs_cui_recover_work( ri->ri_type = pmap->pe_flags & XFS_REFCOUNT_EXTENT_TYPE_MASK; ri->ri_startblock = pmap->pe_startblock; ri->ri_blockcount = pmap->pe_len; - xfs_refcount_update_get_group(mp, ri); + ri->ri_pag = xfs_perag_intent_get(mp, pmap->pe_startblock); xfs_defer_add_item(dfp, &ri->ri_list); } diff --git a/fs/xfs/xfs_refcount_item.h b/fs/xfs/xfs_refcount_item.h index eb0ab13682d0b..bfee8f30c63ce 100644 --- a/fs/xfs/xfs_refcount_item.h +++ b/fs/xfs/xfs_refcount_item.h @@ -71,4 +71,9 @@ struct xfs_cud_log_item { extern struct kmem_cache *xfs_cui_cache; extern struct kmem_cache *xfs_cud_cache; +struct xfs_refcount_intent; + +void xfs_refcount_defer_add(struct xfs_trans *tp, + struct xfs_refcount_intent *ri); + #endif /* __XFS_REFCOUNT_ITEM_H__ */