Possible small bug in xfsprogs-dev/db/metadump.c
Richard Sharpe
realrichardsharpe at gmail.com
Mon Sep 28 12:36:13 CDT 2009
On Mon, Sep 28, 2009 at 10:21 AM, Christoph Hellwig <hch at infradead.org> wrote:
> [Cc'ed to the list, where people including the most active person on the
> userspace side hang out]
>
> On Sun, Sep 27, 2009 at 12:20:33PM -0700, Richard Sharpe wrote:
>> Hi folks,
>>
>> There seems to be a small bug in
>> xfsprogs-dev/db/metadump.c:scanfunc_freesp (although I think the same
>> problem exists in other functions).
>>
>> It has a check to see if the number of records is invalid:
>>
>> numrecs = be16_to_cpu(block->bb_numrecs);
>> if (numrecs > mp->m_alloc_mxr[1]) {
>> if (show_warnings)
>> print_warning("invalid numrecs (%u) in %s block %u/%u",
>> numrecs, typtab[btype].name, agno, agbno);
>> return 1;
>> }
>>
>> However, it seems to me that you should pay attention to bb_level in
>> the node when using that test, because leaf nodes can appear at
>> multiple levels in the tree.
>
> Before that code there is a
>
> if (level == 0)
> return 1;
>
> which should take care of the leaf nodes by exiting early.
Well, yes there is, but that is the problem I encountered. It is level
as passed in when starting at the top of the tree, which is obtained
from the levels value in the AGF, and is decremented by one on each
recursion:
if (!(*func)(iocur_top->data, agno, agbno, level - 1, btype, arg))
However, what should really be looked at is the value bb_level in the
header in each free-space Btree node.
After I made that change to my changes, I started being able to
properly count all leaf nodes and free extents, and the numbers came
out where I expected them to be (instead of not seeing many leaf nodes
and vastly undercounting free extents).
--
Regards,
Richard Sharpe
More information about the xfs
mailing list