[Ocfs2-tools-devel] [PATCH 08/15] dx_dirs v11: fsck.ocfs2 support

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



On 04/23/2010 10:39 PM, Tao Ma Wrote:
> Hi Coly,
> 
> Coly Li wrote:
>> This patch does a basic indexed dirs support in fsck.ocfs2.
>>
>> During pass2, if a directory block is changed, and indexed dirs in
>> enabled, the indexed tree of this directory will be
>> truncate, then rebuild with the modified directory data. All the
>> modified directories' inode numbers are recored in a
>> rb-tree, when all directories get scanned, truncate and rebuild the
>> directories whose inode recorded in the rb-tree.
>>
>> Signed-off-by: Coly Li <coly.li at suse.de>
>> Cc: Mark Fasheh <mfasheh at suse.com>
>> ---
> <snip>
>> +static errcode_t o2fsck_check_dx_dir(o2fsck_state *ost, struct
>> ocfs2_dinode *di)
>> +{
>> +    errcode_t ret = 0;
>> +    char *buf = NULL;
>> +    struct ocfs2_dx_root_block *dx_root;
>> +    ocfs2_filesys *fs = ost->ost_fs;
>> +    struct extent_info ei = {0,};
>> +    int changed = 0;
>> +
>> +    if (!ocfs2_supports_indexed_dirs(OCFS2_RAW_SB(fs->fs_super)))
>> +        goto out;
>> +
>> +    if (!ocfs2_dir_indexed(di))
>> +        goto out;
>> +
>> +    ret = ocfs2_malloc_block(fs->fs_io, &buf);
>> +    if (ret)
>> +        goto out;
>> +
>> +    ret = ocfs2_read_dx_root(fs, (uint64_t)di->i_dx_root, buf);
>> +    if (ret)
>> +        goto out;
>> +
>> +    dx_root = (struct ocfs2_dx_root_block *)buf;
>> +    if (dx_root->dr_flags & OCFS2_DX_FLAG_INLINE)
>> +        goto out;
>> +
>> +    ret = check_el(ost, &ei, di->i_blkno, &dx_root->dr_list,
>> +            ocfs2_extent_recs_per_dx_root(fs->fs_blocksize),
>> +            &changed);
>> +    if (ret)
>> +        goto out;
>> +
>> +    if (changed) {
>> +        ret = ocfs2_write_dx_root(fs, (uint64_t)di->i_dx_root, (char
>> *)dx_root);
>> +        if (ret)
>> +            com_err(whoami, ret, "while writing an updated "
>> +                "dx_root block at %"PRIu64" for inode %"PRIu64,
>> +                (uint64_t)di->i_dx_root, (uint64_t)di->i_blkno);
>> +    }
>> +out:
>> +    if (buf)
>> +        ocfs2_free(&buf);
>> +    return ret;
>> +}
>> +
> I am just curious about one thing. What if we have changed the dx_root's
> dr_list. Is there any chance the file is missing from the index dir
> while it is in the dir block? How can we handle this?
> 

Mark posted a patch adds fix_dirent_index() to fix the above issue. The patch (commit 4c1cf617) can be found from
dx_dirs branch.

Thanks for the review.

-- 
Coly Li
SuSE Labs



More information about the Ocfs2-tools-devel mailing list