Linux XFS filesystem development
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Andrey Albershteyn <aalbersh@kernel.org>
Cc: "Darrick J . Wong" <djwong@kernel.org>, linux-xfs@vger.kernel.org
Subject: [PATCH 17/32] xfs: prepare xfs_rtfile_initialize_blocks for larger than FSB blocks
Date: Thu, 24 Sep 2026 12:04:07 +0200	[thread overview]
Message-ID: <20260924100512.2733748-18-hch@lst.de> (raw)
In-Reply-To: <20260924100512.2733748-1-hch@lst.de>

Source kernel commit: e2ab369189d3a62e28b9f7a1de255a21bc8b1534

The upcoming RT data checksum feature will use larger than FSB blocks.
Prepare xfs_rtfile_initialize_blocks to pass the number of FSBs per
RT blocks, and to pass bmapi_flags to ask for contiguous allocation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 libxfs/xfs_rtbitmap.c | 44 +++++++++++++++++++++++++------------------
 libxfs/xfs_rtbitmap.h |  3 ++-
 2 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c
index 39a6b45d9526..3abc495c2a3c 100644
--- a/libxfs/xfs_rtbitmap.c
+++ b/libxfs/xfs_rtbitmap.c
@@ -1343,6 +1343,7 @@ xfs_rtfile_alloc_blocks(
 	struct xfs_inode	*ip,
 	xfs_fileoff_t		offset_fsb,
 	xfs_filblks_t		count_fsb,
+	uint32_t		bmapi_flags,
 	struct xfs_bmbt_irec	*map)
 {
 	struct xfs_mount	*mp = ip->i_mount;
@@ -1364,7 +1365,7 @@ xfs_rtfile_alloc_blocks(
 		goto out_trans_cancel;
 
 	error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb,
-			XFS_BMAPI_METADATA, 0, map, &nmap);
+			XFS_BMAPI_METADATA | bmapi_flags, 0, map, &nmap);
 	if (error)
 		goto out_trans_cancel;
 
@@ -1402,34 +1403,43 @@ xfs_rtfile_initialize_block(
 	struct xfs_rtgroup	*rtg,
 	enum xfs_rtg_inodes	type,
 	xfs_fsblock_t		fsbno,
-	void			*data)
+	xfs_filblks_t		nblks,
+	void			**data)
 {
 	struct xfs_mount	*mp = rtg_mount(rtg);
 	struct xfs_inode	*ip = rtg->rtg_inodes[type];
+	size_t			len = XFS_FSB_TO_B(mp, nblks);
+	size_t			copylen = len;
+	struct xfs_trans_res	tres = M_RES(mp)->tr_growrtzero;
 	struct xfs_trans	*tp;
 	struct xfs_buf		*bp;
-	const size_t		copylen = mp->m_blockwsize << XFS_WORDLOG;
 	int			error;
 
-	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_growrtzero, 0, 0, 0, &tp);
+	tres.tr_logres *= nblks;
+	error = xfs_trans_alloc(mp, &tres, 0, 0, 0, &tp);
 	if (error)
 		return error;
 	xfs_ilock(ip, XFS_ILOCK_EXCL);
 	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
 
 	error = xfs_trans_get_buf(tp, mp->m_ddev_targp,
-			XFS_FSB_TO_DADDR(mp, fsbno), mp->m_bsize, 0, &bp);
+			XFS_FSB_TO_DADDR(mp, fsbno), BTOBB(len), 0, &bp);
 	if (error) {
 		xfs_trans_cancel(tp);
 		return error;
 	}
 
+	if (xfs_has_rtgroups(mp))
+		copylen -= sizeof(struct xfs_rtbuf_blkinfo);
+
 	xfs_rtfile_initialize_buf(rtg, type, bp, tp);
-	if (data)
-		memcpy(xfs_rtblock_payload(bp), data, copylen);
-	else
+	if (*data) {
+		memcpy(xfs_rtblock_payload(bp), *data, copylen);
+		*data += copylen;
+	} else {
 		memset(xfs_rtblock_payload(bp), 0, copylen);
-	xfs_trans_log_buf(tp, bp, 0, mp->m_sb.sb_blocksize - 1);
+	}
+	xfs_trans_log_buf(tp, bp, 0, len - 1);
 	return xfs_trans_commit(tp);
 }
 
