From patchwork Wed Dec 27 13:08:25 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: 13508272 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 C9034384 for ; Mon, 1 Jan 2024 00:08:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="u44ayiPD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 519BBC433C8; Mon, 1 Jan 2024 00:08:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704067706; bh=pEvOO33gUEhbQq7rSpMI+jyAam78/ZFSg/l5+FXG9fs=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=u44ayiPD7ia5BKUa1kaFj3oCpPNj/U0JTft1PnpV3+qs/UV6x3u4ayTT6HFvEvdY4 d5C1+Z9NsUn2DoOvI/RbG+cQWBfP/ISJhUv3Nd9wrWv7YhXXpF4tGqcWbTeeyguVxC YnrhM6D3Qxce4JcsUzQAmB01yd1r1/qYLmGcgolLT+/0+XB+TxCSgZ4BGh42ADRjVs wPPKZJi/nXxJ/PMQFBLQyB4uDCRLZAj9N8ZsQ0gJKu0IflO5QjULNI1gi0WQ6n96z4 +wGXQYAgTDZbAiDBBK4NJk0t3Ycvqeyqn5eVKWYx6IOu8keqCfLF3VXbb/5BI7LvUe P4oLPwvFyXZWQ== Date: Sun, 31 Dec 2023 16:08:25 +9900 Subject: [PATCH 1/9] xfs: attach rtgroup objects to btree cursors From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Message-ID: <170405014833.1815232.13061250777423956598.stgit@frogsfrogsfrogs> In-Reply-To: <170405014813.1815232.16195473149230327174.stgit@frogsfrogsfrogs> References: <170405014813.1815232.16195473149230327174.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 Make it so that we can attach realtime group objects to btree cursors. This will be crucial for enabling rmap btrees in realtime groups. Signed-off-by: Darrick J. Wong --- libxfs/xfs_btree.c | 4 ++++ libxfs/xfs_btree.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c index 165ce251376..e0276ad655a 100644 --- a/libxfs/xfs_btree.c +++ b/libxfs/xfs_btree.c @@ -28,6 +28,7 @@ #include "xfile.h" #include "xfbtree.h" #include "xfs_btree_mem.h" +#include "xfs_rtgroup.h" /* * Btree magic numbers. @@ -473,6 +474,9 @@ xfs_btree_del_cursor( xfs_is_shutdown(cur->bc_mp) || error != 0); if (unlikely(cur->bc_flags & XFS_BTREE_STAGING)) kmem_free(cur->bc_ops); + if ((cur->bc_flags & XFS_BTREE_ROOT_IN_INODE) && + !(cur->bc_flags & XFS_BTREE_IN_XFILE) && cur->bc_ino.rtg) + xfs_rtgroup_put(cur->bc_ino.rtg); if (!(cur->bc_flags & XFS_BTREE_LONG_PTRS) && !(cur->bc_flags & XFS_BTREE_IN_XFILE) && cur->bc_ag.pag) xfs_perag_put(cur->bc_ag.pag); diff --git a/libxfs/xfs_btree.h b/libxfs/xfs_btree.h index bb6c2feecea..ce0bc5dfffe 100644 --- a/libxfs/xfs_btree.h +++ b/libxfs/xfs_btree.h @@ -12,6 +12,7 @@ struct xfs_mount; struct xfs_trans; struct xfs_ifork; struct xfs_perag; +struct xfs_rtgroup; /* * Generic key, ptr and record wrapper structures. @@ -247,6 +248,7 @@ struct xfs_btree_cur_ag { /* Btree-in-inode cursor information */ struct xfs_btree_cur_ino { struct xfs_inode *ip; + struct xfs_rtgroup *rtg; /* if realtime metadata */ struct xbtree_ifakeroot *ifake; /* for staging cursor */ int allocated; short forksize; From patchwork Wed Dec 27 13:08:41 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: 13508273 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 1BC94384 for ; Mon, 1 Jan 2024 00:08:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LuCk1eOQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E250DC433C7; Mon, 1 Jan 2024 00:08:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704067721; bh=hbWr5nmOcsQyTlDi48Ic5uQDAZo4kfazEIl9D1cPvaI=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=LuCk1eOQMHw7p/3FWpAa/knohflwn4m+Fwo5bKBkFENucOO1LztC3hj7W+gM0WM/F Q+WAXTg524Rqdi70qnXBtGvaC3ELuoaeuU9TMnqe4rnqSracYe6TjdQvri0knaWy1a CmaYjlJy45EVj7ZEPEc/PS/LImAfWcxptUjh3QEL2Qx0MQU2Coz3WnFk5+Ma1gciCl ujd4c+R09OcP/i8zO9WJnbOPFgiKfYRxchRxR14a50uyZdT4CKj0gJ8Xyxq5VumBnT LkRH2kXVvENIe/9E7Yxuo/QyASQL2RkE/vV2Tyv5UFw4Yl9M6CXtENj4DiP0cWGuch 30mPWSR3f9i/g== Date: Sun, 31 Dec 2023 16:08:41 +9900 Subject: [PATCH 2/9] xfs: give rmap 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: <170405014846.1815232.15906808276779223619.stgit@frogsfrogsfrogs> In-Reply-To: <170405014813.1815232.16195473149230327174.stgit@frogsfrogsfrogs> References: <170405014813.1815232.16195473149230327174.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 Create a new tracepoint class for btree-related errors, then convert all the rmap tracepoints to use it. Also fix the one tracepoint that was abusing the old class by making it a separate tracepoint. Signed-off-by: Darrick J. Wong --- libxfs/xfs_rmap.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/libxfs/xfs_rmap.c b/libxfs/xfs_rmap.c index 8df591840dc..5b2cac8302a 100644 --- a/libxfs/xfs_rmap.c +++ b/libxfs/xfs_rmap.c @@ -110,8 +110,7 @@ xfs_rmap_update( xfs_rmap_irec_offset_pack(irec)); error = xfs_btree_update(cur, &rec); if (error) - trace_xfs_rmap_update_error(cur->bc_mp, - cur->bc_ag.pag->pag_agno, error, _RET_IP_); + trace_xfs_rmap_update_error(cur, error, _RET_IP_); return error; } @@ -154,8 +153,7 @@ xfs_rmap_insert( } done: if (error) - trace_xfs_rmap_insert_error(rcur->bc_mp, - rcur->bc_ag.pag->pag_agno, error, _RET_IP_); + trace_xfs_rmap_insert_error(rcur, error, _RET_IP_); return error; } @@ -193,8 +191,7 @@ xfs_rmap_delete( } done: if (error) - trace_xfs_rmap_delete_error(rcur->bc_mp, - rcur->bc_ag.pag->pag_agno, error, _RET_IP_); + trace_xfs_rmap_delete_error(rcur, error, _RET_IP_); return error; } @@ -815,8 +812,7 @@ xfs_rmap_unmap( unwritten, oinfo); out_error: if (error) - trace_xfs_rmap_unmap_error(mp, cur->bc_ag.pag->pag_agno, - error, _RET_IP_); + trace_xfs_rmap_unmap_error(cur, error, _RET_IP_); return error; } @@ -1138,8 +1134,7 @@ xfs_rmap_map( unwritten, oinfo); out_error: if (error) - trace_xfs_rmap_map_error(mp, cur->bc_ag.pag->pag_agno, - error, _RET_IP_); + trace_xfs_rmap_map_error(cur, error, _RET_IP_); return error; } @@ -1334,8 +1329,7 @@ xfs_rmap_convert( RIGHT.rm_blockcount > XFS_RMAP_LEN_MAX) state &= ~RMAP_RIGHT_CONTIG; - trace_xfs_rmap_convert_state(mp, cur->bc_ag.pag->pag_agno, state, - _RET_IP_); + trace_xfs_rmap_convert_state(cur, state, _RET_IP_); /* reset the cursor back to PREV */ error = xfs_rmap_lookup_le(cur, bno, owner, offset, oldext, NULL, &i); @@ -1688,8 +1682,7 @@ xfs_rmap_convert( unwritten, oinfo); done: if (error) - trace_xfs_rmap_convert_error(cur->bc_mp, - cur->bc_ag.pag->pag_agno, error, _RET_IP_); + trace_xfs_rmap_convert_error(cur, error, _RET_IP_); return error; } @@ -1812,8 +1805,7 @@ xfs_rmap_convert_shared( RIGHT.rm_blockcount > XFS_RMAP_LEN_MAX) state &= ~RMAP_RIGHT_CONTIG; - trace_xfs_rmap_convert_state(mp, cur->bc_ag.pag->pag_agno, state, - _RET_IP_); + trace_xfs_rmap_convert_state(cur, state, _RET_IP_); /* * Switch out based on the FILLING and CONTIG state bits. */ @@ -2115,8 +2107,7 @@ xfs_rmap_convert_shared( unwritten, oinfo); done: if (error) - trace_xfs_rmap_convert_error(cur->bc_mp, - cur->bc_ag.pag->pag_agno, error, _RET_IP_); + trace_xfs_rmap_convert_error(cur, error, _RET_IP_); return error; } @@ -2315,8 +2306,7 @@ xfs_rmap_unmap_shared( unwritten, oinfo); out_error: if (error) - trace_xfs_rmap_unmap_error(cur->bc_mp, - cur->bc_ag.pag->pag_agno, error, _RET_IP_); + trace_xfs_rmap_unmap_error(cur, error, _RET_IP_); return error; } @@ -2476,8 +2466,7 @@ xfs_rmap_map_shared( unwritten, oinfo); out_error: if (error) - trace_xfs_rmap_map_error(cur->bc_mp, - cur->bc_ag.pag->pag_agno, error, _RET_IP_); + trace_xfs_rmap_map_error(cur, error, _RET_IP_); return error; } From patchwork Wed Dec 27 13:08:57 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: 13508274 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 C78B338B for ; Mon, 1 Jan 2024 00:08:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gP0D6Adc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 922C9C433C7; Mon, 1 Jan 2024 00:08:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704067737; bh=s0csPSDHns2QxgiqM4VvcRJe4lF4KfowfcxCt6ehpak=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=gP0D6Adcl6UGA+UOVKQqz5dQF6sHoyM9HKmqMdZ7ka425H8/qdtQovb2aAuFlO4uI KsN+GIAiXcggPgTYPtKwJ43kdOezzkIcoIMGTz1OGuZ/6kbqw9chN+nTROzHyzo0xX AncVZvargDsfSbOgyyOTRElC4XV5bzJho9RwYbw/uSpyG8IWg5Vzxh7RnIyBMyma1C Bi6eNT0gVcqjfg8PHNocXccOdDPxfggkjxlm/FvttHvR/yqdV8QxfZEj4u01dCxGcX dXpP+TWY/pup4VTXZQ4ycQ65c4autLJU0abWDwKYJIujZ13OJoFj/vYMRiHes0dYG1 FgWKjBxAvZ1Wg== Date: Sun, 31 Dec 2023 16:08:57 +9900 Subject: [PATCH 3/9] xfs: prepare rmap btree tracepoints for widening From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Message-ID: <170405014858.1815232.5660442449836109892.stgit@frogsfrogsfrogs> In-Reply-To: <170405014813.1815232.16195473149230327174.stgit@frogsfrogsfrogs> References: <170405014813.1815232.16195473149230327174.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 rmap btree tracepoints for use with realtime rmap btrees by making them take the btree cursor object as a parameter. This will save us a lot of trouble later on. Signed-off-by: Darrick J. Wong --- libxfs/xfs_rmap.c | 184 +++++++++++++++++++++-------------------------------- 1 file changed, 73 insertions(+), 111 deletions(-) diff --git a/libxfs/xfs_rmap.c b/libxfs/xfs_rmap.c index 5b2cac8302a..3c4f705ce59 100644 --- a/libxfs/xfs_rmap.c +++ b/libxfs/xfs_rmap.c @@ -99,8 +99,7 @@ xfs_rmap_update( union xfs_btree_rec rec; int error; - trace_xfs_rmap_update(cur->bc_mp, cur->bc_ag.pag->pag_agno, - irec->rm_startblock, irec->rm_blockcount, + trace_xfs_rmap_update(cur, irec->rm_startblock, irec->rm_blockcount, irec->rm_owner, irec->rm_offset, irec->rm_flags); rec.rmap.rm_startblock = cpu_to_be32(irec->rm_startblock); @@ -126,8 +125,7 @@ xfs_rmap_insert( int i; int error; - trace_xfs_rmap_insert(rcur->bc_mp, rcur->bc_ag.pag->pag_agno, agbno, - len, owner, offset, flags); + trace_xfs_rmap_insert(rcur, agbno, len, owner, offset, flags); error = xfs_rmap_lookup_eq(rcur, agbno, len, owner, offset, flags, &i); if (error) @@ -169,8 +167,7 @@ xfs_rmap_delete( int i; int error; - trace_xfs_rmap_delete(rcur->bc_mp, rcur->bc_ag.pag->pag_agno, agbno, - len, owner, offset, flags); + trace_xfs_rmap_delete(rcur, agbno, len, owner, offset, flags); error = xfs_rmap_lookup_eq(rcur, agbno, len, owner, offset, flags, &i); if (error) @@ -338,8 +335,7 @@ xfs_rmap_find_left_neighbor_helper( { struct xfs_find_left_neighbor_info *info = priv; - trace_xfs_rmap_find_left_neighbor_candidate(cur->bc_mp, - cur->bc_ag.pag->pag_agno, rec->rm_startblock, + trace_xfs_rmap_find_left_neighbor_candidate(cur, rec->rm_startblock, rec->rm_blockcount, rec->rm_owner, rec->rm_offset, rec->rm_flags); @@ -389,8 +385,8 @@ xfs_rmap_find_left_neighbor( info.high.rm_blockcount = 0; info.irec = irec; - trace_xfs_rmap_find_left_neighbor_query(cur->bc_mp, - cur->bc_ag.pag->pag_agno, bno, 0, owner, offset, flags); + trace_xfs_rmap_find_left_neighbor_query(cur, bno, 0, owner, offset, + flags); /* * Historically, we always used the range query to walk every reverse @@ -421,8 +417,7 @@ xfs_rmap_find_left_neighbor( return error; *stat = 1; - trace_xfs_rmap_find_left_neighbor_result(cur->bc_mp, - cur->bc_ag.pag->pag_agno, irec->rm_startblock, + trace_xfs_rmap_find_left_neighbor_result(cur, irec->rm_startblock, irec->rm_blockcount, irec->rm_owner, irec->rm_offset, irec->rm_flags); return 0; @@ -437,8 +432,7 @@ xfs_rmap_lookup_le_range_helper( { struct xfs_find_left_neighbor_info *info = priv; - trace_xfs_rmap_lookup_le_range_candidate(cur->bc_mp, - cur->bc_ag.pag->pag_agno, rec->rm_startblock, + trace_xfs_rmap_lookup_le_range_candidate(cur, rec->rm_startblock, rec->rm_blockcount, rec->rm_owner, rec->rm_offset, rec->rm_flags); @@ -485,8 +479,7 @@ xfs_rmap_lookup_le_range( *stat = 0; info.irec = irec; - trace_xfs_rmap_lookup_le_range(cur->bc_mp, cur->bc_ag.pag->pag_agno, - bno, 0, owner, offset, flags); + trace_xfs_rmap_lookup_le_range(cur, bno, 0, owner, offset, flags); /* * Historically, we always used the range query to walk every reverse @@ -517,8 +510,7 @@ xfs_rmap_lookup_le_range( return error; *stat = 1; - trace_xfs_rmap_lookup_le_range_result(cur->bc_mp, - cur->bc_ag.pag->pag_agno, irec->rm_startblock, + trace_xfs_rmap_lookup_le_range_result(cur, irec->rm_startblock, irec->rm_blockcount, irec->rm_owner, irec->rm_offset, irec->rm_flags); return 0; @@ -630,8 +622,7 @@ xfs_rmap_unmap( (flags & XFS_RMAP_BMBT_BLOCK); if (unwritten) flags |= XFS_RMAP_UNWRITTEN; - trace_xfs_rmap_unmap(mp, cur->bc_ag.pag->pag_agno, bno, len, - unwritten, oinfo); + trace_xfs_rmap_unmap(cur, bno, len, unwritten, oinfo); /* * We should always have a left record because there's a static record @@ -647,10 +638,9 @@ xfs_rmap_unmap( goto out_error; } - trace_xfs_rmap_lookup_le_range_result(cur->bc_mp, - cur->bc_ag.pag->pag_agno, ltrec.rm_startblock, - ltrec.rm_blockcount, ltrec.rm_owner, - ltrec.rm_offset, ltrec.rm_flags); + trace_xfs_rmap_lookup_le_range_result(cur, ltrec.rm_startblock, + ltrec.rm_blockcount, ltrec.rm_owner, ltrec.rm_offset, + ltrec.rm_flags); ltoff = ltrec.rm_offset; /* @@ -717,10 +707,9 @@ xfs_rmap_unmap( if (ltrec.rm_startblock == bno && ltrec.rm_blockcount == len) { /* exact match, simply remove the record from rmap tree */ - trace_xfs_rmap_delete(mp, cur->bc_ag.pag->pag_agno, - ltrec.rm_startblock, ltrec.rm_blockcount, - ltrec.rm_owner, ltrec.rm_offset, - ltrec.rm_flags); + trace_xfs_rmap_delete(cur, ltrec.rm_startblock, + ltrec.rm_blockcount, ltrec.rm_owner, + ltrec.rm_offset, ltrec.rm_flags); error = xfs_btree_delete(cur, &i); if (error) goto out_error; @@ -796,8 +785,7 @@ xfs_rmap_unmap( else cur->bc_rec.r.rm_offset = offset + len; cur->bc_rec.r.rm_flags = flags; - trace_xfs_rmap_insert(mp, cur->bc_ag.pag->pag_agno, - cur->bc_rec.r.rm_startblock, + trace_xfs_rmap_insert(cur, cur->bc_rec.r.rm_startblock, cur->bc_rec.r.rm_blockcount, cur->bc_rec.r.rm_owner, cur->bc_rec.r.rm_offset, @@ -808,8 +796,7 @@ xfs_rmap_unmap( } out_done: - trace_xfs_rmap_unmap_done(mp, cur->bc_ag.pag->pag_agno, bno, len, - unwritten, oinfo); + trace_xfs_rmap_unmap_done(cur, bno, len, unwritten, oinfo); out_error: if (error) trace_xfs_rmap_unmap_error(cur, error, _RET_IP_); @@ -973,8 +960,7 @@ xfs_rmap_map( (flags & XFS_RMAP_BMBT_BLOCK); if (unwritten) flags |= XFS_RMAP_UNWRITTEN; - trace_xfs_rmap_map(mp, cur->bc_ag.pag->pag_agno, bno, len, - unwritten, oinfo); + trace_xfs_rmap_map(cur, bno, len, unwritten, oinfo); ASSERT(!xfs_rmap_should_skip_owner_update(oinfo)); /* @@ -987,8 +973,7 @@ xfs_rmap_map( if (error) goto out_error; if (have_lt) { - trace_xfs_rmap_lookup_le_range_result(cur->bc_mp, - cur->bc_ag.pag->pag_agno, ltrec.rm_startblock, + trace_xfs_rmap_lookup_le_range_result(cur, ltrec.rm_startblock, ltrec.rm_blockcount, ltrec.rm_owner, ltrec.rm_offset, ltrec.rm_flags); @@ -1026,10 +1011,10 @@ xfs_rmap_map( error = -EFSCORRUPTED; goto out_error; } - trace_xfs_rmap_find_right_neighbor_result(cur->bc_mp, - cur->bc_ag.pag->pag_agno, gtrec.rm_startblock, - gtrec.rm_blockcount, gtrec.rm_owner, - gtrec.rm_offset, gtrec.rm_flags); + trace_xfs_rmap_find_right_neighbor_result(cur, + gtrec.rm_startblock, gtrec.rm_blockcount, + gtrec.rm_owner, gtrec.rm_offset, + gtrec.rm_flags); if (!xfs_rmap_is_mergeable(>rec, owner, flags)) have_gt = 0; } @@ -1066,12 +1051,9 @@ xfs_rmap_map( * result: |rrrrrrrrrrrrrrrrrrrrrrrrrrrrr| */ ltrec.rm_blockcount += gtrec.rm_blockcount; - trace_xfs_rmap_delete(mp, cur->bc_ag.pag->pag_agno, - gtrec.rm_startblock, - gtrec.rm_blockcount, - gtrec.rm_owner, - gtrec.rm_offset, - gtrec.rm_flags); + trace_xfs_rmap_delete(cur, gtrec.rm_startblock, + gtrec.rm_blockcount, gtrec.rm_owner, + gtrec.rm_offset, gtrec.rm_flags); error = xfs_btree_delete(cur, &i); if (error) goto out_error; @@ -1118,8 +1100,7 @@ xfs_rmap_map( cur->bc_rec.r.rm_owner = owner; cur->bc_rec.r.rm_offset = offset; cur->bc_rec.r.rm_flags = flags; - trace_xfs_rmap_insert(mp, cur->bc_ag.pag->pag_agno, bno, len, - owner, offset, flags); + trace_xfs_rmap_insert(cur, bno, len, owner, offset, flags); error = xfs_btree_insert(cur, &i); if (error) goto out_error; @@ -1130,8 +1111,7 @@ xfs_rmap_map( } } - trace_xfs_rmap_map_done(mp, cur->bc_ag.pag->pag_agno, bno, len, - unwritten, oinfo); + trace_xfs_rmap_map_done(cur, bno, len, unwritten, oinfo); out_error: if (error) trace_xfs_rmap_map_error(cur, error, _RET_IP_); @@ -1208,8 +1188,7 @@ xfs_rmap_convert( (flags & (XFS_RMAP_ATTR_FORK | XFS_RMAP_BMBT_BLOCK)))); oldext = unwritten ? XFS_RMAP_UNWRITTEN : 0; new_endoff = offset + len; - trace_xfs_rmap_convert(mp, cur->bc_ag.pag->pag_agno, bno, len, - unwritten, oinfo); + trace_xfs_rmap_convert(cur, bno, len, unwritten, oinfo); /* * For the initial lookup, look for an exact match or the left-adjacent @@ -1225,10 +1204,9 @@ xfs_rmap_convert( goto done; } - trace_xfs_rmap_lookup_le_range_result(cur->bc_mp, - cur->bc_ag.pag->pag_agno, PREV.rm_startblock, - PREV.rm_blockcount, PREV.rm_owner, - PREV.rm_offset, PREV.rm_flags); + trace_xfs_rmap_lookup_le_range_result(cur, PREV.rm_startblock, + PREV.rm_blockcount, PREV.rm_owner, PREV.rm_offset, + PREV.rm_flags); ASSERT(PREV.rm_offset <= offset); ASSERT(PREV.rm_offset + PREV.rm_blockcount >= new_endoff); @@ -1269,10 +1247,9 @@ xfs_rmap_convert( error = -EFSCORRUPTED; goto done; } - trace_xfs_rmap_find_left_neighbor_result(cur->bc_mp, - cur->bc_ag.pag->pag_agno, LEFT.rm_startblock, - LEFT.rm_blockcount, LEFT.rm_owner, - LEFT.rm_offset, LEFT.rm_flags); + trace_xfs_rmap_find_left_neighbor_result(cur, + LEFT.rm_startblock, LEFT.rm_blockcount, + LEFT.rm_owner, LEFT.rm_offset, LEFT.rm_flags); if (LEFT.rm_startblock + LEFT.rm_blockcount == bno && LEFT.rm_offset + LEFT.rm_blockcount == offset && xfs_rmap_is_mergeable(&LEFT, owner, newext)) @@ -1310,10 +1287,10 @@ xfs_rmap_convert( error = -EFSCORRUPTED; goto done; } - trace_xfs_rmap_find_right_neighbor_result(cur->bc_mp, - cur->bc_ag.pag->pag_agno, RIGHT.rm_startblock, - RIGHT.rm_blockcount, RIGHT.rm_owner, - RIGHT.rm_offset, RIGHT.rm_flags); + trace_xfs_rmap_find_right_neighbor_result(cur, + RIGHT.rm_startblock, RIGHT.rm_blockcount, + RIGHT.rm_owner, RIGHT.rm_offset, + RIGHT.rm_flags); if (bno + len == RIGHT.rm_startblock && offset + len == RIGHT.rm_offset && xfs_rmap_is_mergeable(&RIGHT, owner, newext)) @@ -1360,10 +1337,9 @@ xfs_rmap_convert( error = -EFSCORRUPTED; goto done; } - trace_xfs_rmap_delete(mp, cur->bc_ag.pag->pag_agno, - RIGHT.rm_startblock, RIGHT.rm_blockcount, - RIGHT.rm_owner, RIGHT.rm_offset, - RIGHT.rm_flags); + trace_xfs_rmap_delete(cur, RIGHT.rm_startblock, + RIGHT.rm_blockcount, RIGHT.rm_owner, + RIGHT.rm_offset, RIGHT.rm_flags); error = xfs_btree_delete(cur, &i); if (error) goto done; @@ -1380,10 +1356,9 @@ xfs_rmap_convert( error = -EFSCORRUPTED; goto done; } - trace_xfs_rmap_delete(mp, cur->bc_ag.pag->pag_agno, - PREV.rm_startblock, PREV.rm_blockcount, - PREV.rm_owner, PREV.rm_offset, - PREV.rm_flags); + trace_xfs_rmap_delete(cur, PREV.rm_startblock, + PREV.rm_blockcount, PREV.rm_owner, + PREV.rm_offset, PREV.rm_flags); error = xfs_btree_delete(cur, &i); if (error) goto done; @@ -1412,10 +1387,9 @@ xfs_rmap_convert( * Setting all of a previous oldext extent to newext. * The left neighbor is contiguous, the right is not. */ - trace_xfs_rmap_delete(mp, cur->bc_ag.pag->pag_agno, - PREV.rm_startblock, PREV.rm_blockcount, - PREV.rm_owner, PREV.rm_offset, - PREV.rm_flags); + trace_xfs_rmap_delete(cur, PREV.rm_startblock, + PREV.rm_blockcount, PREV.rm_owner, + PREV.rm_offset, PREV.rm_flags); error = xfs_btree_delete(cur, &i); if (error) goto done; @@ -1452,10 +1426,9 @@ xfs_rmap_convert( error = -EFSCORRUPTED; goto done; } - trace_xfs_rmap_delete(mp, cur->bc_ag.pag->pag_agno, - RIGHT.rm_startblock, RIGHT.rm_blockcount, - RIGHT.rm_owner, RIGHT.rm_offset, - RIGHT.rm_flags); + trace_xfs_rmap_delete(cur, RIGHT.rm_startblock, + RIGHT.rm_blockcount, RIGHT.rm_owner, + RIGHT.rm_offset, RIGHT.rm_flags); error = xfs_btree_delete(cur, &i); if (error) goto done; @@ -1533,8 +1506,7 @@ xfs_rmap_convert( NEW.rm_blockcount = len; NEW.rm_flags = newext; cur->bc_rec.r = NEW; - trace_xfs_rmap_insert(mp, cur->bc_ag.pag->pag_agno, bno, - len, owner, offset, newext); + trace_xfs_rmap_insert(cur, bno, len, owner, offset, newext); error = xfs_btree_insert(cur, &i); if (error) goto done; @@ -1592,8 +1564,7 @@ xfs_rmap_convert( NEW.rm_blockcount = len; NEW.rm_flags = newext; cur->bc_rec.r = NEW; - trace_xfs_rmap_insert(mp, cur->bc_ag.pag->pag_agno, bno, - len, owner, offset, newext); + trace_xfs_rmap_insert(cur, bno, len, owner, offset, newext); error = xfs_btree_insert(cur, &i); if (error) goto done; @@ -1624,9 +1595,8 @@ xfs_rmap_convert( NEW = PREV; NEW.rm_blockcount = offset - PREV.rm_offset; cur->bc_rec.r = NEW; - trace_xfs_rmap_insert(mp, cur->bc_ag.pag->pag_agno, - NEW.rm_startblock, NEW.rm_blockcount, - NEW.rm_owner, NEW.rm_offset, + trace_xfs_rmap_insert(cur, NEW.rm_startblock, + NEW.rm_blockcount, NEW.rm_owner, NEW.rm_offset, NEW.rm_flags); error = xfs_btree_insert(cur, &i); if (error) @@ -1653,8 +1623,7 @@ xfs_rmap_convert( /* new middle extent - newext */ cur->bc_rec.r.rm_flags &= ~XFS_RMAP_UNWRITTEN; cur->bc_rec.r.rm_flags |= newext; - trace_xfs_rmap_insert(mp, cur->bc_ag.pag->pag_agno, bno, len, - owner, offset, newext); + trace_xfs_rmap_insert(cur, bno, len, owner, offset, newext); error = xfs_btree_insert(cur, &i); if (error) goto done; @@ -1678,8 +1647,7 @@ xfs_rmap_convert( ASSERT(0); } - trace_xfs_rmap_convert_done(mp, cur->bc_ag.pag->pag_agno, bno, len, - unwritten, oinfo); + trace_xfs_rmap_convert_done(cur, bno, len, unwritten, oinfo); done: if (error) trace_xfs_rmap_convert_error(cur, error, _RET_IP_); @@ -1718,8 +1686,7 @@ xfs_rmap_convert_shared( (flags & (XFS_RMAP_ATTR_FORK | XFS_RMAP_BMBT_BLOCK)))); oldext = unwritten ? XFS_RMAP_UNWRITTEN : 0; new_endoff = offset + len; - trace_xfs_rmap_convert(mp, cur->bc_ag.pag->pag_agno, bno, len, - unwritten, oinfo); + trace_xfs_rmap_convert(cur, bno, len, unwritten, oinfo); /* * For the initial lookup, look for and exact match or the left-adjacent @@ -1788,10 +1755,10 @@ xfs_rmap_convert_shared( error = -EFSCORRUPTED; goto done; } - trace_xfs_rmap_find_right_neighbor_result(cur->bc_mp, - cur->bc_ag.pag->pag_agno, RIGHT.rm_startblock, - RIGHT.rm_blockcount, RIGHT.rm_owner, - RIGHT.rm_offset, RIGHT.rm_flags); + trace_xfs_rmap_find_right_neighbor_result(cur, + RIGHT.rm_startblock, RIGHT.rm_blockcount, + RIGHT.rm_owner, RIGHT.rm_offset, + RIGHT.rm_flags); if (xfs_rmap_is_mergeable(&RIGHT, owner, newext)) state |= RMAP_RIGHT_CONTIG; } @@ -2103,8 +2070,7 @@ xfs_rmap_convert_shared( ASSERT(0); } - trace_xfs_rmap_convert_done(mp, cur->bc_ag.pag->pag_agno, bno, len, - unwritten, oinfo); + trace_xfs_rmap_convert_done(cur, bno, len, unwritten, oinfo); done: if (error) trace_xfs_rmap_convert_error(cur, error, _RET_IP_); @@ -2145,8 +2111,7 @@ xfs_rmap_unmap_shared( xfs_owner_info_unpack(oinfo, &owner, &offset, &flags); if (unwritten) flags |= XFS_RMAP_UNWRITTEN; - trace_xfs_rmap_unmap(mp, cur->bc_ag.pag->pag_agno, bno, len, - unwritten, oinfo); + trace_xfs_rmap_unmap(cur, bno, len, unwritten, oinfo); /* * We should always have a left record because there's a static record @@ -2302,8 +2267,7 @@ xfs_rmap_unmap_shared( goto out_error; } - trace_xfs_rmap_unmap_done(mp, cur->bc_ag.pag->pag_agno, bno, len, - unwritten, oinfo); + trace_xfs_rmap_unmap_done(cur, bno, len, unwritten, oinfo); out_error: if (error) trace_xfs_rmap_unmap_error(cur, error, _RET_IP_); @@ -2341,8 +2305,7 @@ xfs_rmap_map_shared( xfs_owner_info_unpack(oinfo, &owner, &offset, &flags); if (unwritten) flags |= XFS_RMAP_UNWRITTEN; - trace_xfs_rmap_map(mp, cur->bc_ag.pag->pag_agno, bno, len, - unwritten, oinfo); + trace_xfs_rmap_map(cur, bno, len, unwritten, oinfo); /* Is there a left record that abuts our range? */ error = xfs_rmap_find_left_neighbor(cur, bno, owner, offset, flags, @@ -2367,10 +2330,10 @@ xfs_rmap_map_shared( error = -EFSCORRUPTED; goto out_error; } - trace_xfs_rmap_find_right_neighbor_result(cur->bc_mp, - cur->bc_ag.pag->pag_agno, gtrec.rm_startblock, - gtrec.rm_blockcount, gtrec.rm_owner, - gtrec.rm_offset, gtrec.rm_flags); + trace_xfs_rmap_find_right_neighbor_result(cur, + gtrec.rm_startblock, gtrec.rm_blockcount, + gtrec.rm_owner, gtrec.rm_offset, + gtrec.rm_flags); if (!xfs_rmap_is_mergeable(>rec, owner, flags)) have_gt = 0; @@ -2462,8 +2425,7 @@ xfs_rmap_map_shared( goto out_error; } - trace_xfs_rmap_map_done(mp, cur->bc_ag.pag->pag_agno, bno, len, - unwritten, oinfo); + trace_xfs_rmap_map_done(cur, bno, len, unwritten, oinfo); out_error: if (error) trace_xfs_rmap_map_error(cur, error, _RET_IP_); From patchwork Wed Dec 27 13:09:12 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: 13508275 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 D4CCB389 for ; Mon, 1 Jan 2024 00:09:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PgfLcGBO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 443E1C433C7; Mon, 1 Jan 2024 00:09:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704067753; bh=GMAfoMqimiJscvoLR7CQenzGGKvZk40u/pbYj/MfZII=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=PgfLcGBObOiW+oJkhiTlJGj8XMS3CkaCscHP5ftDsaomEa04/4nV7GFtBhSwW6IxJ 9scJ41SPZiM4M8l8ytHJ2vcxL4SB5/l6S1LbXgyyGD1mksuUDlc4vomnRV0yMRiJ+Q 1WqejpTnbs0BQXucEG38/5lzEB/aeVQ87gjBxR6ROb9QzNcWQucb22a2/jj3u0Sm6H 1GcTG/3K32gZusD2ro3QEmnLJ4h2didsnn13OpwlTaVzSyYaH+MCznDVCFMLEarjvm OH9jCp1AThX/01OcMahy3PxMvqKgMpDvpB5UBav7YcTSK6XGDmZpraaki8+RqdWjSN BlUYMGe7aApjg== Date: Sun, 31 Dec 2023 16:09:12 +9900 Subject: [PATCH 4/9] xfs: clean up rmap log intent item tracepoint callsites From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Message-ID: <170405014871.1815232.17265076679281352849.stgit@frogsfrogsfrogs> In-Reply-To: <170405014813.1815232.16195473149230327174.stgit@frogsfrogsfrogs> References: <170405014813.1815232.16195473149230327174.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 rmap structure to the tracepoints instead of open-coding the argument passing. Signed-off-by: Darrick J. Wong --- libxfs/xfs_rmap.c | 22 +++++----------------- libxfs/xfs_rmap.h | 10 ++++++++++ 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/libxfs/xfs_rmap.c b/libxfs/xfs_rmap.c index 3c4f705ce59..3c00b05d8d0 100644 --- a/libxfs/xfs_rmap.c +++ b/libxfs/xfs_rmap.c @@ -2575,20 +2575,15 @@ xfs_rmap_finish_one( struct xfs_rmap_intent *ri, struct xfs_btree_cur **pcur) { + struct xfs_owner_info oinfo; struct xfs_mount *mp = tp->t_mountp; struct xfs_btree_cur *rcur; struct xfs_buf *agbp = NULL; - int error = 0; - struct xfs_owner_info oinfo; xfs_agblock_t bno; bool unwritten; + int error = 0; - bno = XFS_FSB_TO_AGBNO(mp, ri->ri_bmap.br_startblock); - - trace_xfs_rmap_deferred(mp, ri->ri_pag->pag_agno, ri->ri_type, bno, - ri->ri_owner, ri->ri_whichfork, - ri->ri_bmap.br_startoff, ri->ri_bmap.br_blockcount, - ri->ri_bmap.br_state); + trace_xfs_rmap_deferred(mp, ri); if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_RMAP_FINISH_ONE)) return -EIO; @@ -2663,15 +2658,6 @@ __xfs_rmap_add( { struct xfs_rmap_intent *ri; - trace_xfs_rmap_defer(tp->t_mountp, - XFS_FSB_TO_AGNO(tp->t_mountp, bmap->br_startblock), - type, - XFS_FSB_TO_AGBNO(tp->t_mountp, bmap->br_startblock), - owner, whichfork, - bmap->br_startoff, - bmap->br_blockcount, - bmap->br_state); - ri = kmem_cache_alloc(xfs_rmap_intent_cache, GFP_NOFS | __GFP_NOFAIL); INIT_LIST_HEAD(&ri->ri_list); ri->ri_type = type; @@ -2679,6 +2665,8 @@ __xfs_rmap_add( ri->ri_whichfork = whichfork; ri->ri_bmap = *bmap; + trace_xfs_rmap_defer(tp->t_mountp, ri); + xfs_rmap_update_get_group(tp->t_mountp, ri); xfs_defer_add(tp, &ri->ri_list, &xfs_rmap_update_defer_type); } diff --git a/libxfs/xfs_rmap.h b/libxfs/xfs_rmap.h index 3a153b4801b..f16b07d851d 100644 --- a/libxfs/xfs_rmap.h +++ b/libxfs/xfs_rmap.h @@ -157,6 +157,16 @@ enum xfs_rmap_intent_type { XFS_RMAP_FREE, }; +#define XFS_RMAP_INTENT_STRINGS \ + { XFS_RMAP_MAP, "map" }, \ + { XFS_RMAP_MAP_SHARED, "map_shared" }, \ + { XFS_RMAP_UNMAP, "unmap" }, \ + { XFS_RMAP_UNMAP_SHARED, "unmap_shared" }, \ + { XFS_RMAP_CONVERT, "cvt" }, \ + { XFS_RMAP_CONVERT_SHARED, "cvt_shared" }, \ + { XFS_RMAP_ALLOC, "alloc" }, \ + { XFS_RMAP_FREE, "free" } + struct xfs_rmap_intent { struct list_head ri_list; enum xfs_rmap_intent_type ri_type; From patchwork Wed Dec 27 13:09:28 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: 13508276 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 5751E38E for ; Mon, 1 Jan 2024 00:09:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oUAsGfHD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E048EC433C8; Mon, 1 Jan 2024 00:09:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704067769; bh=U3kXH8HUtA358UPGU5vNNB0P2XkzNj5NTeoC5oNC0Uw=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=oUAsGfHDG0BFm5u94p/wS/FIIYBjLxh22fYPNUhU9kIc0ac6jDfi3SO0DU4o/lQhq djiU40BQaHQHeQvdXXDF3XGrp7/jLkZLkfycPs3qRfn8qXkba+iZAiwO+RrpQ1OLM2 Paoo7uQBMWlXgp3PPUpulGwT8bkzMPFcKcr9mJZY/ZetvPA6QYW5pUqMCiJ1nC1JWH vc1Mx4cJl0dE7pkuNoyLOTwn2k/lLiyPRIUVClC/wtnAdfV1eXiqpgHsHfUqIWtAhW aCHAYjy1VO0YKrIbDDFCTXs7D2hyMtwDS4Afx6nl/thPbQ32dSRtqwlrGfUKyeQtuf 6AFVK8klvvBTQ== Date: Sun, 31 Dec 2023 16:09:28 +9900 Subject: [PATCH 5/9] xfs: add a ri_entry helper From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Message-ID: <170405014884.1815232.3576515918053401150.stgit@frogsfrogsfrogs> In-Reply-To: <170405014813.1815232.16195473149230327174.stgit@frogsfrogsfrogs> References: <170405014813.1815232.16195473149230327174.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 rmap_intent_item structure and use it so shorten assignments and avoid the need for extra local variables. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/defer_item.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c index 82b70575bc5..8fc27e9efd4 100644 --- a/libxfs/defer_item.c +++ b/libxfs/defer_item.c @@ -275,6 +275,11 @@ const struct xfs_defer_op_type xfs_agfl_free_defer_type = { /* Reverse Mapping */ +static inline struct xfs_rmap_intent *ri_entry(const struct list_head *e) +{ + return list_entry(e, struct xfs_rmap_intent, ri_list); +} + /* Sort rmap intents by AG. */ static int xfs_rmap_update_diff_items( @@ -282,11 +287,8 @@ xfs_rmap_update_diff_items( const struct list_head *a, const struct list_head *b) { - const struct xfs_rmap_intent *ra; - const struct xfs_rmap_intent *rb; - - ra = container_of(a, struct xfs_rmap_intent, ri_list); - rb = container_of(b, struct xfs_rmap_intent, ri_list); + struct xfs_rmap_intent *ra = ri_entry(a); + struct xfs_rmap_intent *rb = ri_entry(b); return ra->ri_pag->pag_agno - rb->ri_pag->pag_agno; } @@ -341,11 +343,9 @@ xfs_rmap_update_finish_item( struct list_head *item, struct xfs_btree_cur **state) { - struct xfs_rmap_intent *ri; + struct xfs_rmap_intent *ri = ri_entry(item); int error; - ri = container_of(item, struct xfs_rmap_intent, ri_list); - error = xfs_rmap_finish_one(tp, ri, state); xfs_rmap_update_put_group(ri); @@ -365,9 +365,7 @@ STATIC void xfs_rmap_update_cancel_item( struct list_head *item) { - struct xfs_rmap_intent *ri; - - ri = container_of(item, struct xfs_rmap_intent, ri_list); + struct xfs_rmap_intent *ri = ri_entry(item); xfs_rmap_update_put_group(ri); kmem_cache_free(xfs_rmap_intent_cache, ri); From patchwork Wed Dec 27 13:09:44 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: 13508277 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 B5C7638B for ; Mon, 1 Jan 2024 00:09:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="opDQZCXS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CB80C433C8; Mon, 1 Jan 2024 00:09:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704067784; bh=PleTMzUg2BgAjO0KcsHT8FuREoSZ4eFvygNkdcgYdWU=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=opDQZCXSrQlPNacnldINp6DyQXYZwwyGhete+Pv2D2C72HFRlfHu+EYpUbedFQ7lu dhp+nYmvq8VlOFIiqFhJr7N6Nt8OnYVe9aMB9GdCVQPAuawN4VU44d69W8W5g3Gfz5 BLWocYnmZG6Q1QeD2rLbrYV44vwVVFOBi8AynYBErJIvdf2JDxXUQnneHRidGXQDVy 3sT+eNgbyjNHFgZYC39isJsXam/rKsPhaSz9K28XUKDsxKuCWtJi3IELjSxrygoGUh TcKdd+TQRMZ+Mt/XkWG+6kiJ9h5RsBTXYP+aj50R717qejRKDb9C3ylWBvNIKaOdNo U9boRZz0hP9zA== Date: Sun, 31 Dec 2023 16:09:44 +9900 Subject: [PATCH 6/9] xfs: reuse xfs_rmap_update_cancel_item From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Message-ID: <170405014897.1815232.859570840654002099.stgit@frogsfrogsfrogs> In-Reply-To: <170405014813.1815232.16195473149230327174.stgit@frogsfrogsfrogs> References: <170405014813.1815232.16195473149230327174.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_rmap_update_cancel_item to put the AG/RTG and free the item in a few places that currently open code the logic. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong 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 8fc27e9efd4..e7277b54532 100644 --- a/libxfs/defer_item.c +++ b/libxfs/defer_item.c @@ -335,6 +335,17 @@ xfs_rmap_update_put_group( xfs_perag_intent_put(ri->ri_pag); } +/* Cancel a deferred rmap update. */ +STATIC void +xfs_rmap_update_cancel_item( + struct list_head *item) +{ + struct xfs_rmap_intent *ri = ri_entry(item); + + xfs_rmap_update_put_group(ri); + kmem_cache_free(xfs_rmap_intent_cache, ri); +} + /* Process a deferred rmap update. */ STATIC int xfs_rmap_update_finish_item( @@ -348,8 +359,7 @@ xfs_rmap_update_finish_item( error = xfs_rmap_finish_one(tp, ri, state); - xfs_rmap_update_put_group(ri); - kmem_cache_free(xfs_rmap_intent_cache, ri); + xfs_rmap_update_cancel_item(item); return error; } @@ -360,17 +370,6 @@ xfs_rmap_update_abort_intent( { } -/* Cancel a deferred rmap update. */ -STATIC void -xfs_rmap_update_cancel_item( - struct list_head *item) -{ - struct xfs_rmap_intent *ri = ri_entry(item); - - xfs_rmap_update_put_group(ri); - kmem_cache_free(xfs_rmap_intent_cache, ri); -} - const struct xfs_defer_op_type xfs_rmap_update_defer_type = { .name = "rmap", .create_intent = xfs_rmap_update_create_intent, From patchwork Wed Dec 27 13:09:59 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: 13508278 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 5A703389 for ; Mon, 1 Jan 2024 00:10:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZPF19ukd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2EB4FC433C8; Mon, 1 Jan 2024 00:10:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704067800; bh=UsjfBHgyUYEe/jdja//W3C3UGL0XDewdg4yjonKyVs8=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=ZPF19ukdSnGwd2jxMWnOn9XpvV4eljIkDseDrLNO2wu70/eBO2j3NAJGImRYrX+kJ NDDv7TjycjHvzb4ifu4LgcJDGcJaNWbNT/Oz0GZMnGFfCF4es1Rg8UJnYa8iTFmBVl EsW7ZEzctKqDXGs5PhHWClTDbSk3iiTMFDn5hgU4tHnHt8M92cTuIOJsMnL68D2RZp zj5Y8Xzz0UNHHwhPk5h1hnNQv6WqEYAalaFhe+kNj2Qfgxd5EpAWioYcT0XYNQxpLi n/Npo2iPJmSUIA3iUdAti3ak6babynCMkbCdwXVBIAiobAW3aqjHxIP3zXlKLhheAb jZg4witCdFNUg== Date: Sun, 31 Dec 2023 16:09:59 +9900 Subject: [PATCH 7/9] xfs: don't bother calling xfs_rmap_finish_one_cleanup in xfs_rmap_finish_one From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Message-ID: <170405014910.1815232.12389006596438249563.stgit@frogsfrogsfrogs> In-Reply-To: <170405014813.1815232.16195473149230327174.stgit@frogsfrogsfrogs> References: <170405014813.1815232.16195473149230327174.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: Christoph Hellwig In xfs_rmap_finish_one we known the cursor is non-zero when calling xfs_rmap_finish_one_cleanup and we pass a 0 error variable. This means xfs_rmap_finish_one_cleanup is just doing a xfs_btree_del_cursor. Open code that and move xfs_rmap_finish_one_cleanup to fs/xfs/xfs_rmap_item.c. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong [djwong: minor porting changes] Signed-off-by: Darrick J. Wong --- libxfs/xfs_rmap.c | 19 +------------------ libxfs/xfs_rmap.h | 2 -- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/libxfs/xfs_rmap.c b/libxfs/xfs_rmap.c index 3c00b05d8d0..a1a9f4927bd 100644 --- a/libxfs/xfs_rmap.c +++ b/libxfs/xfs_rmap.c @@ -2513,23 +2513,6 @@ xfs_rmap_query_all( return xfs_btree_query_all(cur, xfs_rmap_query_range_helper, &query); } -/* Clean up after calling xfs_rmap_finish_one. */ -void -xfs_rmap_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); -} - /* Commit an rmap operation into the ondisk tree. */ int __xfs_rmap_finish_intent( @@ -2594,7 +2577,7 @@ xfs_rmap_finish_one( */ rcur = *pcur; if (rcur != NULL && rcur->bc_ag.pag != ri->ri_pag) { - xfs_rmap_finish_one_cleanup(tp, rcur, 0); + xfs_btree_del_cursor(rcur, 0); rcur = NULL; *pcur = NULL; } diff --git a/libxfs/xfs_rmap.h b/libxfs/xfs_rmap.h index f16b07d851d..2513ee36aa2 100644 --- a/libxfs/xfs_rmap.h +++ b/libxfs/xfs_rmap.h @@ -192,8 +192,6 @@ void xfs_rmap_alloc_extent(struct xfs_trans *tp, xfs_agnumber_t agno, void xfs_rmap_free_extent(struct xfs_trans *tp, xfs_agnumber_t agno, xfs_agblock_t bno, xfs_extlen_t len, uint64_t owner); -void xfs_rmap_finish_one_cleanup(struct xfs_trans *tp, - struct xfs_btree_cur *rcur, int error); int xfs_rmap_finish_one(struct xfs_trans *tp, struct xfs_rmap_intent *ri, struct xfs_btree_cur **pcur); int __xfs_rmap_finish_intent(struct xfs_btree_cur *rcur, From patchwork Wed Dec 27 13:10:15 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: 13508279 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 6DF1138B for ; Mon, 1 Jan 2024 00:10:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="biegenIq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBE74C433C7; Mon, 1 Jan 2024 00:10:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704067815; bh=qRYFiKy7ItnHSueIs8dGQR6lzI0wsxgysD1J2Z5BaEk=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=biegenIqpI9Pr91R4fL6JqG7WLGqouW4vxG5r+sA04qxiCbTiNCZOxzEwDyGRReYa z/Ip7FgoWGeTgV5vhzfspfGuZiBCxf6R2qw7PvItcPzMmEy54I+NeQt4r0+rYRfvgs utpxSFGwUM9ICw/5zqoH8YCbV7mx8Vpu66FniTur+KchzN+edOvC/ujpm2tDXZP/cN onpZDp6ToJca4OOcz7qIpz9/dISS7Qj126A0a1sNXDsjnEpEIbKqxq7QIslQkFdAFS soKHJRufQhTgLFkmp/njdhQM/s1lQMUQ1HYBQ1cyIlDkg6p1JCTGGPDiS2qn4XGGOc gTwQ41sCYVzTg== Date: Sun, 31 Dec 2023 16:10:15 +9900 Subject: [PATCH 8/9] xfs: simplify usage of the rcur local variable in xfs_rmap_finish_one From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Message-ID: <170405014922.1815232.16239681065099082707.stgit@frogsfrogsfrogs> In-Reply-To: <170405014813.1815232.16195473149230327174.stgit@frogsfrogsfrogs> References: <170405014813.1815232.16195473149230327174.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: Christoph Hellwig Only update rcur when we know the final *pcur value. Signed-off-by: Christoph Hellwig [djwong: don't leave the caller with a dangling ref] Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/defer_item.c | 18 ++++++++++++++++++ libxfs/xfs_rmap.c | 6 ++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c index e7277b54532..d3df56f0a2b 100644 --- a/libxfs/defer_item.c +++ b/libxfs/defer_item.c @@ -28,6 +28,7 @@ #include "xfs_ag.h" #include "xfs_swapext.h" #include "defer_item.h" +#include "xfs_btree.h" /* Dummy defer item ops, since we don't do logging. */ @@ -370,6 +371,23 @@ xfs_rmap_update_abort_intent( { } +/* Clean up after calling xfs_rmap_finish_one. */ +STATIC void +xfs_rmap_finish_one_cleanup( + struct xfs_trans *tp, + struct xfs_btree_cur *rcur, + int error) +{ + struct xfs_buf *agbp = NULL; + + if (rcur == NULL) + return; + agbp = rcur->bc_ag.agbp; + xfs_btree_del_cursor(rcur, error); + if (error && agbp) + xfs_trans_brelse(tp, agbp); +} + const struct xfs_defer_op_type xfs_rmap_update_defer_type = { .name = "rmap", .create_intent = xfs_rmap_update_create_intent, diff --git a/libxfs/xfs_rmap.c b/libxfs/xfs_rmap.c index a1a9f4927bd..183e840b7f1 100644 --- a/libxfs/xfs_rmap.c +++ b/libxfs/xfs_rmap.c @@ -2560,7 +2560,7 @@ xfs_rmap_finish_one( { struct xfs_owner_info oinfo; struct xfs_mount *mp = tp->t_mountp; - struct xfs_btree_cur *rcur; + struct xfs_btree_cur *rcur = *pcur; struct xfs_buf *agbp = NULL; xfs_agblock_t bno; bool unwritten; @@ -2575,7 +2575,6 @@ xfs_rmap_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) { xfs_btree_del_cursor(rcur, 0); rcur = NULL; @@ -2597,9 +2596,8 @@ xfs_rmap_finish_one( return -EFSCORRUPTED; } - rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, ri->ri_pag); + *pcur = rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, ri->ri_pag); } - *pcur = rcur; xfs_rmap_ino_owner(&oinfo, ri->ri_owner, ri->ri_whichfork, ri->ri_bmap.br_startoff); From patchwork Wed Dec 27 13:10:31 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: 13508280 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 066EE38B for ; Mon, 1 Jan 2024 00:10:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SgAPIcf4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7619FC433C8; Mon, 1 Jan 2024 00:10:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704067831; bh=v369iSh5QgxhvS+WBHi4OeoGv7u5vNt48NNd5U45hss=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=SgAPIcf4YBn/1+S63snoC8nCO4/dobyu67G5F0LoVEE57BNS/nDxb5XNyWZ7YFhWL yhFSDRDf8TJoLvz17o6F1qAT5hLaPcUQGj0QdcH81V4ZlM0qA/zqiN3ocYgANaDyX0 a2RGJEj46iVn5V8/HsigPj3svvACpDJcqfQnhkzE2FrSsTHCwGxoIgr6YAWwyC0AaH IgIptpD4NW2nzKfFtv8yRRis0iE15ViLCbghOeR44wEf4VIDwLcmnoG0HCZZ+0f1RQ kf2ARqGfSrcSLYR3fc81ApCTgjg3NSBS1LWwglP4b0AUtHlWdzKht2ajSCuIaifS7U kR4HfOaqEq7Iw== Date: Sun, 31 Dec 2023 16:10:31 +9900 Subject: [PATCH 9/9] xfs: move xfs_rmap_update_defer_add to xfs_rmap_item.c From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org Message-ID: <170405014935.1815232.9270614482521381464.stgit@frogsfrogsfrogs> In-Reply-To: <170405014813.1815232.16195473149230327174.stgit@frogsfrogsfrogs> References: <170405014813.1815232.16195473149230327174.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_rmap_update_item deferred work data to a transaction live with the RUI log item code. This means that the rmap code no longer has to know about the inner workings of the RUI 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 | 4 ++++ libxfs/xfs_rmap.c | 6 ++---- libxfs/xfs_rmap.h | 3 --- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c index d3df56f0a2b..5399a20f186 100644 --- a/libxfs/defer_item.c +++ b/libxfs/defer_item.c @@ -319,21 +319,18 @@ xfs_rmap_update_create_done( return NULL; } -/* Take an active ref to the AG containing the space we're rmapping. */ +/* Add this deferred RUI to the transaction. */ void -xfs_rmap_update_get_group( - struct xfs_mount *mp, +xfs_rmap_defer_add( + struct xfs_trans *tp, struct xfs_rmap_intent *ri) { + struct xfs_mount *mp = tp->t_mountp; + + trace_xfs_rmap_defer(mp, ri); + ri->ri_pag = xfs_perag_intent_get(mp, ri->ri_bmap.br_startblock); -} - -/* Release an active AG ref after finishing rmapping work. */ -static inline void -xfs_rmap_update_put_group( - struct xfs_rmap_intent *ri) -{ - xfs_perag_intent_put(ri->ri_pag); + xfs_defer_add(tp, &ri->ri_list, &xfs_rmap_update_defer_type); } /* Cancel a deferred rmap update. */ @@ -343,7 +340,7 @@ xfs_rmap_update_cancel_item( { struct xfs_rmap_intent *ri = ri_entry(item); - xfs_rmap_update_put_group(ri); + xfs_perag_intent_put(ri->ri_pag); kmem_cache_free(xfs_rmap_intent_cache, ri); } diff --git a/libxfs/defer_item.h b/libxfs/defer_item.h index 79e957eb8ff..3ef31ad0aec 100644 --- a/libxfs/defer_item.h +++ b/libxfs/defer_item.h @@ -20,4 +20,8 @@ void xfs_extent_free_defer_add(struct xfs_trans *tp, struct xfs_extent_free_item *xefi, struct xfs_defer_pending **dfpp); +struct xfs_rmap_intent; + +void xfs_rmap_defer_add(struct xfs_trans *tp, struct xfs_rmap_intent *ri); + #endif /* __LIBXFS_DEFER_ITEM_H_ */ diff --git a/libxfs/xfs_rmap.c b/libxfs/xfs_rmap.c index 183e840b7f1..24daf0ffb66 100644 --- a/libxfs/xfs_rmap.c +++ b/libxfs/xfs_rmap.c @@ -23,6 +23,7 @@ #include "xfs_inode.h" #include "xfs_ag.h" #include "xfs_health.h" +#include "defer_item.h" struct kmem_cache *xfs_rmap_intent_cache; @@ -2646,10 +2647,7 @@ __xfs_rmap_add( ri->ri_whichfork = whichfork; ri->ri_bmap = *bmap; - trace_xfs_rmap_defer(tp->t_mountp, ri); - - xfs_rmap_update_get_group(tp->t_mountp, ri); - xfs_defer_add(tp, &ri->ri_list, &xfs_rmap_update_defer_type); + xfs_rmap_defer_add(tp, ri); } /* Map an extent into a file. */ diff --git a/libxfs/xfs_rmap.h b/libxfs/xfs_rmap.h index 2513ee36aa2..e6240efd6fe 100644 --- a/libxfs/xfs_rmap.h +++ b/libxfs/xfs_rmap.h @@ -176,9 +176,6 @@ struct xfs_rmap_intent { struct xfs_perag *ri_pag; }; -void xfs_rmap_update_get_group(struct xfs_mount *mp, - struct xfs_rmap_intent *ri); - /* functions for updating the rmapbt based on bmbt map/unmap operations */ void xfs_rmap_map_extent(struct xfs_trans *tp, struct xfs_inode *ip, int whichfork, struct xfs_bmbt_irec *imap);