Skip to content

Commit

Permalink
ocfs2: Add refcount b-tree as a new extent tree.
Browse files Browse the repository at this point in the history
Add refcount b-tree as a new extent tree so that it can
use the b-tree to store and maniuplate ocfs2_refcount_rec.

Signed-off-by: Tao Ma <[email protected]>
  • Loading branch information
Tao Ma authored and Joel Becker committed Sep 23, 2009
1 parent 555936b commit fe92441
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
54 changes: 54 additions & 0 deletions fs/ocfs2/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,52 @@ static struct ocfs2_extent_tree_operations ocfs2_dx_root_et_ops = {
.eo_fill_root_el = ocfs2_dx_root_fill_root_el,
};

static void ocfs2_refcount_tree_fill_root_el(struct ocfs2_extent_tree *et)
{
struct ocfs2_refcount_block *rb = et->et_object;

et->et_root_el = &rb->rf_list;
}

static void ocfs2_refcount_tree_set_last_eb_blk(struct ocfs2_extent_tree *et,
u64 blkno)
{
struct ocfs2_refcount_block *rb = et->et_object;

rb->rf_last_eb_blk = cpu_to_le64(blkno);
}

static u64 ocfs2_refcount_tree_get_last_eb_blk(struct ocfs2_extent_tree *et)
{
struct ocfs2_refcount_block *rb = et->et_object;

return le64_to_cpu(rb->rf_last_eb_blk);
}

static void ocfs2_refcount_tree_update_clusters(struct ocfs2_extent_tree *et,
u32 clusters)
{
struct ocfs2_refcount_block *rb = et->et_object;

le32_add_cpu(&rb->rf_clusters, clusters);
}

static enum ocfs2_contig_type
ocfs2_refcount_tree_extent_contig(struct ocfs2_extent_tree *et,
struct ocfs2_extent_rec *ext,
struct ocfs2_extent_rec *insert_rec)
{
return CONTIG_NONE;
}

static struct ocfs2_extent_tree_operations ocfs2_refcount_tree_et_ops = {
.eo_set_last_eb_blk = ocfs2_refcount_tree_set_last_eb_blk,
.eo_get_last_eb_blk = ocfs2_refcount_tree_get_last_eb_blk,
.eo_update_clusters = ocfs2_refcount_tree_update_clusters,
.eo_fill_root_el = ocfs2_refcount_tree_fill_root_el,
.eo_extent_contig = ocfs2_refcount_tree_extent_contig,
};

static void __ocfs2_init_extent_tree(struct ocfs2_extent_tree *et,
struct ocfs2_caching_info *ci,
struct buffer_head *bh,
Expand Down Expand Up @@ -439,6 +485,14 @@ void ocfs2_init_dx_root_extent_tree(struct ocfs2_extent_tree *et,
NULL, &ocfs2_dx_root_et_ops);
}

void ocfs2_init_refcount_extent_tree(struct ocfs2_extent_tree *et,
struct ocfs2_caching_info *ci,
struct buffer_head *bh)
{
__ocfs2_init_extent_tree(et, ci, bh, ocfs2_journal_access_rb,
NULL, &ocfs2_refcount_tree_et_ops);
}

static inline void ocfs2_et_set_last_eb_blk(struct ocfs2_extent_tree *et,
u64 new_last_eb_blk)
{
Expand Down
3 changes: 3 additions & 0 deletions fs/ocfs2/alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et,
void ocfs2_init_dx_root_extent_tree(struct ocfs2_extent_tree *et,
struct ocfs2_caching_info *ci,
struct buffer_head *bh);
void ocfs2_init_refcount_extent_tree(struct ocfs2_extent_tree *et,
struct ocfs2_caching_info *ci,
struct buffer_head *bh);

/*
* Read an extent block into *bh. If *bh is NULL, a bh will be
Expand Down

0 comments on commit fe92441

Please sign in to comment.