aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-08-22 15:46:09 -0400
committerMark Fasheh <mfasheh@suse.com>2008-10-13 19:57:05 -0400
commit8d6220d6a74a33552cf877bcea25503d7f6a59e6 (patch)
tree2c3f662c55ab4a0a22989c06edf0d027387bfbed /fs/ocfs2
parent1625f8ac151743e452ec062c2989669c508ffa48 (diff)
ocfs2: Change ocfs2_get_*_extent_tree() to ocfs2_init_*_extent_tree()
The original get/put_extent_tree() functions held a reference on et_root_bh. However, every single caller already has a safe reference, making the get/put cycle irrelevant. We change ocfs2_get_*_extent_tree() to ocfs2_init_*_extent_tree(). It no longer gets a reference on et_root_bh. ocfs2_put_extent_tree() is removed. Callers now have a simpler init+use pattern. Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/alloc.c49
-rw-r--r--fs/ocfs2/alloc.h26
-rw-r--r--fs/ocfs2/aops.c6
-rw-r--r--fs/ocfs2/dir.c6
-rw-r--r--fs/ocfs2/file.c10
-rw-r--r--fs/ocfs2/xattr.c14
6 files changed, 44 insertions, 67 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 06b9bd73d6d2..47201b67dbf2 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -55,7 +55,7 @@
55 * 55 *
56 * To implement an on-disk btree (extent tree) type in ocfs2, add 56 * To implement an on-disk btree (extent tree) type in ocfs2, add
57 * an ocfs2_extent_tree_operations structure and the matching 57 * an ocfs2_extent_tree_operations structure and the matching
58 * ocfs2_get_<thingy>_extent_tree() function. That's pretty much it 58 * ocfs2_init_<thingy>_extent_tree() function. That's pretty much it
59 * for the allocation portion of the extent tree. 59 * for the allocation portion of the extent tree.
60 */ 60 */
61struct ocfs2_extent_tree_operations { 61struct ocfs2_extent_tree_operations {
@@ -301,14 +301,13 @@ static struct ocfs2_extent_tree_operations ocfs2_xattr_tree_et_ops = {
301 .eo_fill_max_leaf_clusters = ocfs2_xattr_tree_fill_max_leaf_clusters, 301 .eo_fill_max_leaf_clusters = ocfs2_xattr_tree_fill_max_leaf_clusters,
302}; 302};
303 303
304static void __ocfs2_get_extent_tree(struct ocfs2_extent_tree *et, 304static void __ocfs2_init_extent_tree(struct ocfs2_extent_tree *et,
305 struct inode *inode, 305 struct inode *inode,
306 struct buffer_head *bh, 306 struct buffer_head *bh,
307 void *obj, 307 void *obj,
308 struct ocfs2_extent_tree_operations *ops) 308 struct ocfs2_extent_tree_operations *ops)
309{ 309{
310 et->et_ops = ops; 310 et->et_ops = ops;
311 get_bh(bh);
312 et->et_root_bh = bh; 311 et->et_root_bh = bh;
313 if (!obj) 312 if (!obj)
314 obj = (void *)bh->b_data; 313 obj = (void *)bh->b_data;
@@ -321,33 +320,28 @@ static void __ocfs2_get_extent_tree(struct ocfs2_extent_tree *et,
321 et->et_ops->eo_fill_max_leaf_clusters(inode, et); 320 et->et_ops->eo_fill_max_leaf_clusters(inode, et);
322} 321}
323 322
324void ocfs2_get_dinode_extent_tree(struct ocfs2_extent_tree *et, 323void ocfs2_init_dinode_extent_tree(struct ocfs2_extent_tree *et,
325 struct inode *inode, 324 struct inode *inode,
326 struct buffer_head *bh) 325 struct buffer_head *bh)
327{
328 __ocfs2_get_extent_tree(et, inode, bh, NULL, &ocfs2_dinode_et_ops);
329}
330
331void ocfs2_get_xattr_tree_extent_tree(struct ocfs2_extent_tree *et,
332 struct inode *inode,
333 struct buffer_head *bh)
334{ 326{
335 __ocfs2_get_extent_tree(et, inode, bh, NULL, 327 __ocfs2_init_extent_tree(et, inode, bh, NULL, &ocfs2_dinode_et_ops);
336 &ocfs2_xattr_tree_et_ops);
337} 328}
338 329
339void ocfs2_get_xattr_value_extent_tree(struct ocfs2_extent_tree *et, 330void ocfs2_init_xattr_tree_extent_tree(struct ocfs2_extent_tree *et,
340 struct inode *inode, 331 struct inode *inode,
341 struct buffer_head *bh, 332 struct buffer_head *bh)
342 struct ocfs2_xattr_value_root *xv)
343{ 333{
344 __ocfs2_get_extent_tree(et, inode, bh, xv, 334 __ocfs2_init_extent_tree(et, inode, bh, NULL,
345 &ocfs2_xattr_value_et_ops); 335 &ocfs2_xattr_tree_et_ops);
346} 336}
347 337
348void ocfs2_put_extent_tree(struct ocfs2_extent_tree *et) 338void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et,
339 struct inode *inode,
340 struct buffer_head *bh,
341 struct ocfs2_xattr_value_root *xv)
349{ 342{
350 brelse(et->et_root_bh); 343 __ocfs2_init_extent_tree(et, inode, bh, xv,
344 &ocfs2_xattr_value_et_ops);
351} 345}
352 346
353static inline void ocfs2_et_set_last_eb_blk(struct ocfs2_extent_tree *et, 347static inline void ocfs2_et_set_last_eb_blk(struct ocfs2_extent_tree *et,
@@ -6791,10 +6785,9 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode,
6791 * this proves to be false, we could always re-build 6785 * this proves to be false, we could always re-build
6792 * the in-inode data from our pages. 6786 * the in-inode data from our pages.
6793 */ 6787 */
6794 ocfs2_get_dinode_extent_tree(&et, inode, di_bh); 6788 ocfs2_init_dinode_extent_tree(&et, inode, di_bh);
6795 ret = ocfs2_insert_extent(osb, handle, inode, &et, 6789 ret = ocfs2_insert_extent(osb, handle, inode, &et,
6796 0, block, 1, 0, NULL); 6790 0, block, 1, 0, NULL);
6797 ocfs2_put_extent_tree(&et);
6798 if (ret) { 6791 if (ret) {
6799 mlog_errno(ret); 6792 mlog_errno(ret);
6800 goto out_commit; 6793 goto out_commit;
diff --git a/fs/ocfs2/alloc.h b/fs/ocfs2/alloc.h
index 35ad07f96104..70257c84cfbe 100644
--- a/fs/ocfs2/alloc.h
+++ b/fs/ocfs2/alloc.h
@@ -41,7 +41,7 @@
41 * 41 *
42 * ocfs2_extent_tree becomes the first-class object for extent tree 42 * ocfs2_extent_tree becomes the first-class object for extent tree
43 * manipulation. Callers of the alloc.c code need to fill it via one of 43 * manipulation. Callers of the alloc.c code need to fill it via one of
44 * the ocfs2_get_*_extent_tree() operations below. 44 * the ocfs2_init_*_extent_tree() operations below.
45 * 45 *
46 * ocfs2_extent_tree contains info for the root of the b-tree, it must have a 46 * ocfs2_extent_tree contains info for the root of the b-tree, it must have a
47 * root ocfs2_extent_list and a root_bh so that they can be used in the b-tree 47 * root ocfs2_extent_list and a root_bh so that they can be used in the b-tree
@@ -59,21 +59,19 @@ struct ocfs2_extent_tree {
59}; 59};
60 60
61/* 61/*
62 * ocfs2_*_get_extent_tree() will fill an ocfs2_extent_tree from the 62 * ocfs2_init_*_extent_tree() will fill an ocfs2_extent_tree from the
63 * specified object buffer. The bh is referenced until 63 * specified object buffer.
64 * ocfs2_put_extent_tree().
65 */ 64 */
66void ocfs2_get_dinode_extent_tree(struct ocfs2_extent_tree *et, 65void ocfs2_init_dinode_extent_tree(struct ocfs2_extent_tree *et,
67 struct inode *inode, 66 struct inode *inode,
68 struct buffer_head *bh); 67 struct buffer_head *bh);
69void ocfs2_get_xattr_tree_extent_tree(struct ocfs2_extent_tree *et, 68void ocfs2_init_xattr_tree_extent_tree(struct ocfs2_extent_tree *et,
70 struct inode *inode,
71 struct buffer_head *bh);
72void ocfs2_get_xattr_value_extent_tree(struct ocfs2_extent_tree *et,
73 struct inode *inode, 69 struct inode *inode,
74 struct buffer_head *bh, 70 struct buffer_head *bh);
75 struct ocfs2_xattr_value_root *xv); 71void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et,
76void ocfs2_put_extent_tree(struct ocfs2_extent_tree *et); 72 struct inode *inode,
73 struct buffer_head *bh,
74 struct ocfs2_xattr_value_root *xv);
77 75
78struct ocfs2_alloc_context; 76struct ocfs2_alloc_context;
79int ocfs2_insert_extent(struct ocfs2_super *osb, 77int ocfs2_insert_extent(struct ocfs2_super *osb,
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index ed937fa9e4e3..259775eedb85 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -1277,11 +1277,10 @@ static int ocfs2_write_cluster(struct address_space *mapping,
1277 goto out; 1277 goto out;
1278 } 1278 }
1279 } else if (unwritten) { 1279 } else if (unwritten) {
1280 ocfs2_get_dinode_extent_tree(&et, inode, wc->w_di_bh); 1280 ocfs2_init_dinode_extent_tree(&et, inode, wc->w_di_bh);
1281 ret = ocfs2_mark_extent_written(inode, &et, 1281 ret = ocfs2_mark_extent_written(inode, &et,
1282 wc->w_handle, cpos, 1, phys, 1282 wc->w_handle, cpos, 1, phys,
1283 meta_ac, &wc->w_dealloc); 1283 meta_ac, &wc->w_dealloc);
1284 ocfs2_put_extent_tree(&et);
1285 if (ret < 0) { 1284 if (ret < 0) {
1286 mlog_errno(ret); 1285 mlog_errno(ret);
1287 goto out; 1286 goto out;
@@ -1722,11 +1721,10 @@ int ocfs2_write_begin_nolock(struct address_space *mapping,
1722 (long long)i_size_read(inode), le32_to_cpu(di->i_clusters), 1721 (long long)i_size_read(inode), le32_to_cpu(di->i_clusters),
1723 clusters_to_alloc, extents_to_split); 1722 clusters_to_alloc, extents_to_split);
1724 1723
1725 ocfs2_get_dinode_extent_tree(&et, inode, wc->w_di_bh); 1724 ocfs2_init_dinode_extent_tree(&et, inode, wc->w_di_bh);
1726 ret = ocfs2_lock_allocators(inode, &et, 1725 ret = ocfs2_lock_allocators(inode, &et,
1727 clusters_to_alloc, extents_to_split, 1726 clusters_to_alloc, extents_to_split,
1728 &data_ac, &meta_ac); 1727 &data_ac, &meta_ac);
1729 ocfs2_put_extent_tree(&et);
1730 if (ret) { 1728 if (ret) {
1731 mlog_errno(ret); 1729 mlog_errno(ret);
1732 goto out; 1730 goto out;
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 2cdc55390348..167e6c96277d 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -1194,7 +1194,7 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
1194 handle_t *handle; 1194 handle_t *handle;
1195 struct ocfs2_extent_tree et; 1195 struct ocfs2_extent_tree et;
1196 1196
1197 ocfs2_get_dinode_extent_tree(&et, dir, di_bh); 1197 ocfs2_init_dinode_extent_tree(&et, dir, di_bh);
1198 1198
1199 alloc = ocfs2_clusters_for_bytes(sb, bytes); 1199 alloc = ocfs2_clusters_for_bytes(sb, bytes);
1200 1200
@@ -1363,7 +1363,6 @@ out:
1363 1363
1364 brelse(dirdata_bh); 1364 brelse(dirdata_bh);
1365 1365
1366 ocfs2_put_extent_tree(&et);
1367 return ret; 1366 return ret;
1368} 1367}
1369 1368
@@ -1485,9 +1484,8 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
1485 spin_lock(&OCFS2_I(dir)->ip_lock); 1484 spin_lock(&OCFS2_I(dir)->ip_lock);
1486 if (dir_i_size == ocfs2_clusters_to_bytes(sb, OCFS2_I(dir)->ip_clusters)) { 1485 if (dir_i_size == ocfs2_clusters_to_bytes(sb, OCFS2_I(dir)->ip_clusters)) {
1487 spin_unlock(&OCFS2_I(dir)->ip_lock); 1486 spin_unlock(&OCFS2_I(dir)->ip_lock);
1488 ocfs2_get_dinode_extent_tree(&et, dir, parent_fe_bh); 1487 ocfs2_init_dinode_extent_tree(&et, dir, parent_fe_bh);
1489 num_free_extents = ocfs2_num_free_extents(osb, dir, &et); 1488 num_free_extents = ocfs2_num_free_extents(osb, dir, &et);
1490 ocfs2_put_extent_tree(&et);
1491 if (num_free_extents < 0) { 1489 if (num_free_extents < 0) {
1492 status = num_free_extents; 1490 status = num_free_extents;
1493 mlog_errno(status); 1491 mlog_errno(status);
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index ca3d38addbb9..441c6a94059d 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -512,12 +512,11 @@ int ocfs2_add_inode_data(struct ocfs2_super *osb,
512 int ret; 512 int ret;
513 struct ocfs2_extent_tree et; 513 struct ocfs2_extent_tree et;
514 514
515 ocfs2_get_dinode_extent_tree(&et, inode, fe_bh); 515 ocfs2_init_dinode_extent_tree(&et, inode, fe_bh);
516 ret = ocfs2_add_clusters_in_btree(osb, inode, logical_offset, 516 ret = ocfs2_add_clusters_in_btree(osb, inode, logical_offset,
517 clusters_to_add, mark_unwritten, 517 clusters_to_add, mark_unwritten,
518 &et, handle, 518 &et, handle,
519 data_ac, meta_ac, reason_ret); 519 data_ac, meta_ac, reason_ret);
520 ocfs2_put_extent_tree(&et);
521 520
522 return ret; 521 return ret;
523} 522}
@@ -568,10 +567,9 @@ restart_all:
568 (unsigned long long)OCFS2_I(inode)->ip_blkno, 567 (unsigned long long)OCFS2_I(inode)->ip_blkno,
569 (long long)i_size_read(inode), le32_to_cpu(fe->i_clusters), 568 (long long)i_size_read(inode), le32_to_cpu(fe->i_clusters),
570 clusters_to_add); 569 clusters_to_add);
571 ocfs2_get_dinode_extent_tree(&et, inode, bh); 570 ocfs2_init_dinode_extent_tree(&et, inode, bh);
572 status = ocfs2_lock_allocators(inode, &et, clusters_to_add, 0, 571 status = ocfs2_lock_allocators(inode, &et, clusters_to_add, 0,
573 &data_ac, &meta_ac); 572 &data_ac, &meta_ac);
574 ocfs2_put_extent_tree(&et);
575 if (status) { 573 if (status) {
576 mlog_errno(status); 574 mlog_errno(status);
577 goto leave; 575 goto leave;
@@ -1243,11 +1241,10 @@ static int __ocfs2_remove_inode_range(struct inode *inode,
1243 struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; 1241 struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data;
1244 struct ocfs2_extent_tree et; 1242 struct ocfs2_extent_tree et;
1245 1243
1246 ocfs2_get_dinode_extent_tree(&et, inode, di_bh); 1244 ocfs2_init_dinode_extent_tree(&et, inode, di_bh);
1247 1245
1248 ret = ocfs2_lock_allocators(inode, &et, 0, 1, NULL, &meta_ac); 1246 ret = ocfs2_lock_allocators(inode, &et, 0, 1, NULL, &meta_ac);
1249 if (ret) { 1247 if (ret) {
1250 ocfs2_put_extent_tree(&et);
1251 mlog_errno(ret); 1248 mlog_errno(ret);
1252 return ret; 1249 return ret;
1253 } 1250 }
@@ -1304,7 +1301,6 @@ out:
1304 if (meta_ac) 1301 if (meta_ac)
1305 ocfs2_free_alloc_context(meta_ac); 1302 ocfs2_free_alloc_context(meta_ac);
1306 1303
1307 ocfs2_put_extent_tree(&et);
1308 return ret; 1304 return ret;
1309} 1305}
1310 1306
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 9c3d4dc3e2ea..1a4de3dc2ba9 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -211,7 +211,7 @@ static int ocfs2_xattr_extend_allocation(struct inode *inode,
211 211
212 mlog(0, "(clusters_to_add for xattr= %u)\n", clusters_to_add); 212 mlog(0, "(clusters_to_add for xattr= %u)\n", clusters_to_add);
213 213
214 ocfs2_get_xattr_value_extent_tree(&et, inode, xattr_bh, xv); 214 ocfs2_init_xattr_value_extent_tree(&et, inode, xattr_bh, xv);
215 215
216restart_all: 216restart_all:
217 217
@@ -307,7 +307,6 @@ leave:
307 goto restart_all; 307 goto restart_all;
308 } 308 }
309 309
310 ocfs2_put_extent_tree(&et);
311 return status; 310 return status;
312} 311}
313 312
@@ -325,11 +324,10 @@ static int __ocfs2_remove_xattr_range(struct inode *inode,
325 struct ocfs2_alloc_context *meta_ac = NULL; 324 struct ocfs2_alloc_context *meta_ac = NULL;
326 struct ocfs2_extent_tree et; 325 struct ocfs2_extent_tree et;
327 326
328 ocfs2_get_xattr_value_extent_tree(&et, inode, root_bh, xv); 327 ocfs2_init_xattr_value_extent_tree(&et, inode, root_bh, xv);
329 328
330 ret = ocfs2_lock_allocators(inode, &et, 0, 1, NULL, &meta_ac); 329 ret = ocfs2_lock_allocators(inode, &et, 0, 1, NULL, &meta_ac);
331 if (ret) { 330 if (ret) {
332 ocfs2_put_extent_tree(&et);
333 mlog_errno(ret); 331 mlog_errno(ret);
334 return ret; 332 return ret;
335 } 333 }
@@ -385,7 +383,6 @@ out:
385 if (meta_ac) 383 if (meta_ac)
386 ocfs2_free_alloc_context(meta_ac); 384 ocfs2_free_alloc_context(meta_ac);
387 385
388 ocfs2_put_extent_tree(&et);
389 return ret; 386 return ret;
390} 387}
391 388
@@ -3632,7 +3629,7 @@ static int ocfs2_add_new_xattr_cluster(struct inode *inode,
3632 (unsigned long long)OCFS2_I(inode)->ip_blkno, 3629 (unsigned long long)OCFS2_I(inode)->ip_blkno,
3633 prev_cpos, prev_blkno); 3630 prev_cpos, prev_blkno);
3634 3631
3635 ocfs2_get_xattr_tree_extent_tree(&et, inode, root_bh); 3632 ocfs2_init_xattr_tree_extent_tree(&et, inode, root_bh);
3636 3633
3637 ret = ocfs2_lock_allocators(inode, &et, clusters_to_add, 0, 3634 ret = ocfs2_lock_allocators(inode, &et, clusters_to_add, 0,
3638 &data_ac, &meta_ac); 3635 &data_ac, &meta_ac);
@@ -3727,7 +3724,6 @@ leave:
3727 if (meta_ac) 3724 if (meta_ac)
3728 ocfs2_free_alloc_context(meta_ac); 3725 ocfs2_free_alloc_context(meta_ac);
3729 3726
3730 ocfs2_put_extent_tree(&et);
3731 return ret; 3727 return ret;
3732} 3728}
3733 3729
@@ -4336,7 +4332,7 @@ static int ocfs2_rm_xattr_cluster(struct inode *inode,
4336 struct ocfs2_cached_dealloc_ctxt dealloc; 4332 struct ocfs2_cached_dealloc_ctxt dealloc;
4337 struct ocfs2_extent_tree et; 4333 struct ocfs2_extent_tree et;
4338 4334
4339 ocfs2_get_xattr_tree_extent_tree(&et, inode, root_bh); 4335 ocfs2_init_xattr_tree_extent_tree(&et, inode, root_bh);
4340 4336
4341 ocfs2_init_dealloc_ctxt(&dealloc); 4337 ocfs2_init_dealloc_ctxt(&dealloc);
4342 4338
@@ -4347,7 +4343,6 @@ static int ocfs2_rm_xattr_cluster(struct inode *inode,
4347 4343
4348 ret = ocfs2_lock_allocators(inode, &et, 0, 1, NULL, &meta_ac); 4344 ret = ocfs2_lock_allocators(inode, &et, 0, 1, NULL, &meta_ac);
4349 if (ret) { 4345 if (ret) {
4350 ocfs2_put_extent_tree(&et);
4351 mlog_errno(ret); 4346 mlog_errno(ret);
4352 return ret; 4347 return ret;
4353 } 4348 }
@@ -4407,7 +4402,6 @@ out:
4407 4402
4408 ocfs2_run_deallocs(osb, &dealloc); 4403 ocfs2_run_deallocs(osb, &dealloc);
4409 4404
4410 ocfs2_put_extent_tree(&et);
4411 return ret; 4405 return ret;
4412} 4406}
4413 4407