aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-08-20 20:44:24 -0400
committerMark Fasheh <mfasheh@suse.com>2008-10-13 19:57:05 -0400
commit1a09f556e5415a29cdddaf9a6ebf474194161cf3 (patch)
tree902dc5cc4719ffce151c610b3441baa3511aa50e /fs
parent943cced39ee45ed2db25efd25eee8ba49cf2dfc4 (diff)
ocfs2: Create specific get_extent_tree functions.
A caller knows what kind of extent tree they have. There's no reason they have to call ocfs2_get_extent_tree() with a NULL when they could just as easily call a specific function to their type of extent tree. Introduce ocfs2_dinode_get_extent_tree(), ocfs2_xattr_tree_get_extent_tree(), and ocfs2_xattr_value_get_extent_tree(). They only take the necessary arguments, calling into the underlying __ocfs2_get_extent_tree() to do the real work. __ocfs2_get_extent_tree() is the old ocfs2_get_extent_tree(), but without needing any switch-by-type logic. ocfs2_get_extent_tree() is now a wrapper around the specific calls. It exists because a couple alloc.c functions can take et_type. This will go later. Another benefit is that ocfs2_xattr_value_get_extent_tree() can take a struct ocfs2_xattr_value_root* instead of void*. This gives us typechecking where we didn't have it before. Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/ocfs2/alloc.c76
-rw-r--r--fs/ocfs2/alloc.h2
2 files changed, 56 insertions, 22 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 64f1af4e999e..7b08180a4c67 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -192,7 +192,7 @@ static int ocfs2_xattr_value_sanity_check(struct inode *inode,
192 return 0; 192 return 0;
193} 193}
194 194
195static struct ocfs2_extent_tree_operations ocfs2_xattr_et_ops = { 195static struct ocfs2_extent_tree_operations ocfs2_xattr_value_et_ops = {
196 .eo_set_last_eb_blk = ocfs2_xattr_value_set_last_eb_blk, 196 .eo_set_last_eb_blk = ocfs2_xattr_value_set_last_eb_blk,
197 .eo_get_last_eb_blk = ocfs2_xattr_value_get_last_eb_blk, 197 .eo_get_last_eb_blk = ocfs2_xattr_value_get_last_eb_blk,
198 .eo_update_clusters = ocfs2_xattr_value_update_clusters, 198 .eo_update_clusters = ocfs2_xattr_value_update_clusters,
@@ -256,27 +256,21 @@ static struct ocfs2_extent_tree_operations ocfs2_xattr_tree_et_ops = {
256 .eo_fill_max_leaf_clusters = ocfs2_xattr_tree_fill_max_leaf_clusters, 256 .eo_fill_max_leaf_clusters = ocfs2_xattr_tree_fill_max_leaf_clusters,
257}; 257};
258 258
259static void ocfs2_get_extent_tree(struct ocfs2_extent_tree *et, 259static void __ocfs2_get_extent_tree(struct ocfs2_extent_tree *et,
260 struct inode *inode, 260 struct inode *inode,
261 struct buffer_head *bh, 261 struct buffer_head *bh,
262 enum ocfs2_extent_tree_type et_type, 262 void *obj,
263 void *obj) 263 enum ocfs2_extent_tree_type et_type,
264 struct ocfs2_extent_tree_operations *ops)
264{ 265{
265 et->et_type = et_type; 266 et->et_type = et_type;
267 et->et_ops = ops;
266 get_bh(bh); 268 get_bh(bh);
267 et->et_root_bh = bh; 269 et->et_root_bh = bh;
268 if (!obj) 270 if (!obj)
269 obj = (void *)bh->b_data; 271 obj = (void *)bh->b_data;
270 et->et_object = obj; 272 et->et_object = obj;
271 273
272 if (et_type == OCFS2_DINODE_EXTENT) {
273 et->et_ops = &ocfs2_dinode_et_ops;
274 } else if (et_type == OCFS2_XATTR_VALUE_EXTENT) {
275 et->et_ops = &ocfs2_xattr_et_ops;
276 } else if (et_type == OCFS2_XATTR_TREE_EXTENT) {
277 et->et_ops = &ocfs2_xattr_tree_et_ops;
278 }
279
280 et->et_ops->eo_fill_root_el(et); 274 et->et_ops->eo_fill_root_el(et);
281 if (!et->et_ops->eo_fill_max_leaf_clusters) 275 if (!et->et_ops->eo_fill_max_leaf_clusters)
282 et->et_max_leaf_clusters = 0; 276 et->et_max_leaf_clusters = 0;
@@ -284,6 +278,49 @@ static void ocfs2_get_extent_tree(struct ocfs2_extent_tree *et,
284 et->et_ops->eo_fill_max_leaf_clusters(inode, et); 278 et->et_ops->eo_fill_max_leaf_clusters(inode, et);
285} 279}
286 280
281static void ocfs2_get_dinode_extent_tree(struct ocfs2_extent_tree *et,
282 struct inode *inode,
283 struct buffer_head *bh)
284{
285 __ocfs2_get_extent_tree(et, inode, bh, NULL, OCFS2_DINODE_EXTENT,
286 &ocfs2_dinode_et_ops);
287}
288
289static void ocfs2_get_xattr_tree_extent_tree(struct ocfs2_extent_tree *et,
290 struct inode *inode,
291 struct buffer_head *bh)
292{
293 __ocfs2_get_extent_tree(et, inode, bh, NULL,
294 OCFS2_XATTR_TREE_EXTENT,
295 &ocfs2_xattr_tree_et_ops);
296}
297
298static void ocfs2_get_xattr_value_extent_tree(struct ocfs2_extent_tree *et,
299 struct inode *inode,
300 struct buffer_head *bh,
301 struct ocfs2_xattr_value_root *xv)
302{
303 __ocfs2_get_extent_tree(et, inode, bh, xv,
304 OCFS2_XATTR_VALUE_EXTENT,
305 &ocfs2_xattr_value_et_ops);
306}
307
308static void ocfs2_get_extent_tree(struct ocfs2_extent_tree *et,
309 struct inode *inode,
310 struct buffer_head *bh,
311 enum ocfs2_extent_tree_type et_type,
312 void *obj)
313{
314 if (et_type == OCFS2_DINODE_EXTENT)
315 ocfs2_get_dinode_extent_tree(et, inode, bh);
316 else if (et_type == OCFS2_XATTR_VALUE_EXTENT)
317 ocfs2_get_xattr_tree_extent_tree(et, inode, bh);
318 else if (et_type == OCFS2_XATTR_TREE_EXTENT)
319 ocfs2_get_xattr_value_extent_tree(et, inode, bh, obj);
320 else
321 BUG();
322}
323
287static void ocfs2_put_extent_tree(struct ocfs2_extent_tree *et) 324static void ocfs2_put_extent_tree(struct ocfs2_extent_tree *et)
288{ 325{
289 brelse(et->et_root_bh); 326 brelse(et->et_root_bh);
@@ -4432,8 +4469,7 @@ int ocfs2_dinode_insert_extent(struct ocfs2_super *osb,
4432 int status; 4469 int status;
4433 struct ocfs2_extent_tree et; 4470 struct ocfs2_extent_tree et;
4434 4471
4435 ocfs2_get_extent_tree(&et, inode, root_bh, OCFS2_DINODE_EXTENT, 4472 ocfs2_get_dinode_extent_tree(&et, inode, root_bh);
4436 NULL);
4437 status = ocfs2_insert_extent(osb, handle, inode, root_bh, 4473 status = ocfs2_insert_extent(osb, handle, inode, root_bh,
4438 cpos, start_blk, new_clusters, 4474 cpos, start_blk, new_clusters,
4439 flags, meta_ac, &et); 4475 flags, meta_ac, &et);
@@ -4451,13 +4487,12 @@ int ocfs2_xattr_value_insert_extent(struct ocfs2_super *osb,
4451 u32 new_clusters, 4487 u32 new_clusters,
4452 u8 flags, 4488 u8 flags,
4453 struct ocfs2_alloc_context *meta_ac, 4489 struct ocfs2_alloc_context *meta_ac,
4454 void *obj) 4490 struct ocfs2_xattr_value_root *xv)
4455{ 4491{
4456 int status; 4492 int status;
4457 struct ocfs2_extent_tree et; 4493 struct ocfs2_extent_tree et;
4458 4494
4459 ocfs2_get_extent_tree(&et, inode, root_bh, 4495 ocfs2_get_xattr_value_extent_tree(&et, inode, root_bh, xv);
4460 OCFS2_XATTR_VALUE_EXTENT, obj);
4461 status = ocfs2_insert_extent(osb, handle, inode, root_bh, 4496 status = ocfs2_insert_extent(osb, handle, inode, root_bh,
4462 cpos, start_blk, new_clusters, 4497 cpos, start_blk, new_clusters,
4463 flags, meta_ac, &et); 4498 flags, meta_ac, &et);
@@ -4479,8 +4514,7 @@ int ocfs2_xattr_tree_insert_extent(struct ocfs2_super *osb,
4479 int status; 4514 int status;
4480 struct ocfs2_extent_tree et; 4515 struct ocfs2_extent_tree et;
4481 4516
4482 ocfs2_get_extent_tree(&et, inode, root_bh, OCFS2_XATTR_TREE_EXTENT, 4517 ocfs2_get_xattr_tree_extent_tree(&et, inode, root_bh);
4483 NULL);
4484 status = ocfs2_insert_extent(osb, handle, inode, root_bh, 4518 status = ocfs2_insert_extent(osb, handle, inode, root_bh,
4485 cpos, start_blk, new_clusters, 4519 cpos, start_blk, new_clusters,
4486 flags, meta_ac, &et); 4520 flags, meta_ac, &et);
diff --git a/fs/ocfs2/alloc.h b/fs/ocfs2/alloc.h
index 23c695ddaa52..5cc9a83cf1a1 100644
--- a/fs/ocfs2/alloc.h
+++ b/fs/ocfs2/alloc.h
@@ -56,7 +56,7 @@ int ocfs2_xattr_value_insert_extent(struct ocfs2_super *osb,
56 u32 new_clusters, 56 u32 new_clusters,
57 u8 flags, 57 u8 flags,
58 struct ocfs2_alloc_context *meta_ac, 58 struct ocfs2_alloc_context *meta_ac,
59 void *private); 59 struct ocfs2_xattr_value_root *xv);
60int ocfs2_xattr_tree_insert_extent(struct ocfs2_super *osb, 60int ocfs2_xattr_tree_insert_extent(struct ocfs2_super *osb,
61 handle_t *handle, 61 handle_t *handle,
62 struct inode *inode, 62 struct inode *inode,