]>
Commit | Line | Data |
---|---|---|
2cb7cef9 BS |
1 | From: Joel Becker <joel.becker@oracle.com> |
2 | Subject: ocfs2: Make 'private' into 'object' on ocfs2_extent_tree. | |
3 | Patch-mainline: 2.6.28? | |
4 | References: FATE302067 | |
5 | ||
6 | The 'private' pointer was a way to store off xattr values, which don't | |
7 | live at a set place in the bh. But the concept of "the object | |
8 | containing the extent tree" is much more generic. For an inode it's the | |
9 | struct ocfs2_dinode, for an xattr value its the value. Let's save off | |
10 | the 'object' at all times. If NULL is passed to | |
11 | ocfs2_get_extent_tree(), 'object' is set to bh->b_data; | |
12 | ||
13 | Signed-off-by: Joel Becker <joel.becker@oracle.com> | |
14 | Acked-by: Mark Fasheh <mark.fasheh@suse.com> | |
15 | --- | |
16 | fs/ocfs2/alloc.c | 62 +++++++++++++++++++++++++---------------------------- | |
17 | 1 files changed, 29 insertions(+), 33 deletions(-) | |
18 | ||
19 | diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c | |
20 | index 0abf11e..93f44f4 100644 | |
21 | --- a/fs/ocfs2/alloc.c | |
22 | +++ b/fs/ocfs2/alloc.c | |
23 | @@ -79,15 +79,14 @@ struct ocfs2_extent_tree { | |
24 | struct ocfs2_extent_tree_operations *et_ops; | |
25 | struct buffer_head *et_root_bh; | |
26 | struct ocfs2_extent_list *et_root_el; | |
27 | - void *et_private; | |
28 | + void *et_object; | |
29 | unsigned int et_max_leaf_clusters; | |
30 | }; | |
31 | ||
32 | static void ocfs2_dinode_set_last_eb_blk(struct ocfs2_extent_tree *et, | |
33 | u64 blkno) | |
34 | { | |
35 | - struct ocfs2_dinode *di = | |
36 | - (struct ocfs2_dinode *)et->et_root_bh->b_data; | |
37 | + struct ocfs2_dinode *di = et->et_object; | |
38 | ||
39 | BUG_ON(et->et_type != OCFS2_DINODE_EXTENT); | |
40 | di->i_last_eb_blk = cpu_to_le64(blkno); | |
41 | @@ -95,8 +94,7 @@ static void ocfs2_dinode_set_last_eb_blk(struct ocfs2_extent_tree *et, | |
42 | ||
43 | static u64 ocfs2_dinode_get_last_eb_blk(struct ocfs2_extent_tree *et) | |
44 | { | |
45 | - struct ocfs2_dinode *di = | |
46 | - (struct ocfs2_dinode *)et->et_root_bh->b_data; | |
47 | + struct ocfs2_dinode *di = et->et_object; | |
48 | ||
49 | BUG_ON(et->et_type != OCFS2_DINODE_EXTENT); | |
50 | return le64_to_cpu(di->i_last_eb_blk); | |
51 | @@ -106,8 +104,7 @@ static void ocfs2_dinode_update_clusters(struct inode *inode, | |
52 | struct ocfs2_extent_tree *et, | |
53 | u32 clusters) | |
54 | { | |
55 | - struct ocfs2_dinode *di = | |
56 | - (struct ocfs2_dinode *)et->et_root_bh->b_data; | |
57 | + struct ocfs2_dinode *di = et->et_object; | |
58 | ||
59 | le32_add_cpu(&di->i_clusters, clusters); | |
60 | spin_lock(&OCFS2_I(inode)->ip_lock); | |
61 | @@ -123,7 +120,7 @@ static int ocfs2_dinode_sanity_check(struct inode *inode, | |
62 | ||
63 | BUG_ON(et->et_type != OCFS2_DINODE_EXTENT); | |
64 | ||
65 | - di = (struct ocfs2_dinode *)et->et_root_bh->b_data; | |
66 | + di = et->et_object; | |
67 | if (!OCFS2_IS_VALID_DINODE(di)) { | |
68 | ret = -EIO; | |
69 | ocfs2_error(inode->i_sb, | |
70 | @@ -145,7 +142,7 @@ static void ocfs2_xattr_value_set_last_eb_blk(struct ocfs2_extent_tree *et, | |
71 | u64 blkno) | |
72 | { | |
73 | struct ocfs2_xattr_value_root *xv = | |
74 | - (struct ocfs2_xattr_value_root *)et->et_private; | |
75 | + (struct ocfs2_xattr_value_root *)et->et_object; | |
76 | ||
77 | xv->xr_last_eb_blk = cpu_to_le64(blkno); | |
78 | } | |
79 | @@ -153,7 +150,7 @@ static void ocfs2_xattr_value_set_last_eb_blk(struct ocfs2_extent_tree *et, | |
80 | static u64 ocfs2_xattr_value_get_last_eb_blk(struct ocfs2_extent_tree *et) | |
81 | { | |
82 | struct ocfs2_xattr_value_root *xv = | |
83 | - (struct ocfs2_xattr_value_root *) et->et_private; | |
84 | + (struct ocfs2_xattr_value_root *) et->et_object; | |
85 | ||
86 | return le64_to_cpu(xv->xr_last_eb_blk); | |
87 | } | |
88 | @@ -163,7 +160,7 @@ static void ocfs2_xattr_value_update_clusters(struct inode *inode, | |
89 | u32 clusters) | |
90 | { | |
91 | struct ocfs2_xattr_value_root *xv = | |
92 | - (struct ocfs2_xattr_value_root *)et->et_private; | |
93 | + (struct ocfs2_xattr_value_root *)et->et_object; | |
94 | ||
95 | le32_add_cpu(&xv->xr_clusters, clusters); | |
96 | } | |
97 | @@ -184,8 +181,7 @@ static struct ocfs2_extent_tree_operations ocfs2_xattr_et_ops = { | |
98 | static void ocfs2_xattr_tree_set_last_eb_blk(struct ocfs2_extent_tree *et, | |
99 | u64 blkno) | |
100 | { | |
101 | - struct ocfs2_xattr_block *xb = | |
102 | - (struct ocfs2_xattr_block *) et->et_root_bh->b_data; | |
103 | + struct ocfs2_xattr_block *xb = et->et_object; | |
104 | struct ocfs2_xattr_tree_root *xt = &xb->xb_attrs.xb_root; | |
105 | ||
106 | xt->xt_last_eb_blk = cpu_to_le64(blkno); | |
107 | @@ -193,8 +189,7 @@ static void ocfs2_xattr_tree_set_last_eb_blk(struct ocfs2_extent_tree *et, | |
108 | ||
109 | static u64 ocfs2_xattr_tree_get_last_eb_blk(struct ocfs2_extent_tree *et) | |
110 | { | |
111 | - struct ocfs2_xattr_block *xb = | |
112 | - (struct ocfs2_xattr_block *) et->et_root_bh->b_data; | |
113 | + struct ocfs2_xattr_block *xb = et->et_object; | |
114 | struct ocfs2_xattr_tree_root *xt = &xb->xb_attrs.xb_root; | |
115 | ||
116 | return le64_to_cpu(xt->xt_last_eb_blk); | |
117 | @@ -204,8 +199,7 @@ static void ocfs2_xattr_tree_update_clusters(struct inode *inode, | |
118 | struct ocfs2_extent_tree *et, | |
119 | u32 clusters) | |
120 | { | |
121 | - struct ocfs2_xattr_block *xb = | |
122 | - (struct ocfs2_xattr_block *)et->et_root_bh->b_data; | |
123 | + struct ocfs2_xattr_block *xb = et->et_object; | |
124 | ||
125 | le32_add_cpu(&xb->xb_attrs.xb_root.xt_clusters, clusters); | |
126 | } | |
127 | @@ -227,26 +221,28 @@ static void ocfs2_get_extent_tree(struct ocfs2_extent_tree *et, | |
128 | struct inode *inode, | |
129 | struct buffer_head *bh, | |
130 | enum ocfs2_extent_tree_type et_type, | |
131 | - void *private) | |
132 | + void *obj) | |
133 | { | |
134 | et->et_type = et_type; | |
135 | get_bh(bh); | |
136 | et->et_root_bh = bh; | |
137 | - et->et_private = private; | |
138 | et->et_max_leaf_clusters = 0; | |
139 | + if (!obj) | |
140 | + obj = (void *)bh->b_data; | |
141 | + et->et_object = obj; | |
142 | ||
143 | if (et_type == OCFS2_DINODE_EXTENT) { | |
144 | et->et_root_el = | |
145 | - &((struct ocfs2_dinode *)bh->b_data)->id2.i_list; | |
146 | + &((struct ocfs2_dinode *)obj)->id2.i_list; | |
147 | et->et_ops = &ocfs2_dinode_et_ops; | |
148 | } else if (et_type == OCFS2_XATTR_VALUE_EXTENT) { | |
149 | struct ocfs2_xattr_value_root *xv = | |
150 | - (struct ocfs2_xattr_value_root *) private; | |
151 | + (struct ocfs2_xattr_value_root *)obj; | |
152 | et->et_root_el = &xv->xr_list; | |
153 | et->et_ops = &ocfs2_xattr_et_ops; | |
154 | } else if (et_type == OCFS2_XATTR_TREE_EXTENT) { | |
155 | struct ocfs2_xattr_block *xb = | |
156 | - (struct ocfs2_xattr_block *)bh->b_data; | |
157 | + (struct ocfs2_xattr_block *)obj; | |
158 | et->et_root_el = &xb->xb_attrs.xb_root.xt_list; | |
159 | et->et_ops = &ocfs2_xattr_tree_et_ops; | |
160 | et->et_max_leaf_clusters = ocfs2_clusters_for_bytes(inode->i_sb, | |
161 | @@ -593,7 +589,7 @@ int ocfs2_num_free_extents(struct ocfs2_super *osb, | |
162 | struct inode *inode, | |
163 | struct buffer_head *root_bh, | |
164 | enum ocfs2_extent_tree_type type, | |
165 | - void *private) | |
166 | + void *obj) | |
167 | { | |
168 | int retval; | |
169 | struct ocfs2_extent_list *el = NULL; | |
170 | @@ -617,7 +613,7 @@ int ocfs2_num_free_extents(struct ocfs2_super *osb, | |
171 | el = &fe->id2.i_list; | |
172 | } else if (type == OCFS2_XATTR_VALUE_EXTENT) { | |
173 | struct ocfs2_xattr_value_root *xv = | |
174 | - (struct ocfs2_xattr_value_root *) private; | |
175 | + (struct ocfs2_xattr_value_root *) obj; | |
176 | ||
177 | last_eb_blk = le64_to_cpu(xv->xr_last_eb_blk); | |
178 | el = &xv->xr_list; | |
179 | @@ -4450,13 +4446,13 @@ int ocfs2_xattr_value_insert_extent(struct ocfs2_super *osb, | |
180 | u32 new_clusters, | |
181 | u8 flags, | |
182 | struct ocfs2_alloc_context *meta_ac, | |
183 | - void *private) | |
184 | + void *obj) | |
185 | { | |
186 | int status; | |
187 | struct ocfs2_extent_tree et; | |
188 | ||
189 | ocfs2_get_extent_tree(&et, inode, root_bh, | |
190 | - OCFS2_XATTR_VALUE_EXTENT, private); | |
191 | + OCFS2_XATTR_VALUE_EXTENT, obj); | |
192 | status = ocfs2_insert_extent(osb, handle, inode, root_bh, | |
193 | cpos, start_blk, new_clusters, | |
194 | flags, meta_ac, &et); | |
195 | @@ -4507,7 +4503,7 @@ int ocfs2_add_clusters_in_btree(struct ocfs2_super *osb, | |
196 | struct ocfs2_alloc_context *meta_ac, | |
197 | enum ocfs2_alloc_restarted *reason_ret, | |
198 | enum ocfs2_extent_tree_type type, | |
199 | - void *private) | |
200 | + void *obj) | |
201 | { | |
202 | int status = 0; | |
203 | int free_extents; | |
204 | @@ -4522,7 +4518,7 @@ int ocfs2_add_clusters_in_btree(struct ocfs2_super *osb, | |
205 | flags = OCFS2_EXT_UNWRITTEN; | |
206 | ||
207 | free_extents = ocfs2_num_free_extents(osb, inode, root_bh, type, | |
208 | - private); | |
209 | + obj); | |
210 | if (free_extents < 0) { | |
211 | status = free_extents; | |
212 | mlog_errno(status); | |
213 | @@ -4584,7 +4580,7 @@ int ocfs2_add_clusters_in_btree(struct ocfs2_super *osb, | |
214 | inode, root_bh, | |
215 | *logical_offset, | |
216 | block, num_bits, flags, | |
217 | - meta_ac, private); | |
218 | + meta_ac, obj); | |
219 | if (status < 0) { | |
220 | mlog_errno(status); | |
221 | goto leave; | |
222 | @@ -4866,7 +4862,7 @@ int ocfs2_mark_extent_written(struct inode *inode, struct buffer_head *root_bh, | |
223 | struct ocfs2_alloc_context *meta_ac, | |
224 | struct ocfs2_cached_dealloc_ctxt *dealloc, | |
225 | enum ocfs2_extent_tree_type et_type, | |
226 | - void *private) | |
227 | + void *obj) | |
228 | { | |
229 | int ret, index; | |
230 | u64 start_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys); | |
231 | @@ -4878,7 +4874,7 @@ int ocfs2_mark_extent_written(struct inode *inode, struct buffer_head *root_bh, | |
232 | mlog(0, "Inode %lu cpos %u, len %u, phys %u (%llu)\n", | |
233 | inode->i_ino, cpos, len, phys, (unsigned long long)start_blkno); | |
234 | ||
235 | - ocfs2_get_extent_tree(&et, inode, root_bh, et_type, private); | |
236 | + ocfs2_get_extent_tree(&et, inode, root_bh, et_type, obj); | |
237 | ||
238 | if (!ocfs2_writes_unwritten_extents(OCFS2_SB(inode->i_sb))) { | |
239 | ocfs2_error(inode->i_sb, "Inode %llu has unwritten extents " | |
240 | @@ -5170,7 +5166,7 @@ int ocfs2_remove_extent(struct inode *inode, struct buffer_head *root_bh, | |
241 | struct ocfs2_alloc_context *meta_ac, | |
242 | struct ocfs2_cached_dealloc_ctxt *dealloc, | |
243 | enum ocfs2_extent_tree_type et_type, | |
244 | - void *private) | |
245 | + void *obj) | |
246 | { | |
247 | int ret, index; | |
248 | u32 rec_range, trunc_range; | |
249 | @@ -5179,7 +5175,7 @@ int ocfs2_remove_extent(struct inode *inode, struct buffer_head *root_bh, | |
250 | struct ocfs2_path *path = NULL; | |
251 | struct ocfs2_extent_tree et; | |
252 | ||
253 | - ocfs2_get_extent_tree(&et, inode, root_bh, et_type, private); | |
254 | + ocfs2_get_extent_tree(&et, inode, root_bh, et_type, obj); | |
255 | ||
256 | ocfs2_extent_map_trunc(inode, 0); | |
257 | ||
258 | -- | |
259 | 1.5.4.5 | |
260 |