From: Zorro Lang Date: Mon, 17 Aug 2020 21:20:17 +0000 (-0400) Subject: xfs_db: use correct inode to set inode type X-Git-Tag: v5.8.0-rc1~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b1a48c4fe86624e7d41539e48e7f86e9492ae151;p=thirdparty%2Fxfsprogs-dev.git xfs_db: use correct inode to set inode type A test fails as: # xfs_db -c "inode 133" -c "addr" -c "p core.size" -c "type inode" -c "addr" -c "p core.size" /dev/sdb1 current byte offset 68096, length 512 buffer block 128 (fsbno 16), 32 bbs inode 133, dir inode -1, type inode core.size = 123142 current byte offset 65536, length 512 buffer block 128 (fsbno 16), 32 bbs inode 128, dir inode 128, type inode core.size = 42 The "type inode" command accidentally moves the io cursor because it forgets to include the io cursor's buffer offset when it computes the inode number from the io cursor's location. Fixes: 533d1d229a88 ("xfs_db: properly set inode type") Reported-by: Jianhong Yin Signed-off-by: Zorro Lang Reviewed-by: Eric Sandeen Signed-off-by: Eric Sandeen --- diff --git a/db/io.c b/db/io.c index 6628d061b..884da5998 100644 --- a/db/io.c +++ b/db/io.c @@ -588,18 +588,20 @@ set_iocur_type( { struct xfs_buf *bp = iocur_top->bp; - /* Inodes are special; verifier checks all inodes in the chunk */ + /* + * Inodes are special; verifier checks all inodes in the chunk, the + * set_cur_inode() will help that + */ if (type->typnm == TYP_INODE) { xfs_daddr_t b = iocur_top->bb; + xfs_agblock_t agbno; + xfs_agino_t agino; 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) % - XFS_AGB_TO_AGINO(mp, mp->m_sb.sb_agblocks)); + agbno = xfs_daddr_to_agbno(mp, b); + agino = XFS_OFFBNO_TO_AGINO(mp, agbno, + iocur_top->boff / mp->m_sb.sb_inodesize); + ino = XFS_AGINO_TO_INO(mp, xfs_daddr_to_agno(mp, b), agino); set_cur_inode(ino); return; }