]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_db: properly set inode type
authorEric Sandeen <sandeen@redhat.com>
Thu, 20 Jul 2017 15:51:46 +0000 (10:51 -0500)
committerEric Sandeen <sandeen@redhat.com>
Thu, 20 Jul 2017 15:51:46 +0000 (10:51 -0500)
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

diff --git a/db/io.c b/db/io.c
index b046c8d37f8a6504f44e868bae1c676b0531e13b..1f27f6b33441692974d17f38b1ca2a874dda80dc 100644 (file)
--- a/db/io.c
+++ b/db/io.c
@@ -616,6 +616,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 */