[Ocfs2-tools-devel] [PATCH 40/50] libocfs2: Add helper function for creating and attaching refcount tree.
Joel Becker
Joel.Becker at oracle.com
Tue Jan 19 14:33:39 PST 2010
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.
Joel
--
"Three o'clock is always too late or too early for anything you
want to do."
- Jean-Paul Sartre
Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
More information about the Ocfs2-tools-devel
mailing list