*
* To implement an on-disk btree (extent tree) type in ocfs2, add
* an ocfs2_extent_tree_operations structure and the matching
- * ocfs2_get_<thingy>_extent_tree() function. That's pretty much it
+ * ocfs2_init_<thingy>_extent_tree() function. That's pretty much it
* for the allocation portion of the extent tree.
*/
struct ocfs2_extent_tree_operations {
.eo_fill_max_leaf_clusters = ocfs2_xattr_tree_fill_max_leaf_clusters,
};
-static void __ocfs2_get_extent_tree(struct ocfs2_extent_tree *et,
- struct inode *inode,
- struct buffer_head *bh,
- void *obj,
- struct ocfs2_extent_tree_operations *ops)
+static void __ocfs2_init_extent_tree(struct ocfs2_extent_tree *et,
+ struct inode *inode,
+ struct buffer_head *bh,
+ void *obj,
+ struct ocfs2_extent_tree_operations *ops)
{
et->et_ops = ops;
- get_bh(bh);
et->et_root_bh = bh;
if (!obj)
obj = (void *)bh->b_data;
et->et_ops->eo_fill_max_leaf_clusters(inode, et);
}
-void ocfs2_get_dinode_extent_tree(struct ocfs2_extent_tree *et,
- struct inode *inode,
- struct buffer_head *bh)
-{
- __ocfs2_get_extent_tree(et, inode, bh, NULL, &ocfs2_dinode_et_ops);
-}
-
-void ocfs2_get_xattr_tree_extent_tree(struct ocfs2_extent_tree *et,
- struct inode *inode,
- struct buffer_head *bh)
+void ocfs2_init_dinode_extent_tree(struct ocfs2_extent_tree *et,
+ struct inode *inode,
+ struct buffer_head *bh)
{
- __ocfs2_get_extent_tree(et, inode, bh, NULL,
- &ocfs2_xattr_tree_et_ops);
+ __ocfs2_init_extent_tree(et, inode, bh, NULL, &ocfs2_dinode_et_ops);
}
-void ocfs2_get_xattr_value_extent_tree(struct ocfs2_extent_tree *et,
+void ocfs2_init_xattr_tree_extent_tree(struct ocfs2_extent_tree *et,
struct inode *inode,
- struct buffer_head *bh,
- struct ocfs2_xattr_value_root *xv)
+ struct buffer_head *bh)
{
- __ocfs2_get_extent_tree(et, inode, bh, xv,
- &ocfs2_xattr_value_et_ops);
+ __ocfs2_init_extent_tree(et, inode, bh, NULL,
+ &ocfs2_xattr_tree_et_ops);
}
-void ocfs2_put_extent_tree(struct ocfs2_extent_tree *et)
+void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et,
+ struct inode *inode,
+ struct buffer_head *bh,
+ struct ocfs2_xattr_value_root *xv)
{
- brelse(et->et_root_bh);
+ __ocfs2_init_extent_tree(et, inode, bh, xv,
+ &ocfs2_xattr_value_et_ops);
}
static inline void ocfs2_et_set_last_eb_blk(struct ocfs2_extent_tree *et,
* this proves to be false, we could always re-build
* the in-inode data from our pages.
*/
- ocfs2_get_dinode_extent_tree(&et, inode, di_bh);
+ ocfs2_init_dinode_extent_tree(&et, inode, di_bh);
ret = ocfs2_insert_extent(osb, handle, inode, &et,
0, block, 1, 0, NULL);
- ocfs2_put_extent_tree(&et);
if (ret) {
mlog_errno(ret);
goto out_commit;
*
* ocfs2_extent_tree becomes the first-class object for extent tree
* manipulation. Callers of the alloc.c code need to fill it via one of
- * the ocfs2_get_*_extent_tree() operations below.
+ * the ocfs2_init_*_extent_tree() operations below.
*
* ocfs2_extent_tree contains info for the root of the b-tree, it must have a
* root ocfs2_extent_list and a root_bh so that they can be used in the b-tree
};
/*
- * ocfs2_*_get_extent_tree() will fill an ocfs2_extent_tree from the
- * specified object buffer. The bh is referenced until
- * ocfs2_put_extent_tree().
+ * ocfs2_init_*_extent_tree() will fill an ocfs2_extent_tree from the
+ * specified object buffer.
*/
-void ocfs2_get_dinode_extent_tree(struct ocfs2_extent_tree *et,
- struct inode *inode,
- struct buffer_head *bh);
-void ocfs2_get_xattr_tree_extent_tree(struct ocfs2_extent_tree *et,
- struct inode *inode,
- struct buffer_head *bh);
-void ocfs2_get_xattr_value_extent_tree(struct ocfs2_extent_tree *et,
+void ocfs2_init_dinode_extent_tree(struct ocfs2_extent_tree *et,
+ struct inode *inode,
+ struct buffer_head *bh);
+void ocfs2_init_xattr_tree_extent_tree(struct ocfs2_extent_tree *et,
struct inode *inode,
- struct buffer_head *bh,
- struct ocfs2_xattr_value_root *xv);
-void ocfs2_put_extent_tree(struct ocfs2_extent_tree *et);
+ struct buffer_head *bh);
+void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et,
+ struct inode *inode,
+ struct buffer_head *bh,
+ struct ocfs2_xattr_value_root *xv);
struct ocfs2_alloc_context;
int ocfs2_insert_extent(struct ocfs2_super *osb,
goto out;
}
} else if (unwritten) {
- ocfs2_get_dinode_extent_tree(&et, inode, wc->w_di_bh);
+ ocfs2_init_dinode_extent_tree(&et, inode, wc->w_di_bh);
ret = ocfs2_mark_extent_written(inode, &et,
wc->w_handle, cpos, 1, phys,
meta_ac, &wc->w_dealloc);
- ocfs2_put_extent_tree(&et);
if (ret < 0) {
mlog_errno(ret);
goto out;
(long long)i_size_read(inode), le32_to_cpu(di->i_clusters),
clusters_to_alloc, extents_to_split);
- ocfs2_get_dinode_extent_tree(&et, inode, wc->w_di_bh);
+ ocfs2_init_dinode_extent_tree(&et, inode, wc->w_di_bh);
ret = ocfs2_lock_allocators(inode, &et,
clusters_to_alloc, extents_to_split,
&data_ac, &meta_ac);
- ocfs2_put_extent_tree(&et);
if (ret) {
mlog_errno(ret);
goto out;
handle_t *handle;
struct ocfs2_extent_tree et;
- ocfs2_get_dinode_extent_tree(&et, dir, di_bh);
+ ocfs2_init_dinode_extent_tree(&et, dir, di_bh);
alloc = ocfs2_clusters_for_bytes(sb, bytes);
brelse(dirdata_bh);
- ocfs2_put_extent_tree(&et);
return ret;
}
spin_lock(&OCFS2_I(dir)->ip_lock);
if (dir_i_size == ocfs2_clusters_to_bytes(sb, OCFS2_I(dir)->ip_clusters)) {
spin_unlock(&OCFS2_I(dir)->ip_lock);
- ocfs2_get_dinode_extent_tree(&et, dir, parent_fe_bh);
+ ocfs2_init_dinode_extent_tree(&et, dir, parent_fe_bh);
num_free_extents = ocfs2_num_free_extents(osb, dir, &et);
- ocfs2_put_extent_tree(&et);
if (num_free_extents < 0) {
status = num_free_extents;
mlog_errno(status);
int ret;
struct ocfs2_extent_tree et;
- ocfs2_get_dinode_extent_tree(&et, inode, fe_bh);
+ ocfs2_init_dinode_extent_tree(&et, inode, fe_bh);
ret = ocfs2_add_clusters_in_btree(osb, inode, logical_offset,
clusters_to_add, mark_unwritten,
&et, handle,
data_ac, meta_ac, reason_ret);
- ocfs2_put_extent_tree(&et);
return ret;
}
(unsigned long long)OCFS2_I(inode)->ip_blkno,
(long long)i_size_read(inode), le32_to_cpu(fe->i_clusters),
clusters_to_add);
- ocfs2_get_dinode_extent_tree(&et, inode, bh);
+ ocfs2_init_dinode_extent_tree(&et, inode, bh);
status = ocfs2_lock_allocators(inode, &et, clusters_to_add, 0,
&data_ac, &meta_ac);
- ocfs2_put_extent_tree(&et);
if (status) {
mlog_errno(status);
goto leave;
struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data;
struct ocfs2_extent_tree et;
- ocfs2_get_dinode_extent_tree(&et, inode, di_bh);
+ ocfs2_init_dinode_extent_tree(&et, inode, di_bh);
ret = ocfs2_lock_allocators(inode, &et, 0, 1, NULL, &meta_ac);
if (ret) {
- ocfs2_put_extent_tree(&et);
mlog_errno(ret);
return ret;
}
if (meta_ac)
ocfs2_free_alloc_context(meta_ac);
- ocfs2_put_extent_tree(&et);
return ret;
}
mlog(0, "(clusters_to_add for xattr= %u)\n", clusters_to_add);
- ocfs2_get_xattr_value_extent_tree(&et, inode, xattr_bh, xv);
+ ocfs2_init_xattr_value_extent_tree(&et, inode, xattr_bh, xv);
restart_all:
goto restart_all;
}
- ocfs2_put_extent_tree(&et);
return status;
}
struct ocfs2_alloc_context *meta_ac = NULL;
struct ocfs2_extent_tree et;
- ocfs2_get_xattr_value_extent_tree(&et, inode, root_bh, xv);
+ ocfs2_init_xattr_value_extent_tree(&et, inode, root_bh, xv);
ret = ocfs2_lock_allocators(inode, &et, 0, 1, NULL, &meta_ac);
if (ret) {
- ocfs2_put_extent_tree(&et);
mlog_errno(ret);
return ret;
}
if (meta_ac)
ocfs2_free_alloc_context(meta_ac);
- ocfs2_put_extent_tree(&et);
return ret;
}
(unsigned long long)OCFS2_I(inode)->ip_blkno,
prev_cpos, prev_blkno);
- ocfs2_get_xattr_tree_extent_tree(&et, inode, root_bh);
+ ocfs2_init_xattr_tree_extent_tree(&et, inode, root_bh);
ret = ocfs2_lock_allocators(inode, &et, clusters_to_add, 0,
&data_ac, &meta_ac);
if (meta_ac)
ocfs2_free_alloc_context(meta_ac);
- ocfs2_put_extent_tree(&et);
return ret;
}
struct ocfs2_cached_dealloc_ctxt dealloc;
struct ocfs2_extent_tree et;
- ocfs2_get_xattr_tree_extent_tree(&et, inode, root_bh);
+ ocfs2_init_xattr_tree_extent_tree(&et, inode, root_bh);
ocfs2_init_dealloc_ctxt(&dealloc);
ret = ocfs2_lock_allocators(inode, &et, 0, 1, NULL, &meta_ac);
if (ret) {
- ocfs2_put_extent_tree(&et);
mlog_errno(ret);
return ret;
}
ocfs2_run_deallocs(osb, &dealloc);
- ocfs2_put_extent_tree(&et);
return ret;
}