From: Mark Fasheh <mfasheh@suse.com>
To: linux-kernel@vger.kernel.org
Cc: joel.becker@oracle.com, ocfs2-devel@oss.oracle.com,
linux-fsdevel@vger.kernel.org, Mark Fasheh <mfasheh@suse.com>
Subject: [PATCH 33/39] ocfs2: Change ocfs2_get_*_extent_tree() to ocfs2_init_*_extent_tree()
Date: Wed, 24 Sep 2008 15:01:14 -0700 [thread overview]
Message-ID: <1222293680-15451-34-git-send-email-mfasheh@suse.com> (raw)
In-Reply-To: <1222293680-15451-1-git-send-email-mfasheh@suse.com>
From: Joel Becker <joel.becker@oracle.com>
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>
---
fs/ocfs2/alloc.c | 49 +++++++++++++++++++++----------------------------
fs/ocfs2/alloc.h | 26 ++++++++++++--------------
fs/ocfs2/aops.c | 6 ++----
fs/ocfs2/dir.c | 6 ++----
fs/ocfs2/file.c | 10 +++-------
fs/ocfs2/xattr.c | 14 ++++----------
6 files changed, 44 insertions(+), 67 deletions(-)
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 51c3183..5f44ef8 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -55,7 +55,7 @@
*
* 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 {
@@ -301,14 +301,13 @@ static struct ocfs2_extent_tree_operations ocfs2_xattr_tree_et_ops = {
.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;
@@ -321,33 +320,28 @@ static void __ocfs2_get_extent_tree(struct ocfs2_extent_tree *et,
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,
@@ -6800,10 +6794,9 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode,
* 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;
diff --git a/fs/ocfs2/alloc.h b/fs/ocfs2/alloc.h
index 27311da..a0ae6bd 100644
--- a/fs/ocfs2/alloc.h
+++ b/fs/ocfs2/alloc.h
@@ -41,7 +41,7 @@
*
* 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
@@ -59,21 +59,19 @@ struct ocfs2_extent_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,
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index ed937fa..259775e 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -1277,11 +1277,10 @@ static int ocfs2_write_cluster(struct address_space *mapping,
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;
@@ -1722,11 +1721,10 @@ int ocfs2_write_begin_nolock(struct address_space *mapping,
(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;
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 2cdc553..167e6c9 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,
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);
@@ -1363,7 +1363,6 @@ out:
brelse(dirdata_bh);
- ocfs2_put_extent_tree(&et);
return ret;
}
@@ -1485,9 +1484,8 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
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);
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 659eb70..480412a 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -512,12 +512,11 @@ int ocfs2_add_inode_data(struct ocfs2_super *osb,
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;
}
@@ -568,10 +567,9 @@ restart_all:
(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;
@@ -1243,11 +1241,10 @@ static int __ocfs2_remove_inode_range(struct inode *inode,
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;
}
@@ -1304,7 +1301,6 @@ out:
if (meta_ac)
ocfs2_free_alloc_context(meta_ac);
- ocfs2_put_extent_tree(&et);
return ret;
}
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 9c3d4dc..1a4de3d 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -211,7 +211,7 @@ static int ocfs2_xattr_extend_allocation(struct inode *inode,
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:
@@ -307,7 +307,6 @@ leave:
goto restart_all;
}
- ocfs2_put_extent_tree(&et);
return status;
}
@@ -325,11 +324,10 @@ static int __ocfs2_remove_xattr_range(struct inode *inode,
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;
}
@@ -385,7 +383,6 @@ out:
if (meta_ac)
ocfs2_free_alloc_context(meta_ac);
- ocfs2_put_extent_tree(&et);
return ret;
}
@@ -3632,7 +3629,7 @@ static int ocfs2_add_new_xattr_cluster(struct inode *inode,
(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);
@@ -3727,7 +3724,6 @@ leave:
if (meta_ac)
ocfs2_free_alloc_context(meta_ac);
- ocfs2_put_extent_tree(&et);
return ret;
}
@@ -4336,7 +4332,7 @@ static int ocfs2_rm_xattr_cluster(struct inode *inode,
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);
@@ -4347,7 +4343,6 @@ static int ocfs2_rm_xattr_cluster(struct inode *inode,
ret = ocfs2_lock_allocators(inode, &et, 0, 1, NULL, &meta_ac);
if (ret) {
- ocfs2_put_extent_tree(&et);
mlog_errno(ret);
return ret;
}
@@ -4407,7 +4402,6 @@ out:
ocfs2_run_deallocs(osb, &dealloc);
- ocfs2_put_extent_tree(&et);
return ret;
}
--
1.5.4.5
next prev parent reply other threads:[~2008-09-24 22:14 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-24 22:00 [PATCH 0/39] Ocfs2 updates for 2.6.28 Mark Fasheh
2008-09-24 22:00 ` [PATCH 01/39] ocfs2: POSIX file locks support Mark Fasheh
2008-10-02 6:11 ` Andrew Morton
2008-10-07 20:09 ` Mark Fasheh
2008-09-24 22:00 ` [PATCH 02/39] ocfs2: Track local alloc bits internally Mark Fasheh
2008-09-24 22:00 ` [PATCH 03/39] ocfs2: throttle back local alloc when low on disk space Mark Fasheh
2008-10-02 6:11 ` Andrew Morton
2008-09-24 22:00 ` [PATCH 04/39] ocfs2: track local alloc state via debugfs Mark Fasheh
2008-10-02 6:11 ` Andrew Morton
2008-10-07 20:10 ` Mark Fasheh
2008-09-24 22:00 ` [PATCH 05/39] ocfs2: Modify ocfs2_num_free_extents for future xattr usage Mark Fasheh
2008-09-24 22:00 ` [PATCH 06/39] ocfs2: Use ocfs2_extent_list instead of ocfs2_dinode Mark Fasheh
2008-09-24 22:00 ` [PATCH 07/39] ocfs2: Abstract ocfs2_extent_tree in b-tree operations Mark Fasheh
2008-09-24 22:00 ` [PATCH 08/39] ocfs2: Make high level btree extend code generic Mark Fasheh
2008-09-24 22:00 ` [PATCH 09/39] ocfs2: Add the basic xattr disk layout in ocfs2_fs.h Mark Fasheh
2008-09-24 22:00 ` [PATCH 10/39] ocfs2: Add helper function in uptodate.c for removing xattr clusters Mark Fasheh
2008-10-02 6:11 ` Andrew Morton
2008-10-07 20:18 ` Mark Fasheh
2008-09-24 22:00 ` [PATCH 11/39] ocfs2: Add extent tree operation for xattr value btrees Mark Fasheh
2008-10-02 6:12 ` Andrew Morton
2008-10-07 20:19 ` Mark Fasheh
2008-10-02 6:12 ` Andrew Morton
2008-10-07 21:19 ` Mark Fasheh
2008-09-24 22:00 ` [PATCH 12/39] ocfs2: reserve inline space for extended attribute Mark Fasheh
2008-09-24 22:00 ` [PATCH 13/39] ocfs2: Add extended attribute support Mark Fasheh
2008-10-02 6:12 ` Andrew Morton
2008-10-07 20:22 ` Mark Fasheh
2008-10-02 8:16 ` [Ocfs2-devel] " Christoph Hellwig
2008-10-07 22:08 ` Mark Fasheh
2008-10-08 1:56 ` Tiger Yang
2008-10-08 13:16 ` Christoph Hellwig
2008-10-08 13:34 ` Christoph Hellwig
2008-10-08 14:04 ` Tao Ma
2008-10-09 0:38 ` Mark Fasheh
2008-10-08 13:22 ` Christoph Hellwig
2008-09-24 22:00 ` [PATCH 14/39] ocfs2: Add xattr index tree operations Mark Fasheh
2008-09-24 22:00 ` [PATCH 15/39] ocfs2: Add xattr bucket iteration for large numbers of EAs Mark Fasheh
2008-09-24 22:00 ` [PATCH 16/39] ocfs2: Add xattr lookup code xattr btrees Mark Fasheh
2008-09-24 22:00 ` [PATCH 17/39] ocfs2: Optionally limit extent size in ocfs2_insert_extent() Mark Fasheh
2008-09-24 22:00 ` [PATCH 18/39] ocfs2: Enable xattr set in index btree Mark Fasheh
2008-09-24 22:01 ` [PATCH 19/39] ocfs2: Delete all xattr buckets during inode removal Mark Fasheh
2008-09-24 22:01 ` [PATCH 20/39] ocfs2: Add incompatible flag for extended attribute Mark Fasheh
2008-09-24 22:01 ` [PATCH 21/39] ocfs2: fix printk format warnings Mark Fasheh
2008-09-24 22:01 ` [PATCH 22/39] ocfs2: Prefix the extent tree operations structure Mark Fasheh
2008-09-24 22:01 ` [PATCH 23/39] ocfs2: Prefix the ocfs2_extent_tree structure Mark Fasheh
2008-09-24 22:01 ` [PATCH 24/39] ocfs2: Make ocfs2_extent_tree get/put instead of alloc Mark Fasheh
2008-09-24 22:01 ` [PATCH 25/39] ocfs2: Make 'private' into 'object' on ocfs2_extent_tree Mark Fasheh
2008-09-24 22:01 ` [PATCH 26/39] ocfs2: Provide the get_root_el() method to ocfs2_extent_tree_operations Mark Fasheh
2008-09-24 22:01 ` [PATCH 27/39] ocfs2: Use struct ocfs2_extent_tree in ocfs2_num_free_extents() Mark Fasheh
2008-09-24 22:01 ` [PATCH 28/39] ocfs2: Determine an extent tree's max_leaf_clusters in an et_op Mark Fasheh
2008-09-24 22:01 ` [PATCH 29/39] ocfs2: Create specific get_extent_tree functions Mark Fasheh
2008-09-24 22:01 ` [PATCH 30/39] ocfs2: Add an insertion check to ocfs2_extent_tree_operations Mark Fasheh
2008-09-24 22:01 ` [PATCH 31/39] ocfs2: Make ocfs2_extent_tree the first-class representation of a tree Mark Fasheh
2008-09-24 22:01 ` [PATCH 32/39] ocfs2: Comment struct ocfs2_extent_tree_operations Mark Fasheh
2008-09-24 22:01 ` Mark Fasheh [this message]
2008-09-24 22:01 ` [PATCH 34/39] ocfs2: bug-fix for journal extend in xattr Mark Fasheh
2008-09-24 22:01 ` [PATCH 35/39] ocfs2: Resolve deadlock in ocfs2_xattr_free_block Mark Fasheh
2008-09-24 22:01 ` [PATCH 36/39] ocfs2: Limit inode allocation to 32bits Mark Fasheh
2008-09-24 22:01 ` [PATCH 37/39] ocfs2: Add the 'inode64' mount option Mark Fasheh
2008-09-24 22:01 ` [PATCH 38/39] ocfs2: Switch over to JBD2 Mark Fasheh
2008-09-24 22:01 ` [PATCH 39/39] ocfs2: Add xattr mount option in ocfs2_show_options() Mark Fasheh
2008-09-28 5:16 ` [PATCH 0/39] Ocfs2 updates for 2.6.28 Tao Ma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1222293680-15451-34-git-send-email-mfasheh@suse.com \
--to=mfasheh@suse.com \
--cc=joel.becker@oracle.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ocfs2-devel@oss.oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®