[Ocfs2-tools-devel] [PATCH 40/50] libocfs2: Add helper function for creating and attaching refcount tree.

Tao Ma tao.ma at oracle.com
Tue Jan 19 17:16:30 PST 2010



Joel Becker wrote:
> On Mon, Jan 11, 2010 at 11:31:26PM +0800, Tao Ma wrote:
>> +errcode_t ocfs2_attach_refcount_tree(ocfs2_filesys *fs,
>> +				     uint64_t ino, uint64_t refcount_loc)
>> +{
>> +	errcode_t ret;
>> +	char *buf = NULL;
>> +	struct ocfs2_dinode *di;
>> +
>> +	ret = ocfs2_malloc_block(fs->fs_io, &buf);
>> +	if (ret)
>> +		return ret;
>> +
>> +	ret = ocfs2_read_inode(fs, ino, buf);
>> +	if (ret)
>> +		goto out;
>> +
>> +	di = (struct ocfs2_dinode *)buf;
>> +
>> +	assert(!(di->i_dyn_features & OCFS2_HAS_REFCOUNT_FL));
>> +	assert(!di->i_refcount_loc);
>> +
>> +	di->i_refcount_loc = refcount_loc;
>> +	di->i_dyn_features |= OCFS2_HAS_REFCOUNT_FL;
>> +
>> +	ret = ocfs2_write_inode(fs, ino, buf);
>> +out:
>> +	ocfs2_free(&buf);
>> +	return ret;
>> +}
> 
> 	Don't you need to increment rb->rf_count here?  Otherwise you'll
> have a refcount tree attached with rf_count==0.
oh, you are right.

So it seems that we need another fsck type to check rf_count also. ;)

Regards,
Tao



More information about the Ocfs2-tools-devel mailing list