]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/patches/suse-2.6.27.25/patches.suse/ocfs2-Create-specific-get_extent_tree-functions.patch
Updated xen patches taken from suse.
[people/teissler/ipfire-2.x.git] / src / patches / suse-2.6.27.25 / patches.suse / ocfs2-Create-specific-get_extent_tree-functions.patch
1 From: Joel Becker <joel.becker@oracle.com>
2 Subject: ocfs2: Create specific get_extent_tree functions.
3 Patch-mainline: 2.6.28?
4 References: FATE302067
5
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.
9
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
14 the real work.
15
16 __ocfs2_get_extent_tree() is the old ocfs2_get_extent_tree(), but
17 without needing any switch-by-type logic.
18
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
21 go later.
22
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.
26
27 Signed-off-by: Joel Becker <joel.becker@oracle.com>
28 Acked-by: Mark Fasheh <mark.fasheh@suse.com>
29 ---
30 fs/ocfs2/alloc.c | 76 +++++++++++++++++++++++++++++++++++++++---------------
31 fs/ocfs2/alloc.h | 2 +-
32 2 files changed, 56 insertions(+), 22 deletions(-)
33
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,
39 return 0;
40 }
41
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,
49 };
50
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,
55 - void *obj)
56 +static void __ocfs2_get_extent_tree(struct ocfs2_extent_tree *et,
57 + struct inode *inode,
58 + struct buffer_head *bh,
59 + void *obj,
60 + enum ocfs2_extent_tree_type et_type,
61 + struct ocfs2_extent_tree_operations *ops)
62 {
63 et->et_type = et_type;
64 + et->et_ops = ops;
65 get_bh(bh);
66 et->et_root_bh = bh;
67 if (!obj)
68 obj = (void *)bh->b_data;
69 et->et_object = obj;
70
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;
77 - }
78 -
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);
84 }
85
86 +static void ocfs2_get_dinode_extent_tree(struct ocfs2_extent_tree *et,
87 + struct inode *inode,
88 + struct buffer_head *bh)
89 +{
90 + __ocfs2_get_extent_tree(et, inode, bh, NULL, OCFS2_DINODE_EXTENT,
91 + &ocfs2_dinode_et_ops);
92 +}
93 +
94 +static void ocfs2_get_xattr_tree_extent_tree(struct ocfs2_extent_tree *et,
95 + struct inode *inode,
96 + struct buffer_head *bh)
97 +{
98 + __ocfs2_get_extent_tree(et, inode, bh, NULL,
99 + OCFS2_XATTR_TREE_EXTENT,
100 + &ocfs2_xattr_tree_et_ops);
101 +}
102 +
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)
107 +{
108 + __ocfs2_get_extent_tree(et, inode, bh, xv,
109 + OCFS2_XATTR_VALUE_EXTENT,
110 + &ocfs2_xattr_value_et_ops);
111 +}
112 +
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,
117 + void *obj)
118 +{
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);
125 + else
126 + BUG();
127 +}
128 +
129 static void ocfs2_put_extent_tree(struct ocfs2_extent_tree *et)
130 {
131 brelse(et->et_root_bh);
132 @@ -4441,8 +4478,7 @@ int ocfs2_dinode_insert_extent(struct ocfs2_super *osb,
133 int status;
134 struct ocfs2_extent_tree et;
135
136 - ocfs2_get_extent_tree(&et, inode, root_bh, OCFS2_DINODE_EXTENT,
137 - NULL);
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,
143 u32 new_clusters,
144 u8 flags,
145 struct ocfs2_alloc_context *meta_ac,
146 - void *obj)
147 + struct ocfs2_xattr_value_root *xv)
148 {
149 int status;
150 struct ocfs2_extent_tree et;
151
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,
159 int status;
160 struct ocfs2_extent_tree et;
161
162 - ocfs2_get_extent_tree(&et, inode, root_bh, OCFS2_XATTR_TREE_EXTENT,
163 - NULL);
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,
173 u32 new_clusters,
174 u8 flags,
175 struct ocfs2_alloc_context *meta_ac,
176 - void *private);
177 + struct ocfs2_xattr_value_root *xv);
178 int ocfs2_xattr_tree_insert_extent(struct ocfs2_super *osb,
179 handle_t *handle,
180 struct inode *inode,
181 --
182 1.5.4.5
183