1 From: Joel Becker <joel.becker@oracle.com>
2 Subject: ocfs2: Create specific get_extent_tree functions.
3 Patch-mainline: 2.6.28?
6 A caller knows what kind of extent tree they have. There's no reason
7 they have to call ocfs2_get_extent_tree() with a NULL when they could
8 just as easily call a specific function to their type of extent tree.
10 Introduce ocfs2_dinode_get_extent_tree(),
11 ocfs2_xattr_tree_get_extent_tree(), and
12 ocfs2_xattr_value_get_extent_tree(). They only take the necessary
13 arguments, calling into the underlying __ocfs2_get_extent_tree() to do
16 __ocfs2_get_extent_tree() is the old ocfs2_get_extent_tree(), but
17 without needing any switch-by-type logic.
19 ocfs2_get_extent_tree() is now a wrapper around the specific calls. It
20 exists because a couple alloc.c functions can take et_type. This will
23 Another benefit is that ocfs2_xattr_value_get_extent_tree() can take a
24 struct ocfs2_xattr_value_root* instead of void*. This gives us
25 typechecking where we didn't have it before.
27 Signed-off-by: Joel Becker <joel.becker@oracle.com>
28 Acked-by: Mark Fasheh <mark.fasheh@suse.com>
30 fs/ocfs2/alloc.c | 76 +++++++++++++++++++++++++++++++++++++++---------------
31 fs/ocfs2/alloc.h | 2 +-
32 2 files changed, 56 insertions(+), 22 deletions(-)
34 diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
35 index 7c0721d..243bacf 100644
36 --- a/fs/ocfs2/alloc.c
37 +++ b/fs/ocfs2/alloc.c
38 @@ -192,7 +192,7 @@ static int ocfs2_xattr_value_sanity_check(struct inode *inode,
42 -static struct ocfs2_extent_tree_operations ocfs2_xattr_et_ops = {
43 +static struct ocfs2_extent_tree_operations ocfs2_xattr_value_et_ops = {
44 .eo_set_last_eb_blk = ocfs2_xattr_value_set_last_eb_blk,
45 .eo_get_last_eb_blk = ocfs2_xattr_value_get_last_eb_blk,
46 .eo_update_clusters = ocfs2_xattr_value_update_clusters,
47 @@ -256,27 +256,21 @@ static struct ocfs2_extent_tree_operations ocfs2_xattr_tree_et_ops = {
48 .eo_fill_max_leaf_clusters = ocfs2_xattr_tree_fill_max_leaf_clusters,
51 -static void ocfs2_get_extent_tree(struct ocfs2_extent_tree *et,
52 - struct inode *inode,
53 - struct buffer_head *bh,
54 - enum ocfs2_extent_tree_type et_type,
56 +static void __ocfs2_get_extent_tree(struct ocfs2_extent_tree *et,
57 + struct inode *inode,
58 + struct buffer_head *bh,
60 + enum ocfs2_extent_tree_type et_type,
61 + struct ocfs2_extent_tree_operations *ops)
63 et->et_type = et_type;
68 obj = (void *)bh->b_data;
71 - if (et_type == OCFS2_DINODE_EXTENT) {
72 - et->et_ops = &ocfs2_dinode_et_ops;
73 - } else if (et_type == OCFS2_XATTR_VALUE_EXTENT) {
74 - et->et_ops = &ocfs2_xattr_et_ops;
75 - } else if (et_type == OCFS2_XATTR_TREE_EXTENT) {
76 - et->et_ops = &ocfs2_xattr_tree_et_ops;
79 et->et_ops->eo_fill_root_el(et);
80 if (!et->et_ops->eo_fill_max_leaf_clusters)
81 et->et_max_leaf_clusters = 0;
82 @@ -284,6 +278,49 @@ static void ocfs2_get_extent_tree(struct ocfs2_extent_tree *et,
83 et->et_ops->eo_fill_max_leaf_clusters(inode, et);
86 +static void ocfs2_get_dinode_extent_tree(struct ocfs2_extent_tree *et,
87 + struct inode *inode,
88 + struct buffer_head *bh)
90 + __ocfs2_get_extent_tree(et, inode, bh, NULL, OCFS2_DINODE_EXTENT,
91 + &ocfs2_dinode_et_ops);
94 +static void ocfs2_get_xattr_tree_extent_tree(struct ocfs2_extent_tree *et,
95 + struct inode *inode,
96 + struct buffer_head *bh)
98 + __ocfs2_get_extent_tree(et, inode, bh, NULL,
99 + OCFS2_XATTR_TREE_EXTENT,
100 + &ocfs2_xattr_tree_et_ops);
103 +static void ocfs2_get_xattr_value_extent_tree(struct ocfs2_extent_tree *et,
104 + struct inode *inode,
105 + struct buffer_head *bh,
106 + struct ocfs2_xattr_value_root *xv)
108 + __ocfs2_get_extent_tree(et, inode, bh, xv,
109 + OCFS2_XATTR_VALUE_EXTENT,
110 + &ocfs2_xattr_value_et_ops);
113 +static void ocfs2_get_extent_tree(struct ocfs2_extent_tree *et,
114 + struct inode *inode,
115 + struct buffer_head *bh,
116 + enum ocfs2_extent_tree_type et_type,
119 + if (et_type == OCFS2_DINODE_EXTENT)
120 + ocfs2_get_dinode_extent_tree(et, inode, bh);
121 + else if (et_type == OCFS2_XATTR_VALUE_EXTENT)
122 + ocfs2_get_xattr_tree_extent_tree(et, inode, bh);
123 + else if (et_type == OCFS2_XATTR_TREE_EXTENT)
124 + ocfs2_get_xattr_value_extent_tree(et, inode, bh, obj);
129 static void ocfs2_put_extent_tree(struct ocfs2_extent_tree *et)
131 brelse(et->et_root_bh);
132 @@ -4441,8 +4478,7 @@ int ocfs2_dinode_insert_extent(struct ocfs2_super *osb,
134 struct ocfs2_extent_tree et;
136 - ocfs2_get_extent_tree(&et, inode, root_bh, OCFS2_DINODE_EXTENT,
138 + ocfs2_get_dinode_extent_tree(&et, inode, root_bh);
139 status = ocfs2_insert_extent(osb, handle, inode, root_bh,
140 cpos, start_blk, new_clusters,
141 flags, meta_ac, &et);
142 @@ -4460,13 +4496,12 @@ int ocfs2_xattr_value_insert_extent(struct ocfs2_super *osb,
145 struct ocfs2_alloc_context *meta_ac,
147 + struct ocfs2_xattr_value_root *xv)
150 struct ocfs2_extent_tree et;
152 - ocfs2_get_extent_tree(&et, inode, root_bh,
153 - OCFS2_XATTR_VALUE_EXTENT, obj);
154 + ocfs2_get_xattr_value_extent_tree(&et, inode, root_bh, xv);
155 status = ocfs2_insert_extent(osb, handle, inode, root_bh,
156 cpos, start_blk, new_clusters,
157 flags, meta_ac, &et);
158 @@ -4488,8 +4523,7 @@ int ocfs2_xattr_tree_insert_extent(struct ocfs2_super *osb,
160 struct ocfs2_extent_tree et;
162 - ocfs2_get_extent_tree(&et, inode, root_bh, OCFS2_XATTR_TREE_EXTENT,
164 + ocfs2_get_xattr_tree_extent_tree(&et, inode, root_bh);
165 status = ocfs2_insert_extent(osb, handle, inode, root_bh,
166 cpos, start_blk, new_clusters,
167 flags, meta_ac, &et);
168 diff --git a/fs/ocfs2/alloc.h b/fs/ocfs2/alloc.h
169 index ff40c8f..04a551f 100644
170 --- a/fs/ocfs2/alloc.h
171 +++ b/fs/ocfs2/alloc.h
172 @@ -56,7 +56,7 @@ int ocfs2_xattr_value_insert_extent(struct ocfs2_super *osb,
175 struct ocfs2_alloc_context *meta_ac,
177 + struct ocfs2_xattr_value_root *xv);
178 int ocfs2_xattr_tree_insert_extent(struct ocfs2_super *osb,