Skip to content

Commit fe92441

Browse files
Tao MaJoel Becker
authored andcommitted
ocfs2: Add refcount b-tree as a new extent tree.
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 <tao.ma@oracle.com>
1 parent 555936b commit fe92441

2 files changed

Lines changed: 57 additions & 0 deletions

File tree

‎fs/ocfs2/alloc.c‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,52 @@ static struct ocfs2_extent_tree_operations ocfs2_dx_root_et_ops = {
385385
.eo_fill_root_el = ocfs2_dx_root_fill_root_el,
386386
};
387387

388+
static void ocfs2_refcount_tree_fill_root_el(struct ocfs2_extent_tree *et)
389+
{
390+
struct ocfs2_refcount_block *rb = et->et_object;
391+
392+
et->et_root_el = &rb->rf_list;
393+
}
394+
395+
static void ocfs2_refcount_tree_set_last_eb_blk(struct ocfs2_extent_tree *et,
396+
u64 blkno)
397+
{
398+
struct ocfs2_refcount_block *rb = et->et_object;
399+
400+
rb->rf_last_eb_blk = cpu_to_le64(blkno);
401+
}
402+
403+
static u64 ocfs2_refcount_tree_get_last_eb_blk(struct ocfs2_extent_tree *et)
404+
{
405+
struct ocfs2_refcount_block *rb = et->et_object;
406+
407+
return le64_to_cpu(rb->rf_last_eb_blk);
408+
}
409+
410+
static void ocfs2_refcount_tree_update_clusters(struct ocfs2_extent_tree *et,
411+
u32 clusters)
412+
{
413+
struct ocfs2_refcount_block *rb = et->et_object;
414+
415+
le32_add_cpu(&rb->rf_clusters, clusters);
416+
}
417+
418+
static enum ocfs2_contig_type
419+
ocfs2_refcount_tree_extent_contig(struct ocfs2_extent_tree *et,
420+
struct ocfs2_extent_rec *ext,
421+
struct ocfs2_extent_rec *insert_rec)
422+
{
423+
return CONTIG_NONE;
424+
}
425+
426+
static struct ocfs2_extent_tree_operations ocfs2_refcount_tree_et_ops = {
427+
.eo_set_last_eb_blk = ocfs2_refcount_tree_set_last_eb_blk,
428+
.eo_get_last_eb_blk = ocfs2_refcount_tree_get_last_eb_blk,
429+
.eo_update_clusters = ocfs2_refcount_tree_update_clusters,
430+
.eo_fill_root_el = ocfs2_refcount_tree_fill_root_el,
431+
.eo_extent_contig = ocfs2_refcount_tree_extent_contig,
432+
};
433+
388434
static void __ocfs2_init_extent_tree(struct ocfs2_extent_tree *et,
389435
struct ocfs2_caching_info *ci,
390436
struct buffer_head *bh,
@@ -439,6 +485,14 @@ void ocfs2_init_dx_root_extent_tree(struct ocfs2_extent_tree *et,
439485
NULL, &ocfs2_dx_root_et_ops);
440486
}
441487

488+
void ocfs2_init_refcount_extent_tree(struct ocfs2_extent_tree *et,
489+
struct ocfs2_caching_info *ci,
490+
struct buffer_head *bh)
491+
{
492+
__ocfs2_init_extent_tree(et, ci, bh, ocfs2_journal_access_rb,
493+
NULL, &ocfs2_refcount_tree_et_ops);
494+
}
495+
442496
static inline void ocfs2_et_set_last_eb_blk(struct ocfs2_extent_tree *et,
443497
u64 new_last_eb_blk)
444498
{

‎fs/ocfs2/alloc.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et,
8080
void ocfs2_init_dx_root_extent_tree(struct ocfs2_extent_tree *et,
8181
struct ocfs2_caching_info *ci,
8282
struct buffer_head *bh);
83+
void ocfs2_init_refcount_extent_tree(struct ocfs2_extent_tree *et,
84+
struct ocfs2_caching_info *ci,
85+
struct buffer_head *bh);
8386

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

0 commit comments

Comments
 (0)