diff options
author | Tao Ma <tao.ma@oracle.com> | 2009-08-17 23:22:18 -0400 |
---|---|---|
committer | Joel Becker <joel.becker@oracle.com> | 2009-09-22 23:09:30 -0400 |
commit | 853a3a1439b18d5a70ada2cb3fcd468e70b7d095 (patch) | |
tree | 96f4a2f3ca4380a6d0feb6f1b8af038bb62946c5 /fs | |
parent | 8bf396de984e68491569b49770e4fd7aca40ba65 (diff) |
ocfs2: Wrap ocfs2_extent_contig in ocfs2_extent_tree.
Add a new operation eo_ocfs2_extent_contig int the extent tree's
operations vector. So that with the new refcount tree, We want
this so that refcount trees can always return CONTIG_NONE and
prevent extent merging.
Signed-off-by: Tao Ma <tao.ma@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ocfs2/alloc.c | 57 |
1 files changed, 41 insertions, 16 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index ab4d2b59b472..75e65df34b69 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
@@ -52,7 +52,17 @@ | |||
52 | 52 | ||
53 | #include "buffer_head_io.h" | 53 | #include "buffer_head_io.h" |
54 | 54 | ||
55 | enum ocfs2_contig_type { | ||
56 | CONTIG_NONE = 0, | ||
57 | CONTIG_LEFT, | ||
58 | CONTIG_RIGHT, | ||
59 | CONTIG_LEFTRIGHT, | ||
60 | }; | ||
55 | 61 | ||
62 | static enum ocfs2_contig_type | ||
63 | ocfs2_extent_rec_contig(struct super_block *sb, | ||
64 | struct ocfs2_extent_rec *ext, | ||
65 | struct ocfs2_extent_rec *insert_rec); | ||
56 | /* | 66 | /* |
57 | * Operations for a specific extent tree type. | 67 | * Operations for a specific extent tree type. |
58 | * | 68 | * |
@@ -122,6 +132,16 @@ struct ocfs2_extent_tree_operations { | |||
122 | * to 0 (unlimited). Optional. | 132 | * to 0 (unlimited). Optional. |
123 | */ | 133 | */ |
124 | void (*eo_fill_max_leaf_clusters)(struct ocfs2_extent_tree *et); | 134 | void (*eo_fill_max_leaf_clusters)(struct ocfs2_extent_tree *et); |
135 | |||
136 | /* | ||
137 | * ->eo_extent_contig test whether the 2 ocfs2_extent_rec | ||
138 | * are contiguous or not. Optional. Don't need to set it if use | ||
139 | * ocfs2_extent_rec as the tree leaf. | ||
140 | */ | ||
141 | enum ocfs2_contig_type | ||
142 | (*eo_extent_contig)(struct ocfs2_extent_tree *et, | ||
143 | struct ocfs2_extent_rec *ext, | ||
144 | struct ocfs2_extent_rec *insert_rec); | ||
125 | }; | 145 | }; |
126 | 146 | ||
127 | 147 | ||
@@ -458,6 +478,19 @@ static inline int ocfs2_et_root_journal_access(handle_t *handle, | |||
458 | type); | 478 | type); |
459 | } | 479 | } |
460 | 480 | ||
481 | static inline enum ocfs2_contig_type | ||
482 | ocfs2_et_extent_contig(struct ocfs2_extent_tree *et, | ||
483 | struct ocfs2_extent_rec *rec, | ||
484 | struct ocfs2_extent_rec *insert_rec) | ||
485 | { | ||
486 | if (et->et_ops->eo_extent_contig) | ||
487 | return et->et_ops->eo_extent_contig(et, rec, insert_rec); | ||
488 | |||
489 | return ocfs2_extent_rec_contig( | ||
490 | ocfs2_metadata_cache_get_super(et->et_ci), | ||
491 | rec, insert_rec); | ||
492 | } | ||
493 | |||
461 | static inline int ocfs2_et_insert_check(struct ocfs2_extent_tree *et, | 494 | static inline int ocfs2_et_insert_check(struct ocfs2_extent_tree *et, |
462 | struct ocfs2_extent_rec *rec) | 495 | struct ocfs2_extent_rec *rec) |
463 | { | 496 | { |
@@ -736,17 +769,9 @@ int ocfs2_search_extent_list(struct ocfs2_extent_list *el, u32 v_cluster) | |||
736 | return ret; | 769 | return ret; |
737 | } | 770 | } |
738 | 771 | ||
739 | enum ocfs2_contig_type { | ||
740 | CONTIG_NONE = 0, | ||
741 | CONTIG_LEFT, | ||
742 | CONTIG_RIGHT, | ||
743 | CONTIG_LEFTRIGHT, | ||
744 | }; | ||
745 | |||
746 | |||
747 | /* | 772 | /* |
748 | * NOTE: ocfs2_block_extent_contig(), ocfs2_extents_adjacent() and | 773 | * NOTE: ocfs2_block_extent_contig(), ocfs2_extents_adjacent() and |
749 | * ocfs2_extent_contig only work properly against leaf nodes! | 774 | * ocfs2_extent_rec_contig only work properly against leaf nodes! |
750 | */ | 775 | */ |
751 | static int ocfs2_block_extent_contig(struct super_block *sb, | 776 | static int ocfs2_block_extent_contig(struct super_block *sb, |
752 | struct ocfs2_extent_rec *ext, | 777 | struct ocfs2_extent_rec *ext, |
@@ -772,9 +797,9 @@ static int ocfs2_extents_adjacent(struct ocfs2_extent_rec *left, | |||
772 | } | 797 | } |
773 | 798 | ||
774 | static enum ocfs2_contig_type | 799 | static enum ocfs2_contig_type |
775 | ocfs2_extent_contig(struct super_block *sb, | 800 | ocfs2_extent_rec_contig(struct super_block *sb, |
776 | struct ocfs2_extent_rec *ext, | 801 | struct ocfs2_extent_rec *ext, |
777 | struct ocfs2_extent_rec *insert_rec) | 802 | struct ocfs2_extent_rec *insert_rec) |
778 | { | 803 | { |
779 | u64 blkno = le64_to_cpu(insert_rec->e_blkno); | 804 | u64 blkno = le64_to_cpu(insert_rec->e_blkno); |
780 | 805 | ||
@@ -4400,7 +4425,7 @@ ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et, | |||
4400 | if (split_rec->e_cpos == el->l_recs[index].e_cpos) | 4425 | if (split_rec->e_cpos == el->l_recs[index].e_cpos) |
4401 | ret = CONTIG_RIGHT; | 4426 | ret = CONTIG_RIGHT; |
4402 | } else { | 4427 | } else { |
4403 | ret = ocfs2_extent_contig(sb, rec, split_rec); | 4428 | ret = ocfs2_et_extent_contig(et, rec, split_rec); |
4404 | } | 4429 | } |
4405 | } | 4430 | } |
4406 | 4431 | ||
@@ -4445,7 +4470,7 @@ ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et, | |||
4445 | if (rec) { | 4470 | if (rec) { |
4446 | enum ocfs2_contig_type contig_type; | 4471 | enum ocfs2_contig_type contig_type; |
4447 | 4472 | ||
4448 | contig_type = ocfs2_extent_contig(sb, rec, split_rec); | 4473 | contig_type = ocfs2_et_extent_contig(et, rec, split_rec); |
4449 | 4474 | ||
4450 | if (contig_type == CONTIG_LEFT && ret == CONTIG_RIGHT) | 4475 | if (contig_type == CONTIG_LEFT && ret == CONTIG_RIGHT) |
4451 | ret = CONTIG_LEFTRIGHT; | 4476 | ret = CONTIG_LEFTRIGHT; |
@@ -4473,8 +4498,8 @@ static void ocfs2_figure_contig_type(struct ocfs2_extent_tree *et, | |||
4473 | BUG_ON(le16_to_cpu(el->l_tree_depth) != 0); | 4498 | BUG_ON(le16_to_cpu(el->l_tree_depth) != 0); |
4474 | 4499 | ||
4475 | for(i = 0; i < le16_to_cpu(el->l_next_free_rec); i++) { | 4500 | for(i = 0; i < le16_to_cpu(el->l_next_free_rec); i++) { |
4476 | contig_type = ocfs2_extent_contig(ocfs2_metadata_cache_get_super(et->et_ci), | 4501 | contig_type = ocfs2_et_extent_contig(et, &el->l_recs[i], |
4477 | &el->l_recs[i], insert_rec); | 4502 | insert_rec); |
4478 | if (contig_type != CONTIG_NONE) { | 4503 | if (contig_type != CONTIG_NONE) { |
4479 | insert->ins_contig_index = i; | 4504 | insert->ins_contig_index = i; |
4480 | break; | 4505 | break; |