aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2009-02-13 05:50:12 -0500
committerJoel Becker <joel.becker@oracle.com>2009-09-04 19:08:03 -0400
commit4c911eefca316f580f174940cd67d561b4b7e6e8 (patch)
tree785ae90d5e2f0fe71c37aa39027c7144abab3d0c
parent043beebb6c467a07ccd7aa666095f87fade1c28e (diff)
ocfs2: Make truncating the extent map an extent_tree_operation.
ocfs2_remove_extent() wants to truncate the extent map if it's truncating an inode data extent. But since many btrees can call that function, let's make it an op on ocfs2_extent_tree. Other tree types can leave it empty. Signed-off-by: Joel Becker <joel.becker@oracle.com>
-rw-r--r--fs/ocfs2/alloc.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 4022fa4dffb5..cdf96974a6a2 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -83,6 +83,13 @@ struct ocfs2_extent_tree_operations {
83 u32 new_clusters); 83 u32 new_clusters);
84 84
85 /* 85 /*
86 * If this extent tree is supported by an extent map, truncate the
87 * map to clusters,
88 */
89 void (*eo_extent_map_truncate)(struct ocfs2_extent_tree *et,
90 u32 clusters);
91
92 /*
86 * If ->eo_insert_check() exists, it is called before rec is 93 * If ->eo_insert_check() exists, it is called before rec is
87 * inserted into the extent tree. It is optional. 94 * inserted into the extent tree. It is optional.
88 */ 95 */
@@ -120,6 +127,8 @@ static void ocfs2_dinode_set_last_eb_blk(struct ocfs2_extent_tree *et,
120 u64 blkno); 127 u64 blkno);
121static void ocfs2_dinode_update_clusters(struct ocfs2_extent_tree *et, 128static void ocfs2_dinode_update_clusters(struct ocfs2_extent_tree *et,
122 u32 clusters); 129 u32 clusters);
130static void ocfs2_dinode_extent_map_truncate(struct ocfs2_extent_tree *et,
131 u32 clusters);
123static int ocfs2_dinode_insert_check(struct ocfs2_extent_tree *et, 132static int ocfs2_dinode_insert_check(struct ocfs2_extent_tree *et,
124 struct ocfs2_extent_rec *rec); 133 struct ocfs2_extent_rec *rec);
125static int ocfs2_dinode_sanity_check(struct ocfs2_extent_tree *et); 134static int ocfs2_dinode_sanity_check(struct ocfs2_extent_tree *et);
@@ -128,6 +137,7 @@ static struct ocfs2_extent_tree_operations ocfs2_dinode_et_ops = {
128 .eo_set_last_eb_blk = ocfs2_dinode_set_last_eb_blk, 137 .eo_set_last_eb_blk = ocfs2_dinode_set_last_eb_blk,
129 .eo_get_last_eb_blk = ocfs2_dinode_get_last_eb_blk, 138 .eo_get_last_eb_blk = ocfs2_dinode_get_last_eb_blk,
130 .eo_update_clusters = ocfs2_dinode_update_clusters, 139 .eo_update_clusters = ocfs2_dinode_update_clusters,
140 .eo_extent_map_truncate = ocfs2_dinode_extent_map_truncate,
131 .eo_insert_check = ocfs2_dinode_insert_check, 141 .eo_insert_check = ocfs2_dinode_insert_check,
132 .eo_sanity_check = ocfs2_dinode_sanity_check, 142 .eo_sanity_check = ocfs2_dinode_sanity_check,
133 .eo_fill_root_el = ocfs2_dinode_fill_root_el, 143 .eo_fill_root_el = ocfs2_dinode_fill_root_el,
@@ -162,6 +172,14 @@ static void ocfs2_dinode_update_clusters(struct ocfs2_extent_tree *et,
162 spin_unlock(&oi->ip_lock); 172 spin_unlock(&oi->ip_lock);
163} 173}
164 174
175static void ocfs2_dinode_extent_map_truncate(struct ocfs2_extent_tree *et,
176 u32 clusters)
177{
178 struct inode *inode = &cache_info_to_inode(et->et_ci)->vfs_inode;
179
180 ocfs2_extent_map_trunc(inode, clusters);
181}
182
165static int ocfs2_dinode_insert_check(struct ocfs2_extent_tree *et, 183static int ocfs2_dinode_insert_check(struct ocfs2_extent_tree *et,
166 struct ocfs2_extent_rec *rec) 184 struct ocfs2_extent_rec *rec)
167{ 185{
@@ -400,6 +418,13 @@ static inline void ocfs2_et_update_clusters(struct ocfs2_extent_tree *et,
400 et->et_ops->eo_update_clusters(et, clusters); 418 et->et_ops->eo_update_clusters(et, clusters);
401} 419}
402 420
421static inline void ocfs2_et_extent_map_truncate(struct ocfs2_extent_tree *et,
422 u32 clusters)
423{
424 if (et->et_ops->eo_extent_map_truncate)
425 et->et_ops->eo_extent_map_truncate(et, clusters);
426}
427
403static inline int ocfs2_et_root_journal_access(handle_t *handle, 428static inline int ocfs2_et_root_journal_access(handle_t *handle,
404 struct ocfs2_extent_tree *et, 429 struct ocfs2_extent_tree *et,
405 int type) 430 int type)
@@ -5106,12 +5131,8 @@ int ocfs2_mark_extent_written(struct inode *inode,
5106 /* 5131 /*
5107 * XXX: This should be fixed up so that we just re-insert the 5132 * XXX: This should be fixed up so that we just re-insert the
5108 * next extent records. 5133 * next extent records.
5109 *
5110 * XXX: This is a hack on the extent tree, maybe it should be
5111 * an op?
5112 */ 5134 */
5113 if (et->et_ops == &ocfs2_dinode_et_ops) 5135 ocfs2_et_extent_map_truncate(et, 0);
5114 ocfs2_extent_map_trunc(inode, 0);
5115 5136
5116 left_path = ocfs2_new_path_from_et(et); 5137 left_path = ocfs2_new_path_from_et(et);
5117 if (!left_path) { 5138 if (!left_path) {
@@ -5393,7 +5414,11 @@ int ocfs2_remove_extent(struct inode *inode,
5393 struct ocfs2_extent_list *el; 5414 struct ocfs2_extent_list *el;
5394 struct ocfs2_path *path = NULL; 5415 struct ocfs2_path *path = NULL;
5395 5416
5396 ocfs2_extent_map_trunc(inode, 0); 5417 /*
5418 * XXX: Why are we truncating to 0 instead of wherever this
5419 * affects us?
5420 */
5421 ocfs2_et_extent_map_truncate(et, 0);
5397 5422
5398 path = ocfs2_new_path_from_et(et); 5423 path = ocfs2_new_path_from_et(et);
5399 if (!path) { 5424 if (!path) {