Blame SOURCES/xfsprogs-5.10.0-xfs_repair-Use-proper-min-max-values-in-compute_level_geometry.patch

48cf7c
xfs_repair: Use proper min/max values in compute_level_geometry
48cf7c
48cf7c
When compute_level_geometry was added it exclusively uses
48cf7c
m_alloc_mnr/m_alloc_mxr but the rmap btree should be using
48cf7c
m_rmap_mnr/m_rmap_mxr.  Pass those in directly to fix the
48cf7c
problem.
48cf7c
48cf7c
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
48cf7c
---
48cf7c
48cf7c
diff --git a/repair/phase5.c b/repair/phase5.c
48cf7c
index 0b8a55ff..dff342c8 100644
48cf7c
--- a/repair/phase5.c
48cf7c
+++ b/repair/phase5.c
48cf7c
@@ -355,12 +355,12 @@ compute_level_geometry(
48cf7c
 	struct bt_stat_level	*lptr,
48cf7c
 	uint64_t		nr_this_level,
48cf7c
 	int			slack,
48cf7c
-	bool			leaf)
48cf7c
+	uint			maxrecs,
48cf7c
+	uint			minrecs)
48cf7c
 {
48cf7c
-	unsigned int		maxrecs = mp->m_alloc_mxr[!leaf];
48cf7c
 	unsigned int		desired_npb;
48cf7c
 
48cf7c
-	desired_npb = max(mp->m_alloc_mnr[!leaf], maxrecs - slack);
48cf7c
+	desired_npb = max(minrecs, maxrecs - slack);
48cf7c
 	lptr->num_recs_tot = nr_this_level;
48cf7c
 	lptr->num_blocks = max(1ULL, nr_this_level / desired_npb);
48cf7c
 
48cf7c
@@ -410,7 +410,8 @@ calculate_freespace_cursor(xfs_mount_t *mp, xfs_agnumber_t agno,
48cf7c
 	 * of the tree and set up the cursor for the leaf level
48cf7c
 	 * (note that the same code is duplicated further down)
48cf7c
 	 */
48cf7c
-	compute_level_geometry(mp, lptr, num_extents, 2, true);
48cf7c
+	compute_level_geometry(mp, lptr, num_extents, 2,
48cf7c
+			mp->m_alloc_mxr[0], mp->m_alloc_mnr[0]);
48cf7c
 	level = 1;
48cf7c
 
48cf7c
 #ifdef XR_BLD_FREE_TRACE
48cf7c
@@ -429,7 +430,8 @@ calculate_freespace_cursor(xfs_mount_t *mp, xfs_agnumber_t agno,
48cf7c
 		lptr = &btree_curs->level[level];
48cf7c
 
48cf7c
 		compute_level_geometry(mp, lptr,
48cf7c
-				p_lptr->num_blocks, 0, false);
48cf7c
+				p_lptr->num_blocks, 0,
48cf7c
+				mp->m_alloc_mxr[1], mp->m_alloc_mnr[1]);
48cf7c
 #ifdef XR_BLD_FREE_TRACE
48cf7c
 		fprintf(stderr, "%s %d %d %d %d %d\n", __func__,
48cf7c
 				level,
48cf7c
@@ -509,7 +511,8 @@ calculate_freespace_cursor(xfs_mount_t *mp, xfs_agnumber_t agno,
48cf7c
 	 * of the number of extents changing
48cf7c
 	 */
48cf7c
 	old_blocks = btree_curs->level[0].num_blocks;
48cf7c
-	compute_level_geometry(mp, &btree_curs->level[0], num_extents, 2, true);
48cf7c
+	compute_level_geometry(mp, &btree_curs->level[0], num_extents, 2,
48cf7c
+				mp->m_alloc_mxr[0], mp->m_alloc_mnr[0]);
48cf7c
 	extra_blocks = 0;
48cf7c
 
48cf7c
 	if (old_blocks != btree_curs->level[0].num_blocks)  {
48cf7c
@@ -578,7 +581,8 @@ calculate_freespace_cursor(xfs_mount_t *mp, xfs_agnumber_t agno,
48cf7c
 			lptr = &btree_curs->level[level++];
48cf7c
 
48cf7c
 			compute_level_geometry(mp, lptr,
48cf7c
-					p_lptr->num_blocks, 0, false);
48cf7c
+					p_lptr->num_blocks, 0,
48cf7c
+					mp->m_alloc_mxr[1], mp->m_alloc_mnr[1]);
48cf7c
 		}
48cf7c
 		ASSERT(level < XFS_BTREE_MAXLEVELS);
48cf7c
 		ASSERT(lptr->num_blocks == 1);
48cf7c
@@ -1399,7 +1403,8 @@ init_rmapbt_cursor(
48cf7c
 	 * metadata AG entries without too many splits.
48cf7c
 	 */
48cf7c
 	compute_level_geometry(mp, lptr, num_recs,
48cf7c
-			num_recs > mp->m_rmap_mxr[0] ? 10 : 0, true);
48cf7c
+			num_recs > mp->m_rmap_mxr[0] ? 10 : 0,
48cf7c
+			mp->m_rmap_mxr[0], mp->m_rmap_mnr[0]);
48cf7c
 	blocks_allocated = lptr->num_blocks;
48cf7c
 	level = 1;
48cf7c
 
48cf7c
@@ -1408,7 +1413,8 @@ init_rmapbt_cursor(
48cf7c
 		lptr = &btree_curs->level[level++];
48cf7c
 
48cf7c
 		compute_level_geometry(mp, lptr,
48cf7c
-				p_lptr->num_blocks, 0, false);
48cf7c
+				p_lptr->num_blocks, 0,
48cf7c
+				mp->m_rmap_mxr[1], mp->m_rmap_mnr[1]);
48cf7c
 		blocks_allocated += lptr->num_blocks;
48cf7c
 	}
48cf7c
 	ASSERT(level < XFS_BTREE_MAXLEVELS);
48cf7c
48cf7c