From patchwork Wed Dec 27 13:24:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13508332 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 C9EB07EE for ; Mon, 1 Jan 2024 00:24:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="B7XFXoCk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 484FFC433C7; Mon, 1 Jan 2024 00:24:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704068644; bh=mCJ8BMV6ts9SnuR70cgNVZcsbguM5ReZVqmfoa48Y9o=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=B7XFXoCkf1QD4/f7grgVoLHij4jBzZggmSvxOIkx5ddUVuNqM8Qwq2JNtoWFtOzsY YhJm1HqjOCvDZJGw48g8xMBia1PeduF28xNQToSHY1xkDSvQ109SvekI+YnItPetBi rSDeYhY96LMXA2+nEmVBiJGGms6LEH8HO/giuMQ8UWj3XfZrDKXDLsNBv9VbWH23jH Rn1jX/b1mNhUHjY46MCcUwSeHe0g3xJXIfXUld7bJny/bpICcHpm+J9iH45P+P8lz2 efiwIKEeG1zvREJkJMUsXLTX7z6zmZ+9+pQf/c9x8C2+3EIar7d0OOCAOzcEjSAyyQ k5rRS60HX743A== Date: Sun, 31 Dec 2023 16:24:03 +9900 Subject: [PATCH 1/9] xfs: give refcount btree cursor error tracepoints their own class From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Message-ID: <170405016635.1816837.4406725381956185137.stgit@frogsfrogsfrogs> In-Reply-To: <170405016616.1816837.2298941345938137266.stgit@frogsfrogsfrogs> References: <170405016616.1816837.2298941345938137266.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 --- libxfs/xfs_refcount.c | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/libxfs/xfs_refcount.c b/libxfs/xfs_refcount.c index 0e8daab9986..9bb7acbdc6f 100644 --- a/libxfs/xfs_refcount.c +++ b/libxfs/xfs_refcount.c @@ -210,8 +210,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; } @@ -246,8 +245,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; } @@ -287,8 +285,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; } @@ -437,8 +434,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; } @@ -521,8 +517,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; } @@ -588,8 +583,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; } @@ -657,8 +651,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; } @@ -752,8 +745,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; } @@ -847,8 +839,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; } @@ -1253,8 +1244,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; } @@ -1314,8 +1304,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; } @@ -1629,8 +1618,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; } @@ -1785,8 +1773,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; } @@ -1832,8 +1819,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; } From patchwork Wed Dec 27 13:24:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13508333 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 174427EF for ; Mon, 1 Jan 2024 00:24:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gkY+vTzk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D63D8C433C7; Mon, 1 Jan 2024 00:24:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704068659; bh=BNwdIpPKFBlDRw5hA0Y+A8PqXshVISXAxiamsmADKxY=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=gkY+vTzk8b9UluXHCKfiOt/KAmDBI6HnNikHdq+1S4RUfTN1uhS42jloTsVRXHpoQ STmzEGBZk1kNxjJ3Ak3dA3dpGtPTDd1Bc5BXK9WPTH3627+kQPkmMDA/v0S3MNrTyu cbeem+Gx/1re1LE/YQtRB1KHapeGfP4p4HLlBpGEfr4egq7n95jd8CJW5AG+rah1No Zbhv3Nc0VH/6BrNki4/Q3FBOSe0icqh1/AIofVskvxaDdO0taZbQ8fd0YvVYemaDZo dWQZe66Umqsj5g+OHr1QKpLUOUpzwNP5uVSdMbb7Z0+lG4l8T6eAQ4OYii6Qox6+le UmnBqlaOrGX/g== Date: Sun, 31 Dec 2023 16:24:19 +9900 Subject: [PATCH 2/9] xfs: create specialized classes for refcount tracepoints From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Message-ID: <170405016648.1816837.6387518588947985482.stgit@frogsfrogsfrogs> In-Reply-To: <170405016616.1816837.2298941345938137266.stgit@frogsfrogsfrogs> References: <170405016616.1816837.2298941345938137266.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 --- libxfs/xfs_refcount.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/libxfs/xfs_refcount.c b/libxfs/xfs_refcount.c index 9bb7acbdc6f..67c9895efb3 100644 --- a/libxfs/xfs_refcount.c +++ b/libxfs/xfs_refcount.c @@ -50,7 +50,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; @@ -70,7 +70,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; @@ -90,7 +90,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; @@ -1261,11 +1261,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. @@ -1525,8 +1523,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; @@ -1613,8 +1610,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) @@ -1832,8 +1828,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, @@ -1849,8 +1844,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, From patchwork Wed Dec 27 13:24:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13508334 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 A25987F9 for ; Mon, 1 Jan 2024 00:24:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ui1CiSIn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7426CC433C7; Mon, 1 Jan 2024 00:24:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704068675; bh=4eHgG/TI82OxTm4U2KOwiC8afDrwasXbwOHA1K8EPG8=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=ui1CiSIn6IOKJmdE0STtv8ZyvgWJ9m8dS0r/WygpoRzvZe75064kAmW59yCO+EOGG oDMzh0YcjWsDrcN5jqImcJX7066aS3G1olkq2OZ2xjGhzfyxztK1fTG6GExfV86FCQ Yng6syyjg9xPv0c8XdfPXLRaOQVbWakDWjGbs6IRPG3XWpu9seWOftlmF1RMW3k0mE M3cU7lELlX4PfEJ9OJZMuD7XsNnbTmeZBAHM9KgxydjezkWCSgGTga5SeHyAzsLKSd O+S5U357BMhL4mO1MhuEJzkHUfX0mf9w/ODxfIkULavhBQm9VQKJu9QoXmynpPVeza 8YnoxZ8emOTHA== Date: Sun, 31 Dec 2023 16:24:35 +9900 Subject: [PATCH 3/9] xfs: prepare refcount btree tracepoints for widening From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Message-ID: <170405016661.1816837.9388177485349245842.stgit@frogsfrogsfrogs> In-Reply-To: <170405016616.1816837.2298941345938137266.stgit@frogsfrogsfrogs> References: <170405016616.1816837.2298941345938137266.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 --- libxfs/xfs_refcount.c | 42 +++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/libxfs/xfs_refcount.c b/libxfs/xfs_refcount.c index 67c9895efb3..18b04c38cdd 100644 --- a/libxfs/xfs_refcount.c +++ b/libxfs/xfs_refcount.c @@ -182,7 +182,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; } @@ -200,7 +200,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); @@ -227,7 +227,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; @@ -272,7 +272,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); @@ -409,8 +409,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; @@ -453,8 +452,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); @@ -535,8 +533,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); @@ -600,8 +597,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); @@ -740,8 +736,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: @@ -834,8 +829,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: @@ -1138,8 +1133,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 @@ -1204,8 +1198,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_ag.refc.nr_ops++; if (ext.rc_refcount > 1) { error = xfs_refcount_update(cur, &ext); @@ -1720,8 +1713,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); @@ -1752,8 +1744,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; @@ -1987,9 +1978,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); From patchwork Wed Dec 27 13:24:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13508335 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 AA7907EE for ; Mon, 1 Jan 2024 00:24:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WbXJFZ03" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14576C433C7; Mon, 1 Jan 2024 00:24:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704068691; bh=mQLvLoWsR8xQnyv5hkRoe4T/lRU8EnO8XIqlmfZHOSY=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=WbXJFZ03gaAHRvN5VpiByYXGJo7V8IXAo3eEqSfhZcjJpaK9vRIuF06RSyl/Le9LW sCOaD/ojM3TdzolC6YQrPSvtgXl75QwgrrMN/HijWUXzAHBrx3UY0LuoW7FGrQBo+/ wBqPG3ygpusUyesbP8lAqz+srdUDW5z8NWZak9ltqLYGkSJDdVSfLkER7O+2UHigf4 ioL5NqrU4F0U9DXf8Zey0V6TAM/t12vqFg55b5q46l56kpMwde5AAZLta5tFnTAi0Z 8YU3Sk5FnutFgYBoPsxrq/VTrkUSAJ7r0xi40DY4UeB7Fo5QdKxOyd9kHgg8BKdeMr LrEOUhr1WIuBA== Date: Sun, 31 Dec 2023 16:24:50 +9900 Subject: [PATCH 4/9] xfs: clean up refcount log intent item tracepoint callsites From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Message-ID: <170405016674.1816837.1510641157689213799.stgit@frogsfrogsfrogs> In-Reply-To: <170405016616.1816837.2298941345938137266.stgit@frogsfrogsfrogs> References: <170405016616.1816837.2298941345938137266.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 --- libxfs/xfs_refcount.c | 14 ++++---------- libxfs/xfs_refcount.h | 6 ++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libxfs/xfs_refcount.c b/libxfs/xfs_refcount.c index 18b04c38cdd..3ae68ea22e3 100644 --- a/libxfs/xfs_refcount.c +++ b/libxfs/xfs_refcount.c @@ -1366,9 +1366,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; @@ -1431,8 +1429,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; } @@ -1448,11 +1445,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_NOFS | __GFP_NOFAIL); INIT_LIST_HEAD(&ri->ri_list); @@ -1460,6 +1452,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/libxfs/xfs_refcount.h b/libxfs/xfs_refcount.h index 9b56768a590..01a20621192 100644 --- a/libxfs/xfs_refcount.h +++ b/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; From patchwork Wed Dec 27 13:25:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13508336 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 24A647ED for ; Mon, 1 Jan 2024 00:25:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IA9+YC7/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6280C433C8; Mon, 1 Jan 2024 00:25:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704068706; bh=eyqyI9y4pDC5YcaQI7j3qP4STWt0ttaQFy2OIKIse6o=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=IA9+YC7/BzlqMt9uCAiowkTjAWeDYYNSbwjAoqbJHJgibeRIv9PVQljOGR5b12h6d Ur9wzQJo9GT7YyPyG5SkagS4XDqr1el1TtIMzldsPjRvWOg5Bri+1fwjAhC3IAMIgA MjWrY1S7arwVy6YrdKKgNkYjZVNsZ+Tpk2ov34T3rPkGJ+XKc+ckufZO9N8D0rvYz6 dYOqrcuDXCFvB0Vnu+a/2SODHBMHG5CAjs+AAyYElyNCxDevQC4fzePEv4Jp6HxN9B Tq31DoqEvWSG2owCgEotxyw2zavJfbNU9/L/anySAqWGBDI/YfEiKaGCeQUoiWppiR zlZYMk1xa24AA== Date: Sun, 31 Dec 2023 16:25:06 +9900 Subject: [PATCH 5/9] xfs: add a ci_entry helper From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Message-ID: <170405016687.1816837.6258236545791657769.stgit@frogsfrogsfrogs> In-Reply-To: <170405016616.1816837.2298941345938137266.stgit@frogsfrogsfrogs> References: <170405016616.1816837.2298941345938137266.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 --- libxfs/defer_item.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c index e7270d02c4b..471e4f6867d 100644 --- a/libxfs/defer_item.c +++ b/libxfs/defer_item.c @@ -485,6 +485,11 @@ const struct xfs_defer_op_type xfs_rtrmap_update_defer_type = { /* Reference Counting */ +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( @@ -492,11 +497,8 @@ xfs_refcount_update_diff_items( const struct list_head *a, const struct list_head *b) { - const struct xfs_refcount_intent *ra; - const 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; } @@ -551,10 +553,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); error = xfs_refcount_finish_one(tp, ri, state); /* Did we run out of reservation? Requeue what we didn't finish. */ @@ -581,9 +582,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 Wed Dec 27 13:25:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13508337 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 BE6507EF for ; Mon, 1 Jan 2024 00:25:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NHXGmUMD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 413A8C433C7; Mon, 1 Jan 2024 00:25:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704068722; bh=JG7dtotQDby+Ur1obd3UEDnMjomEGO8/WvpNO296MlU=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=NHXGmUMDczF2hLTuTwftByuQ5pUKBKgLi7NoDP98mNIymNaA3fSfebcwMCHKnaQD7 kLe8xqDxS4d1oIWZnaXUMHBkZ+IcPbShDNhLStkyz+5+7hNFORmhf/UzQ70vgmpI49 b3KcBQps+yosKhvMHtBg5EE5ihRHA/syiAsuNMtkshMpCkNNHp/8/qOufT/b4vkVvw SEO+sLNtqKw+jbCXJ8Dm3Lq5S/K8tumESQlQ3LagXJfghUeRnue4gWmcbZXlEUSXeF 8s0HvrU7NlxH4ORSCowa7/QIFoPNq4hW76FtHDtdMxSmduYGyA5V8f1Rt0qb6+ix/i yd40xa5sNs5sg== Date: Sun, 31 Dec 2023 16:25:21 +9900 Subject: [PATCH 6/9] xfs: reuse xfs_refcount_update_cancel_item From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Message-ID: <170405016700.1816837.13209062353123602860.stgit@frogsfrogsfrogs> In-Reply-To: <170405016616.1816837.2298941345938137266.stgit@frogsfrogsfrogs> References: <170405016616.1816837.2298941345938137266.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 --- libxfs/defer_item.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c index 471e4f6867d..e056c3b449b 100644 --- a/libxfs/defer_item.c +++ b/libxfs/defer_item.c @@ -545,6 +545,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( @@ -565,8 +576,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; } @@ -577,17 +587,6 @@ xfs_refcount_update_abort_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); -} - const struct xfs_defer_op_type xfs_refcount_update_defer_type = { .name = "refcount", .create_intent = xfs_refcount_update_create_intent, From patchwork Wed Dec 27 13:25:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13508338 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 7B9A37ED for ; Mon, 1 Jan 2024 00:25:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iVATvFcD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB17FC433C8; Mon, 1 Jan 2024 00:25:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704068738; bh=ueLlzfXFAadRNJc9jd8/4anPR0BS+wXbDVygxXzMqdE=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=iVATvFcDbYamNA2zBc/ozfTKQXgRzvcqPoscCNFs5kMBRIH575McsT4ZFsfz10xM6 PT5X5y72hTU5rldsu5p2jn7Hwvg31rdgh71B6X1L3Tn2RyD9/dpYEjUB8txYBGNNiy Ag+pc6/Ko2Gg7rtyN3BNn3l/17yHRALYxRdIftu1nBeXExUQ3pjucHFIJtuPtu1un4 UKYjGzImoq5CfcMNVtDu1o2rBZ+JWlHUaProoHbDsTOoIFcsOk/b9lVjytmF7wZLhh hu5Dofu3F9WbS6Rnnw3Ic96F/y+VMrYAZxisL29MTnaAVIXabHc/4gTPPnp5deUORJ Lk07Fd/rBUl1A== Date: Sun, 31 Dec 2023 16:25:37 +9900 Subject: [PATCH 7/9] xfs: don't bother calling xfs_refcount_finish_one_cleanup in xfs_refcount_finish_one From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Message-ID: <170405016714.1816837.16218175860775218003.stgit@frogsfrogsfrogs> In-Reply-To: <170405016616.1816837.2298941345938137266.stgit@frogsfrogsfrogs> References: <170405016616.1816837.2298941345938137266.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 --- libxfs/defer_item.c | 17 +++++++++++++++++ libxfs/xfs_refcount.c | 19 +------------------ libxfs/xfs_refcount.h | 2 -- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c index e056c3b449b..58a18c7876d 100644 --- a/libxfs/defer_item.c +++ b/libxfs/defer_item.c @@ -587,6 +587,23 @@ xfs_refcount_update_abort_intent( { } +/* 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); +} + const struct xfs_defer_op_type xfs_refcount_update_defer_type = { .name = "refcount", .create_intent = xfs_refcount_update_create_intent, diff --git a/libxfs/xfs_refcount.c b/libxfs/xfs_refcount.c index 3ae68ea22e3..635bbf7f99d 100644 --- a/libxfs/xfs_refcount.c +++ b/libxfs/xfs_refcount.c @@ -1299,23 +1299,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. @@ -1379,7 +1362,7 @@ xfs_refcount_finish_one( if (rcur != NULL && rcur->bc_ag.pag != ri->ri_pag) { nr_ops = rcur->bc_ag.refc.nr_ops; shape_changes = rcur->bc_ag.refc.shape_changes; - xfs_refcount_finish_one_cleanup(tp, rcur, 0); + xfs_btree_del_cursor(rcur, 0); rcur = NULL; *pcur = NULL; } diff --git a/libxfs/xfs_refcount.h b/libxfs/xfs_refcount.h index 01a20621192..c94b8f71d40 100644 --- a/libxfs/xfs_refcount.h +++ b/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); From patchwork Wed Dec 27 13:25:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13508339 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 C675A7EF for ; Mon, 1 Jan 2024 00:25:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="q9q1zeaL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 984DCC433C7; Mon, 1 Jan 2024 00:25:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704068753; bh=s+V1zOTwA0bWE3ugeKtBxta3Efg786Qq8zZj/X9MHuQ=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=q9q1zeaLh1yYaVLwzzFf8Gt7fETjDBqCsb5qKwHeNdj4RmNISZA9qutfKl41vpd/5 JSAOY0ATo0gBhmR2uyeRWKassS9rlf0dqiepxKxZIG/Slon30gmnZJl9KWxwv1Jf2B I4gHtpMJld85ZlT+ZoGlh/opYOr2U+fKp9VOk0kycrSdB9Fxa4DQMvX0sqzzMi6mIb lq4rqeIy9K1lxdVMszGCQIcQWG52F2uN2gfud7ZlAGlrY09uduZCRmyPd4raAg/u1q oTcaOqPUp8n+hbpzYOVrVPiVCh3xLCuRp5YgngtjPjmooUs739/PFAXKcKpuDmg/H4 JuwNaLuUz5rLQ== Date: Sun, 31 Dec 2023 16:25:53 +9900 Subject: [PATCH 8/9] xfs: simplify usage of the rcur local variable in xfs_refcount_finish_one From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Message-ID: <170405016727.1816837.12198095586835417075.stgit@frogsfrogsfrogs> In-Reply-To: <170405016616.1816837.2298941345938137266.stgit@frogsfrogsfrogs> References: <170405016616.1816837.2298941345938137266.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 --- libxfs/xfs_refcount.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libxfs/xfs_refcount.c b/libxfs/xfs_refcount.c index 635bbf7f99d..5cd279786ce 100644 --- a/libxfs/xfs_refcount.c +++ b/libxfs/xfs_refcount.c @@ -1340,7 +1340,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; @@ -1358,7 +1358,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_ag.refc.nr_ops; shape_changes = rcur->bc_ag.refc.shape_changes; @@ -1372,11 +1371,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_ag.refc.nr_ops = nr_ops; rcur->bc_ag.refc.shape_changes = shape_changes; } - *pcur = rcur; switch (ri->ri_type) { case XFS_REFCOUNT_INCREASE: From patchwork Wed Dec 27 13:26:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13508340 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 ACB577ED for ; Mon, 1 Jan 2024 00:26:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OAJ5OKOO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F8B5C433C8; Mon, 1 Jan 2024 00:26:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704068769; bh=QTXkFIV6YeknR7VVvK78oK0icqNo6XsZudBsO8I8ip0=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=OAJ5OKOOnKrSiBK753WFP2Q7fTKIqCcukW4NTkJKAWXTLtiXDlKRWOHLnq/axPOvy geVTa+7sP2/oK4jlwKuP1GGEWB8ppOtLmHQK8qtxA1fM5PP4krbJSCghonm9VhRUc0 9kAtr6nGAB295Gse8MAgrkHGM3Z4YGbapA8fUmVeTKeXZbVrfEnIHIiintyBzTAA+g 7xwpdkGFE7FId/iHHri/00vpeITSf6zklL48g+Pw+CPyIBL8fQbxywVfoTPofXcaaN jI/MxxgwGTjf6pH9TNg5LOVTuDcqK9f7YYTTygs7sk+CkMiMxnO1NrgC9yGA8cIuAQ I0+LMGQ3NukkQ== Date: Sun, 31 Dec 2023 16:26:08 +9900 Subject: [PATCH 9/9] xfs: move xfs_refcount_update_defer_add to xfs_refcount_item.c From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Message-ID: <170405016740.1816837.892103686003326408.stgit@frogsfrogsfrogs> In-Reply-To: <170405016616.1816837.2298941345938137266.stgit@frogsfrogsfrogs> References: <170405016616.1816837.2298941345938137266.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 --- libxfs/defer_item.c | 21 +++++++++------------ libxfs/defer_item.h | 5 +++++ libxfs/xfs_refcount.c | 6 ++---- libxfs/xfs_refcount.h | 3 --- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c index 58a18c7876d..3956a38b414 100644 --- a/libxfs/defer_item.c +++ b/libxfs/defer_item.c @@ -528,21 +528,18 @@ xfs_refcount_update_create_done( return NULL; } -/* Take an active 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 an active 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. */ @@ -552,7 +549,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); } diff --git a/libxfs/defer_item.h b/libxfs/defer_item.h index 3ef31ad0aec..bbb4587b97f 100644 --- a/libxfs/defer_item.h +++ b/libxfs/defer_item.h @@ -24,4 +24,9 @@ struct xfs_rmap_intent; void xfs_rmap_defer_add(struct xfs_trans *tp, struct xfs_rmap_intent *ri); +struct xfs_refcount_intent; + +void xfs_refcount_defer_add(struct xfs_trans *tp, + struct xfs_refcount_intent *ri); + #endif /* __LIBXFS_DEFER_ITEM_H_ */ diff --git a/libxfs/xfs_refcount.c b/libxfs/xfs_refcount.c index 5cd279786ce..b094d9a41f6 100644 --- a/libxfs/xfs_refcount.c +++ b/libxfs/xfs_refcount.c @@ -23,6 +23,7 @@ #include "xfs_rmap.h" #include "xfs_ag.h" #include "xfs_health.h" +#include "defer_item.h" struct kmem_cache *xfs_refcount_intent_cache; @@ -1434,10 +1435,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/libxfs/xfs_refcount.h b/libxfs/xfs_refcount.h index c94b8f71d40..68acb0b1b4a 100644 --- a/libxfs/xfs_refcount.h +++ b/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,