@@ -1444,33 +1454,31 @@ xfs_rtfile_initialize_blocks(
 	enum xfs_rtg_inodes	type,
 	xfs_fileoff_t		offset_fsb,	/* offset to start from */
 	xfs_fileoff_t		end_fsb,	/* offset to allocate to */
+	xfs_filblks_t		bsize,
+	uint32_t		bmapi_flags,
 	void			*data)		/* data to fill the blocks */
 {
-	struct xfs_mount	*mp = rtg_mount(rtg);
-	const size_t		copylen = mp->m_blockwsize << XFS_WORDLOG;
-
 	while (offset_fsb < end_fsb) {
 		struct xfs_bmbt_irec	map;
 		xfs_filblks_t		i;
 		int			error;
 
 		error = xfs_rtfile_alloc_blocks(rtg->rtg_inodes[type],
-				offset_fsb, end_fsb - offset_fsb, &map);
+				offset_fsb, end_fsb - offset_fsb, bmapi_flags,
+				&map);
 		if (error)
 			return error;
 
 		/*
-		 * Now we need to clear the allocated blocks.
+		 * Now we need to clear or initialize the allocated blocks.
 		 *
 		 * Do this one block per transaction, to keep it simple.
 		 */
-		for (i = 0; i < map.br_blockcount; i++) {
+		for (i = 0; i < map.br_blockcount; i += bsize) {
 			error = xfs_rtfile_initialize_block(rtg, type,
-					map.br_startblock + i, data);
+					map.br_startblock + i, bsize, &data);
 			if (error)
 				return error;
-			if (data)
-				data += copylen;
 		}
 
 		offset_fsb = map.br_startoff + map.br_blockcount;
diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h
index 750d74fbf4ed..e9e3378d15aa 100644
--- a/libxfs/xfs_rtbitmap.h
+++ b/libxfs/xfs_rtbitmap.h
@@ -410,7 +410,8 @@ void xfs_rtfile_initialize_buf(struct xfs_rtgroup *rtg,
 		struct xfs_trans *tp);
 int xfs_rtfile_initialize_blocks(struct xfs_rtgroup *rtg,
 		enum xfs_rtg_inodes type, xfs_fileoff_t offset_fsb,
-		xfs_fileoff_t end_fsb, void *data);
+		xfs_fileoff_t end_fsb, xfs_filblks_t bsize,
+		uint32_t bmapi_flags, void *data);
 int xfs_rtbitmap_create(struct xfs_rtgroup *rtg, struct xfs_inode *ip,
 		struct xfs_trans *tp, bool init);
 int xfs_rtsummary_create(struct xfs_rtgroup *rtg, struct xfs_inode *ip,
-- 
2.53.0


  parent reply	other threads:[~2026-09-24 10:06 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24 10:03 xfsprogs support for RT data checksums Christoph Hellwig
2026-09-24 10:03 ` [PATCH 01/32] man: fix alignment of the rtstart field in ioctl_xfs_fsgeometry.2 Christoph Hellwig
2026-09-24 20:30   ` Darrick J. Wong
2026-09-26  6:15     ` Christoph Hellwig
2026-09-29 10:14       ` Andrey Albershteyn
2026-09-24 10:03 ` [PATCH 02/32] add cpu_to_le64 and le64_to_cpu_helpers Christoph Hellwig
2026-09-24 20:30   ` Darrick J. Wong
2026-09-24 10:03 ` [PATCH 03/32] libfrog: add a crc64_nvme implementation Christoph Hellwig
2026-09-24 10:03 ` [PATCH 04/32] libxfs: add DIV_ROUND_UP_ULL Christoph Hellwig
2026-09-24 20:44   ` Darrick J. Wong
2026-09-25  6:13     ` Christoph Hellwig
2026-09-24 10:03 ` [PATCH 05/32] libxfs: remove a spurious xfs_rtbitmap.h include in xfs_sb.c Christoph Hellwig
2026-09-25 23:27   ` Darrick J. Wong
2026-09-24 10:03 ` [PATCH 06/32] libxfs: add SZ_* constants Christoph Hellwig
2026-09-25 23:27   ` Darrick J. Wong
2026-09-24 10:03 ` [PATCH 07/32] xfs: remove spurious XBF_DONE clearing on readahead validation failure Christoph Hellwig
2026-09-24 10:03 ` [PATCH 08/32] xfs: hide b_flags manipulation from code outside of xfs_buf.c Christoph Hellwig
2026-09-24 10:03 ` [PATCH 09/32] FIXUP Christoph Hellwig
2026-09-25 23:29   ` Darrick J. Wong
2026-09-26  6:17     ` Christoph Hellwig
2026-09-24 10:04 ` [PATCH 10/32] xfs: add error injection for lazy bounce buffering Christoph Hellwig
2026-09-24 10:04 ` [PATCH 11/32] xfs: add xfs_daddr_to_rgno and xfs_daddr_to_rgbno helpers Christoph Hellwig
2026-09-24 10:04 ` [PATCH 12/32] FIXUP Christoph Hellwig
2026-09-24 10:04 ` [PATCH 13/32] xfs: introduce XFS_BLI_PREALLOC Christoph Hellwig
2026-09-24 10:04 ` [PATCH 14/32] xfs: centralize setting of buf_ops/buf_type/magic for rtblocks Christoph Hellwig
2026-09-24 10:04 ` [PATCH 15/32] xfs: factor out a xfs_rtfile_initialize_buf helper Christoph Hellwig
2026-09-24 10:04 ` [PATCH 16/32] xfs: add a xfs_rtblock_payload helper Christoph Hellwig
2026-09-24 10:04 ` Christoph Hellwig [this message]
2026-09-24 10:04 ` [PATCH 18/32] FIXUP Christoph Hellwig
2026-09-24 10:04 ` [PATCH 19/32] xfs: define the RT data checksum on-disk format Christoph Hellwig
2026-09-24 10:04 ` [PATCH 20/32] FIXUP Christoph Hellwig
2026-09-24 10:04 ` [PATCH 21/32] xfs: add support for per-RTG csum files Christoph Hellwig
2026-09-24 10:04 ` [PATCH 22/32] FIXUP Christoph Hellwig
2026-09-24 10:04 ` [PATCH 23/32] xfs: calculate the log reservation for logging data checksum buffers Christoph Hellwig
2026-09-24 10:04 ` [PATCH 24/32] xfs: report RT data checksum information via XFS_FSOP_GEOM Christoph Hellwig
2026-09-24 10:04 ` [PATCH 25/32] xfs: enable RT data checksums Christoph Hellwig
2026-09-24 10:04 ` [PATCH 26/32] man: document the rtcsum geom fields Christoph Hellwig
2026-09-25 23:31   ` Darrick J. Wong
2026-09-26  6:17     ` Christoph Hellwig
2026-09-24 10:04 ` [PATCH 27/32] libfrog: print csum geometry information Christoph Hellwig
2026-09-25 23:32   ` Darrick J. Wong
2026-09-24 10:04 ` [PATCH 28/32] xfs_io: report checksum information from fs geometry in statfs Christoph Hellwig
2026-09-25 23:33   ` Darrick J. Wong
2026-09-26  6:18     ` Christoph Hellwig
2026-09-24 10:04 ` [PATCH 29/32] mkfs: support RT data checksums Christoph Hellwig
2026-09-25 23:39   ` Darrick J. Wong
2026-09-26  6:19     ` Christoph Hellwig
2026-09-24 10:04 ` [PATCH 30/32] xfs_db: support RT data checksum Christoph Hellwig
2026-09-25 23:43   ` Darrick J. Wong
2026-09-26  6:21     ` Christoph Hellwig
2026-09-26 18:20       ` Darrick J. Wong
2026-09-24 10:04 ` [PATCH 31/32] repair: support RT data checksums Christoph Hellwig
2026-09-25 23:54   ` Darrick J. Wong
2026-09-26  6:23     ` Christoph Hellwig
2026-09-27  0:01       ` Darrick J. Wong
2026-09-24 10:04 ` [PATCH 32/32] xfs_scrub: don't merge over unused space when data checksums are enabled Christoph Hellwig
2026-09-25 23:51   ` Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260924100512.2733748-18-hch@lst.de \
    --to=hch@lst.de \
    --cc=aalbersh@kernel.org \
    --cc=djwong@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox