[Ocfs2-tools-devel] [PATCH 02/15] dx_dirs v11: debugfs.ocfs2 support

Coly Li coly.li at suse.de
Sun Apr 25 11:03:13 PDT 2010



On 04/23/2010 03:34 PM, Tao Ma Wrote:
> Hi Coly,
> 
> Coly Li wrote:
>> This adds a full set of functionality to debugfs.ocfs2 so that we can
>> visualize and debug indexed directories. Aside
>> from updates to other commands to dump newly added/used fields in old
>> structures, we get the following debugfs.ocfs2 commands:
>>
>> dx_space - Show all entries in the free list
>> dx_dump  - Show the directory index (including root block)
>> dx_leaf  - Show a single directory index leaf block
>> dx_root  - Show directory index root block, as well as any extent blocks
>>            for non-inline dx_roots.
>>
>> [modified the patch for code rebase and cleanup -- Coly Li]
>>
>> Signed-off-by: Mark Fasheh <mfasheh at suse.com>
> <snip>
>> +void dump_dx_root(FILE *out, struct ocfs2_dx_root_block *dr)
>> +{
>> +    char tmp_str[30];
>> +    GString *flags = NULL;
>> +
>> +    flags = g_string_new(NULL);
>> +    if (dr->dr_flags & OCFS2_DX_FLAG_INLINE)
>> +        g_string_append(flags, "Inline ");
>> +
>> +    fprintf(out, "\tDir Index Root: %"PRIu64"   FS Generation: %u
>> (0x%x)\n",
>> +        (uint64_t)dr->dr_blkno, dr->dr_fs_generation,
>> +        dr->dr_fs_generation);
>> +
>> +    fprintf(out, "\tClusters: %u   Last Extblk: %"PRIu64"   "
>> +        "Dir Inode: %"PRIu64"\n",
>> +        dr->dr_clusters, (uint64_t)dr->dr_last_eb_blk,
>> +        (uint64_t)dr->dr_dir_blkno);
>> +
>> +    if (dr->dr_suballoc_slot == (uint16_t)OCFS2_INVALID_SLOT)
>> +        strcpy(tmp_str, "Global");
> Can we have a dx_root from "Global"? I am afraid not. ;)

Thanks for the catch. No, we don't have global sub_alloc_slot for global.
In libocfs2, dr_suballoc_slot is initialized to 0. dr->dr_suballoc_slot should not be OCFS2_INVALID_SLOT.

Here is the fix, I don't want to use assert(), just print out "Invalid Slot" may be more readable.
@@ -593,7 +593,7 @@ void dump_dx_root(FILE *out, struct ocfs2_dx_root_block *dr)
                (uint64_t)dr->dr_dir_blkno);

        if (dr->dr_suballoc_slot == (uint16_t)OCFS2_INVALID_SLOT)
-               strcpy(tmp_str, "Global");
+               strcpy(tmp_str, "Invalid Slot");
        else
                sprintf(tmp_str, "%d", dr->dr_suballoc_slot);
        fprintf(out, "\tSub Alloc Slot: %s   Sub Alloc Bit: %u   "

Will post it soon.

-- 
Coly Li
SuSE Labs



More information about the Ocfs2-tools-devel mailing list