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

Tao Ma tao.ma at oracle.com
Fri Apr 23 07:39:27 PDT 2010


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?

Regards,
Tao



More information about the Ocfs2-tools-devel mailing list