diff options
author | Tao Ma <tao.ma@oracle.com> | 2009-08-17 23:22:25 -0400 |
---|---|---|
committer | Joel Becker <joel.becker@oracle.com> | 2009-09-22 23:09:31 -0400 |
commit | fe924415957e60471536762172d127e85519ef78 (patch) | |
tree | c26f47180bbc14fda78dae0cb3d40287d6dafd18 /fs/ocfs2 | |
parent | 555936bfcb1af26c6919d6cedb83710bb03d4322 (diff) |
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>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r-- | fs/ocfs2/alloc.c | 54 | ||||
-rw-r--r-- | fs/ocfs2/alloc.h | 3 |
2 files changed, 57 insertions, 0 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 14b9106849ca..a6296560a5cb 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
@@ -385,6 +385,52 @@ static struct ocfs2_extent_tree_operations ocfs2_dx_root_et_ops = { | |||
385 | .eo_fill_root_el = ocfs2_dx_root_fill_root_el, | 385 | .eo_fill_root_el = ocfs2_dx_root_fill_root_el, |
386 | }; | 386 | }; |
387 | 387 | ||
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 | |||
388 | static void __ocfs2_init_extent_tree(struct ocfs2_extent_tree *et, | 434 | static void __ocfs2_init_extent_tree(struct ocfs2_extent_tree *et, |
389 | struct ocfs2_caching_info *ci, | 435 | struct ocfs2_caching_info *ci, |
390 | struct buffer_head *bh, | 436 | struct buffer_head *bh, |
@@ -439,6 +485,14 @@ void ocfs2_init_dx_root_extent_tree(struct ocfs2_extent_tree *et, | |||
439 | NULL, &ocfs2_dx_root_et_ops); | 485 | NULL, &ocfs2_dx_root_et_ops); |
440 | } | 486 | } |
441 | 487 | ||
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 | |||
442 | static inline void ocfs2_et_set_last_eb_blk(struct ocfs2_extent_tree *et, | 496 | static inline void ocfs2_et_set_last_eb_blk(struct ocfs2_extent_tree *et, |
443 | u64 new_last_eb_blk) | 497 | u64 new_last_eb_blk) |
444 | { | 498 | { |
diff --git a/fs/ocfs2/alloc.h b/fs/ocfs2/alloc.h index bcf6aa42ae53..df0e778a2b68 100644 --- a/fs/ocfs2/alloc.h +++ b/fs/ocfs2/alloc.h | |||
@@ -80,6 +80,9 @@ void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et, | |||
80 | void ocfs2_init_dx_root_extent_tree(struct ocfs2_extent_tree *et, | 80 | void ocfs2_init_dx_root_extent_tree(struct ocfs2_extent_tree *et, |
81 | struct ocfs2_caching_info *ci, | 81 | struct ocfs2_caching_info *ci, |
82 | struct buffer_head *bh); | 82 | 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); | ||
83 | 86 | ||
84 | /* | 87 | /* |
85 | * Read an extent block into *bh. If *bh is NULL, a bh will be | 88 | * Read an extent block into *bh. If *bh is NULL, a bh will be |