diff options
author | Joel Becker <joel.becker@oracle.com> | 2009-02-13 06:18:34 -0500 |
---|---|---|
committer | Joel Becker <joel.becker@oracle.com> | 2009-09-04 19:08:08 -0400 |
commit | 92ba470c44c1404ff18ca0f4ecce1e5b116bb933 (patch) | |
tree | 76e29703dfc37acb9ad3d129936ae4d1ddfee258 /fs | |
parent | 627961b77e68b725851cb227db10084bf15f6920 (diff) |
ocfs2: Make extent map insertion an extent_tree_operation.
ocfs2_insert_extent() wants to insert a record into the extent map if
it's 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>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ocfs2/alloc.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 3d09f4ba39eb..ed869889c4fb 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, insert | ||
87 | * a record into the map. | ||
88 | */ | ||
89 | void (*eo_extent_map_insert)(struct ocfs2_extent_tree *et, | ||
90 | struct ocfs2_extent_rec *rec); | ||
91 | |||
92 | /* | ||
86 | * If this extent tree is supported by an extent map, truncate the | 93 | * If this extent tree is supported by an extent map, truncate the |
87 | * map to clusters, | 94 | * map to clusters, |
88 | */ | 95 | */ |
@@ -127,6 +134,8 @@ static void ocfs2_dinode_set_last_eb_blk(struct ocfs2_extent_tree *et, | |||
127 | u64 blkno); | 134 | u64 blkno); |
128 | static void ocfs2_dinode_update_clusters(struct ocfs2_extent_tree *et, | 135 | static void ocfs2_dinode_update_clusters(struct ocfs2_extent_tree *et, |
129 | u32 clusters); | 136 | u32 clusters); |
137 | static void ocfs2_dinode_extent_map_insert(struct ocfs2_extent_tree *et, | ||
138 | struct ocfs2_extent_rec *rec); | ||
130 | static void ocfs2_dinode_extent_map_truncate(struct ocfs2_extent_tree *et, | 139 | static void ocfs2_dinode_extent_map_truncate(struct ocfs2_extent_tree *et, |
131 | u32 clusters); | 140 | u32 clusters); |
132 | static int ocfs2_dinode_insert_check(struct ocfs2_extent_tree *et, | 141 | static int ocfs2_dinode_insert_check(struct ocfs2_extent_tree *et, |
@@ -137,6 +146,7 @@ static struct ocfs2_extent_tree_operations ocfs2_dinode_et_ops = { | |||
137 | .eo_set_last_eb_blk = ocfs2_dinode_set_last_eb_blk, | 146 | .eo_set_last_eb_blk = ocfs2_dinode_set_last_eb_blk, |
138 | .eo_get_last_eb_blk = ocfs2_dinode_get_last_eb_blk, | 147 | .eo_get_last_eb_blk = ocfs2_dinode_get_last_eb_blk, |
139 | .eo_update_clusters = ocfs2_dinode_update_clusters, | 148 | .eo_update_clusters = ocfs2_dinode_update_clusters, |
149 | .eo_extent_map_insert = ocfs2_dinode_extent_map_insert, | ||
140 | .eo_extent_map_truncate = ocfs2_dinode_extent_map_truncate, | 150 | .eo_extent_map_truncate = ocfs2_dinode_extent_map_truncate, |
141 | .eo_insert_check = ocfs2_dinode_insert_check, | 151 | .eo_insert_check = ocfs2_dinode_insert_check, |
142 | .eo_sanity_check = ocfs2_dinode_sanity_check, | 152 | .eo_sanity_check = ocfs2_dinode_sanity_check, |
@@ -172,6 +182,14 @@ static void ocfs2_dinode_update_clusters(struct ocfs2_extent_tree *et, | |||
172 | spin_unlock(&oi->ip_lock); | 182 | spin_unlock(&oi->ip_lock); |
173 | } | 183 | } |
174 | 184 | ||
185 | static void ocfs2_dinode_extent_map_insert(struct ocfs2_extent_tree *et, | ||
186 | struct ocfs2_extent_rec *rec) | ||
187 | { | ||
188 | struct inode *inode = &cache_info_to_inode(et->et_ci)->vfs_inode; | ||
189 | |||
190 | ocfs2_extent_map_insert_rec(inode, rec); | ||
191 | } | ||
192 | |||
175 | static void ocfs2_dinode_extent_map_truncate(struct ocfs2_extent_tree *et, | 193 | static void ocfs2_dinode_extent_map_truncate(struct ocfs2_extent_tree *et, |
176 | u32 clusters) | 194 | u32 clusters) |
177 | { | 195 | { |
@@ -418,6 +436,13 @@ static inline void ocfs2_et_update_clusters(struct ocfs2_extent_tree *et, | |||
418 | et->et_ops->eo_update_clusters(et, clusters); | 436 | et->et_ops->eo_update_clusters(et, clusters); |
419 | } | 437 | } |
420 | 438 | ||
439 | static inline void ocfs2_et_extent_map_insert(struct ocfs2_extent_tree *et, | ||
440 | struct ocfs2_extent_rec *rec) | ||
441 | { | ||
442 | if (et->et_ops->eo_extent_map_insert) | ||
443 | et->et_ops->eo_extent_map_insert(et, rec); | ||
444 | } | ||
445 | |||
421 | static inline void ocfs2_et_extent_map_truncate(struct ocfs2_extent_tree *et, | 446 | static inline void ocfs2_et_extent_map_truncate(struct ocfs2_extent_tree *et, |
422 | u32 clusters) | 447 | u32 clusters) |
423 | { | 448 | { |
@@ -4717,8 +4742,8 @@ int ocfs2_insert_extent(struct ocfs2_super *osb, | |||
4717 | status = ocfs2_do_insert_extent(handle, et, &rec, &insert); | 4742 | status = ocfs2_do_insert_extent(handle, et, &rec, &insert); |
4718 | if (status < 0) | 4743 | if (status < 0) |
4719 | mlog_errno(status); | 4744 | mlog_errno(status); |
4720 | else if (et->et_ops == &ocfs2_dinode_et_ops) | 4745 | else |
4721 | ocfs2_extent_map_insert_rec(inode, &rec); | 4746 | ocfs2_et_extent_map_insert(et, &rec); |
4722 | 4747 | ||
4723 | bail: | 4748 | bail: |
4724 | brelse(last_eb_bh); | 4749 | brelse(last_eb_bh); |