summaryrefslogtreecommitdiff
path: root/fs/xfs/libxfs
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2021-09-01 11:18:43 -0700
committerDarrick J. Wong <djwong@kernel.org>2021-10-22 16:41:08 -0700
commitc5750e66fc0a8af7e9e9a5180bb5dd1c0cb90808 (patch)
treef27069170c00700077fe59a7deb7c0b310e8d181 /fs/xfs/libxfs
parentc700bf855784c9fee4053a4f1b24ad199062795e (diff)
xfs: compute rtrmap btree max levels when reflink enabled
Compute the maximum possible height of the realtime rmap btree when reflink is enabled. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Diffstat (limited to 'fs/xfs/libxfs')
-rw-r--r--fs/xfs/libxfs/xfs_rtrmap_btree.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/xfs/libxfs/xfs_rtrmap_btree.c b/fs/xfs/libxfs/xfs_rtrmap_btree.c
index eca0211f1c1d..a1584784991e 100644
--- a/fs/xfs/libxfs/xfs_rtrmap_btree.c
+++ b/fs/xfs/libxfs/xfs_rtrmap_btree.c
@@ -594,9 +594,17 @@ xfs_rtrmapbt_compute_maxlevels(
* The realtime rmapbt lives on the data device, which means that its
* maximum height is constrained by the size of the data device and
* the height required to store one rmap record for each rt block.
+ *
+ * On a reflink filesystem, each rt block can have up to 2^32 (per the
+ * refcount record format) owners, which means that theoretically we
+ * could face up to 2^96 rmap records. This makes the computation of
+ * maxlevels based on record count meaningless, so we only consider the
+ * size of the data device.
*/
d_maxlevels = xfs_btree_compute_maxlevels_size(dblocks,
mp->m_rtrmap_mnr[1]);
+ if (xfs_has_rtreflink(mp))
+ return d_maxlevels + 1;
r_maxlevels = xfs_btree_compute_maxlevels(mp->m_rtrmap_mnr, rblocks);
/* Add one level to handle the inode root level. */