diff options
Diffstat (limited to 'fs/ocfs2/alloc.c')
-rw-r--r-- | fs/ocfs2/alloc.c | 913 |
1 files changed, 662 insertions, 251 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 29ff57ec5d1f..0cc2deb9394c 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
@@ -49,6 +49,340 @@ | |||
49 | 49 | ||
50 | #include "buffer_head_io.h" | 50 | #include "buffer_head_io.h" |
51 | 51 | ||
52 | |||
53 | /* | ||
54 | * Operations for a specific extent tree type. | ||
55 | * | ||
56 | * To implement an on-disk btree (extent tree) type in ocfs2, add | ||
57 | * an ocfs2_extent_tree_operations structure and the matching | ||
58 | * ocfs2_init_<thingy>_extent_tree() function. That's pretty much it | ||
59 | * for the allocation portion of the extent tree. | ||
60 | */ | ||
61 | struct ocfs2_extent_tree_operations { | ||
62 | /* | ||
63 | * last_eb_blk is the block number of the right most leaf extent | ||
64 | * block. Most on-disk structures containing an extent tree store | ||
65 | * this value for fast access. The ->eo_set_last_eb_blk() and | ||
66 | * ->eo_get_last_eb_blk() operations access this value. They are | ||
67 | * both required. | ||
68 | */ | ||
69 | void (*eo_set_last_eb_blk)(struct ocfs2_extent_tree *et, | ||
70 | u64 blkno); | ||
71 | u64 (*eo_get_last_eb_blk)(struct ocfs2_extent_tree *et); | ||
72 | |||
73 | /* | ||
74 | * The on-disk structure usually keeps track of how many total | ||
75 | * clusters are stored in this extent tree. This function updates | ||
76 | * that value. new_clusters is the delta, and must be | ||
77 | * added to the total. Required. | ||
78 | */ | ||
79 | void (*eo_update_clusters)(struct inode *inode, | ||
80 | struct ocfs2_extent_tree *et, | ||
81 | u32 new_clusters); | ||
82 | |||
83 | /* | ||
84 | * If ->eo_insert_check() exists, it is called before rec is | ||
85 | * inserted into the extent tree. It is optional. | ||
86 | */ | ||
87 | int (*eo_insert_check)(struct inode *inode, | ||
88 | struct ocfs2_extent_tree *et, | ||
89 | struct ocfs2_extent_rec *rec); | ||
90 | int (*eo_sanity_check)(struct inode *inode, struct ocfs2_extent_tree *et); | ||
91 | |||
92 | /* | ||
93 | * -------------------------------------------------------------- | ||
94 | * The remaining are internal to ocfs2_extent_tree and don't have | ||
95 | * accessor functions | ||
96 | */ | ||
97 | |||
98 | /* | ||
99 | * ->eo_fill_root_el() takes et->et_object and sets et->et_root_el. | ||
100 | * It is required. | ||
101 | */ | ||
102 | void (*eo_fill_root_el)(struct ocfs2_extent_tree *et); | ||
103 | |||
104 | /* | ||
105 | * ->eo_fill_max_leaf_clusters sets et->et_max_leaf_clusters if | ||
106 | * it exists. If it does not, et->et_max_leaf_clusters is set | ||
107 | * to 0 (unlimited). Optional. | ||
108 | */ | ||
109 | void (*eo_fill_max_leaf_clusters)(struct inode *inode, | ||
110 | struct ocfs2_extent_tree *et); | ||
111 | }; | ||
112 | |||
113 | |||
114 | /* | ||
115 | * Pre-declare ocfs2_dinode_et_ops so we can use it as a sanity check | ||
116 | * in the methods. | ||
117 | */ | ||
118 | static u64 ocfs2_dinode_get_last_eb_blk(struct ocfs2_extent_tree *et); | ||
119 | static void ocfs2_dinode_set_last_eb_blk(struct ocfs2_extent_tree *et, | ||
120 | u64 blkno); | ||
121 | static void ocfs2_dinode_update_clusters(struct inode *inode, | ||
122 | struct ocfs2_extent_tree *et, | ||
123 | u32 clusters); | ||
124 | static int ocfs2_dinode_insert_check(struct inode *inode, | ||
125 | struct ocfs2_extent_tree *et, | ||
126 | struct ocfs2_extent_rec *rec); | ||
127 | static int ocfs2_dinode_sanity_check(struct inode *inode, | ||
128 | struct ocfs2_extent_tree *et); | ||
129 | static void ocfs2_dinode_fill_root_el(struct ocfs2_extent_tree *et); | ||
130 | static struct ocfs2_extent_tree_operations ocfs2_dinode_et_ops = { | ||
131 | .eo_set_last_eb_blk = ocfs2_dinode_set_last_eb_blk, | ||
132 | .eo_get_last_eb_blk = ocfs2_dinode_get_last_eb_blk, | ||
133 | .eo_update_clusters = ocfs2_dinode_update_clusters, | ||
134 | .eo_insert_check = ocfs2_dinode_insert_check, | ||
135 | .eo_sanity_check = ocfs2_dinode_sanity_check, | ||
136 | .eo_fill_root_el = ocfs2_dinode_fill_root_el, | ||
137 | }; | ||
138 | |||
139 | static void ocfs2_dinode_set_last_eb_blk(struct ocfs2_extent_tree *et, | ||
140 | u64 blkno) | ||
141 | { | ||
142 | struct ocfs2_dinode *di = et->et_object; | ||
143 | |||
144 | BUG_ON(et->et_ops != &ocfs2_dinode_et_ops); | ||
145 | di->i_last_eb_blk = cpu_to_le64(blkno); | ||
146 | } | ||
147 | |||
148 | static u64 ocfs2_dinode_get_last_eb_blk(struct ocfs2_extent_tree *et) | ||
149 | { | ||
150 | struct ocfs2_dinode *di = et->et_object; | ||
151 | |||
152 | BUG_ON(et->et_ops != &ocfs2_dinode_et_ops); | ||
153 | return le64_to_cpu(di->i_last_eb_blk); | ||
154 | } | ||
155 | |||
156 | static void ocfs2_dinode_update_clusters(struct inode *inode, | ||
157 | struct ocfs2_extent_tree *et, | ||
158 | u32 clusters) | ||
159 | { | ||
160 | struct ocfs2_dinode *di = et->et_object; | ||
161 | |||
162 | le32_add_cpu(&di->i_clusters, clusters); | ||
163 | spin_lock(&OCFS2_I(inode)->ip_lock); | ||
164 | OCFS2_I(inode)->ip_clusters = le32_to_cpu(di->i_clusters); | ||
165 | spin_unlock(&OCFS2_I(inode)->ip_lock); | ||
166 | } | ||
167 | |||
168 | static int ocfs2_dinode_insert_check(struct inode *inode, | ||
169 | struct ocfs2_extent_tree *et, | ||
170 | struct ocfs2_extent_rec *rec) | ||
171 | { | ||
172 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
173 | |||
174 | BUG_ON(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL); | ||
175 | mlog_bug_on_msg(!ocfs2_sparse_alloc(osb) && | ||
176 | (OCFS2_I(inode)->ip_clusters != rec->e_cpos), | ||
177 | "Device %s, asking for sparse allocation: inode %llu, " | ||
178 | "cpos %u, clusters %u\n", | ||
179 | osb->dev_str, | ||
180 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | ||
181 | rec->e_cpos, | ||
182 | OCFS2_I(inode)->ip_clusters); | ||
183 | |||
184 | return 0; | ||
185 | } | ||
186 | |||
187 | static int ocfs2_dinode_sanity_check(struct inode *inode, | ||
188 | struct ocfs2_extent_tree *et) | ||
189 | { | ||
190 | int ret = 0; | ||
191 | struct ocfs2_dinode *di; | ||
192 | |||
193 | BUG_ON(et->et_ops != &ocfs2_dinode_et_ops); | ||
194 | |||
195 | di = et->et_object; | ||
196 | if (!OCFS2_IS_VALID_DINODE(di)) { | ||
197 | ret = -EIO; | ||
198 | ocfs2_error(inode->i_sb, | ||
199 | "Inode %llu has invalid path root", | ||
200 | (unsigned long long)OCFS2_I(inode)->ip_blkno); | ||
201 | } | ||
202 | |||
203 | return ret; | ||
204 | } | ||
205 | |||
206 | static void ocfs2_dinode_fill_root_el(struct ocfs2_extent_tree *et) | ||
207 | { | ||
208 | struct ocfs2_dinode *di = et->et_object; | ||
209 | |||
210 | et->et_root_el = &di->id2.i_list; | ||
211 | } | ||
212 | |||
213 | |||
214 | static void ocfs2_xattr_value_fill_root_el(struct ocfs2_extent_tree *et) | ||
215 | { | ||
216 | struct ocfs2_xattr_value_root *xv = et->et_object; | ||
217 | |||
218 | et->et_root_el = &xv->xr_list; | ||
219 | } | ||
220 | |||
221 | static void ocfs2_xattr_value_set_last_eb_blk(struct ocfs2_extent_tree *et, | ||
222 | u64 blkno) | ||
223 | { | ||
224 | struct ocfs2_xattr_value_root *xv = | ||
225 | (struct ocfs2_xattr_value_root *)et->et_object; | ||
226 | |||
227 | xv->xr_last_eb_blk = cpu_to_le64(blkno); | ||
228 | } | ||
229 | |||
230 | static u64 ocfs2_xattr_value_get_last_eb_blk(struct ocfs2_extent_tree *et) | ||
231 | { | ||
232 | struct ocfs2_xattr_value_root *xv = | ||
233 | (struct ocfs2_xattr_value_root *) et->et_object; | ||
234 | |||
235 | return le64_to_cpu(xv->xr_last_eb_blk); | ||
236 | } | ||
237 | |||
238 | static void ocfs2_xattr_value_update_clusters(struct inode *inode, | ||
239 | struct ocfs2_extent_tree *et, | ||
240 | u32 clusters) | ||
241 | { | ||
242 | struct ocfs2_xattr_value_root *xv = | ||
243 | (struct ocfs2_xattr_value_root *)et->et_object; | ||
244 | |||
245 | le32_add_cpu(&xv->xr_clusters, clusters); | ||
246 | } | ||
247 | |||
248 | static struct ocfs2_extent_tree_operations ocfs2_xattr_value_et_ops = { | ||
249 | .eo_set_last_eb_blk = ocfs2_xattr_value_set_last_eb_blk, | ||
250 | .eo_get_last_eb_blk = ocfs2_xattr_value_get_last_eb_blk, | ||
251 | .eo_update_clusters = ocfs2_xattr_value_update_clusters, | ||
252 | .eo_fill_root_el = ocfs2_xattr_value_fill_root_el, | ||
253 | }; | ||
254 | |||
255 | static void ocfs2_xattr_tree_fill_root_el(struct ocfs2_extent_tree *et) | ||
256 | { | ||
257 | struct ocfs2_xattr_block *xb = et->et_object; | ||
258 | |||
259 | et->et_root_el = &xb->xb_attrs.xb_root.xt_list; | ||
260 | } | ||
261 | |||
262 | static void ocfs2_xattr_tree_fill_max_leaf_clusters(struct inode *inode, | ||
263 | struct ocfs2_extent_tree *et) | ||
264 | { | ||
265 | et->et_max_leaf_clusters = | ||
266 | ocfs2_clusters_for_bytes(inode->i_sb, | ||
267 | OCFS2_MAX_XATTR_TREE_LEAF_SIZE); | ||
268 | } | ||
269 | |||
270 | static void ocfs2_xattr_tree_set_last_eb_blk(struct ocfs2_extent_tree *et, | ||
271 | u64 blkno) | ||
272 | { | ||
273 | struct ocfs2_xattr_block *xb = et->et_object; | ||
274 | struct ocfs2_xattr_tree_root *xt = &xb->xb_attrs.xb_root; | ||
275 | |||
276 | xt->xt_last_eb_blk = cpu_to_le64(blkno); | ||
277 | } | ||
278 | |||
279 | static u64 ocfs2_xattr_tree_get_last_eb_blk(struct ocfs2_extent_tree *et) | ||
280 | { | ||
281 | struct ocfs2_xattr_block *xb = et->et_object; | ||
282 | struct ocfs2_xattr_tree_root *xt = &xb->xb_attrs.xb_root; | ||
283 | |||
284 | return le64_to_cpu(xt->xt_last_eb_blk); | ||
285 | } | ||
286 | |||
287 | static void ocfs2_xattr_tree_update_clusters(struct inode *inode, | ||
288 | struct ocfs2_extent_tree *et, | ||
289 | u32 clusters) | ||
290 | { | ||
291 | struct ocfs2_xattr_block *xb = et->et_object; | ||
292 | |||
293 | le32_add_cpu(&xb->xb_attrs.xb_root.xt_clusters, clusters); | ||
294 | } | ||
295 | |||
296 | static struct ocfs2_extent_tree_operations ocfs2_xattr_tree_et_ops = { | ||
297 | .eo_set_last_eb_blk = ocfs2_xattr_tree_set_last_eb_blk, | ||
298 | .eo_get_last_eb_blk = ocfs2_xattr_tree_get_last_eb_blk, | ||
299 | .eo_update_clusters = ocfs2_xattr_tree_update_clusters, | ||
300 | .eo_fill_root_el = ocfs2_xattr_tree_fill_root_el, | ||
301 | .eo_fill_max_leaf_clusters = ocfs2_xattr_tree_fill_max_leaf_clusters, | ||
302 | }; | ||
303 | |||
304 | static void __ocfs2_init_extent_tree(struct ocfs2_extent_tree *et, | ||
305 | struct inode *inode, | ||
306 | struct buffer_head *bh, | ||
307 | void *obj, | ||
308 | struct ocfs2_extent_tree_operations *ops) | ||
309 | { | ||
310 | et->et_ops = ops; | ||
311 | et->et_root_bh = bh; | ||
312 | if (!obj) | ||
313 | obj = (void *)bh->b_data; | ||
314 | et->et_object = obj; | ||
315 | |||
316 | et->et_ops->eo_fill_root_el(et); | ||
317 | if (!et->et_ops->eo_fill_max_leaf_clusters) | ||
318 | et->et_max_leaf_clusters = 0; | ||
319 | else | ||
320 | et->et_ops->eo_fill_max_leaf_clusters(inode, et); | ||
321 | } | ||
322 | |||
323 | void ocfs2_init_dinode_extent_tree(struct ocfs2_extent_tree *et, | ||
324 | struct inode *inode, | ||
325 | struct buffer_head *bh) | ||
326 | { | ||
327 | __ocfs2_init_extent_tree(et, inode, bh, NULL, &ocfs2_dinode_et_ops); | ||
328 | } | ||
329 | |||
330 | void ocfs2_init_xattr_tree_extent_tree(struct ocfs2_extent_tree *et, | ||
331 | struct inode *inode, | ||
332 | struct buffer_head *bh) | ||
333 | { | ||
334 | __ocfs2_init_extent_tree(et, inode, bh, NULL, | ||
335 | &ocfs2_xattr_tree_et_ops); | ||
336 | } | ||
337 | |||
338 | void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et, | ||
339 | struct inode *inode, | ||
340 | struct buffer_head *bh, | ||
341 | struct ocfs2_xattr_value_root *xv) | ||
342 | { | ||
343 | __ocfs2_init_extent_tree(et, inode, bh, xv, | ||
344 | &ocfs2_xattr_value_et_ops); | ||
345 | } | ||
346 | |||
347 | static inline void ocfs2_et_set_last_eb_blk(struct ocfs2_extent_tree *et, | ||
348 | u64 new_last_eb_blk) | ||
349 | { | ||
350 | et->et_ops->eo_set_last_eb_blk(et, new_last_eb_blk); | ||
351 | } | ||
352 | |||
353 | static inline u64 ocfs2_et_get_last_eb_blk(struct ocfs2_extent_tree *et) | ||
354 | { | ||
355 | return et->et_ops->eo_get_last_eb_blk(et); | ||
356 | } | ||
357 | |||
358 | static inline void ocfs2_et_update_clusters(struct inode *inode, | ||
359 | struct ocfs2_extent_tree *et, | ||
360 | u32 clusters) | ||
361 | { | ||
362 | et->et_ops->eo_update_clusters(inode, et, clusters); | ||
363 | } | ||
364 | |||
365 | static inline int ocfs2_et_insert_check(struct inode *inode, | ||
366 | struct ocfs2_extent_tree *et, | ||
367 | struct ocfs2_extent_rec *rec) | ||
368 | { | ||
369 | int ret = 0; | ||
370 | |||
371 | if (et->et_ops->eo_insert_check) | ||
372 | ret = et->et_ops->eo_insert_check(inode, et, rec); | ||
373 | return ret; | ||
374 | } | ||
375 | |||
376 | static inline int ocfs2_et_sanity_check(struct inode *inode, | ||
377 | struct ocfs2_extent_tree *et) | ||
378 | { | ||
379 | int ret = 0; | ||
380 | |||
381 | if (et->et_ops->eo_sanity_check) | ||
382 | ret = et->et_ops->eo_sanity_check(inode, et); | ||
383 | return ret; | ||
384 | } | ||
385 | |||
52 | static void ocfs2_free_truncate_context(struct ocfs2_truncate_context *tc); | 386 | static void ocfs2_free_truncate_context(struct ocfs2_truncate_context *tc); |
53 | static int ocfs2_cache_extent_block_free(struct ocfs2_cached_dealloc_ctxt *ctxt, | 387 | static int ocfs2_cache_extent_block_free(struct ocfs2_cached_dealloc_ctxt *ctxt, |
54 | struct ocfs2_extent_block *eb); | 388 | struct ocfs2_extent_block *eb); |
@@ -205,17 +539,6 @@ static struct ocfs2_path *ocfs2_new_path(struct buffer_head *root_bh, | |||
205 | } | 539 | } |
206 | 540 | ||
207 | /* | 541 | /* |
208 | * Allocate and initialize a new path based on a disk inode tree. | ||
209 | */ | ||
210 | static struct ocfs2_path *ocfs2_new_inode_path(struct buffer_head *di_bh) | ||
211 | { | ||
212 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; | ||
213 | struct ocfs2_extent_list *el = &di->id2.i_list; | ||
214 | |||
215 | return ocfs2_new_path(di_bh, el); | ||
216 | } | ||
217 | |||
218 | /* | ||
219 | * Convenience function to journal all components in a path. | 542 | * Convenience function to journal all components in a path. |
220 | */ | 543 | */ |
221 | static int ocfs2_journal_access_path(struct inode *inode, handle_t *handle, | 544 | static int ocfs2_journal_access_path(struct inode *inode, handle_t *handle, |
@@ -368,39 +691,35 @@ struct ocfs2_merge_ctxt { | |||
368 | */ | 691 | */ |
369 | int ocfs2_num_free_extents(struct ocfs2_super *osb, | 692 | int ocfs2_num_free_extents(struct ocfs2_super *osb, |
370 | struct inode *inode, | 693 | struct inode *inode, |
371 | struct ocfs2_dinode *fe) | 694 | struct ocfs2_extent_tree *et) |
372 | { | 695 | { |
373 | int retval; | 696 | int retval; |
374 | struct ocfs2_extent_list *el; | 697 | struct ocfs2_extent_list *el = NULL; |
375 | struct ocfs2_extent_block *eb; | 698 | struct ocfs2_extent_block *eb; |
376 | struct buffer_head *eb_bh = NULL; | 699 | struct buffer_head *eb_bh = NULL; |
700 | u64 last_eb_blk = 0; | ||
377 | 701 | ||
378 | mlog_entry_void(); | 702 | mlog_entry_void(); |
379 | 703 | ||
380 | if (!OCFS2_IS_VALID_DINODE(fe)) { | 704 | el = et->et_root_el; |
381 | OCFS2_RO_ON_INVALID_DINODE(inode->i_sb, fe); | 705 | last_eb_blk = ocfs2_et_get_last_eb_blk(et); |
382 | retval = -EIO; | ||
383 | goto bail; | ||
384 | } | ||
385 | 706 | ||
386 | if (fe->i_last_eb_blk) { | 707 | if (last_eb_blk) { |
387 | retval = ocfs2_read_block(osb, le64_to_cpu(fe->i_last_eb_blk), | 708 | retval = ocfs2_read_block(inode, last_eb_blk, |
388 | &eb_bh, OCFS2_BH_CACHED, inode); | 709 | &eb_bh); |
389 | if (retval < 0) { | 710 | if (retval < 0) { |
390 | mlog_errno(retval); | 711 | mlog_errno(retval); |
391 | goto bail; | 712 | goto bail; |
392 | } | 713 | } |
393 | eb = (struct ocfs2_extent_block *) eb_bh->b_data; | 714 | eb = (struct ocfs2_extent_block *) eb_bh->b_data; |
394 | el = &eb->h_list; | 715 | el = &eb->h_list; |
395 | } else | 716 | } |
396 | el = &fe->id2.i_list; | ||
397 | 717 | ||
398 | BUG_ON(el->l_tree_depth != 0); | 718 | BUG_ON(el->l_tree_depth != 0); |
399 | 719 | ||
400 | retval = le16_to_cpu(el->l_count) - le16_to_cpu(el->l_next_free_rec); | 720 | retval = le16_to_cpu(el->l_count) - le16_to_cpu(el->l_next_free_rec); |
401 | bail: | 721 | bail: |
402 | if (eb_bh) | 722 | brelse(eb_bh); |
403 | brelse(eb_bh); | ||
404 | 723 | ||
405 | mlog_exit(retval); | 724 | mlog_exit(retval); |
406 | return retval; | 725 | return retval; |
@@ -486,8 +805,7 @@ static int ocfs2_create_new_meta_bhs(struct ocfs2_super *osb, | |||
486 | bail: | 805 | bail: |
487 | if (status < 0) { | 806 | if (status < 0) { |
488 | for(i = 0; i < wanted; i++) { | 807 | for(i = 0; i < wanted; i++) { |
489 | if (bhs[i]) | 808 | brelse(bhs[i]); |
490 | brelse(bhs[i]); | ||
491 | bhs[i] = NULL; | 809 | bhs[i] = NULL; |
492 | } | 810 | } |
493 | } | 811 | } |
@@ -531,7 +849,7 @@ static inline u32 ocfs2_sum_rightmost_rec(struct ocfs2_extent_list *el) | |||
531 | static int ocfs2_add_branch(struct ocfs2_super *osb, | 849 | static int ocfs2_add_branch(struct ocfs2_super *osb, |
532 | handle_t *handle, | 850 | handle_t *handle, |
533 | struct inode *inode, | 851 | struct inode *inode, |
534 | struct buffer_head *fe_bh, | 852 | struct ocfs2_extent_tree *et, |
535 | struct buffer_head *eb_bh, | 853 | struct buffer_head *eb_bh, |
536 | struct buffer_head **last_eb_bh, | 854 | struct buffer_head **last_eb_bh, |
537 | struct ocfs2_alloc_context *meta_ac) | 855 | struct ocfs2_alloc_context *meta_ac) |
@@ -540,7 +858,6 @@ static int ocfs2_add_branch(struct ocfs2_super *osb, | |||
540 | u64 next_blkno, new_last_eb_blk; | 858 | u64 next_blkno, new_last_eb_blk; |
541 | struct buffer_head *bh; | 859 | struct buffer_head *bh; |
542 | struct buffer_head **new_eb_bhs = NULL; | 860 | struct buffer_head **new_eb_bhs = NULL; |
543 | struct ocfs2_dinode *fe; | ||
544 | struct ocfs2_extent_block *eb; | 861 | struct ocfs2_extent_block *eb; |
545 | struct ocfs2_extent_list *eb_el; | 862 | struct ocfs2_extent_list *eb_el; |
546 | struct ocfs2_extent_list *el; | 863 | struct ocfs2_extent_list *el; |
@@ -550,13 +867,11 @@ static int ocfs2_add_branch(struct ocfs2_super *osb, | |||
550 | 867 | ||
551 | BUG_ON(!last_eb_bh || !*last_eb_bh); | 868 | BUG_ON(!last_eb_bh || !*last_eb_bh); |
552 | 869 | ||
553 | fe = (struct ocfs2_dinode *) fe_bh->b_data; | ||
554 | |||
555 | if (eb_bh) { | 870 | if (eb_bh) { |
556 | eb = (struct ocfs2_extent_block *) eb_bh->b_data; | 871 | eb = (struct ocfs2_extent_block *) eb_bh->b_data; |
557 | el = &eb->h_list; | 872 | el = &eb->h_list; |
558 | } else | 873 | } else |
559 | el = &fe->id2.i_list; | 874 | el = et->et_root_el; |
560 | 875 | ||
561 | /* we never add a branch to a leaf. */ | 876 | /* we never add a branch to a leaf. */ |
562 | BUG_ON(!el->l_tree_depth); | 877 | BUG_ON(!el->l_tree_depth); |
@@ -646,7 +961,7 @@ static int ocfs2_add_branch(struct ocfs2_super *osb, | |||
646 | mlog_errno(status); | 961 | mlog_errno(status); |
647 | goto bail; | 962 | goto bail; |
648 | } | 963 | } |
649 | status = ocfs2_journal_access(handle, inode, fe_bh, | 964 | status = ocfs2_journal_access(handle, inode, et->et_root_bh, |
650 | OCFS2_JOURNAL_ACCESS_WRITE); | 965 | OCFS2_JOURNAL_ACCESS_WRITE); |
651 | if (status < 0) { | 966 | if (status < 0) { |
652 | mlog_errno(status); | 967 | mlog_errno(status); |
@@ -662,7 +977,7 @@ static int ocfs2_add_branch(struct ocfs2_super *osb, | |||
662 | } | 977 | } |
663 | 978 | ||
664 | /* Link the new branch into the rest of the tree (el will | 979 | /* Link the new branch into the rest of the tree (el will |
665 | * either be on the fe, or the extent block passed in. */ | 980 | * either be on the root_bh, or the extent block passed in. */ |
666 | i = le16_to_cpu(el->l_next_free_rec); | 981 | i = le16_to_cpu(el->l_next_free_rec); |
667 | el->l_recs[i].e_blkno = cpu_to_le64(next_blkno); | 982 | el->l_recs[i].e_blkno = cpu_to_le64(next_blkno); |
668 | el->l_recs[i].e_cpos = cpu_to_le32(new_cpos); | 983 | el->l_recs[i].e_cpos = cpu_to_le32(new_cpos); |
@@ -671,7 +986,7 @@ static int ocfs2_add_branch(struct ocfs2_super *osb, | |||
671 | 986 | ||
672 | /* fe needs a new last extent block pointer, as does the | 987 | /* fe needs a new last extent block pointer, as does the |
673 | * next_leaf on the previously last-extent-block. */ | 988 | * next_leaf on the previously last-extent-block. */ |
674 | fe->i_last_eb_blk = cpu_to_le64(new_last_eb_blk); | 989 | ocfs2_et_set_last_eb_blk(et, new_last_eb_blk); |
675 | 990 | ||
676 | eb = (struct ocfs2_extent_block *) (*last_eb_bh)->b_data; | 991 | eb = (struct ocfs2_extent_block *) (*last_eb_bh)->b_data; |
677 | eb->h_next_leaf_blk = cpu_to_le64(new_last_eb_blk); | 992 | eb->h_next_leaf_blk = cpu_to_le64(new_last_eb_blk); |
@@ -679,7 +994,7 @@ static int ocfs2_add_branch(struct ocfs2_super *osb, | |||
679 | status = ocfs2_journal_dirty(handle, *last_eb_bh); | 994 | status = ocfs2_journal_dirty(handle, *last_eb_bh); |
680 | if (status < 0) | 995 | if (status < 0) |
681 | mlog_errno(status); | 996 | mlog_errno(status); |
682 | status = ocfs2_journal_dirty(handle, fe_bh); | 997 | status = ocfs2_journal_dirty(handle, et->et_root_bh); |
683 | if (status < 0) | 998 | if (status < 0) |
684 | mlog_errno(status); | 999 | mlog_errno(status); |
685 | if (eb_bh) { | 1000 | if (eb_bh) { |
@@ -700,8 +1015,7 @@ static int ocfs2_add_branch(struct ocfs2_super *osb, | |||
700 | bail: | 1015 | bail: |
701 | if (new_eb_bhs) { | 1016 | if (new_eb_bhs) { |
702 | for (i = 0; i < new_blocks; i++) | 1017 | for (i = 0; i < new_blocks; i++) |
703 | if (new_eb_bhs[i]) | 1018 | brelse(new_eb_bhs[i]); |
704 | brelse(new_eb_bhs[i]); | ||
705 | kfree(new_eb_bhs); | 1019 | kfree(new_eb_bhs); |
706 | } | 1020 | } |
707 | 1021 | ||
@@ -717,16 +1031,15 @@ bail: | |||
717 | static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, | 1031 | static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, |
718 | handle_t *handle, | 1032 | handle_t *handle, |
719 | struct inode *inode, | 1033 | struct inode *inode, |
720 | struct buffer_head *fe_bh, | 1034 | struct ocfs2_extent_tree *et, |
721 | struct ocfs2_alloc_context *meta_ac, | 1035 | struct ocfs2_alloc_context *meta_ac, |
722 | struct buffer_head **ret_new_eb_bh) | 1036 | struct buffer_head **ret_new_eb_bh) |
723 | { | 1037 | { |
724 | int status, i; | 1038 | int status, i; |
725 | u32 new_clusters; | 1039 | u32 new_clusters; |
726 | struct buffer_head *new_eb_bh = NULL; | 1040 | struct buffer_head *new_eb_bh = NULL; |
727 | struct ocfs2_dinode *fe; | ||
728 | struct ocfs2_extent_block *eb; | 1041 | struct ocfs2_extent_block *eb; |
729 | struct ocfs2_extent_list *fe_el; | 1042 | struct ocfs2_extent_list *root_el; |
730 | struct ocfs2_extent_list *eb_el; | 1043 | struct ocfs2_extent_list *eb_el; |
731 | 1044 | ||
732 | mlog_entry_void(); | 1045 | mlog_entry_void(); |
@@ -746,8 +1059,7 @@ static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, | |||
746 | } | 1059 | } |
747 | 1060 | ||
748 | eb_el = &eb->h_list; | 1061 | eb_el = &eb->h_list; |
749 | fe = (struct ocfs2_dinode *) fe_bh->b_data; | 1062 | root_el = et->et_root_el; |
750 | fe_el = &fe->id2.i_list; | ||
751 | 1063 | ||
752 | status = ocfs2_journal_access(handle, inode, new_eb_bh, | 1064 | status = ocfs2_journal_access(handle, inode, new_eb_bh, |
753 | OCFS2_JOURNAL_ACCESS_CREATE); | 1065 | OCFS2_JOURNAL_ACCESS_CREATE); |
@@ -756,11 +1068,11 @@ static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, | |||
756 | goto bail; | 1068 | goto bail; |
757 | } | 1069 | } |
758 | 1070 | ||
759 | /* copy the fe data into the new extent block */ | 1071 | /* copy the root extent list data into the new extent block */ |
760 | eb_el->l_tree_depth = fe_el->l_tree_depth; | 1072 | eb_el->l_tree_depth = root_el->l_tree_depth; |
761 | eb_el->l_next_free_rec = fe_el->l_next_free_rec; | 1073 | eb_el->l_next_free_rec = root_el->l_next_free_rec; |
762 | for(i = 0; i < le16_to_cpu(fe_el->l_next_free_rec); i++) | 1074 | for (i = 0; i < le16_to_cpu(root_el->l_next_free_rec); i++) |
763 | eb_el->l_recs[i] = fe_el->l_recs[i]; | 1075 | eb_el->l_recs[i] = root_el->l_recs[i]; |
764 | 1076 | ||
765 | status = ocfs2_journal_dirty(handle, new_eb_bh); | 1077 | status = ocfs2_journal_dirty(handle, new_eb_bh); |
766 | if (status < 0) { | 1078 | if (status < 0) { |
@@ -768,7 +1080,7 @@ static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, | |||
768 | goto bail; | 1080 | goto bail; |
769 | } | 1081 | } |
770 | 1082 | ||
771 | status = ocfs2_journal_access(handle, inode, fe_bh, | 1083 | status = ocfs2_journal_access(handle, inode, et->et_root_bh, |
772 | OCFS2_JOURNAL_ACCESS_WRITE); | 1084 | OCFS2_JOURNAL_ACCESS_WRITE); |
773 | if (status < 0) { | 1085 | if (status < 0) { |
774 | mlog_errno(status); | 1086 | mlog_errno(status); |
@@ -777,21 +1089,21 @@ static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, | |||
777 | 1089 | ||
778 | new_clusters = ocfs2_sum_rightmost_rec(eb_el); | 1090 | new_clusters = ocfs2_sum_rightmost_rec(eb_el); |
779 | 1091 | ||
780 | /* update fe now */ | 1092 | /* update root_bh now */ |
781 | le16_add_cpu(&fe_el->l_tree_depth, 1); | 1093 | le16_add_cpu(&root_el->l_tree_depth, 1); |
782 | fe_el->l_recs[0].e_cpos = 0; | 1094 | root_el->l_recs[0].e_cpos = 0; |
783 | fe_el->l_recs[0].e_blkno = eb->h_blkno; | 1095 | root_el->l_recs[0].e_blkno = eb->h_blkno; |
784 | fe_el->l_recs[0].e_int_clusters = cpu_to_le32(new_clusters); | 1096 | root_el->l_recs[0].e_int_clusters = cpu_to_le32(new_clusters); |
785 | for(i = 1; i < le16_to_cpu(fe_el->l_next_free_rec); i++) | 1097 | for (i = 1; i < le16_to_cpu(root_el->l_next_free_rec); i++) |
786 | memset(&fe_el->l_recs[i], 0, sizeof(struct ocfs2_extent_rec)); | 1098 | memset(&root_el->l_recs[i], 0, sizeof(struct ocfs2_extent_rec)); |
787 | fe_el->l_next_free_rec = cpu_to_le16(1); | 1099 | root_el->l_next_free_rec = cpu_to_le16(1); |
788 | 1100 | ||
789 | /* If this is our 1st tree depth shift, then last_eb_blk | 1101 | /* If this is our 1st tree depth shift, then last_eb_blk |
790 | * becomes the allocated extent block */ | 1102 | * becomes the allocated extent block */ |
791 | if (fe_el->l_tree_depth == cpu_to_le16(1)) | 1103 | if (root_el->l_tree_depth == cpu_to_le16(1)) |
792 | fe->i_last_eb_blk = eb->h_blkno; | 1104 | ocfs2_et_set_last_eb_blk(et, le64_to_cpu(eb->h_blkno)); |
793 | 1105 | ||
794 | status = ocfs2_journal_dirty(handle, fe_bh); | 1106 | status = ocfs2_journal_dirty(handle, et->et_root_bh); |
795 | if (status < 0) { | 1107 | if (status < 0) { |
796 | mlog_errno(status); | 1108 | mlog_errno(status); |
797 | goto bail; | 1109 | goto bail; |
@@ -801,8 +1113,7 @@ static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, | |||
801 | new_eb_bh = NULL; | 1113 | new_eb_bh = NULL; |
802 | status = 0; | 1114 | status = 0; |
803 | bail: | 1115 | bail: |
804 | if (new_eb_bh) | 1116 | brelse(new_eb_bh); |
805 | brelse(new_eb_bh); | ||
806 | 1117 | ||
807 | mlog_exit(status); | 1118 | mlog_exit(status); |
808 | return status; | 1119 | return status; |
@@ -817,22 +1128,21 @@ bail: | |||
817 | * 1) a lowest extent block is found, then we pass it back in | 1128 | * 1) a lowest extent block is found, then we pass it back in |
818 | * *lowest_eb_bh and return '0' | 1129 | * *lowest_eb_bh and return '0' |
819 | * | 1130 | * |
820 | * 2) the search fails to find anything, but the dinode has room. We | 1131 | * 2) the search fails to find anything, but the root_el has room. We |
821 | * pass NULL back in *lowest_eb_bh, but still return '0' | 1132 | * pass NULL back in *lowest_eb_bh, but still return '0' |
822 | * | 1133 | * |
823 | * 3) the search fails to find anything AND the dinode is full, in | 1134 | * 3) the search fails to find anything AND the root_el is full, in |
824 | * which case we return > 0 | 1135 | * which case we return > 0 |
825 | * | 1136 | * |
826 | * return status < 0 indicates an error. | 1137 | * return status < 0 indicates an error. |
827 | */ | 1138 | */ |
828 | static int ocfs2_find_branch_target(struct ocfs2_super *osb, | 1139 | static int ocfs2_find_branch_target(struct ocfs2_super *osb, |
829 | struct inode *inode, | 1140 | struct inode *inode, |
830 | struct buffer_head *fe_bh, | 1141 | struct ocfs2_extent_tree *et, |
831 | struct buffer_head **target_bh) | 1142 | struct buffer_head **target_bh) |
832 | { | 1143 | { |
833 | int status = 0, i; | 1144 | int status = 0, i; |
834 | u64 blkno; | 1145 | u64 blkno; |
835 | struct ocfs2_dinode *fe; | ||
836 | struct ocfs2_extent_block *eb; | 1146 | struct ocfs2_extent_block *eb; |
837 | struct ocfs2_extent_list *el; | 1147 | struct ocfs2_extent_list *el; |
838 | struct buffer_head *bh = NULL; | 1148 | struct buffer_head *bh = NULL; |
@@ -842,8 +1152,7 @@ static int ocfs2_find_branch_target(struct ocfs2_super *osb, | |||
842 | 1152 | ||
843 | *target_bh = NULL; | 1153 | *target_bh = NULL; |
844 | 1154 | ||
845 | fe = (struct ocfs2_dinode *) fe_bh->b_data; | 1155 | el = et->et_root_el; |
846 | el = &fe->id2.i_list; | ||
847 | 1156 | ||
848 | while(le16_to_cpu(el->l_tree_depth) > 1) { | 1157 | while(le16_to_cpu(el->l_tree_depth) > 1) { |
849 | if (le16_to_cpu(el->l_next_free_rec) == 0) { | 1158 | if (le16_to_cpu(el->l_next_free_rec) == 0) { |
@@ -864,13 +1173,10 @@ static int ocfs2_find_branch_target(struct ocfs2_super *osb, | |||
864 | goto bail; | 1173 | goto bail; |
865 | } | 1174 | } |
866 | 1175 | ||
867 | if (bh) { | 1176 | brelse(bh); |
868 | brelse(bh); | 1177 | bh = NULL; |
869 | bh = NULL; | ||
870 | } | ||
871 | 1178 | ||
872 | status = ocfs2_read_block(osb, blkno, &bh, OCFS2_BH_CACHED, | 1179 | status = ocfs2_read_block(inode, blkno, &bh); |
873 | inode); | ||
874 | if (status < 0) { | 1180 | if (status < 0) { |
875 | mlog_errno(status); | 1181 | mlog_errno(status); |
876 | goto bail; | 1182 | goto bail; |
@@ -886,8 +1192,7 @@ static int ocfs2_find_branch_target(struct ocfs2_super *osb, | |||
886 | 1192 | ||
887 | if (le16_to_cpu(el->l_next_free_rec) < | 1193 | if (le16_to_cpu(el->l_next_free_rec) < |
888 | le16_to_cpu(el->l_count)) { | 1194 | le16_to_cpu(el->l_count)) { |
889 | if (lowest_bh) | 1195 | brelse(lowest_bh); |
890 | brelse(lowest_bh); | ||
891 | lowest_bh = bh; | 1196 | lowest_bh = bh; |
892 | get_bh(lowest_bh); | 1197 | get_bh(lowest_bh); |
893 | } | 1198 | } |
@@ -895,14 +1200,13 @@ static int ocfs2_find_branch_target(struct ocfs2_super *osb, | |||
895 | 1200 | ||
896 | /* If we didn't find one and the fe doesn't have any room, | 1201 | /* If we didn't find one and the fe doesn't have any room, |
897 | * then return '1' */ | 1202 | * then return '1' */ |
898 | if (!lowest_bh | 1203 | el = et->et_root_el; |
899 | && (fe->id2.i_list.l_next_free_rec == fe->id2.i_list.l_count)) | 1204 | if (!lowest_bh && (el->l_next_free_rec == el->l_count)) |
900 | status = 1; | 1205 | status = 1; |
901 | 1206 | ||
902 | *target_bh = lowest_bh; | 1207 | *target_bh = lowest_bh; |
903 | bail: | 1208 | bail: |
904 | if (bh) | 1209 | brelse(bh); |
905 | brelse(bh); | ||
906 | 1210 | ||
907 | mlog_exit(status); | 1211 | mlog_exit(status); |
908 | return status; | 1212 | return status; |
@@ -919,19 +1223,19 @@ bail: | |||
919 | * *last_eb_bh will be updated by ocfs2_add_branch(). | 1223 | * *last_eb_bh will be updated by ocfs2_add_branch(). |
920 | */ | 1224 | */ |
921 | static int ocfs2_grow_tree(struct inode *inode, handle_t *handle, | 1225 | static int ocfs2_grow_tree(struct inode *inode, handle_t *handle, |
922 | struct buffer_head *di_bh, int *final_depth, | 1226 | struct ocfs2_extent_tree *et, int *final_depth, |
923 | struct buffer_head **last_eb_bh, | 1227 | struct buffer_head **last_eb_bh, |
924 | struct ocfs2_alloc_context *meta_ac) | 1228 | struct ocfs2_alloc_context *meta_ac) |
925 | { | 1229 | { |
926 | int ret, shift; | 1230 | int ret, shift; |
927 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; | 1231 | struct ocfs2_extent_list *el = et->et_root_el; |
928 | int depth = le16_to_cpu(di->id2.i_list.l_tree_depth); | 1232 | int depth = le16_to_cpu(el->l_tree_depth); |
929 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 1233 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
930 | struct buffer_head *bh = NULL; | 1234 | struct buffer_head *bh = NULL; |
931 | 1235 | ||
932 | BUG_ON(meta_ac == NULL); | 1236 | BUG_ON(meta_ac == NULL); |
933 | 1237 | ||
934 | shift = ocfs2_find_branch_target(osb, inode, di_bh, &bh); | 1238 | shift = ocfs2_find_branch_target(osb, inode, et, &bh); |
935 | if (shift < 0) { | 1239 | if (shift < 0) { |
936 | ret = shift; | 1240 | ret = shift; |
937 | mlog_errno(ret); | 1241 | mlog_errno(ret); |
@@ -948,7 +1252,7 @@ static int ocfs2_grow_tree(struct inode *inode, handle_t *handle, | |||
948 | /* ocfs2_shift_tree_depth will return us a buffer with | 1252 | /* ocfs2_shift_tree_depth will return us a buffer with |
949 | * the new extent block (so we can pass that to | 1253 | * the new extent block (so we can pass that to |
950 | * ocfs2_add_branch). */ | 1254 | * ocfs2_add_branch). */ |
951 | ret = ocfs2_shift_tree_depth(osb, handle, inode, di_bh, | 1255 | ret = ocfs2_shift_tree_depth(osb, handle, inode, et, |
952 | meta_ac, &bh); | 1256 | meta_ac, &bh); |
953 | if (ret < 0) { | 1257 | if (ret < 0) { |
954 | mlog_errno(ret); | 1258 | mlog_errno(ret); |
@@ -975,7 +1279,7 @@ static int ocfs2_grow_tree(struct inode *inode, handle_t *handle, | |||
975 | /* call ocfs2_add_branch to add the final part of the tree with | 1279 | /* call ocfs2_add_branch to add the final part of the tree with |
976 | * the new data. */ | 1280 | * the new data. */ |
977 | mlog(0, "add branch. bh = %p\n", bh); | 1281 | mlog(0, "add branch. bh = %p\n", bh); |
978 | ret = ocfs2_add_branch(osb, handle, inode, di_bh, bh, last_eb_bh, | 1282 | ret = ocfs2_add_branch(osb, handle, inode, et, bh, last_eb_bh, |
979 | meta_ac); | 1283 | meta_ac); |
980 | if (ret < 0) { | 1284 | if (ret < 0) { |
981 | mlog_errno(ret); | 1285 | mlog_errno(ret); |
@@ -1236,8 +1540,7 @@ static int __ocfs2_find_path(struct inode *inode, | |||
1236 | 1540 | ||
1237 | brelse(bh); | 1541 | brelse(bh); |
1238 | bh = NULL; | 1542 | bh = NULL; |
1239 | ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), blkno, | 1543 | ret = ocfs2_read_block(inode, blkno, &bh); |
1240 | &bh, OCFS2_BH_CACHED, inode); | ||
1241 | if (ret) { | 1544 | if (ret) { |
1242 | mlog_errno(ret); | 1545 | mlog_errno(ret); |
1243 | goto out; | 1546 | goto out; |
@@ -2058,11 +2361,11 @@ static int ocfs2_rotate_subtree_left(struct inode *inode, handle_t *handle, | |||
2058 | struct ocfs2_path *right_path, | 2361 | struct ocfs2_path *right_path, |
2059 | int subtree_index, | 2362 | int subtree_index, |
2060 | struct ocfs2_cached_dealloc_ctxt *dealloc, | 2363 | struct ocfs2_cached_dealloc_ctxt *dealloc, |
2061 | int *deleted) | 2364 | int *deleted, |
2365 | struct ocfs2_extent_tree *et) | ||
2062 | { | 2366 | { |
2063 | int ret, i, del_right_subtree = 0, right_has_empty = 0; | 2367 | int ret, i, del_right_subtree = 0, right_has_empty = 0; |
2064 | struct buffer_head *root_bh, *di_bh = path_root_bh(right_path); | 2368 | struct buffer_head *root_bh, *et_root_bh = path_root_bh(right_path); |
2065 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; | ||
2066 | struct ocfs2_extent_list *right_leaf_el, *left_leaf_el; | 2369 | struct ocfs2_extent_list *right_leaf_el, *left_leaf_el; |
2067 | struct ocfs2_extent_block *eb; | 2370 | struct ocfs2_extent_block *eb; |
2068 | 2371 | ||
@@ -2114,7 +2417,7 @@ static int ocfs2_rotate_subtree_left(struct inode *inode, handle_t *handle, | |||
2114 | * We have to update i_last_eb_blk during the meta | 2417 | * We have to update i_last_eb_blk during the meta |
2115 | * data delete. | 2418 | * data delete. |
2116 | */ | 2419 | */ |
2117 | ret = ocfs2_journal_access(handle, inode, di_bh, | 2420 | ret = ocfs2_journal_access(handle, inode, et_root_bh, |
2118 | OCFS2_JOURNAL_ACCESS_WRITE); | 2421 | OCFS2_JOURNAL_ACCESS_WRITE); |
2119 | if (ret) { | 2422 | if (ret) { |
2120 | mlog_errno(ret); | 2423 | mlog_errno(ret); |
@@ -2189,7 +2492,7 @@ static int ocfs2_rotate_subtree_left(struct inode *inode, handle_t *handle, | |||
2189 | ocfs2_update_edge_lengths(inode, handle, left_path); | 2492 | ocfs2_update_edge_lengths(inode, handle, left_path); |
2190 | 2493 | ||
2191 | eb = (struct ocfs2_extent_block *)path_leaf_bh(left_path)->b_data; | 2494 | eb = (struct ocfs2_extent_block *)path_leaf_bh(left_path)->b_data; |
2192 | di->i_last_eb_blk = eb->h_blkno; | 2495 | ocfs2_et_set_last_eb_blk(et, le64_to_cpu(eb->h_blkno)); |
2193 | 2496 | ||
2194 | /* | 2497 | /* |
2195 | * Removal of the extent in the left leaf was skipped | 2498 | * Removal of the extent in the left leaf was skipped |
@@ -2199,7 +2502,7 @@ static int ocfs2_rotate_subtree_left(struct inode *inode, handle_t *handle, | |||
2199 | if (right_has_empty) | 2502 | if (right_has_empty) |
2200 | ocfs2_remove_empty_extent(left_leaf_el); | 2503 | ocfs2_remove_empty_extent(left_leaf_el); |
2201 | 2504 | ||
2202 | ret = ocfs2_journal_dirty(handle, di_bh); | 2505 | ret = ocfs2_journal_dirty(handle, et_root_bh); |
2203 | if (ret) | 2506 | if (ret) |
2204 | mlog_errno(ret); | 2507 | mlog_errno(ret); |
2205 | 2508 | ||
@@ -2322,7 +2625,8 @@ static int __ocfs2_rotate_tree_left(struct inode *inode, | |||
2322 | handle_t *handle, int orig_credits, | 2625 | handle_t *handle, int orig_credits, |
2323 | struct ocfs2_path *path, | 2626 | struct ocfs2_path *path, |
2324 | struct ocfs2_cached_dealloc_ctxt *dealloc, | 2627 | struct ocfs2_cached_dealloc_ctxt *dealloc, |
2325 | struct ocfs2_path **empty_extent_path) | 2628 | struct ocfs2_path **empty_extent_path, |
2629 | struct ocfs2_extent_tree *et) | ||
2326 | { | 2630 | { |
2327 | int ret, subtree_root, deleted; | 2631 | int ret, subtree_root, deleted; |
2328 | u32 right_cpos; | 2632 | u32 right_cpos; |
@@ -2395,7 +2699,7 @@ static int __ocfs2_rotate_tree_left(struct inode *inode, | |||
2395 | 2699 | ||
2396 | ret = ocfs2_rotate_subtree_left(inode, handle, left_path, | 2700 | ret = ocfs2_rotate_subtree_left(inode, handle, left_path, |
2397 | right_path, subtree_root, | 2701 | right_path, subtree_root, |
2398 | dealloc, &deleted); | 2702 | dealloc, &deleted, et); |
2399 | if (ret == -EAGAIN) { | 2703 | if (ret == -EAGAIN) { |
2400 | /* | 2704 | /* |
2401 | * The rotation has to temporarily stop due to | 2705 | * The rotation has to temporarily stop due to |
@@ -2438,29 +2742,20 @@ out: | |||
2438 | } | 2742 | } |
2439 | 2743 | ||
2440 | static int ocfs2_remove_rightmost_path(struct inode *inode, handle_t *handle, | 2744 | static int ocfs2_remove_rightmost_path(struct inode *inode, handle_t *handle, |
2441 | struct ocfs2_path *path, | 2745 | struct ocfs2_path *path, |
2442 | struct ocfs2_cached_dealloc_ctxt *dealloc) | 2746 | struct ocfs2_cached_dealloc_ctxt *dealloc, |
2747 | struct ocfs2_extent_tree *et) | ||
2443 | { | 2748 | { |
2444 | int ret, subtree_index; | 2749 | int ret, subtree_index; |
2445 | u32 cpos; | 2750 | u32 cpos; |
2446 | struct ocfs2_path *left_path = NULL; | 2751 | struct ocfs2_path *left_path = NULL; |
2447 | struct ocfs2_dinode *di; | ||
2448 | struct ocfs2_extent_block *eb; | 2752 | struct ocfs2_extent_block *eb; |
2449 | struct ocfs2_extent_list *el; | 2753 | struct ocfs2_extent_list *el; |
2450 | 2754 | ||
2451 | /* | ||
2452 | * XXX: This code assumes that the root is an inode, which is | ||
2453 | * true for now but may change as tree code gets generic. | ||
2454 | */ | ||
2455 | di = (struct ocfs2_dinode *)path_root_bh(path)->b_data; | ||
2456 | if (!OCFS2_IS_VALID_DINODE(di)) { | ||
2457 | ret = -EIO; | ||
2458 | ocfs2_error(inode->i_sb, | ||
2459 | "Inode %llu has invalid path root", | ||
2460 | (unsigned long long)OCFS2_I(inode)->ip_blkno); | ||
2461 | goto out; | ||
2462 | } | ||
2463 | 2755 | ||
2756 | ret = ocfs2_et_sanity_check(inode, et); | ||
2757 | if (ret) | ||
2758 | goto out; | ||
2464 | /* | 2759 | /* |
2465 | * There's two ways we handle this depending on | 2760 | * There's two ways we handle this depending on |
2466 | * whether path is the only existing one. | 2761 | * whether path is the only existing one. |
@@ -2517,7 +2812,7 @@ static int ocfs2_remove_rightmost_path(struct inode *inode, handle_t *handle, | |||
2517 | ocfs2_update_edge_lengths(inode, handle, left_path); | 2812 | ocfs2_update_edge_lengths(inode, handle, left_path); |
2518 | 2813 | ||
2519 | eb = (struct ocfs2_extent_block *)path_leaf_bh(left_path)->b_data; | 2814 | eb = (struct ocfs2_extent_block *)path_leaf_bh(left_path)->b_data; |
2520 | di->i_last_eb_blk = eb->h_blkno; | 2815 | ocfs2_et_set_last_eb_blk(et, le64_to_cpu(eb->h_blkno)); |
2521 | } else { | 2816 | } else { |
2522 | /* | 2817 | /* |
2523 | * 'path' is also the leftmost path which | 2818 | * 'path' is also the leftmost path which |
@@ -2528,12 +2823,12 @@ static int ocfs2_remove_rightmost_path(struct inode *inode, handle_t *handle, | |||
2528 | */ | 2823 | */ |
2529 | ocfs2_unlink_path(inode, handle, dealloc, path, 1); | 2824 | ocfs2_unlink_path(inode, handle, dealloc, path, 1); |
2530 | 2825 | ||
2531 | el = &di->id2.i_list; | 2826 | el = et->et_root_el; |
2532 | el->l_tree_depth = 0; | 2827 | el->l_tree_depth = 0; |
2533 | el->l_next_free_rec = 0; | 2828 | el->l_next_free_rec = 0; |
2534 | memset(&el->l_recs[0], 0, sizeof(struct ocfs2_extent_rec)); | 2829 | memset(&el->l_recs[0], 0, sizeof(struct ocfs2_extent_rec)); |
2535 | 2830 | ||
2536 | di->i_last_eb_blk = 0; | 2831 | ocfs2_et_set_last_eb_blk(et, 0); |
2537 | } | 2832 | } |
2538 | 2833 | ||
2539 | ocfs2_journal_dirty(handle, path_root_bh(path)); | 2834 | ocfs2_journal_dirty(handle, path_root_bh(path)); |
@@ -2561,7 +2856,8 @@ out: | |||
2561 | */ | 2856 | */ |
2562 | static int ocfs2_rotate_tree_left(struct inode *inode, handle_t *handle, | 2857 | static int ocfs2_rotate_tree_left(struct inode *inode, handle_t *handle, |
2563 | struct ocfs2_path *path, | 2858 | struct ocfs2_path *path, |
2564 | struct ocfs2_cached_dealloc_ctxt *dealloc) | 2859 | struct ocfs2_cached_dealloc_ctxt *dealloc, |
2860 | struct ocfs2_extent_tree *et) | ||
2565 | { | 2861 | { |
2566 | int ret, orig_credits = handle->h_buffer_credits; | 2862 | int ret, orig_credits = handle->h_buffer_credits; |
2567 | struct ocfs2_path *tmp_path = NULL, *restart_path = NULL; | 2863 | struct ocfs2_path *tmp_path = NULL, *restart_path = NULL; |
@@ -2575,7 +2871,7 @@ static int ocfs2_rotate_tree_left(struct inode *inode, handle_t *handle, | |||
2575 | if (path->p_tree_depth == 0) { | 2871 | if (path->p_tree_depth == 0) { |
2576 | rightmost_no_delete: | 2872 | rightmost_no_delete: |
2577 | /* | 2873 | /* |
2578 | * In-inode extents. This is trivially handled, so do | 2874 | * Inline extents. This is trivially handled, so do |
2579 | * it up front. | 2875 | * it up front. |
2580 | */ | 2876 | */ |
2581 | ret = ocfs2_rotate_rightmost_leaf_left(inode, handle, | 2877 | ret = ocfs2_rotate_rightmost_leaf_left(inode, handle, |
@@ -2629,7 +2925,7 @@ rightmost_no_delete: | |||
2629 | */ | 2925 | */ |
2630 | 2926 | ||
2631 | ret = ocfs2_remove_rightmost_path(inode, handle, path, | 2927 | ret = ocfs2_remove_rightmost_path(inode, handle, path, |
2632 | dealloc); | 2928 | dealloc, et); |
2633 | if (ret) | 2929 | if (ret) |
2634 | mlog_errno(ret); | 2930 | mlog_errno(ret); |
2635 | goto out; | 2931 | goto out; |
@@ -2641,7 +2937,7 @@ rightmost_no_delete: | |||
2641 | */ | 2937 | */ |
2642 | try_rotate: | 2938 | try_rotate: |
2643 | ret = __ocfs2_rotate_tree_left(inode, handle, orig_credits, path, | 2939 | ret = __ocfs2_rotate_tree_left(inode, handle, orig_credits, path, |
2644 | dealloc, &restart_path); | 2940 | dealloc, &restart_path, et); |
2645 | if (ret && ret != -EAGAIN) { | 2941 | if (ret && ret != -EAGAIN) { |
2646 | mlog_errno(ret); | 2942 | mlog_errno(ret); |
2647 | goto out; | 2943 | goto out; |
@@ -2653,7 +2949,7 @@ try_rotate: | |||
2653 | 2949 | ||
2654 | ret = __ocfs2_rotate_tree_left(inode, handle, orig_credits, | 2950 | ret = __ocfs2_rotate_tree_left(inode, handle, orig_credits, |
2655 | tmp_path, dealloc, | 2951 | tmp_path, dealloc, |
2656 | &restart_path); | 2952 | &restart_path, et); |
2657 | if (ret && ret != -EAGAIN) { | 2953 | if (ret && ret != -EAGAIN) { |
2658 | mlog_errno(ret); | 2954 | mlog_errno(ret); |
2659 | goto out; | 2955 | goto out; |
@@ -2939,6 +3235,7 @@ static int ocfs2_merge_rec_left(struct inode *inode, | |||
2939 | handle_t *handle, | 3235 | handle_t *handle, |
2940 | struct ocfs2_extent_rec *split_rec, | 3236 | struct ocfs2_extent_rec *split_rec, |
2941 | struct ocfs2_cached_dealloc_ctxt *dealloc, | 3237 | struct ocfs2_cached_dealloc_ctxt *dealloc, |
3238 | struct ocfs2_extent_tree *et, | ||
2942 | int index) | 3239 | int index) |
2943 | { | 3240 | { |
2944 | int ret, i, subtree_index = 0, has_empty_extent = 0; | 3241 | int ret, i, subtree_index = 0, has_empty_extent = 0; |
@@ -3059,7 +3356,8 @@ static int ocfs2_merge_rec_left(struct inode *inode, | |||
3059 | le16_to_cpu(el->l_next_free_rec) == 1) { | 3356 | le16_to_cpu(el->l_next_free_rec) == 1) { |
3060 | 3357 | ||
3061 | ret = ocfs2_remove_rightmost_path(inode, handle, | 3358 | ret = ocfs2_remove_rightmost_path(inode, handle, |
3062 | right_path, dealloc); | 3359 | right_path, |
3360 | dealloc, et); | ||
3063 | if (ret) { | 3361 | if (ret) { |
3064 | mlog_errno(ret); | 3362 | mlog_errno(ret); |
3065 | goto out; | 3363 | goto out; |
@@ -3086,7 +3384,8 @@ static int ocfs2_try_to_merge_extent(struct inode *inode, | |||
3086 | int split_index, | 3384 | int split_index, |
3087 | struct ocfs2_extent_rec *split_rec, | 3385 | struct ocfs2_extent_rec *split_rec, |
3088 | struct ocfs2_cached_dealloc_ctxt *dealloc, | 3386 | struct ocfs2_cached_dealloc_ctxt *dealloc, |
3089 | struct ocfs2_merge_ctxt *ctxt) | 3387 | struct ocfs2_merge_ctxt *ctxt, |
3388 | struct ocfs2_extent_tree *et) | ||
3090 | 3389 | ||
3091 | { | 3390 | { |
3092 | int ret = 0; | 3391 | int ret = 0; |
@@ -3104,7 +3403,7 @@ static int ocfs2_try_to_merge_extent(struct inode *inode, | |||
3104 | * illegal. | 3403 | * illegal. |
3105 | */ | 3404 | */ |
3106 | ret = ocfs2_rotate_tree_left(inode, handle, path, | 3405 | ret = ocfs2_rotate_tree_left(inode, handle, path, |
3107 | dealloc); | 3406 | dealloc, et); |
3108 | if (ret) { | 3407 | if (ret) { |
3109 | mlog_errno(ret); | 3408 | mlog_errno(ret); |
3110 | goto out; | 3409 | goto out; |
@@ -3147,7 +3446,8 @@ static int ocfs2_try_to_merge_extent(struct inode *inode, | |||
3147 | BUG_ON(!ocfs2_is_empty_extent(&el->l_recs[0])); | 3446 | BUG_ON(!ocfs2_is_empty_extent(&el->l_recs[0])); |
3148 | 3447 | ||
3149 | /* The merge left us with an empty extent, remove it. */ | 3448 | /* The merge left us with an empty extent, remove it. */ |
3150 | ret = ocfs2_rotate_tree_left(inode, handle, path, dealloc); | 3449 | ret = ocfs2_rotate_tree_left(inode, handle, path, |
3450 | dealloc, et); | ||
3151 | if (ret) { | 3451 | if (ret) { |
3152 | mlog_errno(ret); | 3452 | mlog_errno(ret); |
3153 | goto out; | 3453 | goto out; |
@@ -3161,7 +3461,7 @@ static int ocfs2_try_to_merge_extent(struct inode *inode, | |||
3161 | */ | 3461 | */ |
3162 | ret = ocfs2_merge_rec_left(inode, path, | 3462 | ret = ocfs2_merge_rec_left(inode, path, |
3163 | handle, rec, | 3463 | handle, rec, |
3164 | dealloc, | 3464 | dealloc, et, |
3165 | split_index); | 3465 | split_index); |
3166 | 3466 | ||
3167 | if (ret) { | 3467 | if (ret) { |
@@ -3170,7 +3470,7 @@ static int ocfs2_try_to_merge_extent(struct inode *inode, | |||
3170 | } | 3470 | } |
3171 | 3471 | ||
3172 | ret = ocfs2_rotate_tree_left(inode, handle, path, | 3472 | ret = ocfs2_rotate_tree_left(inode, handle, path, |
3173 | dealloc); | 3473 | dealloc, et); |
3174 | /* | 3474 | /* |
3175 | * Error from this last rotate is not critical, so | 3475 | * Error from this last rotate is not critical, so |
3176 | * print but don't bubble it up. | 3476 | * print but don't bubble it up. |
@@ -3190,7 +3490,7 @@ static int ocfs2_try_to_merge_extent(struct inode *inode, | |||
3190 | ret = ocfs2_merge_rec_left(inode, | 3490 | ret = ocfs2_merge_rec_left(inode, |
3191 | path, | 3491 | path, |
3192 | handle, split_rec, | 3492 | handle, split_rec, |
3193 | dealloc, | 3493 | dealloc, et, |
3194 | split_index); | 3494 | split_index); |
3195 | if (ret) { | 3495 | if (ret) { |
3196 | mlog_errno(ret); | 3496 | mlog_errno(ret); |
@@ -3213,7 +3513,7 @@ static int ocfs2_try_to_merge_extent(struct inode *inode, | |||
3213 | * our leaf. Try to rotate it away. | 3513 | * our leaf. Try to rotate it away. |
3214 | */ | 3514 | */ |
3215 | ret = ocfs2_rotate_tree_left(inode, handle, path, | 3515 | ret = ocfs2_rotate_tree_left(inode, handle, path, |
3216 | dealloc); | 3516 | dealloc, et); |
3217 | if (ret) | 3517 | if (ret) |
3218 | mlog_errno(ret); | 3518 | mlog_errno(ret); |
3219 | ret = 0; | 3519 | ret = 0; |
@@ -3347,16 +3647,6 @@ rotate: | |||
3347 | ocfs2_rotate_leaf(el, insert_rec); | 3647 | ocfs2_rotate_leaf(el, insert_rec); |
3348 | } | 3648 | } |
3349 | 3649 | ||
3350 | static inline void ocfs2_update_dinode_clusters(struct inode *inode, | ||
3351 | struct ocfs2_dinode *di, | ||
3352 | u32 clusters) | ||
3353 | { | ||
3354 | le32_add_cpu(&di->i_clusters, clusters); | ||
3355 | spin_lock(&OCFS2_I(inode)->ip_lock); | ||
3356 | OCFS2_I(inode)->ip_clusters = le32_to_cpu(di->i_clusters); | ||
3357 | spin_unlock(&OCFS2_I(inode)->ip_lock); | ||
3358 | } | ||
3359 | |||
3360 | static void ocfs2_adjust_rightmost_records(struct inode *inode, | 3650 | static void ocfs2_adjust_rightmost_records(struct inode *inode, |
3361 | handle_t *handle, | 3651 | handle_t *handle, |
3362 | struct ocfs2_path *path, | 3652 | struct ocfs2_path *path, |
@@ -3558,8 +3848,8 @@ static void ocfs2_split_record(struct inode *inode, | |||
3558 | } | 3848 | } |
3559 | 3849 | ||
3560 | /* | 3850 | /* |
3561 | * This function only does inserts on an allocation b-tree. For dinode | 3851 | * This function only does inserts on an allocation b-tree. For tree |
3562 | * lists, ocfs2_insert_at_leaf() is called directly. | 3852 | * depth = 0, ocfs2_insert_at_leaf() is called directly. |
3563 | * | 3853 | * |
3564 | * right_path is the path we want to do the actual insert | 3854 | * right_path is the path we want to do the actual insert |
3565 | * in. left_path should only be passed in if we need to update that | 3855 | * in. left_path should only be passed in if we need to update that |
@@ -3656,7 +3946,7 @@ out: | |||
3656 | 3946 | ||
3657 | static int ocfs2_do_insert_extent(struct inode *inode, | 3947 | static int ocfs2_do_insert_extent(struct inode *inode, |
3658 | handle_t *handle, | 3948 | handle_t *handle, |
3659 | struct buffer_head *di_bh, | 3949 | struct ocfs2_extent_tree *et, |
3660 | struct ocfs2_extent_rec *insert_rec, | 3950 | struct ocfs2_extent_rec *insert_rec, |
3661 | struct ocfs2_insert_type *type) | 3951 | struct ocfs2_insert_type *type) |
3662 | { | 3952 | { |
@@ -3664,13 +3954,11 @@ static int ocfs2_do_insert_extent(struct inode *inode, | |||
3664 | u32 cpos; | 3954 | u32 cpos; |
3665 | struct ocfs2_path *right_path = NULL; | 3955 | struct ocfs2_path *right_path = NULL; |
3666 | struct ocfs2_path *left_path = NULL; | 3956 | struct ocfs2_path *left_path = NULL; |
3667 | struct ocfs2_dinode *di; | ||
3668 | struct ocfs2_extent_list *el; | 3957 | struct ocfs2_extent_list *el; |
3669 | 3958 | ||
3670 | di = (struct ocfs2_dinode *) di_bh->b_data; | 3959 | el = et->et_root_el; |
3671 | el = &di->id2.i_list; | ||
3672 | 3960 | ||
3673 | ret = ocfs2_journal_access(handle, inode, di_bh, | 3961 | ret = ocfs2_journal_access(handle, inode, et->et_root_bh, |
3674 | OCFS2_JOURNAL_ACCESS_WRITE); | 3962 | OCFS2_JOURNAL_ACCESS_WRITE); |
3675 | if (ret) { | 3963 | if (ret) { |
3676 | mlog_errno(ret); | 3964 | mlog_errno(ret); |
@@ -3682,7 +3970,7 @@ static int ocfs2_do_insert_extent(struct inode *inode, | |||
3682 | goto out_update_clusters; | 3970 | goto out_update_clusters; |
3683 | } | 3971 | } |
3684 | 3972 | ||
3685 | right_path = ocfs2_new_inode_path(di_bh); | 3973 | right_path = ocfs2_new_path(et->et_root_bh, et->et_root_el); |
3686 | if (!right_path) { | 3974 | if (!right_path) { |
3687 | ret = -ENOMEM; | 3975 | ret = -ENOMEM; |
3688 | mlog_errno(ret); | 3976 | mlog_errno(ret); |
@@ -3732,7 +4020,7 @@ static int ocfs2_do_insert_extent(struct inode *inode, | |||
3732 | * ocfs2_rotate_tree_right() might have extended the | 4020 | * ocfs2_rotate_tree_right() might have extended the |
3733 | * transaction without re-journaling our tree root. | 4021 | * transaction without re-journaling our tree root. |
3734 | */ | 4022 | */ |
3735 | ret = ocfs2_journal_access(handle, inode, di_bh, | 4023 | ret = ocfs2_journal_access(handle, inode, et->et_root_bh, |
3736 | OCFS2_JOURNAL_ACCESS_WRITE); | 4024 | OCFS2_JOURNAL_ACCESS_WRITE); |
3737 | if (ret) { | 4025 | if (ret) { |
3738 | mlog_errno(ret); | 4026 | mlog_errno(ret); |
@@ -3757,10 +4045,10 @@ static int ocfs2_do_insert_extent(struct inode *inode, | |||
3757 | 4045 | ||
3758 | out_update_clusters: | 4046 | out_update_clusters: |
3759 | if (type->ins_split == SPLIT_NONE) | 4047 | if (type->ins_split == SPLIT_NONE) |
3760 | ocfs2_update_dinode_clusters(inode, di, | 4048 | ocfs2_et_update_clusters(inode, et, |
3761 | le16_to_cpu(insert_rec->e_leaf_clusters)); | 4049 | le16_to_cpu(insert_rec->e_leaf_clusters)); |
3762 | 4050 | ||
3763 | ret = ocfs2_journal_dirty(handle, di_bh); | 4051 | ret = ocfs2_journal_dirty(handle, et->et_root_bh); |
3764 | if (ret) | 4052 | if (ret) |
3765 | mlog_errno(ret); | 4053 | mlog_errno(ret); |
3766 | 4054 | ||
@@ -3890,7 +4178,8 @@ out: | |||
3890 | static void ocfs2_figure_contig_type(struct inode *inode, | 4178 | static void ocfs2_figure_contig_type(struct inode *inode, |
3891 | struct ocfs2_insert_type *insert, | 4179 | struct ocfs2_insert_type *insert, |
3892 | struct ocfs2_extent_list *el, | 4180 | struct ocfs2_extent_list *el, |
3893 | struct ocfs2_extent_rec *insert_rec) | 4181 | struct ocfs2_extent_rec *insert_rec, |
4182 | struct ocfs2_extent_tree *et) | ||
3894 | { | 4183 | { |
3895 | int i; | 4184 | int i; |
3896 | enum ocfs2_contig_type contig_type = CONTIG_NONE; | 4185 | enum ocfs2_contig_type contig_type = CONTIG_NONE; |
@@ -3906,6 +4195,21 @@ static void ocfs2_figure_contig_type(struct inode *inode, | |||
3906 | } | 4195 | } |
3907 | } | 4196 | } |
3908 | insert->ins_contig = contig_type; | 4197 | insert->ins_contig = contig_type; |
4198 | |||
4199 | if (insert->ins_contig != CONTIG_NONE) { | ||
4200 | struct ocfs2_extent_rec *rec = | ||
4201 | &el->l_recs[insert->ins_contig_index]; | ||
4202 | unsigned int len = le16_to_cpu(rec->e_leaf_clusters) + | ||
4203 | le16_to_cpu(insert_rec->e_leaf_clusters); | ||
4204 | |||
4205 | /* | ||
4206 | * Caller might want us to limit the size of extents, don't | ||
4207 | * calculate contiguousness if we might exceed that limit. | ||
4208 | */ | ||
4209 | if (et->et_max_leaf_clusters && | ||
4210 | (len > et->et_max_leaf_clusters)) | ||
4211 | insert->ins_contig = CONTIG_NONE; | ||
4212 | } | ||
3909 | } | 4213 | } |
3910 | 4214 | ||
3911 | /* | 4215 | /* |
@@ -3914,8 +4218,8 @@ static void ocfs2_figure_contig_type(struct inode *inode, | |||
3914 | * ocfs2_figure_appending_type() will figure out whether we'll have to | 4218 | * ocfs2_figure_appending_type() will figure out whether we'll have to |
3915 | * insert at the tail of the rightmost leaf. | 4219 | * insert at the tail of the rightmost leaf. |
3916 | * | 4220 | * |
3917 | * This should also work against the dinode list for tree's with 0 | 4221 | * This should also work against the root extent list for tree's with 0 |
3918 | * depth. If we consider the dinode list to be the rightmost leaf node | 4222 | * depth. If we consider the root extent list to be the rightmost leaf node |
3919 | * then the logic here makes sense. | 4223 | * then the logic here makes sense. |
3920 | */ | 4224 | */ |
3921 | static void ocfs2_figure_appending_type(struct ocfs2_insert_type *insert, | 4225 | static void ocfs2_figure_appending_type(struct ocfs2_insert_type *insert, |
@@ -3966,14 +4270,13 @@ set_tail_append: | |||
3966 | * structure. | 4270 | * structure. |
3967 | */ | 4271 | */ |
3968 | static int ocfs2_figure_insert_type(struct inode *inode, | 4272 | static int ocfs2_figure_insert_type(struct inode *inode, |
3969 | struct buffer_head *di_bh, | 4273 | struct ocfs2_extent_tree *et, |
3970 | struct buffer_head **last_eb_bh, | 4274 | struct buffer_head **last_eb_bh, |
3971 | struct ocfs2_extent_rec *insert_rec, | 4275 | struct ocfs2_extent_rec *insert_rec, |
3972 | int *free_records, | 4276 | int *free_records, |
3973 | struct ocfs2_insert_type *insert) | 4277 | struct ocfs2_insert_type *insert) |
3974 | { | 4278 | { |
3975 | int ret; | 4279 | int ret; |
3976 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; | ||
3977 | struct ocfs2_extent_block *eb; | 4280 | struct ocfs2_extent_block *eb; |
3978 | struct ocfs2_extent_list *el; | 4281 | struct ocfs2_extent_list *el; |
3979 | struct ocfs2_path *path = NULL; | 4282 | struct ocfs2_path *path = NULL; |
@@ -3981,7 +4284,7 @@ static int ocfs2_figure_insert_type(struct inode *inode, | |||
3981 | 4284 | ||
3982 | insert->ins_split = SPLIT_NONE; | 4285 | insert->ins_split = SPLIT_NONE; |
3983 | 4286 | ||
3984 | el = &di->id2.i_list; | 4287 | el = et->et_root_el; |
3985 | insert->ins_tree_depth = le16_to_cpu(el->l_tree_depth); | 4288 | insert->ins_tree_depth = le16_to_cpu(el->l_tree_depth); |
3986 | 4289 | ||
3987 | if (el->l_tree_depth) { | 4290 | if (el->l_tree_depth) { |
@@ -3991,9 +4294,7 @@ static int ocfs2_figure_insert_type(struct inode *inode, | |||
3991 | * ocfs2_figure_insert_type() and ocfs2_add_branch() | 4294 | * ocfs2_figure_insert_type() and ocfs2_add_branch() |
3992 | * may want it later. | 4295 | * may want it later. |
3993 | */ | 4296 | */ |
3994 | ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), | 4297 | ret = ocfs2_read_block(inode, ocfs2_et_get_last_eb_blk(et), &bh); |
3995 | le64_to_cpu(di->i_last_eb_blk), &bh, | ||
3996 | OCFS2_BH_CACHED, inode); | ||
3997 | if (ret) { | 4298 | if (ret) { |
3998 | mlog_exit(ret); | 4299 | mlog_exit(ret); |
3999 | goto out; | 4300 | goto out; |
@@ -4014,12 +4315,12 @@ static int ocfs2_figure_insert_type(struct inode *inode, | |||
4014 | le16_to_cpu(el->l_next_free_rec); | 4315 | le16_to_cpu(el->l_next_free_rec); |
4015 | 4316 | ||
4016 | if (!insert->ins_tree_depth) { | 4317 | if (!insert->ins_tree_depth) { |
4017 | ocfs2_figure_contig_type(inode, insert, el, insert_rec); | 4318 | ocfs2_figure_contig_type(inode, insert, el, insert_rec, et); |
4018 | ocfs2_figure_appending_type(insert, el, insert_rec); | 4319 | ocfs2_figure_appending_type(insert, el, insert_rec); |
4019 | return 0; | 4320 | return 0; |
4020 | } | 4321 | } |
4021 | 4322 | ||
4022 | path = ocfs2_new_inode_path(di_bh); | 4323 | path = ocfs2_new_path(et->et_root_bh, et->et_root_el); |
4023 | if (!path) { | 4324 | if (!path) { |
4024 | ret = -ENOMEM; | 4325 | ret = -ENOMEM; |
4025 | mlog_errno(ret); | 4326 | mlog_errno(ret); |
@@ -4048,7 +4349,7 @@ static int ocfs2_figure_insert_type(struct inode *inode, | |||
4048 | * into two types of appends: simple record append, or a | 4349 | * into two types of appends: simple record append, or a |
4049 | * rotate inside the tail leaf. | 4350 | * rotate inside the tail leaf. |
4050 | */ | 4351 | */ |
4051 | ocfs2_figure_contig_type(inode, insert, el, insert_rec); | 4352 | ocfs2_figure_contig_type(inode, insert, el, insert_rec, et); |
4052 | 4353 | ||
4053 | /* | 4354 | /* |
4054 | * The insert code isn't quite ready to deal with all cases of | 4355 | * The insert code isn't quite ready to deal with all cases of |
@@ -4069,7 +4370,8 @@ static int ocfs2_figure_insert_type(struct inode *inode, | |||
4069 | * the case that we're doing a tail append, so maybe we can | 4370 | * the case that we're doing a tail append, so maybe we can |
4070 | * take advantage of that information somehow. | 4371 | * take advantage of that information somehow. |
4071 | */ | 4372 | */ |
4072 | if (le64_to_cpu(di->i_last_eb_blk) == path_leaf_bh(path)->b_blocknr) { | 4373 | if (ocfs2_et_get_last_eb_blk(et) == |
4374 | path_leaf_bh(path)->b_blocknr) { | ||
4073 | /* | 4375 | /* |
4074 | * Ok, ocfs2_find_path() returned us the rightmost | 4376 | * Ok, ocfs2_find_path() returned us the rightmost |
4075 | * tree path. This might be an appending insert. There are | 4377 | * tree path. This might be an appending insert. There are |
@@ -4099,7 +4401,7 @@ out: | |||
4099 | int ocfs2_insert_extent(struct ocfs2_super *osb, | 4401 | int ocfs2_insert_extent(struct ocfs2_super *osb, |
4100 | handle_t *handle, | 4402 | handle_t *handle, |
4101 | struct inode *inode, | 4403 | struct inode *inode, |
4102 | struct buffer_head *fe_bh, | 4404 | struct ocfs2_extent_tree *et, |
4103 | u32 cpos, | 4405 | u32 cpos, |
4104 | u64 start_blk, | 4406 | u64 start_blk, |
4105 | u32 new_clusters, | 4407 | u32 new_clusters, |
@@ -4112,26 +4414,21 @@ int ocfs2_insert_extent(struct ocfs2_super *osb, | |||
4112 | struct ocfs2_insert_type insert = {0, }; | 4414 | struct ocfs2_insert_type insert = {0, }; |
4113 | struct ocfs2_extent_rec rec; | 4415 | struct ocfs2_extent_rec rec; |
4114 | 4416 | ||
4115 | BUG_ON(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL); | ||
4116 | |||
4117 | mlog(0, "add %u clusters at position %u to inode %llu\n", | 4417 | mlog(0, "add %u clusters at position %u to inode %llu\n", |
4118 | new_clusters, cpos, (unsigned long long)OCFS2_I(inode)->ip_blkno); | 4418 | new_clusters, cpos, (unsigned long long)OCFS2_I(inode)->ip_blkno); |
4119 | 4419 | ||
4120 | mlog_bug_on_msg(!ocfs2_sparse_alloc(osb) && | ||
4121 | (OCFS2_I(inode)->ip_clusters != cpos), | ||
4122 | "Device %s, asking for sparse allocation: inode %llu, " | ||
4123 | "cpos %u, clusters %u\n", | ||
4124 | osb->dev_str, | ||
4125 | (unsigned long long)OCFS2_I(inode)->ip_blkno, cpos, | ||
4126 | OCFS2_I(inode)->ip_clusters); | ||
4127 | |||
4128 | memset(&rec, 0, sizeof(rec)); | 4420 | memset(&rec, 0, sizeof(rec)); |
4129 | rec.e_cpos = cpu_to_le32(cpos); | 4421 | rec.e_cpos = cpu_to_le32(cpos); |
4130 | rec.e_blkno = cpu_to_le64(start_blk); | 4422 | rec.e_blkno = cpu_to_le64(start_blk); |
4131 | rec.e_leaf_clusters = cpu_to_le16(new_clusters); | 4423 | rec.e_leaf_clusters = cpu_to_le16(new_clusters); |
4132 | rec.e_flags = flags; | 4424 | rec.e_flags = flags; |
4425 | status = ocfs2_et_insert_check(inode, et, &rec); | ||
4426 | if (status) { | ||
4427 | mlog_errno(status); | ||
4428 | goto bail; | ||
4429 | } | ||
4133 | 4430 | ||
4134 | status = ocfs2_figure_insert_type(inode, fe_bh, &last_eb_bh, &rec, | 4431 | status = ocfs2_figure_insert_type(inode, et, &last_eb_bh, &rec, |
4135 | &free_records, &insert); | 4432 | &free_records, &insert); |
4136 | if (status < 0) { | 4433 | if (status < 0) { |
4137 | mlog_errno(status); | 4434 | mlog_errno(status); |
@@ -4145,7 +4442,7 @@ int ocfs2_insert_extent(struct ocfs2_super *osb, | |||
4145 | free_records, insert.ins_tree_depth); | 4442 | free_records, insert.ins_tree_depth); |
4146 | 4443 | ||
4147 | if (insert.ins_contig == CONTIG_NONE && free_records == 0) { | 4444 | if (insert.ins_contig == CONTIG_NONE && free_records == 0) { |
4148 | status = ocfs2_grow_tree(inode, handle, fe_bh, | 4445 | status = ocfs2_grow_tree(inode, handle, et, |
4149 | &insert.ins_tree_depth, &last_eb_bh, | 4446 | &insert.ins_tree_depth, &last_eb_bh, |
4150 | meta_ac); | 4447 | meta_ac); |
4151 | if (status) { | 4448 | if (status) { |
@@ -4155,17 +4452,124 @@ int ocfs2_insert_extent(struct ocfs2_super *osb, | |||
4155 | } | 4452 | } |
4156 | 4453 | ||
4157 | /* Finally, we can add clusters. This might rotate the tree for us. */ | 4454 | /* Finally, we can add clusters. This might rotate the tree for us. */ |
4158 | status = ocfs2_do_insert_extent(inode, handle, fe_bh, &rec, &insert); | 4455 | status = ocfs2_do_insert_extent(inode, handle, et, &rec, &insert); |
4159 | if (status < 0) | 4456 | if (status < 0) |
4160 | mlog_errno(status); | 4457 | mlog_errno(status); |
4161 | else | 4458 | else if (et->et_ops == &ocfs2_dinode_et_ops) |
4162 | ocfs2_extent_map_insert_rec(inode, &rec); | 4459 | ocfs2_extent_map_insert_rec(inode, &rec); |
4163 | 4460 | ||
4164 | bail: | 4461 | bail: |
4165 | if (last_eb_bh) | 4462 | brelse(last_eb_bh); |
4166 | brelse(last_eb_bh); | 4463 | |
4464 | mlog_exit(status); | ||
4465 | return status; | ||
4466 | } | ||
4467 | |||
4468 | /* | ||
4469 | * Allcate and add clusters into the extent b-tree. | ||
4470 | * The new clusters(clusters_to_add) will be inserted at logical_offset. | ||
4471 | * The extent b-tree's root is specified by et, and | ||
4472 | * it is not limited to the file storage. Any extent tree can use this | ||
4473 | * function if it implements the proper ocfs2_extent_tree. | ||
4474 | */ | ||
4475 | int ocfs2_add_clusters_in_btree(struct ocfs2_super *osb, | ||
4476 | struct inode *inode, | ||
4477 | u32 *logical_offset, | ||
4478 | u32 clusters_to_add, | ||
4479 | int mark_unwritten, | ||
4480 | struct ocfs2_extent_tree *et, | ||
4481 | handle_t *handle, | ||
4482 | struct ocfs2_alloc_context *data_ac, | ||
4483 | struct ocfs2_alloc_context *meta_ac, | ||
4484 | enum ocfs2_alloc_restarted *reason_ret) | ||
4485 | { | ||
4486 | int status = 0; | ||
4487 | int free_extents; | ||
4488 | enum ocfs2_alloc_restarted reason = RESTART_NONE; | ||
4489 | u32 bit_off, num_bits; | ||
4490 | u64 block; | ||
4491 | u8 flags = 0; | ||
4492 | |||
4493 | BUG_ON(!clusters_to_add); | ||
4494 | |||
4495 | if (mark_unwritten) | ||
4496 | flags = OCFS2_EXT_UNWRITTEN; | ||
4497 | |||
4498 | free_extents = ocfs2_num_free_extents(osb, inode, et); | ||
4499 | if (free_extents < 0) { | ||
4500 | status = free_extents; | ||
4501 | mlog_errno(status); | ||
4502 | goto leave; | ||
4503 | } | ||
4504 | |||
4505 | /* there are two cases which could cause us to EAGAIN in the | ||
4506 | * we-need-more-metadata case: | ||
4507 | * 1) we haven't reserved *any* | ||
4508 | * 2) we are so fragmented, we've needed to add metadata too | ||
4509 | * many times. */ | ||
4510 | if (!free_extents && !meta_ac) { | ||
4511 | mlog(0, "we haven't reserved any metadata!\n"); | ||
4512 | status = -EAGAIN; | ||
4513 | reason = RESTART_META; | ||
4514 | goto leave; | ||
4515 | } else if ((!free_extents) | ||
4516 | && (ocfs2_alloc_context_bits_left(meta_ac) | ||
4517 | < ocfs2_extend_meta_needed(et->et_root_el))) { | ||
4518 | mlog(0, "filesystem is really fragmented...\n"); | ||
4519 | status = -EAGAIN; | ||
4520 | reason = RESTART_META; | ||
4521 | goto leave; | ||
4522 | } | ||
4523 | |||
4524 | status = __ocfs2_claim_clusters(osb, handle, data_ac, 1, | ||
4525 | clusters_to_add, &bit_off, &num_bits); | ||
4526 | if (status < 0) { | ||
4527 | if (status != -ENOSPC) | ||
4528 | mlog_errno(status); | ||
4529 | goto leave; | ||
4530 | } | ||
4531 | |||
4532 | BUG_ON(num_bits > clusters_to_add); | ||
4167 | 4533 | ||
4534 | /* reserve our write early -- insert_extent may update the inode */ | ||
4535 | status = ocfs2_journal_access(handle, inode, et->et_root_bh, | ||
4536 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
4537 | if (status < 0) { | ||
4538 | mlog_errno(status); | ||
4539 | goto leave; | ||
4540 | } | ||
4541 | |||
4542 | block = ocfs2_clusters_to_blocks(osb->sb, bit_off); | ||
4543 | mlog(0, "Allocating %u clusters at block %u for inode %llu\n", | ||
4544 | num_bits, bit_off, (unsigned long long)OCFS2_I(inode)->ip_blkno); | ||
4545 | status = ocfs2_insert_extent(osb, handle, inode, et, | ||
4546 | *logical_offset, block, | ||
4547 | num_bits, flags, meta_ac); | ||
4548 | if (status < 0) { | ||
4549 | mlog_errno(status); | ||
4550 | goto leave; | ||
4551 | } | ||
4552 | |||
4553 | status = ocfs2_journal_dirty(handle, et->et_root_bh); | ||
4554 | if (status < 0) { | ||
4555 | mlog_errno(status); | ||
4556 | goto leave; | ||
4557 | } | ||
4558 | |||
4559 | clusters_to_add -= num_bits; | ||
4560 | *logical_offset += num_bits; | ||
4561 | |||
4562 | if (clusters_to_add) { | ||
4563 | mlog(0, "need to alloc once more, wanted = %u\n", | ||
4564 | clusters_to_add); | ||
4565 | status = -EAGAIN; | ||
4566 | reason = RESTART_TRANS; | ||
4567 | } | ||
4568 | |||
4569 | leave: | ||
4168 | mlog_exit(status); | 4570 | mlog_exit(status); |
4571 | if (reason_ret) | ||
4572 | *reason_ret = reason; | ||
4169 | return status; | 4573 | return status; |
4170 | } | 4574 | } |
4171 | 4575 | ||
@@ -4192,7 +4596,7 @@ static void ocfs2_make_right_split_rec(struct super_block *sb, | |||
4192 | static int ocfs2_split_and_insert(struct inode *inode, | 4596 | static int ocfs2_split_and_insert(struct inode *inode, |
4193 | handle_t *handle, | 4597 | handle_t *handle, |
4194 | struct ocfs2_path *path, | 4598 | struct ocfs2_path *path, |
4195 | struct buffer_head *di_bh, | 4599 | struct ocfs2_extent_tree *et, |
4196 | struct buffer_head **last_eb_bh, | 4600 | struct buffer_head **last_eb_bh, |
4197 | int split_index, | 4601 | int split_index, |
4198 | struct ocfs2_extent_rec *orig_split_rec, | 4602 | struct ocfs2_extent_rec *orig_split_rec, |
@@ -4206,7 +4610,6 @@ static int ocfs2_split_and_insert(struct inode *inode, | |||
4206 | struct ocfs2_extent_rec split_rec = *orig_split_rec; | 4610 | struct ocfs2_extent_rec split_rec = *orig_split_rec; |
4207 | struct ocfs2_insert_type insert; | 4611 | struct ocfs2_insert_type insert; |
4208 | struct ocfs2_extent_block *eb; | 4612 | struct ocfs2_extent_block *eb; |
4209 | struct ocfs2_dinode *di; | ||
4210 | 4613 | ||
4211 | leftright: | 4614 | leftright: |
4212 | /* | 4615 | /* |
@@ -4215,8 +4618,7 @@ leftright: | |||
4215 | */ | 4618 | */ |
4216 | rec = path_leaf_el(path)->l_recs[split_index]; | 4619 | rec = path_leaf_el(path)->l_recs[split_index]; |
4217 | 4620 | ||
4218 | di = (struct ocfs2_dinode *)di_bh->b_data; | 4621 | rightmost_el = et->et_root_el; |
4219 | rightmost_el = &di->id2.i_list; | ||
4220 | 4622 | ||
4221 | depth = le16_to_cpu(rightmost_el->l_tree_depth); | 4623 | depth = le16_to_cpu(rightmost_el->l_tree_depth); |
4222 | if (depth) { | 4624 | if (depth) { |
@@ -4227,8 +4629,8 @@ leftright: | |||
4227 | 4629 | ||
4228 | if (le16_to_cpu(rightmost_el->l_next_free_rec) == | 4630 | if (le16_to_cpu(rightmost_el->l_next_free_rec) == |
4229 | le16_to_cpu(rightmost_el->l_count)) { | 4631 | le16_to_cpu(rightmost_el->l_count)) { |
4230 | ret = ocfs2_grow_tree(inode, handle, di_bh, &depth, last_eb_bh, | 4632 | ret = ocfs2_grow_tree(inode, handle, et, |
4231 | meta_ac); | 4633 | &depth, last_eb_bh, meta_ac); |
4232 | if (ret) { | 4634 | if (ret) { |
4233 | mlog_errno(ret); | 4635 | mlog_errno(ret); |
4234 | goto out; | 4636 | goto out; |
@@ -4265,8 +4667,7 @@ leftright: | |||
4265 | do_leftright = 1; | 4667 | do_leftright = 1; |
4266 | } | 4668 | } |
4267 | 4669 | ||
4268 | ret = ocfs2_do_insert_extent(inode, handle, di_bh, &split_rec, | 4670 | ret = ocfs2_do_insert_extent(inode, handle, et, &split_rec, &insert); |
4269 | &insert); | ||
4270 | if (ret) { | 4671 | if (ret) { |
4271 | mlog_errno(ret); | 4672 | mlog_errno(ret); |
4272 | goto out; | 4673 | goto out; |
@@ -4308,8 +4709,9 @@ out: | |||
4308 | * of the tree is required. All other cases will degrade into a less | 4709 | * of the tree is required. All other cases will degrade into a less |
4309 | * optimal tree layout. | 4710 | * optimal tree layout. |
4310 | * | 4711 | * |
4311 | * last_eb_bh should be the rightmost leaf block for any inode with a | 4712 | * last_eb_bh should be the rightmost leaf block for any extent |
4312 | * btree. Since a split may grow the tree or a merge might shrink it, the caller cannot trust the contents of that buffer after this call. | 4713 | * btree. Since a split may grow the tree or a merge might shrink it, |
4714 | * the caller cannot trust the contents of that buffer after this call. | ||
4313 | * | 4715 | * |
4314 | * This code is optimized for readability - several passes might be | 4716 | * This code is optimized for readability - several passes might be |
4315 | * made over certain portions of the tree. All of those blocks will | 4717 | * made over certain portions of the tree. All of those blocks will |
@@ -4317,7 +4719,7 @@ out: | |||
4317 | * extra overhead is not expressed in terms of disk reads. | 4719 | * extra overhead is not expressed in terms of disk reads. |
4318 | */ | 4720 | */ |
4319 | static int __ocfs2_mark_extent_written(struct inode *inode, | 4721 | static int __ocfs2_mark_extent_written(struct inode *inode, |
4320 | struct buffer_head *di_bh, | 4722 | struct ocfs2_extent_tree *et, |
4321 | handle_t *handle, | 4723 | handle_t *handle, |
4322 | struct ocfs2_path *path, | 4724 | struct ocfs2_path *path, |
4323 | int split_index, | 4725 | int split_index, |
@@ -4357,11 +4759,9 @@ static int __ocfs2_mark_extent_written(struct inode *inode, | |||
4357 | */ | 4759 | */ |
4358 | if (path->p_tree_depth) { | 4760 | if (path->p_tree_depth) { |
4359 | struct ocfs2_extent_block *eb; | 4761 | struct ocfs2_extent_block *eb; |
4360 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; | ||
4361 | 4762 | ||
4362 | ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), | 4763 | ret = ocfs2_read_block(inode, ocfs2_et_get_last_eb_blk(et), |
4363 | le64_to_cpu(di->i_last_eb_blk), | 4764 | &last_eb_bh); |
4364 | &last_eb_bh, OCFS2_BH_CACHED, inode); | ||
4365 | if (ret) { | 4765 | if (ret) { |
4366 | mlog_exit(ret); | 4766 | mlog_exit(ret); |
4367 | goto out; | 4767 | goto out; |
@@ -4394,7 +4794,7 @@ static int __ocfs2_mark_extent_written(struct inode *inode, | |||
4394 | if (ctxt.c_split_covers_rec) | 4794 | if (ctxt.c_split_covers_rec) |
4395 | el->l_recs[split_index] = *split_rec; | 4795 | el->l_recs[split_index] = *split_rec; |
4396 | else | 4796 | else |
4397 | ret = ocfs2_split_and_insert(inode, handle, path, di_bh, | 4797 | ret = ocfs2_split_and_insert(inode, handle, path, et, |
4398 | &last_eb_bh, split_index, | 4798 | &last_eb_bh, split_index, |
4399 | split_rec, meta_ac); | 4799 | split_rec, meta_ac); |
4400 | if (ret) | 4800 | if (ret) |
@@ -4402,7 +4802,7 @@ static int __ocfs2_mark_extent_written(struct inode *inode, | |||
4402 | } else { | 4802 | } else { |
4403 | ret = ocfs2_try_to_merge_extent(inode, handle, path, | 4803 | ret = ocfs2_try_to_merge_extent(inode, handle, path, |
4404 | split_index, split_rec, | 4804 | split_index, split_rec, |
4405 | dealloc, &ctxt); | 4805 | dealloc, &ctxt, et); |
4406 | if (ret) | 4806 | if (ret) |
4407 | mlog_errno(ret); | 4807 | mlog_errno(ret); |
4408 | } | 4808 | } |
@@ -4420,7 +4820,8 @@ out: | |||
4420 | * | 4820 | * |
4421 | * The caller is responsible for passing down meta_ac if we'll need it. | 4821 | * The caller is responsible for passing down meta_ac if we'll need it. |
4422 | */ | 4822 | */ |
4423 | int ocfs2_mark_extent_written(struct inode *inode, struct buffer_head *di_bh, | 4823 | int ocfs2_mark_extent_written(struct inode *inode, |
4824 | struct ocfs2_extent_tree *et, | ||
4424 | handle_t *handle, u32 cpos, u32 len, u32 phys, | 4825 | handle_t *handle, u32 cpos, u32 len, u32 phys, |
4425 | struct ocfs2_alloc_context *meta_ac, | 4826 | struct ocfs2_alloc_context *meta_ac, |
4426 | struct ocfs2_cached_dealloc_ctxt *dealloc) | 4827 | struct ocfs2_cached_dealloc_ctxt *dealloc) |
@@ -4446,10 +4847,14 @@ int ocfs2_mark_extent_written(struct inode *inode, struct buffer_head *di_bh, | |||
4446 | /* | 4847 | /* |
4447 | * XXX: This should be fixed up so that we just re-insert the | 4848 | * XXX: This should be fixed up so that we just re-insert the |
4448 | * next extent records. | 4849 | * next extent records. |
4850 | * | ||
4851 | * XXX: This is a hack on the extent tree, maybe it should be | ||
4852 | * an op? | ||
4449 | */ | 4853 | */ |
4450 | ocfs2_extent_map_trunc(inode, 0); | 4854 | if (et->et_ops == &ocfs2_dinode_et_ops) |
4855 | ocfs2_extent_map_trunc(inode, 0); | ||
4451 | 4856 | ||
4452 | left_path = ocfs2_new_inode_path(di_bh); | 4857 | left_path = ocfs2_new_path(et->et_root_bh, et->et_root_el); |
4453 | if (!left_path) { | 4858 | if (!left_path) { |
4454 | ret = -ENOMEM; | 4859 | ret = -ENOMEM; |
4455 | mlog_errno(ret); | 4860 | mlog_errno(ret); |
@@ -4480,8 +4885,9 @@ int ocfs2_mark_extent_written(struct inode *inode, struct buffer_head *di_bh, | |||
4480 | split_rec.e_flags = path_leaf_el(left_path)->l_recs[index].e_flags; | 4885 | split_rec.e_flags = path_leaf_el(left_path)->l_recs[index].e_flags; |
4481 | split_rec.e_flags &= ~OCFS2_EXT_UNWRITTEN; | 4886 | split_rec.e_flags &= ~OCFS2_EXT_UNWRITTEN; |
4482 | 4887 | ||
4483 | ret = __ocfs2_mark_extent_written(inode, di_bh, handle, left_path, | 4888 | ret = __ocfs2_mark_extent_written(inode, et, handle, left_path, |
4484 | index, &split_rec, meta_ac, dealloc); | 4889 | index, &split_rec, meta_ac, |
4890 | dealloc); | ||
4485 | if (ret) | 4891 | if (ret) |
4486 | mlog_errno(ret); | 4892 | mlog_errno(ret); |
4487 | 4893 | ||
@@ -4490,13 +4896,12 @@ out: | |||
4490 | return ret; | 4896 | return ret; |
4491 | } | 4897 | } |
4492 | 4898 | ||
4493 | static int ocfs2_split_tree(struct inode *inode, struct buffer_head *di_bh, | 4899 | static int ocfs2_split_tree(struct inode *inode, struct ocfs2_extent_tree *et, |
4494 | handle_t *handle, struct ocfs2_path *path, | 4900 | handle_t *handle, struct ocfs2_path *path, |
4495 | int index, u32 new_range, | 4901 | int index, u32 new_range, |
4496 | struct ocfs2_alloc_context *meta_ac) | 4902 | struct ocfs2_alloc_context *meta_ac) |
4497 | { | 4903 | { |
4498 | int ret, depth, credits = handle->h_buffer_credits; | 4904 | int ret, depth, credits = handle->h_buffer_credits; |
4499 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; | ||
4500 | struct buffer_head *last_eb_bh = NULL; | 4905 | struct buffer_head *last_eb_bh = NULL; |
4501 | struct ocfs2_extent_block *eb; | 4906 | struct ocfs2_extent_block *eb; |
4502 | struct ocfs2_extent_list *rightmost_el, *el; | 4907 | struct ocfs2_extent_list *rightmost_el, *el; |
@@ -4513,9 +4918,8 @@ static int ocfs2_split_tree(struct inode *inode, struct buffer_head *di_bh, | |||
4513 | 4918 | ||
4514 | depth = path->p_tree_depth; | 4919 | depth = path->p_tree_depth; |
4515 | if (depth > 0) { | 4920 | if (depth > 0) { |
4516 | ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), | 4921 | ret = ocfs2_read_block(inode, ocfs2_et_get_last_eb_blk(et), |
4517 | le64_to_cpu(di->i_last_eb_blk), | 4922 | &last_eb_bh); |
4518 | &last_eb_bh, OCFS2_BH_CACHED, inode); | ||
4519 | if (ret < 0) { | 4923 | if (ret < 0) { |
4520 | mlog_errno(ret); | 4924 | mlog_errno(ret); |
4521 | goto out; | 4925 | goto out; |
@@ -4526,7 +4930,8 @@ static int ocfs2_split_tree(struct inode *inode, struct buffer_head *di_bh, | |||
4526 | } else | 4930 | } else |
4527 | rightmost_el = path_leaf_el(path); | 4931 | rightmost_el = path_leaf_el(path); |
4528 | 4932 | ||
4529 | credits += path->p_tree_depth + ocfs2_extend_meta_needed(di); | 4933 | credits += path->p_tree_depth + |
4934 | ocfs2_extend_meta_needed(et->et_root_el); | ||
4530 | ret = ocfs2_extend_trans(handle, credits); | 4935 | ret = ocfs2_extend_trans(handle, credits); |
4531 | if (ret) { | 4936 | if (ret) { |
4532 | mlog_errno(ret); | 4937 | mlog_errno(ret); |
@@ -4535,7 +4940,7 @@ static int ocfs2_split_tree(struct inode *inode, struct buffer_head *di_bh, | |||
4535 | 4940 | ||
4536 | if (le16_to_cpu(rightmost_el->l_next_free_rec) == | 4941 | if (le16_to_cpu(rightmost_el->l_next_free_rec) == |
4537 | le16_to_cpu(rightmost_el->l_count)) { | 4942 | le16_to_cpu(rightmost_el->l_count)) { |
4538 | ret = ocfs2_grow_tree(inode, handle, di_bh, &depth, &last_eb_bh, | 4943 | ret = ocfs2_grow_tree(inode, handle, et, &depth, &last_eb_bh, |
4539 | meta_ac); | 4944 | meta_ac); |
4540 | if (ret) { | 4945 | if (ret) { |
4541 | mlog_errno(ret); | 4946 | mlog_errno(ret); |
@@ -4549,7 +4954,7 @@ static int ocfs2_split_tree(struct inode *inode, struct buffer_head *di_bh, | |||
4549 | insert.ins_split = SPLIT_RIGHT; | 4954 | insert.ins_split = SPLIT_RIGHT; |
4550 | insert.ins_tree_depth = depth; | 4955 | insert.ins_tree_depth = depth; |
4551 | 4956 | ||
4552 | ret = ocfs2_do_insert_extent(inode, handle, di_bh, &split_rec, &insert); | 4957 | ret = ocfs2_do_insert_extent(inode, handle, et, &split_rec, &insert); |
4553 | if (ret) | 4958 | if (ret) |
4554 | mlog_errno(ret); | 4959 | mlog_errno(ret); |
4555 | 4960 | ||
@@ -4561,7 +4966,8 @@ out: | |||
4561 | static int ocfs2_truncate_rec(struct inode *inode, handle_t *handle, | 4966 | static int ocfs2_truncate_rec(struct inode *inode, handle_t *handle, |
4562 | struct ocfs2_path *path, int index, | 4967 | struct ocfs2_path *path, int index, |
4563 | struct ocfs2_cached_dealloc_ctxt *dealloc, | 4968 | struct ocfs2_cached_dealloc_ctxt *dealloc, |
4564 | u32 cpos, u32 len) | 4969 | u32 cpos, u32 len, |
4970 | struct ocfs2_extent_tree *et) | ||
4565 | { | 4971 | { |
4566 | int ret; | 4972 | int ret; |
4567 | u32 left_cpos, rec_range, trunc_range; | 4973 | u32 left_cpos, rec_range, trunc_range; |
@@ -4573,7 +4979,7 @@ static int ocfs2_truncate_rec(struct inode *inode, handle_t *handle, | |||
4573 | struct ocfs2_extent_block *eb; | 4979 | struct ocfs2_extent_block *eb; |
4574 | 4980 | ||
4575 | if (ocfs2_is_empty_extent(&el->l_recs[0]) && index > 0) { | 4981 | if (ocfs2_is_empty_extent(&el->l_recs[0]) && index > 0) { |
4576 | ret = ocfs2_rotate_tree_left(inode, handle, path, dealloc); | 4982 | ret = ocfs2_rotate_tree_left(inode, handle, path, dealloc, et); |
4577 | if (ret) { | 4983 | if (ret) { |
4578 | mlog_errno(ret); | 4984 | mlog_errno(ret); |
4579 | goto out; | 4985 | goto out; |
@@ -4704,7 +5110,7 @@ static int ocfs2_truncate_rec(struct inode *inode, handle_t *handle, | |||
4704 | 5110 | ||
4705 | ocfs2_journal_dirty(handle, path_leaf_bh(path)); | 5111 | ocfs2_journal_dirty(handle, path_leaf_bh(path)); |
4706 | 5112 | ||
4707 | ret = ocfs2_rotate_tree_left(inode, handle, path, dealloc); | 5113 | ret = ocfs2_rotate_tree_left(inode, handle, path, dealloc, et); |
4708 | if (ret) { | 5114 | if (ret) { |
4709 | mlog_errno(ret); | 5115 | mlog_errno(ret); |
4710 | goto out; | 5116 | goto out; |
@@ -4715,7 +5121,8 @@ out: | |||
4715 | return ret; | 5121 | return ret; |
4716 | } | 5122 | } |
4717 | 5123 | ||
4718 | int ocfs2_remove_extent(struct inode *inode, struct buffer_head *di_bh, | 5124 | int ocfs2_remove_extent(struct inode *inode, |
5125 | struct ocfs2_extent_tree *et, | ||
4719 | u32 cpos, u32 len, handle_t *handle, | 5126 | u32 cpos, u32 len, handle_t *handle, |
4720 | struct ocfs2_alloc_context *meta_ac, | 5127 | struct ocfs2_alloc_context *meta_ac, |
4721 | struct ocfs2_cached_dealloc_ctxt *dealloc) | 5128 | struct ocfs2_cached_dealloc_ctxt *dealloc) |
@@ -4724,11 +5131,11 @@ int ocfs2_remove_extent(struct inode *inode, struct buffer_head *di_bh, | |||
4724 | u32 rec_range, trunc_range; | 5131 | u32 rec_range, trunc_range; |
4725 | struct ocfs2_extent_rec *rec; | 5132 | struct ocfs2_extent_rec *rec; |
4726 | struct ocfs2_extent_list *el; | 5133 | struct ocfs2_extent_list *el; |
4727 | struct ocfs2_path *path; | 5134 | struct ocfs2_path *path = NULL; |
4728 | 5135 | ||
4729 | ocfs2_extent_map_trunc(inode, 0); | 5136 | ocfs2_extent_map_trunc(inode, 0); |
4730 | 5137 | ||
4731 | path = ocfs2_new_inode_path(di_bh); | 5138 | path = ocfs2_new_path(et->et_root_bh, et->et_root_el); |
4732 | if (!path) { | 5139 | if (!path) { |
4733 | ret = -ENOMEM; | 5140 | ret = -ENOMEM; |
4734 | mlog_errno(ret); | 5141 | mlog_errno(ret); |
@@ -4781,13 +5188,13 @@ int ocfs2_remove_extent(struct inode *inode, struct buffer_head *di_bh, | |||
4781 | 5188 | ||
4782 | if (le32_to_cpu(rec->e_cpos) == cpos || rec_range == trunc_range) { | 5189 | if (le32_to_cpu(rec->e_cpos) == cpos || rec_range == trunc_range) { |
4783 | ret = ocfs2_truncate_rec(inode, handle, path, index, dealloc, | 5190 | ret = ocfs2_truncate_rec(inode, handle, path, index, dealloc, |
4784 | cpos, len); | 5191 | cpos, len, et); |
4785 | if (ret) { | 5192 | if (ret) { |
4786 | mlog_errno(ret); | 5193 | mlog_errno(ret); |
4787 | goto out; | 5194 | goto out; |
4788 | } | 5195 | } |
4789 | } else { | 5196 | } else { |
4790 | ret = ocfs2_split_tree(inode, di_bh, handle, path, index, | 5197 | ret = ocfs2_split_tree(inode, et, handle, path, index, |
4791 | trunc_range, meta_ac); | 5198 | trunc_range, meta_ac); |
4792 | if (ret) { | 5199 | if (ret) { |
4793 | mlog_errno(ret); | 5200 | mlog_errno(ret); |
@@ -4836,7 +5243,7 @@ int ocfs2_remove_extent(struct inode *inode, struct buffer_head *di_bh, | |||
4836 | } | 5243 | } |
4837 | 5244 | ||
4838 | ret = ocfs2_truncate_rec(inode, handle, path, index, dealloc, | 5245 | ret = ocfs2_truncate_rec(inode, handle, path, index, dealloc, |
4839 | cpos, len); | 5246 | cpos, len, et); |
4840 | if (ret) { | 5247 | if (ret) { |
4841 | mlog_errno(ret); | 5248 | mlog_errno(ret); |
4842 | goto out; | 5249 | goto out; |
@@ -5179,8 +5586,7 @@ static int ocfs2_get_truncate_log_info(struct ocfs2_super *osb, | |||
5179 | goto bail; | 5586 | goto bail; |
5180 | } | 5587 | } |
5181 | 5588 | ||
5182 | status = ocfs2_read_block(osb, OCFS2_I(inode)->ip_blkno, &bh, | 5589 | status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh); |
5183 | OCFS2_BH_CACHED, inode); | ||
5184 | if (status < 0) { | 5590 | if (status < 0) { |
5185 | iput(inode); | 5591 | iput(inode); |
5186 | mlog_errno(status); | 5592 | mlog_errno(status); |
@@ -5255,8 +5661,7 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb, | |||
5255 | bail: | 5661 | bail: |
5256 | if (tl_inode) | 5662 | if (tl_inode) |
5257 | iput(tl_inode); | 5663 | iput(tl_inode); |
5258 | if (tl_bh) | 5664 | brelse(tl_bh); |
5259 | brelse(tl_bh); | ||
5260 | 5665 | ||
5261 | if (status < 0 && (*tl_copy)) { | 5666 | if (status < 0 && (*tl_copy)) { |
5262 | kfree(*tl_copy); | 5667 | kfree(*tl_copy); |
@@ -5999,20 +6404,13 @@ bail: | |||
5999 | return status; | 6404 | return status; |
6000 | } | 6405 | } |
6001 | 6406 | ||
6002 | static int ocfs2_writeback_zero_func(handle_t *handle, struct buffer_head *bh) | 6407 | static int ocfs2_zero_func(handle_t *handle, struct buffer_head *bh) |
6003 | { | 6408 | { |
6004 | set_buffer_uptodate(bh); | 6409 | set_buffer_uptodate(bh); |
6005 | mark_buffer_dirty(bh); | 6410 | mark_buffer_dirty(bh); |
6006 | return 0; | 6411 | return 0; |
6007 | } | 6412 | } |
6008 | 6413 | ||
6009 | static int ocfs2_ordered_zero_func(handle_t *handle, struct buffer_head *bh) | ||
6010 | { | ||
6011 | set_buffer_uptodate(bh); | ||
6012 | mark_buffer_dirty(bh); | ||
6013 | return ocfs2_journal_dirty_data(handle, bh); | ||
6014 | } | ||
6015 | |||
6016 | static void ocfs2_map_and_dirty_page(struct inode *inode, handle_t *handle, | 6414 | static void ocfs2_map_and_dirty_page(struct inode *inode, handle_t *handle, |
6017 | unsigned int from, unsigned int to, | 6415 | unsigned int from, unsigned int to, |
6018 | struct page *page, int zero, u64 *phys) | 6416 | struct page *page, int zero, u64 *phys) |
@@ -6031,17 +6429,18 @@ static void ocfs2_map_and_dirty_page(struct inode *inode, handle_t *handle, | |||
6031 | * here if they aren't - ocfs2_map_page_blocks() | 6429 | * here if they aren't - ocfs2_map_page_blocks() |
6032 | * might've skipped some | 6430 | * might've skipped some |
6033 | */ | 6431 | */ |
6034 | if (ocfs2_should_order_data(inode)) { | 6432 | ret = walk_page_buffers(handle, page_buffers(page), |
6035 | ret = walk_page_buffers(handle, | 6433 | from, to, &partial, |
6036 | page_buffers(page), | 6434 | ocfs2_zero_func); |
6037 | from, to, &partial, | 6435 | if (ret < 0) |
6038 | ocfs2_ordered_zero_func); | 6436 | mlog_errno(ret); |
6039 | if (ret < 0) | 6437 | else if (ocfs2_should_order_data(inode)) { |
6040 | mlog_errno(ret); | 6438 | ret = ocfs2_jbd2_file_inode(handle, inode); |
6041 | } else { | 6439 | #ifdef CONFIG_OCFS2_COMPAT_JBD |
6042 | ret = walk_page_buffers(handle, page_buffers(page), | 6440 | ret = walk_page_buffers(handle, page_buffers(page), |
6043 | from, to, &partial, | 6441 | from, to, &partial, |
6044 | ocfs2_writeback_zero_func); | 6442 | ocfs2_journal_dirty_data); |
6443 | #endif | ||
6045 | if (ret < 0) | 6444 | if (ret < 0) |
6046 | mlog_errno(ret); | 6445 | mlog_errno(ret); |
6047 | } | 6446 | } |
@@ -6206,20 +6605,29 @@ out: | |||
6206 | return ret; | 6605 | return ret; |
6207 | } | 6606 | } |
6208 | 6607 | ||
6209 | static void ocfs2_zero_dinode_id2(struct inode *inode, struct ocfs2_dinode *di) | 6608 | static void ocfs2_zero_dinode_id2_with_xattr(struct inode *inode, |
6609 | struct ocfs2_dinode *di) | ||
6210 | { | 6610 | { |
6211 | unsigned int blocksize = 1 << inode->i_sb->s_blocksize_bits; | 6611 | unsigned int blocksize = 1 << inode->i_sb->s_blocksize_bits; |
6612 | unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size); | ||
6212 | 6613 | ||
6213 | memset(&di->id2, 0, blocksize - offsetof(struct ocfs2_dinode, id2)); | 6614 | if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL) |
6615 | memset(&di->id2, 0, blocksize - | ||
6616 | offsetof(struct ocfs2_dinode, id2) - | ||
6617 | xattrsize); | ||
6618 | else | ||
6619 | memset(&di->id2, 0, blocksize - | ||
6620 | offsetof(struct ocfs2_dinode, id2)); | ||
6214 | } | 6621 | } |
6215 | 6622 | ||
6216 | void ocfs2_dinode_new_extent_list(struct inode *inode, | 6623 | void ocfs2_dinode_new_extent_list(struct inode *inode, |
6217 | struct ocfs2_dinode *di) | 6624 | struct ocfs2_dinode *di) |
6218 | { | 6625 | { |
6219 | ocfs2_zero_dinode_id2(inode, di); | 6626 | ocfs2_zero_dinode_id2_with_xattr(inode, di); |
6220 | di->id2.i_list.l_tree_depth = 0; | 6627 | di->id2.i_list.l_tree_depth = 0; |
6221 | di->id2.i_list.l_next_free_rec = 0; | 6628 | di->id2.i_list.l_next_free_rec = 0; |
6222 | di->id2.i_list.l_count = cpu_to_le16(ocfs2_extent_recs_per_inode(inode->i_sb)); | 6629 | di->id2.i_list.l_count = cpu_to_le16( |
6630 | ocfs2_extent_recs_per_inode_with_xattr(inode->i_sb, di)); | ||
6223 | } | 6631 | } |
6224 | 6632 | ||
6225 | void ocfs2_set_inode_data_inline(struct inode *inode, struct ocfs2_dinode *di) | 6633 | void ocfs2_set_inode_data_inline(struct inode *inode, struct ocfs2_dinode *di) |
@@ -6236,9 +6644,10 @@ void ocfs2_set_inode_data_inline(struct inode *inode, struct ocfs2_dinode *di) | |||
6236 | * We clear the entire i_data structure here so that all | 6644 | * We clear the entire i_data structure here so that all |
6237 | * fields can be properly initialized. | 6645 | * fields can be properly initialized. |
6238 | */ | 6646 | */ |
6239 | ocfs2_zero_dinode_id2(inode, di); | 6647 | ocfs2_zero_dinode_id2_with_xattr(inode, di); |
6240 | 6648 | ||
6241 | idata->id_count = cpu_to_le16(ocfs2_max_inline_data(inode->i_sb)); | 6649 | idata->id_count = cpu_to_le16( |
6650 | ocfs2_max_inline_data_with_xattr(inode->i_sb, di)); | ||
6242 | } | 6651 | } |
6243 | 6652 | ||
6244 | int ocfs2_convert_inline_data_to_extents(struct inode *inode, | 6653 | int ocfs2_convert_inline_data_to_extents(struct inode *inode, |
@@ -6253,6 +6662,7 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, | |||
6253 | struct ocfs2_alloc_context *data_ac = NULL; | 6662 | struct ocfs2_alloc_context *data_ac = NULL; |
6254 | struct page **pages = NULL; | 6663 | struct page **pages = NULL; |
6255 | loff_t end = osb->s_clustersize; | 6664 | loff_t end = osb->s_clustersize; |
6665 | struct ocfs2_extent_tree et; | ||
6256 | 6666 | ||
6257 | has_data = i_size_read(inode) ? 1 : 0; | 6667 | has_data = i_size_read(inode) ? 1 : 0; |
6258 | 6668 | ||
@@ -6352,7 +6762,8 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, | |||
6352 | * this proves to be false, we could always re-build | 6762 | * this proves to be false, we could always re-build |
6353 | * the in-inode data from our pages. | 6763 | * the in-inode data from our pages. |
6354 | */ | 6764 | */ |
6355 | ret = ocfs2_insert_extent(osb, handle, inode, di_bh, | 6765 | ocfs2_init_dinode_extent_tree(&et, inode, di_bh); |
6766 | ret = ocfs2_insert_extent(osb, handle, inode, &et, | ||
6356 | 0, block, 1, 0, NULL); | 6767 | 0, block, 1, 0, NULL); |
6357 | if (ret) { | 6768 | if (ret) { |
6358 | mlog_errno(ret); | 6769 | mlog_errno(ret); |
@@ -6395,13 +6806,14 @@ int ocfs2_commit_truncate(struct ocfs2_super *osb, | |||
6395 | handle_t *handle = NULL; | 6806 | handle_t *handle = NULL; |
6396 | struct inode *tl_inode = osb->osb_tl_inode; | 6807 | struct inode *tl_inode = osb->osb_tl_inode; |
6397 | struct ocfs2_path *path = NULL; | 6808 | struct ocfs2_path *path = NULL; |
6809 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)fe_bh->b_data; | ||
6398 | 6810 | ||
6399 | mlog_entry_void(); | 6811 | mlog_entry_void(); |
6400 | 6812 | ||
6401 | new_highest_cpos = ocfs2_clusters_for_bytes(osb->sb, | 6813 | new_highest_cpos = ocfs2_clusters_for_bytes(osb->sb, |
6402 | i_size_read(inode)); | 6814 | i_size_read(inode)); |
6403 | 6815 | ||
6404 | path = ocfs2_new_inode_path(fe_bh); | 6816 | path = ocfs2_new_path(fe_bh, &di->id2.i_list); |
6405 | if (!path) { | 6817 | if (!path) { |
6406 | status = -ENOMEM; | 6818 | status = -ENOMEM; |
6407 | mlog_errno(status); | 6819 | mlog_errno(status); |
@@ -6572,8 +6984,8 @@ int ocfs2_prepare_truncate(struct ocfs2_super *osb, | |||
6572 | ocfs2_init_dealloc_ctxt(&(*tc)->tc_dealloc); | 6984 | ocfs2_init_dealloc_ctxt(&(*tc)->tc_dealloc); |
6573 | 6985 | ||
6574 | if (fe->id2.i_list.l_tree_depth) { | 6986 | if (fe->id2.i_list.l_tree_depth) { |
6575 | status = ocfs2_read_block(osb, le64_to_cpu(fe->i_last_eb_blk), | 6987 | status = ocfs2_read_block(inode, le64_to_cpu(fe->i_last_eb_blk), |
6576 | &last_eb_bh, OCFS2_BH_CACHED, inode); | 6988 | &last_eb_bh); |
6577 | if (status < 0) { | 6989 | if (status < 0) { |
6578 | mlog_errno(status); | 6990 | mlog_errno(status); |
6579 | goto bail; | 6991 | goto bail; |
@@ -6686,8 +7098,7 @@ static void ocfs2_free_truncate_context(struct ocfs2_truncate_context *tc) | |||
6686 | mlog(ML_NOTICE, | 7098 | mlog(ML_NOTICE, |
6687 | "Truncate completion has non-empty dealloc context\n"); | 7099 | "Truncate completion has non-empty dealloc context\n"); |
6688 | 7100 | ||
6689 | if (tc->tc_last_eb_bh) | 7101 | brelse(tc->tc_last_eb_bh); |
6690 | brelse(tc->tc_last_eb_bh); | ||
6691 | 7102 | ||
6692 | kfree(tc); | 7103 | kfree(tc); |
6693 | } | 7104 | } |