Re: xfs_db: bug in bmap command?

Dave Chinner
2012-08-03T02:37:19Z

On Fri, Aug 03, 2012 at 09:30:25AM +1000, Dave Chinner wrote:
> > diff --git a/db/bmap.c b/db/bmap.c
> > index ddad49c..0ef7a62 100644
> > --- a/db/bmap.c
> > +++ b/db/bmap.c
> > @@ -101,9 +101,9 @@ bmap(
> > block = (struct xfs_btree_block *)iocur_top->data;
> > if (be16_to_cpu(block->bb_level) == 0)
> > break;
> > - pp = XFS_BMDR_PTR_ADDR(block, 1,
> > + pp = XFS_BMBT_PTR_ADDR(mp, block, 1,
> > xfs_bmbt_maxrecs(mp, mp->m_sb.sb_blocksize, 0));
> > - kp = XFS_BMDR_KEY_ADDR(block, 1);
> > + kp = XFS_BMBT_KEY_ADDR(mp, block, 1);
>
> That, I'm pretty sure, is wrong, too, because the root block is a
> different format to the tree blocks. IOWs,the old code parses
> tree node blocks with the root block format macro, while your code
> parses the root node with tree block format macros. Both are wrong.
> The original was also wrong in that it used xfs_bmbt_maxrecs()
> instead of xfs_bmdr_maxrecs() for the number of records in the inode
> root block.

Ignore this, I misread the code in bmap(). the root block is already
dealt with before entering the first loop, so it will never come
across the root block and so have to handle it. My mistake, the
patch as is should work just fine.