From 533d1d229a881d5a58a232377c409a3dd7a5cd6f Mon Sep 17 00:00:00 2001
From: Eric Sandeen <sandeen@redhat.com>
Date: Thu, 20 Jul 2017 10:51:46 -0500
Subject: [PATCH] xfs_db: properly set inode type
When we set the type to "inode" the verifier validates multiple
inodes in the current fs block, so setting the buffer size to
that of just one inode is not sufficient and it'll emit spurious
verifier errors for all but the first, as we read off the end:
xfs_db> daddr 99
xfs_db> type inode
Metadata corruption detected at xfs_inode block 0x63/0x200
Metadata corruption detected at xfs_inode block 0x63/0x200
Metadata corruption detected at xfs_inode block 0x63/0x200
Metadata corruption detected at xfs_inode block 0x63/0x200
Metadata corruption detected at xfs_inode block 0x63/0x200
Metadata corruption detected at xfs_inode block 0x63/0x200
Metadata corruption detected at xfs_inode block 0x63/0x200
Use the special set_cur_inode() function for this purpose
as is done in inode_f().
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
[sandeen: remove nag/warning printf for now]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
---
db/io.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
Index: xfsprogs-rhel7.5/db/io.c
===================================================================
--- xfsprogs-rhel7.5.orig/db/io.c
+++ xfsprogs-rhel7.5/db/io.c
@@ -567,6 +567,22 @@ set_iocur_type(
{
struct xfs_buf *bp = iocur_top->bp;
+ /* Inodes are special; verifier checks all inodes in the chunk */
+ if (type->typnm == TYP_INODE) {
+ xfs_daddr_t b = iocur_top->bb;
+ xfs_ino_t ino;
+
+ /*
+ * Note that this will back up to the beginning of the inode
+ * which contains the current disk location; daddr may change.
+ */
+ ino = XFS_AGINO_TO_INO(mp, xfs_daddr_to_agno(mp, b),
+ ((b << BBSHIFT) >> mp->m_sb.sb_inodelog) %
+ (mp->m_sb.sb_agblocks << mp->m_sb.sb_inopblog));
+ set_cur_inode(ino);
+ return;
+ }
+
/* adjust buffer size for types with fields & hence fsize() */
if (type->fields) {
int bb_count; /* type's size in basic blocks */