From patchwork Thu Feb 1 19:55:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13541753 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 DE7AE85289 for ; Thu, 1 Feb 2024 19:55:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706817335; cv=none; b=Kcmk/587FvxVxan0XgrQCthbYncUBiR53KtqSEylB0dNS9mhrJSQpdotKaLN7wzno5Urx6MQx8P/0x5MA8UawBjcVaX4VHUTvQVz98th2MMBsp7qmrNR/95YfM0Gr3pKQJ3PR8RYH1FUgia4quwLuLTOaJAbitgLADRbJ/SI4cQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706817335; c=relaxed/simple; bh=BGd4uGJTF8tNb3Zi+xHvf66c4M4xG+ekvLUtuRudvHk=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Agku5Zsl+2yhYIo6ijLCKN9XpVU1/SMeGeTo/T4PzMLGIU09hyERXNEmuieatSXmZmq4l1OEqUod3cX6z9oJ4oPn/gLnb8FNjkntbdbGsb9O7Px4Pkfi1BF6hRR06MALIuyF3mrkVH77ioefEdoVoQIB/jyP6Em4fr/6unIa8bs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lqZav4YO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lqZav4YO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50B2AC433C7; Thu, 1 Feb 2024 19:55:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706817334; bh=BGd4uGJTF8tNb3Zi+xHvf66c4M4xG+ekvLUtuRudvHk=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=lqZav4YOlFb9xcQK2sXGmxtw7qwiGTwyyePTaChQ9cojUii/EwODbJoLASQNsB4xt N5LqYIPCBbK4k5I6TejpD5fZSuFqrdetoJhvKhf1OnRiyYoRdXeDw2so0RVMKmToUe VmrrOYaf0GOBlSS0oPcNE/1G4ckCN+CfHmaH6IbfPoJ5AU9HGWccLiU4viKCCB3yaA ob2VJfedf9R7LfVrYF/pwkLCF5wI73pRSbFNh7+/LlpGZy/tGvRTyP1Rf1xVNWIvOb TetxRakx3NaEUNP+8on/pzetq+c67Xjjdvz7zHLRrnpiwSR/OVc6U8Ar9uOL33qJEJ elmIqbVFyVi5w== Date: Thu, 01 Feb 2024 11:55:33 -0800 Subject: [PATCH 1/4] xfs: remove xfs_btree_reada_bufl From: "Darrick J. Wong" To: djwong@kernel.org Cc: Christoph Hellwig , hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <170681336146.1608096.870671815956033354.stgit@frogsfrogsfrogs> In-Reply-To: <170681336120.1608096.10255376163152255295.stgit@frogsfrogsfrogs> References: <170681336120.1608096.10255376163152255295.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 xfs_btree_reada_bufl just wraps xfs_btree_readahead and a fsblock to daddr conversion. Just open code it's two callsites in the only caller. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_btree.c | 30 ++++++------------------------ fs/xfs/libxfs/xfs_btree.h | 11 ----------- 2 files changed, 6 insertions(+), 35 deletions(-) diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c index b228b22893fa0..2689cad9b25ab 100644 --- a/fs/xfs/libxfs/xfs_btree.c +++ b/fs/xfs/libxfs/xfs_btree.c @@ -889,25 +889,6 @@ xfs_btree_read_bufl( return 0; } -/* - * Read-ahead the block, don't wait for it, don't return a buffer. - * Long-form addressing. - */ -/* ARGSUSED */ -void -xfs_btree_reada_bufl( - struct xfs_mount *mp, /* file system mount point */ - xfs_fsblock_t fsbno, /* file system block number */ - xfs_extlen_t count, /* count of filesystem blocks */ - const struct xfs_buf_ops *ops) -{ - xfs_daddr_t d; - - ASSERT(fsbno != NULLFSBLOCK); - d = XFS_FSB_TO_DADDR(mp, fsbno); - xfs_buf_readahead(mp->m_ddev_targp, d, mp->m_bsize * count, ops); -} - /* * Read-ahead the block, don't wait for it, don't return a buffer. * Short-form addressing. @@ -935,19 +916,20 @@ xfs_btree_readahead_fsblock( int lr, struct xfs_btree_block *block) { - int rval = 0; + struct xfs_mount *mp = cur->bc_mp; xfs_fsblock_t left = be64_to_cpu(block->bb_u.l.bb_leftsib); xfs_fsblock_t right = be64_to_cpu(block->bb_u.l.bb_rightsib); + int rval = 0; if ((lr & XFS_BTCUR_LEFTRA) && left != NULLFSBLOCK) { - xfs_btree_reada_bufl(cur->bc_mp, left, 1, - cur->bc_ops->buf_ops); + xfs_buf_readahead(mp->m_ddev_targp, XFS_FSB_TO_DADDR(mp, left), + mp->m_bsize, cur->bc_ops->buf_ops); rval++; } if ((lr & XFS_BTCUR_RIGHTRA) && right != NULLFSBLOCK) { - xfs_btree_reada_bufl(cur->bc_mp, right, 1, - cur->bc_ops->buf_ops); + xfs_buf_readahead(mp->m_ddev_targp, XFS_FSB_TO_DADDR(mp, right), + mp->m_bsize, cur->bc_ops->buf_ops); rval++; } diff --git a/fs/xfs/libxfs/xfs_btree.h b/fs/xfs/libxfs/xfs_btree.h index 8544f2f506f80..d95f521a48a74 100644 --- a/fs/xfs/libxfs/xfs_btree.h +++ b/fs/xfs/libxfs/xfs_btree.h @@ -391,17 +391,6 @@ xfs_btree_read_bufl( int refval, /* ref count value for buffer */ const struct xfs_buf_ops *ops); -/* - * Read-ahead the block, don't wait for it, don't return a buffer. - * Long-form addressing. - */ -void /* error */ -xfs_btree_reada_bufl( - struct xfs_mount *mp, /* file system mount point */ - xfs_fsblock_t fsbno, /* file system block number */ - xfs_extlen_t count, /* count of filesystem blocks */ - const struct xfs_buf_ops *ops); - /* * Read-ahead the block, don't wait for it, don't return a buffer. * Short-form addressing. From patchwork Thu Feb 1 19:55:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13541754 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 7EABD43AC7 for ; Thu, 1 Feb 2024 19:55:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706817350; cv=none; b=gjVPZWs33ik1xaIZNtuPmR/qVmlo8atUJ+zMSp0EIGyP0Oyy+l8tI6/h4NSB3J5zP3apekhZOemziiY1KQw+CknHsl9WSxH9aDAQcd+Fc5jHl/kiP26Tj4dX7LE3oWYcWiQFki44KV/L38AN30vGwNYAs1WQ+wHmsz/D02dMnig= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706817350; c=relaxed/simple; bh=VKSXYSvyRDS43aHANWqGsUAviE4RYrFfCGBc+Of2WlI=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=n7Ul2PhbPh9mkJg/s9cNFlLvpAkIarQ+fqusz4p1BXIu0agWlEAONDrfMv7XtD4XWCl22TzP58bHT9Lt1z7IYnA3ibvc9EBpxINlkAOGNoo4n9DugysDm7Ab+OMh8OQYchu7OBRTEJe8Q8PCtVUtSyqKQsl599iGAH4Kw84GTPg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZV402YaJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZV402YaJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2FB4C433F1; Thu, 1 Feb 2024 19:55:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706817350; bh=VKSXYSvyRDS43aHANWqGsUAviE4RYrFfCGBc+Of2WlI=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=ZV402YaJJO1a1R/dg39anM8P+B8Gp62uoV4l9lJTmRRgMiQGcYaxrKlG3Z6adpoTV JhzIfcyAK9J0AGRCafre1gRjH9P/pEuST7/GE+rTucTjyJKMeOZnkmoo3kGtDiOqHP A0LAmLex3mSu1Zt15YvJ5AcXbqQ+xYSdfYGblkrlOouNjQsYcd8WmzKjoEY9CmqErY gSbFNKRNgGBNUKTOUaBGzx9YlMnGcHjUU4gZ+oxvKqAyjGMJTDQFSk4mv4bb5zCTaK vOcCAcaWdSg566hF+77siHWSVvV/stMcikMj6UdLhnhPrAGJP6lSKySvupkpsUbytW hpys7t16h1daQ== Date: Thu, 01 Feb 2024 11:55:49 -0800 Subject: [PATCH 2/4] xfs: remove xfs_btree_reada_bufs From: "Darrick J. Wong" To: djwong@kernel.org Cc: Christoph Hellwig , hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <170681336162.1608096.14665546318489493405.stgit@frogsfrogsfrogs> In-Reply-To: <170681336120.1608096.10255376163152255295.stgit@frogsfrogsfrogs> References: <170681336120.1608096.10255376163152255295.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 xfs_btree_reada_bufl just wraps xfs_btree_readahead and a agblock to daddr conversion. Just open code it's three callsites in the two callers (One of which isn't even btree related). Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_btree.c | 38 ++++++++++---------------------------- fs/xfs/libxfs/xfs_btree.h | 12 ------------ fs/xfs/xfs_iwalk.c | 6 ++++-- 3 files changed, 14 insertions(+), 42 deletions(-) diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c index 2689cad9b25ab..0f06ee026d9aa 100644 --- a/fs/xfs/libxfs/xfs_btree.c +++ b/fs/xfs/libxfs/xfs_btree.c @@ -889,27 +889,6 @@ xfs_btree_read_bufl( return 0; } -/* - * Read-ahead the block, don't wait for it, don't return a buffer. - * Short-form addressing. - */ -/* ARGSUSED */ -void -xfs_btree_reada_bufs( - struct xfs_mount *mp, /* file system mount point */ - xfs_agnumber_t agno, /* allocation group number */ - xfs_agblock_t agbno, /* allocation group block number */ - xfs_extlen_t count, /* count of filesystem blocks */ - const struct xfs_buf_ops *ops) -{ - xfs_daddr_t d; - - ASSERT(agno != NULLAGNUMBER); - ASSERT(agbno != NULLAGBLOCK); - d = XFS_AGB_TO_DADDR(mp, agno, agbno); - xfs_buf_readahead(mp->m_ddev_targp, d, mp->m_bsize * count, ops); -} - STATIC int xfs_btree_readahead_fsblock( struct xfs_btree_cur *cur, @@ -940,22 +919,25 @@ STATIC int xfs_btree_readahead_agblock( struct xfs_btree_cur *cur, int lr, - struct xfs_btree_block *block) + struct xfs_btree_block *block) { - int rval = 0; + struct xfs_mount *mp = cur->bc_mp; + xfs_agnumber_t agno = cur->bc_ag.pag->pag_agno; xfs_agblock_t left = be32_to_cpu(block->bb_u.s.bb_leftsib); xfs_agblock_t right = be32_to_cpu(block->bb_u.s.bb_rightsib); - + int rval = 0; if ((lr & XFS_BTCUR_LEFTRA) && left != NULLAGBLOCK) { - xfs_btree_reada_bufs(cur->bc_mp, cur->bc_ag.pag->pag_agno, - left, 1, cur->bc_ops->buf_ops); + xfs_buf_readahead(mp->m_ddev_targp, + XFS_AGB_TO_DADDR(mp, agno, left), + mp->m_bsize, cur->bc_ops->buf_ops); rval++; } if ((lr & XFS_BTCUR_RIGHTRA) && right != NULLAGBLOCK) { - xfs_btree_reada_bufs(cur->bc_mp, cur->bc_ag.pag->pag_agno, - right, 1, cur->bc_ops->buf_ops); + xfs_buf_readahead(mp->m_ddev_targp, + XFS_AGB_TO_DADDR(mp, agno, right), + mp->m_bsize, cur->bc_ops->buf_ops); rval++; } diff --git a/fs/xfs/libxfs/xfs_btree.h b/fs/xfs/libxfs/xfs_btree.h index d95f521a48a74..5100f84a760c1 100644 --- a/fs/xfs/libxfs/xfs_btree.h +++ b/fs/xfs/libxfs/xfs_btree.h @@ -391,18 +391,6 @@ xfs_btree_read_bufl( int refval, /* ref count value for buffer */ const struct xfs_buf_ops *ops); -/* - * Read-ahead the block, don't wait for it, don't return a buffer. - * Short-form addressing. - */ -void /* error */ -xfs_btree_reada_bufs( - struct xfs_mount *mp, /* file system mount point */ - xfs_agnumber_t agno, /* allocation group number */ - xfs_agblock_t agbno, /* allocation group block number */ - xfs_extlen_t count, /* count of filesystem blocks */ - const struct xfs_buf_ops *ops); - /* * Initialise a new btree block header */ diff --git a/fs/xfs/xfs_iwalk.c b/fs/xfs/xfs_iwalk.c index a36f01b4e23d7..53b643ff7a3fa 100644 --- a/fs/xfs/xfs_iwalk.c +++ b/fs/xfs/xfs_iwalk.c @@ -100,6 +100,7 @@ xfs_iwalk_ichunk_ra( struct xfs_inobt_rec_incore *irec) { struct xfs_ino_geometry *igeo = M_IGEO(mp); + xfs_agnumber_t agno = pag->pag_agno; xfs_agblock_t agbno; struct blk_plug plug; int i; /* inode chunk index */ @@ -112,8 +113,9 @@ xfs_iwalk_ichunk_ra( imask = xfs_inobt_maskn(i, igeo->inodes_per_cluster); if (imask & ~irec->ir_free) { - xfs_btree_reada_bufs(mp, pag->pag_agno, agbno, - igeo->blocks_per_cluster, + xfs_buf_readahead(mp->m_ddev_targp, + XFS_AGB_TO_DADDR(mp, agno, agbno), + igeo->blocks_per_cluster * mp->m_bsize, &xfs_inode_buf_ops); } agbno += igeo->blocks_per_cluster; From patchwork Thu Feb 1 19:56:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13541755 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 CC59343AC7 for ; Thu, 1 Feb 2024 19:56:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706817365; cv=none; b=uXCezNs6vHSwGlXOIiuLa3ostlnKseLdOYN/PPHx6thkvySgrRYQfrfCBLavkA/CDDAqyH1cBEvR/FzA+tJ6link5I9xCu8/HcNdGSOFShF1BXPukzE1NjJDH8g/ca2HmDXNRwc55F7ehwzJb/Kypd3BQfifrJGgTsBlW68cAJM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706817365; c=relaxed/simple; bh=gZFV2lhU0JtNWu94d9JZzDxnTLnVBujb8ijLGhjRbQc=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VFOUqjToBBnx6zkrCro7pGZXvFU5UqioAcKZKhhUETTihXdd/K8HqS0NxUMfF7sSQh7/KYVec8SkoRWl+/IM8GbwdnsUQ3xJtW2kPhMzXu/I7BLlCjDhwVXGn0kKfw2A9psIhyVZ8QUIAk1+VflPOv9doBRpyOjK4pK8pTwbD9c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lMRzjBum; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lMRzjBum" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E198C433F1; Thu, 1 Feb 2024 19:56:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706817365; bh=gZFV2lhU0JtNWu94d9JZzDxnTLnVBujb8ijLGhjRbQc=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=lMRzjBumkda5elaoVtZ7HcuqCE1EJf0OY3hID/4gyVF05eZv4gLxL4pDk5ijX80Dm eNSeepLd5tBgRq3U4euNDawkxF3mSLye6BE+D6f8oA6ofWl0P6cY0XISuTP6+2XVdv 25kvp9Ou3v2b2bqm28l7ELeqyKqzSHSG1pAfEUxI9n3lBVaCyQyalZyQyzPR+ZUjj7 WLjAjEOqV6WtcpOCJ+hAnJYvLgYME8bxFb23iy49YE0vKvO5GEgwDWmkFcD0YxUtls stKBP5VVA0fgzKOI6YVWeqipIIX9LeqflJSmOmmJiNfIcsBizT5Dxz1EpncEKTN5v3 owPPKRfspQNpQ== Date: Thu, 01 Feb 2024 11:56:05 -0800 Subject: [PATCH 3/4] xfs: move and rename xfs_btree_read_bufl From: "Darrick J. Wong" To: djwong@kernel.org Cc: Christoph Hellwig , hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <170681336178.1608096.76946402904328952.stgit@frogsfrogsfrogs> In-Reply-To: <170681336120.1608096.10255376163152255295.stgit@frogsfrogsfrogs> References: <170681336120.1608096.10255376163152255295.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 Despite its name, xfs_btree_read_bufl doesn't contain any btree-related functionaliy and isn't used by the btree code. Move it to xfs_bmap.c, hard code the refval and ops arguments and rename it to xfs_bmap_read_buf. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_bmap.c | 33 +++++++++++++++++++++++++-------- fs/xfs/libxfs/xfs_btree.c | 30 ------------------------------ fs/xfs/libxfs/xfs_btree.h | 13 ------------- 3 files changed, 25 insertions(+), 51 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 5537483c2e539..b4a2adb42df33 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -226,6 +226,28 @@ xfs_bmap_forkoff_reset( } } +static int +xfs_bmap_read_buf( + struct xfs_mount *mp, /* file system mount point */ + struct xfs_trans *tp, /* transaction pointer */ + xfs_fsblock_t fsbno, /* file system block number */ + struct xfs_buf **bpp) /* buffer for fsbno */ +{ + struct xfs_buf *bp; /* return value */ + int error; + + if (!xfs_verify_fsbno(mp, fsbno)) + return -EFSCORRUPTED; + error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, + XFS_FSB_TO_DADDR(mp, fsbno), mp->m_bsize, 0, &bp, + &xfs_bmbt_buf_ops); + if (!error) { + xfs_buf_set_ref(bp, XFS_BMAP_BTREE_REF); + *bpp = bp; + } + return error; +} + #ifdef DEBUG STATIC struct xfs_buf * xfs_bmap_get_bp( @@ -365,9 +387,7 @@ xfs_bmap_check_leaf_extents( bp = xfs_bmap_get_bp(cur, XFS_FSB_TO_DADDR(mp, bno)); if (!bp) { bp_release = 1; - error = xfs_btree_read_bufl(mp, NULL, bno, &bp, - XFS_BMAP_BTREE_REF, - &xfs_bmbt_buf_ops); + error = xfs_bmap_read_buf(mp, NULL, bno, &bp); if (xfs_metadata_is_sick(error)) xfs_btree_mark_sick(cur); if (error) @@ -454,9 +474,7 @@ xfs_bmap_check_leaf_extents( bp = xfs_bmap_get_bp(cur, XFS_FSB_TO_DADDR(mp, bno)); if (!bp) { bp_release = 1; - error = xfs_btree_read_bufl(mp, NULL, bno, &bp, - XFS_BMAP_BTREE_REF, - &xfs_bmbt_buf_ops); + error = xfs_bmap_read_buf(mp, NULL, bno, &bp); if (xfs_metadata_is_sick(error)) xfs_btree_mark_sick(cur); if (error) @@ -573,8 +591,7 @@ xfs_bmap_btree_to_extents( return -EFSCORRUPTED; } #endif - error = xfs_btree_read_bufl(mp, tp, cbno, &cbp, XFS_BMAP_BTREE_REF, - &xfs_bmbt_buf_ops); + error = xfs_bmap_read_buf(mp, tp, cbno, &cbp); if (xfs_metadata_is_sick(error)) xfs_btree_mark_sick(cur); if (error) diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c index 0f06ee026d9aa..ecdd5ea27a038 100644 --- a/fs/xfs/libxfs/xfs_btree.c +++ b/fs/xfs/libxfs/xfs_btree.c @@ -859,36 +859,6 @@ xfs_btree_offsets( } } -/* - * Get a buffer for the block, return it read in. - * Long-form addressing. - */ -int -xfs_btree_read_bufl( - struct xfs_mount *mp, /* file system mount point */ - struct xfs_trans *tp, /* transaction pointer */ - xfs_fsblock_t fsbno, /* file system block number */ - struct xfs_buf **bpp, /* buffer for fsbno */ - int refval, /* ref count value for buffer */ - const struct xfs_buf_ops *ops) -{ - struct xfs_buf *bp; /* return value */ - xfs_daddr_t d; /* real disk block address */ - int error; - - if (!xfs_verify_fsbno(mp, fsbno)) - return -EFSCORRUPTED; - d = XFS_FSB_TO_DADDR(mp, fsbno); - error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, d, - mp->m_bsize, 0, &bp, ops); - if (error) - return error; - if (bp) - xfs_buf_set_ref(bp, refval); - *bpp = bp; - return 0; -} - STATIC int xfs_btree_readahead_fsblock( struct xfs_btree_cur *cur, diff --git a/fs/xfs/libxfs/xfs_btree.h b/fs/xfs/libxfs/xfs_btree.h index 5100f84a760c1..790eccb771866 100644 --- a/fs/xfs/libxfs/xfs_btree.h +++ b/fs/xfs/libxfs/xfs_btree.h @@ -378,19 +378,6 @@ xfs_btree_offsets( int *first, /* output: first byte offset */ int *last); /* output: last byte offset */ -/* - * Get a buffer for the block, return it read in. - * Long-form addressing. - */ -int /* error */ -xfs_btree_read_bufl( - struct xfs_mount *mp, /* file system mount point */ - struct xfs_trans *tp, /* transaction pointer */ - xfs_fsblock_t fsbno, /* file system block number */ - struct xfs_buf **bpp, /* buffer for fsbno */ - int refval, /* ref count value for buffer */ - const struct xfs_buf_ops *ops); - /* * Initialise a new btree block header */ From patchwork Thu Feb 1 19:56:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13541756 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 676CC85286 for ; Thu, 1 Feb 2024 19:56:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706817381; cv=none; b=ljs9VMdxa7yW5gifvaX84uv02kQ/HYf/HvqA/0YkJPIeR48RHyrXDDStuKp9QG39XCBqem4m66H4nzv6xdJ/8kO/opPkphaGA+OOucP5oKMpT8M1wmKvJVuxkytohrbsnSylZTeZW9TR2DXHfWre9/DQ8R+xQ+omG17ET1c8K2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706817381; c=relaxed/simple; bh=6psr/O7SSM8ZuLIXXTCi3J4LVnVP1HaDmpuuo1TuXtI=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EdqJJr/PlQpkS3mVd6vcJx28JLBSIlq7xZ8bOBRJ78HV0IFurG726GpFv4j20RznOHLSM8nVx7Qr/ZZ7gRGcaQzMjr5yfMCsRA+NPmoPKI07vcDi8rnnREZJcHQxDrQRXa3Wdtl+v53rgOtE8wlS7wWbzv+7JSKPBXwPweiYqwY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hZ5J5vIU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hZ5J5vIU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 366E0C433F1; Thu, 1 Feb 2024 19:56:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706817381; bh=6psr/O7SSM8ZuLIXXTCi3J4LVnVP1HaDmpuuo1TuXtI=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=hZ5J5vIUM5rcLRY/aGnapowvRekvLm/KcqX3V/N5nwenYNdNCnXdJP9oV7em5Hh5j FsNFPmUPbEX8ESbb3WAG0qaOi43s51nuPVWCrs1sxEeeDsBKBu7CNiBseMoDj5hte6 M3fAyN8O9CAd02zEhAxeH0buXe/N5EoXmu/JdZ4pp2okjzX9FJ7YVgHwI80jumEsXn 1+dyqNRubni6S8leh2dxYsDWiZtLeVqh+cUC5VZWR1uali3mYV0CeV1JA1PK8ySrE8 rW8+HTmdDTzzn+hd9T2ze5uNUOTPNgrAMAq0xo/xsMiIaNqWI6nd/5zKm40hNbTHNd FQpp2sKueZwAg== Date: Thu, 01 Feb 2024 11:56:20 -0800 Subject: [PATCH 4/4] xfs: split xfs_buf_rele for cached vs uncached buffers From: "Darrick J. Wong" To: djwong@kernel.org Cc: Christoph Hellwig , hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <170681336195.1608096.7359208662047509867.stgit@frogsfrogsfrogs> In-Reply-To: <170681336120.1608096.10255376163152255295.stgit@frogsfrogsfrogs> References: <170681336120.1608096.10255376163152255295.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 xfs_buf_rele is a bit confusing because it mixes up handling of normal cached and the special uncached buffers without much explanation. Split the handling into two different helpers, and use a clearly named helper that checks the hash key to distinguish the two cases instead of checking the pag pointer. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- fs/xfs/xfs_buf.c | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index 8e5bd50d29feb..79a87fb399064 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -60,6 +60,11 @@ xfs_buf_submit( return __xfs_buf_submit(bp, !(bp->b_flags & XBF_ASYNC)); } +static inline bool xfs_buf_is_uncached(struct xfs_buf *bp) +{ + return bp->b_rhash_key == XFS_BUF_DADDR_NULL; +} + static inline int xfs_buf_is_vmapped( struct xfs_buf *bp) @@ -990,12 +995,19 @@ xfs_buf_hold( atomic_inc(&bp->b_hold); } -/* - * Release a hold on the specified buffer. If the hold count is 1, the buffer is - * placed on LRU or freed (depending on b_lru_ref). - */ -void -xfs_buf_rele( +static void +xfs_buf_rele_uncached( + struct xfs_buf *bp) +{ + ASSERT(list_empty(&bp->b_lru)); + if (atomic_dec_and_test(&bp->b_hold)) { + xfs_buf_ioacct_dec(bp); + xfs_buf_free(bp); + } +} + +static void +xfs_buf_rele_cached( struct xfs_buf *bp) { struct xfs_perag *pag = bp->b_pag; @@ -1004,15 +1016,6 @@ xfs_buf_rele( trace_xfs_buf_rele(bp, _RET_IP_); - if (!pag) { - ASSERT(list_empty(&bp->b_lru)); - if (atomic_dec_and_test(&bp->b_hold)) { - xfs_buf_ioacct_dec(bp); - xfs_buf_free(bp); - } - return; - } - ASSERT(atomic_read(&bp->b_hold) > 0); /* @@ -1080,6 +1083,19 @@ xfs_buf_rele( xfs_buf_free(bp); } +/* + * Release a hold on the specified buffer. + */ +void +xfs_buf_rele( + struct xfs_buf *bp) +{ + trace_xfs_buf_rele(bp, _RET_IP_); + if (xfs_buf_is_uncached(bp)) + xfs_buf_rele_uncached(bp); + else + xfs_buf_rele_cached(bp); +} /* * Lock a buffer object, if it is not already locked.