[Top] [All Lists]

Re: Possible small bug in xfsprogs-dev/db/metadump.c

To: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Subject: Re: Possible small bug in xfsprogs-dev/db/metadump.c
From: Richard Sharpe <realrichardsharpe@xxxxxxxxx>
Date: Mon, 28 Sep 2009 10:36:13 -0700
Cc: Dave Chinner <david@xxxxxxxxxxxxx>, xfs@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=du3a3tCr8d3OTnvpiYrCNuB6Y9i4c5vTOy1UJF9uFug=; b=I+ujS61lpy5Y1x/IdMtrci/+8Ftc+EN1YujxtqRkhzlTOQMvAWsmdUUxQbWW9Sq8X6 Qv1GS1Ztze8n1fQj6GCynq0ai4U7yFb/nUUAmUd03lCmVDWYOm49IUDgCfplS6FrsbHc YRq2FDei40v5hWpgF+tvRL+rjxivfTGTLDjF8=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=FsyNZjGjNFfEJPePsy0fQBGp9rz29B7zGRP3/OylQC14uZABHZPcx+iS1/gYTZBvE8 TD/wk75UI+3V2hP34LRrTdF6pg/8cTLnQeS2INtQJ3lcmNXbqAv9t54oxCqxS/VGMell jWmiKKv5sLkfztdrOl2nMmNHMdD+7OyJLGa/4=
In-reply-to: <20090928172137.GA21868@xxxxxxxxxxxxx>
References: <46b8a8850909271220w372d60c3s18a543ed00825082@xxxxxxxxxxxxxx> <20090928172137.GA21868@xxxxxxxxxxxxx>
On Mon, Sep 28, 2009 at 10:21 AM, Christoph Hellwig <hch@xxxxxxxxxxxxx> 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

        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).

Richard Sharpe

<Prev in Thread] Current Thread [Next in Thread>