Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.137.202.133 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793782805; b=zzC2TPIeLLknHwjG/yY1EKlDkqxBj1JtoXqxiTniMN3dO0FHfQwFmAK2Fs9tXFAlUL5o K0YmqRrBGejklXr6FH8/cuF+Sev2LoBd2tjfZ6z5DkncbNlV9iwD86fB9OSesUS3vezUc c++deN1C15K1AqR6o+0bS3AWlsjgog1baH0bnKtVpIQqChW34gWJJ/7MkCNMNlOBl1Lz5 9zYtMVHdWWRxWk496/CuW/N2s68dz/4wXZit8Ci+YCz+mv0uKP9uClc05yNI86YEQoKoL mG1/PhQOah+JGt60ccN4B9VlU+Joxl8R9hKEAUYTKulDPAtvQcl8B+KoBF7mwqnQlTQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793782805; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-SRS-Rewrite; bh=wnuKEgDG/0SJqbQOEdMhJXZ34HOUsQg2ABt9OtV0o3o=; b=qX2n3p/epfMdpU91AXahEU8GoP6LFNs4TQcwQpHL6OA3mwxWoZm9nhd55PCv491rSIjG rJAUz6748w1pYs4qgcfInwCnjNKiJ4RndK094EP1otccGuGTv8OPeDoWXCZm/NkA7wMvE Io30I+l3eCClDMPG7kWw6YZr1xfqHglDyYAVMQZ+cV1Q23NiA0XA3/eELPPnZZ1avE+xn sdwe78+wS2pOHiJfGOsz5O9TOgOXWBleVmWxtipPj0EwVeDCKpm0AkLdWOv0P8hrMRrH/ p8LFBk/7wQNNbc9kJ+VlEspHRawYq55pnmsOlJJX3Hd8zkzCEIQu/KK6YFWlqdw/idw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b="nTxBoYZ/"; arc=none smtp.remote-ip=198.137.202.133 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97C48606A32D; Wed, 4 Nov 2026 09:00:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 97C48606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=nTxBoYZ/ DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=wnuKEgDG/0SJqbQOEdMhJXZ34HOUsQg2ABt9OtV0o3o=; b=nTxBoYZ/Su7PUVGU+Rhwfsxo4R aUMjdmdzl68Wa3HN88873xx3Zx7nZm3WrEZOvLrAbj1e+8fkYI+AuKoYJuW14+94qMIB87NWjdX3G /RnVSvWYG6aN5wJfO+4LNkVk689bROVzTl7ngFK1bGL2Wk7NiztZmU4KhOHHMv1rpIWmyk+/Bjl61 9V7m+zmzb07EJf00B1otOAprZveRgPKt2FvpFZtLXpzWZ09Yc78mjM1q+oGNFzKKyENQXtkUa+M70 IPwAp82ob8EexS+ylMGF4oYBopk31hwK6VVmWES/p/zFgj2kLSsfAlmOodkh5yiS1xeGFoiBCRFCb 7yaFTAPw==; Received: from 2a02-8389-2301-9f00-31e8-efb6-e973-61ca.cable.dynamic.v6.surfer.at ([2a02:8389:2301:9f00:31e8:efb6:e973:61ca] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.100.1 #2 (Red Hat Linux)) id 1xOWqi-00000004oPF-031C; Wed, 04 Nov 2026 09:00:04 +0000 From: Christoph Hellwig To: Carlos Maiolino Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 11/25] xfs: add support for per-RTG csum files Date: Wed, 4 Nov 2026 09:57:15 +0100 Message-ID: <20261104085929.317544-12-hch@lst.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261104085929.317544-1-hch@lst.de> References: <20261104085929.317544-1-hch@lst.de> X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Add the definitions for another per-RTG file that stores data checksums for the RTG. The file is fully preallocated at mkfs/growfs time, and thus bmap lookups for it can be performed without taking locks. Checksums are organized in fixed size large (initially 32Kib or 64KiB) blocks to reduce the lookup and read overhead compare to using the smaller file system block size. Each block uses the standard RT file header for self-describing metadata and can thus reuse the buf_ops including the verifier. Signed-off-by: Christoph Hellwig --- fs/xfs/Makefile | 1 + fs/xfs/libxfs/xfs_cksum.h | 7 +- fs/xfs/libxfs/xfs_fs.h | 1 + fs/xfs/libxfs/xfs_health.h | 4 +- fs/xfs/libxfs/xfs_rtbitmap.c | 10 +++ fs/xfs/libxfs/xfs_rtcsumfile.c | 95 +++++++++++++++++++++ fs/xfs/libxfs/xfs_rtcsumfile.h | 150 +++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_rtgroup.c | 10 +++ fs/xfs/libxfs/xfs_rtgroup.h | 6 ++ fs/xfs/libxfs/xfs_shared.h | 1 + fs/xfs/xfs_buf_item_recover.c | 10 ++- fs/xfs/xfs_health.c | 1 + fs/xfs/xfs_platform.h | 1 + fs/xfs/xfs_rtalloc.c | 7 ++ 14 files changed, 301 insertions(+), 3 deletions(-) create mode 100644 fs/xfs/libxfs/xfs_rtcsumfile.c create mode 100644 fs/xfs/libxfs/xfs_rtcsumfile.h diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile index 399a207f2d0e..79ea4136fbba 100644 --- a/fs/xfs/Makefile +++ b/fs/xfs/Makefile @@ -64,6 +64,7 @@ xfs-y += $(addprefix libxfs/, \ xfs-$(CONFIG_XFS_RT) += $(addprefix libxfs/, \ xfs_rtbitmap.o \ xfs_rtgroup.o \ + xfs_rtcsumfile.o \ xfs_zones.o \ ) diff --git a/fs/xfs/libxfs/xfs_cksum.h b/fs/xfs/libxfs/xfs_cksum.h index 999a290cfd72..315b85ff78ae 100644 --- a/fs/xfs/libxfs/xfs_cksum.h +++ b/fs/xfs/libxfs/xfs_cksum.h @@ -2,7 +2,12 @@ #ifndef _XFS_CKSUM_H #define _XFS_CKSUM_H 1 -#define XFS_CRC_SEED (~(uint32_t)0) +/* + * crc32c() does not include the inversion at the beginning and end, while + * crc64_nvme() does. + */ +#define XFS_CRC_SEED (~(uint32_t)0) +#define XFS_CRC64_SEED 0 /* * Calculate the intermediate checksum for a buffer that has the CRC field diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index 185f09f327c0..226cb96dfae8 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -1003,6 +1003,7 @@ struct xfs_rtgroup_geometry { #define XFS_RTGROUP_GEOM_SICK_SUMMARY (1U << 2) /* rtsummary */ #define XFS_RTGROUP_GEOM_SICK_RMAPBT (1U << 3) /* reverse mappings */ #define XFS_RTGROUP_GEOM_SICK_REFCNTBT (1U << 4) /* reference counts */ +#define XFS_RTGROUP_GEOM_SICK_CSUM (1U << 5) /* data csums */ #define XFS_RTGROUP_GEOM_WRITEPOINTER (1U << 0) /* write pointer */ diff --git a/fs/xfs/libxfs/xfs_health.h b/fs/xfs/libxfs/xfs_health.h index 1d45cf5789e8..349093e75268 100644 --- a/fs/xfs/libxfs/xfs_health.h +++ b/fs/xfs/libxfs/xfs_health.h @@ -72,6 +72,7 @@ struct xfs_rtgroup; #define XFS_SICK_RG_SUMMARY (1 << 2) /* rt groups summary */ #define XFS_SICK_RG_RMAPBT (1 << 3) /* reverse mappings */ #define XFS_SICK_RG_REFCNTBT (1 << 4) /* reference counts */ +#define XFS_SICK_RG_CSUM (1 << 5) /* data checksums */ /* Observable health issues for AG metadata. */ #define XFS_SICK_AG_SB (1 << 0) /* superblock */ @@ -119,7 +120,8 @@ struct xfs_rtgroup; XFS_SICK_RG_BITMAP | \ XFS_SICK_RG_SUMMARY | \ XFS_SICK_RG_RMAPBT | \ - XFS_SICK_RG_REFCNTBT) + XFS_SICK_RG_REFCNTBT | \ + XFS_SICK_RG_CSUM) #define XFS_SICK_AG_PRIMARY (XFS_SICK_AG_SB | \ XFS_SICK_AG_AGF | \ diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c index c83d7f961f40..edf7b6e88c7c 100644 --- a/fs/xfs/libxfs/xfs_rtbitmap.c +++ b/fs/xfs/libxfs/xfs_rtbitmap.c @@ -124,9 +124,18 @@ const struct xfs_buf_ops xfs_rtsummary_buf_ops = { .verify_struct = xfs_rtbuf_verify, }; +const struct xfs_buf_ops xfs_rtcsum_buf_ops = { + .name = "xfs_rtcsum", + .magic = { 0, cpu_to_be32(XFS_RTCSUM_MAGIC) }, + .verify_read = xfs_rtbuf_verify_read, + .verify_write = xfs_rtbuf_verify_write, + .verify_struct = xfs_rtbuf_verify, +}; + static const struct xfs_buf_ops *xfs_rtblock_buf_ops[XFS_RTGI_MAX] = { [XFS_RTGI_SUMMARY] = &xfs_rtsummary_buf_ops, [XFS_RTGI_BITMAP] = &xfs_rtbitmap_buf_ops, + [XFS_RTGI_CSUM] = &xfs_rtcsum_buf_ops, }; const struct xfs_buf_ops * @@ -142,6 +151,7 @@ xfs_rtblock_ops( static enum xfs_blft xfs_rtblock_buf_types[XFS_RTGI_MAX] = { [XFS_RTGI_SUMMARY] = XFS_BLFT_RTSUMMARY_BUF, [XFS_RTGI_BITMAP] = XFS_BLFT_RTBITMAP_BUF, + [XFS_RTGI_CSUM] = XFS_BLFT_RTCSUM_BUF, }; /* Release cached rt bitmap and summary buffers. */ diff --git a/fs/xfs/libxfs/xfs_rtcsumfile.c b/fs/xfs/libxfs/xfs_rtcsumfile.c new file mode 100644 index 000000000000..076ff12ed5cd --- /dev/null +++ b/fs/xfs/libxfs/xfs_rtcsumfile.c @@ -0,0 +1,95 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2026 Christoph Hellwig. + */ +#include "xfs_platform.h" +#include "xfs_fs.h" +#include "xfs_format.h" +#include "xfs_log_format.h" +#include "xfs_shared.h" +#include "xfs_trans_resv.h" +#include "xfs_bit.h" +#include "xfs_mount.h" +#include "xfs_inode.h" +#include "xfs_bmap.h" +#include "xfs_rtbitmap.h" +#include "xfs_bmap_btree.h" +#include "xfs_trans.h" +#include "xfs_error.h" +#include "xfs_health.h" +#include "xfs_rtcsumfile.h" + +int +xfs_rtcsum_bmap( + struct xfs_rtgroup *rtg, + xfs_rgblock_t rgbno, + xfs_daddr_t *daddr) +{ + struct xfs_mount *mp = rtg_mount(rtg); + struct xfs_inode *csumip = rtg_csum(rtg); + struct xfs_ifork *ifp = &csumip->i_df; + unsigned int csum_block = + xfs_rgbno_to_rtcsumblock(mp, rgbno); + xfs_fileoff_t start_fsb = + XFS_B_TO_FSB(mp, mp->m_rtcsum_bsize) * csum_block; + struct xfs_iext_cursor icur; + struct xfs_bmbt_irec got; + + ASSERT(!xfs_need_iread_extents(ifp)); + + if (XFS_IS_CORRUPT(mp, ifp->if_nextents != 1)) + goto sick; + + /* + * We can do an unlocked lookup here because the bmap btree for the + * csum files is immutable once created. + */ + if (XFS_IS_CORRUPT(mp, !xfs_iext_lookup_extent(csumip, ifp, start_fsb, + &icur, &got))) + goto sick; + if (XFS_IS_CORRUPT(mp, got.br_startoff > start_fsb)) + goto sick; + + start_fsb -= got.br_startoff; + *daddr = XFS_FSB_TO_DADDR(mp, got.br_startblock + start_fsb); + return 0; +sick: + xfs_rtginode_mark_sick(rtg, XFS_RTGI_CSUM); + return -EFSCORRUPTED; +} + +xfs_off_t +xfs_rtcsum_file_size( + struct xfs_rtgroup *rtg) +{ + struct xfs_mount *mp = rtg_mount(rtg); + uint64_t raw_size; + + raw_size = (xfs_off_t)rtg_blocks(rtg) << mp->m_rtcsum_shift; + return DIV_ROUND_UP_ULL(raw_size, xfs_rtcsum_payload_size(mp)) * + mp->m_rtcsum_bsize; +} + +int +xfs_rtcsum_alloc_blocks( + struct xfs_rtgroup *rtg) +{ + struct xfs_mount *mp = rtg_mount(rtg); + + return xfs_rtfile_initialize_blocks(rtg, XFS_RTGI_CSUM, 0, + XFS_B_TO_FSB(mp, rtg_csum(rtg)->i_disk_size), + XFS_B_TO_FSB(mp, mp->m_rtcsum_bsize), + XFS_BMAPI_CONTIG, NULL); +} + +int +xfs_rtcsum_create( + struct xfs_rtgroup *rtg, + struct xfs_inode *ip, + struct xfs_trans *tp, + bool init) +{ + ip->i_disk_size = xfs_rtcsum_file_size(rtg); + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); + return 0; +} diff --git a/fs/xfs/libxfs/xfs_rtcsumfile.h b/fs/xfs/libxfs/xfs_rtcsumfile.h new file mode 100644 index 000000000000..a01121761faf --- /dev/null +++ b/fs/xfs/libxfs/xfs_rtcsumfile.h @@ -0,0 +1,150 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _XFS_RTCSUMFILE_H +#define _XFS_RTCSUMFILE_H + +#include "xfs_rtgroup.h" + +/* + * Maximum size of a checksum buffer for writes, used for the log reservation. + */ +#define XFS_RTCSUM_MAX_WRITE SZ_64K + +/* + * Size of the actual payload in the RT data checksum block. This excludes the + * self-describing metadata header. + */ +static inline unsigned int +xfs_rtcsum_payload_size( + struct xfs_mount *mp) +{ + return mp->m_rtcsum_bsize - sizeof(struct xfs_rtbuf_blkinfo); +} + +/* Convert data length in logical blocks to checksum length in bytes. */ +static inline unsigned int +xfs_extlen_to_rtcsum_len( + struct xfs_mount *mp, + xfs_extlen_t nb) +{ + return nb << mp->m_rtcsum_shift; +} + +/* Convert checksum length in bytes to data length in logical blocks. */ +static inline xfs_extlen_t +xfs_rtcsum_len_to_extlen( + struct xfs_mount *mp, + unsigned int csum_len) +{ + return csum_len >> mp->m_rtcsum_shift; +} + +/* Convert an rgbno to the csum byte position in the csum file. */ +static inline xfs_off_t +xfs_rgbno_to_rtcsumpos( + struct xfs_mount *mp, + xfs_rgblock_t rgbno) +{ + return (xfs_off_t)rgbno << mp->m_rtcsum_shift; +} + +/* Convert an rgbno to the csum block index in the csum file. */ +static inline unsigned int +xfs_rgbno_to_rtcsumblock( + struct xfs_mount *mp, + xfs_rgblock_t rgbno) +{ + return div_u64(xfs_rgbno_to_rtcsumpos(mp, rgbno), + xfs_rtcsum_payload_size(mp)); +} + +/* Convert an rgbno to a the checksum offset within an rt csum block. */ +static inline unsigned int +xfs_rgbno_to_rtcsumoff( + struct xfs_mount *mp, + xfs_rgblock_t rgbno) +{ + uint32_t off; + + div_u64_rem(xfs_rgbno_to_rtcsumpos(mp, rgbno), + xfs_rtcsum_payload_size(mp), &off); + return sizeof(struct xfs_rtbuf_blkinfo) + off; +} + +/* Convert an rtbno to a the checksum offset within an rt csum block. */ +static inline unsigned int +xfs_rtb_to_rtcsumoff( + struct xfs_mount *mp, + xfs_rtblock_t fsbno) +{ + return xfs_rgbno_to_rtcsumoff(mp, xfs_rtb_to_rgbno(mp, fsbno)); +} + +int xfs_rtcsum_bmap(struct xfs_rtgroup *rtg, xfs_rgblock_t rgbno, + xfs_daddr_t *daddr); +xfs_off_t xfs_rtcsum_file_size(struct xfs_rtgroup *rtg); +int xfs_rtcsum_alloc_blocks(struct xfs_rtgroup *rtg); +int xfs_rtcsum_create(struct xfs_rtgroup *rtg, struct xfs_inode *ip, + struct xfs_trans *tp, bool init); + +static inline unsigned int +xfs_rtcsum_bufs_per_rtg( + struct xfs_rtgroup *rtg) +{ + struct xfs_mount *mp = rtg_mount(rtg); + + if (xfs_has_rtcsum(mp)) + return div_u64(xfs_rtcsum_file_size(rtg), mp->m_rtcsum_bsize); + return 0; +} + +static inline xfs_filblks_t +xfs_rtcsum_max_len( + struct xfs_mount *mp, + xfs_fsblock_t fsbno) +{ + return xfs_rtcsum_len_to_extlen(mp, + mp->m_rtcsum_bsize - xfs_rtb_to_rtcsumoff(mp, fsbno)); +} + +union xfs_csum { + uint32_t crc32c; + uint64_t crc64; +}; + +static __always_inline void +xfs_csum_seed( + struct xfs_mount *mp, + union xfs_csum *csum) +{ + if (mp->m_sb.sb_rtcsum_type == XFS_CSUM_TYPE_CRC32C) + csum->crc32c = XFS_CRC_SEED; + else + csum->crc64 = XFS_CRC64_SEED; +} + +static __always_inline void +xfs_csum_gen( + struct xfs_mount *mp, + void *data, + unsigned int len, + union xfs_csum *csum) +{ + if (mp->m_sb.sb_rtcsum_type == XFS_CSUM_TYPE_CRC32C) + csum->crc32c = crc32c(csum->crc32c, data, len); + else + csum->crc64 = crc64_nvme(csum->crc64, data, len); +} + +static __always_inline void +xfs_csum_finalize( + struct xfs_mount *mp, + union xfs_disk_csum *to, + union xfs_csum *csum) +{ + if (mp->m_sb.sb_rtcsum_type == XFS_CSUM_TYPE_CRC32C) + to->crc32c = cpu_to_le32(~csum->crc32c); + else + to->crc64 = cpu_to_le64(csum->crc64); +} + +#endif /* _XFS_RTCSUMFILE_H */ diff --git a/fs/xfs/libxfs/xfs_rtgroup.c b/fs/xfs/libxfs/xfs_rtgroup.c index 91961fb85aff..4864adf6f59e 100644 --- a/fs/xfs/libxfs/xfs_rtgroup.c +++ b/fs/xfs/libxfs/xfs_rtgroup.c @@ -34,6 +34,7 @@ #include "xfs_metadir.h" #include "xfs_rtrmap_btree.h" #include "xfs_rtrefcount_btree.h" +#include "xfs_rtcsumfile.h" /* Find the first usable fsblock in this rtgroup. */ static inline uint32_t @@ -399,6 +400,15 @@ static const struct xfs_rtginode_ops xfs_rtginode_ops[XFS_RTGI_MAX] = { .enabled = xfs_has_reflink, .create = xfs_rtrefcountbt_create, }, + [XFS_RTGI_CSUM] = { + .name = "csum", + .metafile_type = XFS_METAFILE_RTCSUM, + .sick = XFS_SICK_RG_CSUM, + .fmt_mask = (1U << XFS_DINODE_FMT_EXTENTS) | + (1U << XFS_DINODE_FMT_BTREE), + .enabled = xfs_has_rtcsum, + .create = xfs_rtcsum_create, + }, }; /* Return the shortname of this rtgroup inode. */ diff --git a/fs/xfs/libxfs/xfs_rtgroup.h b/fs/xfs/libxfs/xfs_rtgroup.h index f26e324f0de3..5cca0f4dd25a 100644 --- a/fs/xfs/libxfs/xfs_rtgroup.h +++ b/fs/xfs/libxfs/xfs_rtgroup.h @@ -16,6 +16,7 @@ enum xfs_rtg_inodes { XFS_RTGI_SUMMARY, /* allocation summary */ XFS_RTGI_RMAP, /* rmap btree inode */ XFS_RTGI_REFCOUNT, /* refcount btree inode */ + XFS_RTGI_CSUM, /* data checksum inode */ XFS_RTGI_MAX, }; @@ -109,6 +110,11 @@ static inline struct xfs_inode *rtg_refcount(const struct xfs_rtgroup *rtg) return rtg->rtg_inodes[XFS_RTGI_REFCOUNT]; } +static inline struct xfs_inode *rtg_csum(const struct xfs_rtgroup *rtg) +{ + return rtg->rtg_inodes[XFS_RTGI_CSUM]; +} + /* Passive rtgroup references */ static inline struct xfs_rtgroup * xfs_rtgroup_get( diff --git a/fs/xfs/libxfs/xfs_shared.h b/fs/xfs/libxfs/xfs_shared.h index b1e0d9bc1f7d..8a60f2c56fe7 100644 --- a/fs/xfs/libxfs/xfs_shared.h +++ b/fs/xfs/libxfs/xfs_shared.h @@ -40,6 +40,7 @@ extern const struct xfs_buf_ops xfs_refcountbt_buf_ops; extern const struct xfs_buf_ops xfs_rmapbt_buf_ops; extern const struct xfs_buf_ops xfs_rtbitmap_buf_ops; extern const struct xfs_buf_ops xfs_rtsummary_buf_ops; +extern const struct xfs_buf_ops xfs_rtcsum_buf_ops; extern const struct xfs_buf_ops xfs_rtbuf_ops; extern const struct xfs_buf_ops xfs_rtsb_buf_ops; extern const struct xfs_buf_ops xfs_rtrefcountbt_buf_ops; diff --git a/fs/xfs/xfs_buf_item_recover.c b/fs/xfs/xfs_buf_item_recover.c index 57929f115055..28fd1f358ba2 100644 --- a/fs/xfs/xfs_buf_item_recover.c +++ b/fs/xfs/xfs_buf_item_recover.c @@ -414,6 +414,13 @@ xlog_recover_validate_buf_type( } bp->b_ops = xfs_rtblock_ops(mp, XFS_RTGI_SUMMARY); break; + case XFS_BLFT_RTCSUM_BUF: + if (xfs_has_rtgroups(mp) && magic32 != XFS_RTCSUM_MAGIC) { + warnmsg = "Bad rtcsum magic!"; + break; + } + bp->b_ops = &xfs_rtcsum_buf_ops; + break; #endif /* CONFIG_XFS_RT */ default: xfs_warn(mp, "Unknown buffer type %d!", @@ -869,7 +876,8 @@ xlog_recover_get_buf_lsn( magic32 = be32_to_cpu(*(__be32 *)blk); switch (magic32) { case XFS_RTSUMMARY_MAGIC: - case XFS_RTBITMAP_MAGIC: { + case XFS_RTBITMAP_MAGIC: + case XFS_RTCSUM_MAGIC: { struct xfs_rtbuf_blkinfo *hdr = blk; lsn = be64_to_cpu(hdr->rt_lsn); diff --git a/fs/xfs/xfs_health.c b/fs/xfs/xfs_health.c index 239b843e83d4..dec452b5b15f 100644 --- a/fs/xfs/xfs_health.c +++ b/fs/xfs/xfs_health.c @@ -571,6 +571,7 @@ static const struct ioctl_sick_map rtgroup_map[] = { { XFS_SICK_RG_SUMMARY, XFS_RTGROUP_GEOM_SICK_SUMMARY }, { XFS_SICK_RG_RMAPBT, XFS_RTGROUP_GEOM_SICK_RMAPBT }, { XFS_SICK_RG_REFCNTBT, XFS_RTGROUP_GEOM_SICK_REFCNTBT }, + { XFS_SICK_RG_CSUM, XFS_RTGROUP_GEOM_SICK_CSUM }, }; /* Fill out rtgroup geometry health info. */ diff --git a/fs/xfs/xfs_platform.h b/fs/xfs/xfs_platform.h index 981488778ccc..2c52b004e82b 100644 --- a/fs/xfs/xfs_platform.h +++ b/fs/xfs/xfs_platform.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 78a1c066c7eb..e2b6113772b6 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c @@ -32,6 +32,7 @@ #include "xfs_error.h" #include "xfs_trace.h" #include "xfs_rtrefcount_btree.h" +#include "xfs_rtcsumfile.h" #include "xfs_reflink.h" #include "xfs_zone_alloc.h" @@ -898,6 +899,12 @@ xfs_growfs_rt_zoned( xfs_rtbxlen_t freed_rtx; int error; + if (xfs_has_rtcsum(mp)) { + error = xfs_rtcsum_alloc_blocks(rtg); + if (error) + return error; + } + /* * Calculate new sb and mount fields for this round. Also ensure the * rtg_extents value is uptodate as the rtbitmap code relies on it. -- 2.53.0