Blame SOURCES/xfsprogs-4.20-xfs_repair-initialize-non-leaf-finobt-blocks-with-co.patch

3bd5a4
From 051dae5efb4fc7c1c47ccb72ff161241fb0815ee Mon Sep 17 00:00:00 2001
3bd5a4
From: Brian Foster <bfoster@redhat.com>
3bd5a4
Date: Mon, 28 Jan 2019 16:05:16 -0600
3bd5a4
Subject: [PATCH] xfs_repair: initialize non-leaf finobt blocks with correct magic
3bd5a4
3bd5a4
The free inode btree construction code in xfs_repair has a bug where
3bd5a4
any non-leaf nodes outside of the leftmost block at the associated
3bd5a4
level in the tree are incorrectly initialized with the inobt magic
3bd5a4
value. Update the prop_ino_cursor() path responsible for growing the
3bd5a4
non-leaf portion of the inode btrees to use the btnum of the
3bd5a4
specific tree being generated rather than the hardcoded inode btree
3bd5a4
type.
3bd5a4
3bd5a4
Signed-off-by: Brian Foster <bfoster@redhat.com>
3bd5a4
Reported-by: Lucas Stach <l.stach@pengutronix.de>
3bd5a4
Root-caused-by: Lucas Stach <l.stach@pengutronix.de>
3bd5a4
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
3bd5a4
Reviewed-by: Dave Chinner <dchinner@redhat.com>
3bd5a4
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
3bd5a4
---
3bd5a4
3bd5a4
(backported for RHEL7)
3bd5a4
3bd5a4
--- xfsprogs-4.5.0/repair/phase5.c	2016-02-28 17:39:26.000000000 -0600
3bd5a4
+++ xfsprogs-4.5.0-mine/repair/phase5.c	2019-02-05 11:18:28.046228329 -0600
3bd5a4
@@ -1003,7 +1003,7 @@ init_ino_cursor(xfs_mount_t *mp, xfs_agn
3bd5a4
 
3bd5a4
 static void
3bd5a4
 prop_ino_cursor(xfs_mount_t *mp, xfs_agnumber_t agno, bt_status_t *btree_curs,
3bd5a4
-	xfs_agino_t startino, int level)
3bd5a4
+	__uint32_t magic, xfs_agino_t startino, int level)
3bd5a4
 {
3bd5a4
 	struct xfs_btree_block	*bt_hdr;
3bd5a4
 	xfs_inobt_key_t		*bt_key;
3bd5a4
@@ -1025,7 +1025,7 @@ prop_ino_cursor(xfs_mount_t *mp, xfs_agn
3bd5a4
 		 * first path up the left side of the tree
3bd5a4
 		 * where the agbno's are already set up
3bd5a4
 		 */
3bd5a4
-		prop_ino_cursor(mp, agno, btree_curs, startino, level);
3bd5a4
+		prop_ino_cursor(mp, agno, btree_curs, magic, startino, level);
3bd5a4
 	}
3bd5a4
 
3bd5a4
 	if (be16_to_cpu(bt_hdr->bb_numrecs) ==
3bd5a4
@@ -1062,11 +1062,11 @@ prop_ino_cursor(xfs_mount_t *mp, xfs_agn
3bd5a4
 		bt_hdr = XFS_BUF_TO_BLOCK(lptr->buf_p);
3bd5a4
 		memset(bt_hdr, 0, mp->m_sb.sb_blocksize);
3bd5a4
 		if (xfs_sb_version_hascrc(&mp->m_sb))
3bd5a4
-			xfs_btree_init_block(mp, lptr->buf_p, XFS_IBT_CRC_MAGIC,
3bd5a4
+			xfs_btree_init_block(mp, lptr->buf_p, magic,
3bd5a4
 						level, 0, agno,
3bd5a4
 						XFS_BTREE_CRC_BLOCKS);
3bd5a4
 		else
3bd5a4
-			xfs_btree_init_block(mp, lptr->buf_p, XFS_IBT_MAGIC,
3bd5a4
+			xfs_btree_init_block(mp, lptr->buf_p, magic,
3bd5a4
 						level, 0, agno, 0);
3bd5a4
 
3bd5a4
 		bt_hdr->bb_u.s.bb_leftsib = cpu_to_be32(lptr->prev_agbno);
3bd5a4
@@ -1074,7 +1074,7 @@ prop_ino_cursor(xfs_mount_t *mp, xfs_agn
3bd5a4
 		/*
3bd5a4
 		 * propagate extent record for first extent in new block up
3bd5a4
 		 */
3bd5a4
-		prop_ino_cursor(mp, agno, btree_curs, startino, level);
3bd5a4
+		prop_ino_cursor(mp, agno, btree_curs, magic, startino, level);
3bd5a4
 	}
3bd5a4
 	/*
3bd5a4
 	 * add inode info to current block
3bd5a4
@@ -1236,7 +1236,7 @@ build_ino_tree(xfs_mount_t *mp, xfs_agnu
3bd5a4
 			lptr->modulo--;
3bd5a4
 
3bd5a4
 		if (lptr->num_recs_pb > 0)
3bd5a4
-			prop_ino_cursor(mp, agno, btree_curs,
3bd5a4
+			prop_ino_cursor(mp, agno, btree_curs, magic,
3bd5a4
 					ino_rec->ino_startnum, 0);
3bd5a4
 
3bd5a4
 		bt_rec = (xfs_inobt_rec_t *)