diff options
Diffstat (limited to 'fs/ocfs2/xattr.c')
-rw-r--r-- | fs/ocfs2/xattr.c | 71 |
1 files changed, 37 insertions, 34 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index 1b349c7367a9..9c3d4dc3e2ea 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c | |||
@@ -206,22 +206,24 @@ static int ocfs2_xattr_extend_allocation(struct inode *inode, | |||
206 | struct ocfs2_alloc_context *meta_ac = NULL; | 206 | struct ocfs2_alloc_context *meta_ac = NULL; |
207 | enum ocfs2_alloc_restarted why; | 207 | enum ocfs2_alloc_restarted why; |
208 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 208 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
209 | struct ocfs2_extent_list *root_el = &xv->xr_list; | ||
210 | u32 prev_clusters, logical_start = le32_to_cpu(xv->xr_clusters); | 209 | u32 prev_clusters, logical_start = le32_to_cpu(xv->xr_clusters); |
210 | struct ocfs2_extent_tree et; | ||
211 | 211 | ||
212 | mlog(0, "(clusters_to_add for xattr= %u)\n", clusters_to_add); | 212 | mlog(0, "(clusters_to_add for xattr= %u)\n", clusters_to_add); |
213 | 213 | ||
214 | ocfs2_get_xattr_value_extent_tree(&et, inode, xattr_bh, xv); | ||
215 | |||
214 | restart_all: | 216 | restart_all: |
215 | 217 | ||
216 | status = ocfs2_lock_allocators(inode, xattr_bh, root_el, | 218 | status = ocfs2_lock_allocators(inode, &et, clusters_to_add, 0, |
217 | clusters_to_add, 0, &data_ac, | 219 | &data_ac, &meta_ac); |
218 | &meta_ac, OCFS2_XATTR_VALUE_EXTENT, xv); | ||
219 | if (status) { | 220 | if (status) { |
220 | mlog_errno(status); | 221 | mlog_errno(status); |
221 | goto leave; | 222 | goto leave; |
222 | } | 223 | } |
223 | 224 | ||
224 | credits = ocfs2_calc_extend_credits(osb->sb, root_el, clusters_to_add); | 225 | credits = ocfs2_calc_extend_credits(osb->sb, et.et_root_el, |
226 | clusters_to_add); | ||
225 | handle = ocfs2_start_trans(osb, credits); | 227 | handle = ocfs2_start_trans(osb, credits); |
226 | if (IS_ERR(handle)) { | 228 | if (IS_ERR(handle)) { |
227 | status = PTR_ERR(handle); | 229 | status = PTR_ERR(handle); |
@@ -244,14 +246,11 @@ restarted_transaction: | |||
244 | &logical_start, | 246 | &logical_start, |
245 | clusters_to_add, | 247 | clusters_to_add, |
246 | 0, | 248 | 0, |
247 | xattr_bh, | 249 | &et, |
248 | root_el, | ||
249 | handle, | 250 | handle, |
250 | data_ac, | 251 | data_ac, |
251 | meta_ac, | 252 | meta_ac, |
252 | &why, | 253 | &why); |
253 | OCFS2_XATTR_VALUE_EXTENT, | ||
254 | xv); | ||
255 | if ((status < 0) && (status != -EAGAIN)) { | 254 | if ((status < 0) && (status != -EAGAIN)) { |
256 | if (status != -ENOSPC) | 255 | if (status != -ENOSPC) |
257 | mlog_errno(status); | 256 | mlog_errno(status); |
@@ -276,7 +275,7 @@ restarted_transaction: | |||
276 | mlog(0, "restarting transaction.\n"); | 275 | mlog(0, "restarting transaction.\n"); |
277 | /* TODO: This can be more intelligent. */ | 276 | /* TODO: This can be more intelligent. */ |
278 | credits = ocfs2_calc_extend_credits(osb->sb, | 277 | credits = ocfs2_calc_extend_credits(osb->sb, |
279 | root_el, | 278 | et.et_root_el, |
280 | clusters_to_add); | 279 | clusters_to_add); |
281 | status = ocfs2_extend_trans(handle, credits); | 280 | status = ocfs2_extend_trans(handle, credits); |
282 | if (status < 0) { | 281 | if (status < 0) { |
@@ -308,6 +307,7 @@ leave: | |||
308 | goto restart_all; | 307 | goto restart_all; |
309 | } | 308 | } |
310 | 309 | ||
310 | ocfs2_put_extent_tree(&et); | ||
311 | return status; | 311 | return status; |
312 | } | 312 | } |
313 | 313 | ||
@@ -323,11 +323,13 @@ static int __ocfs2_remove_xattr_range(struct inode *inode, | |||
323 | struct inode *tl_inode = osb->osb_tl_inode; | 323 | struct inode *tl_inode = osb->osb_tl_inode; |
324 | handle_t *handle; | 324 | handle_t *handle; |
325 | struct ocfs2_alloc_context *meta_ac = NULL; | 325 | struct ocfs2_alloc_context *meta_ac = NULL; |
326 | struct ocfs2_extent_tree et; | ||
327 | |||
328 | ocfs2_get_xattr_value_extent_tree(&et, inode, root_bh, xv); | ||
326 | 329 | ||
327 | ret = ocfs2_lock_allocators(inode, root_bh, &xv->xr_list, | 330 | ret = ocfs2_lock_allocators(inode, &et, 0, 1, NULL, &meta_ac); |
328 | 0, 1, NULL, &meta_ac, | ||
329 | OCFS2_XATTR_VALUE_EXTENT, xv); | ||
330 | if (ret) { | 331 | if (ret) { |
332 | ocfs2_put_extent_tree(&et); | ||
331 | mlog_errno(ret); | 333 | mlog_errno(ret); |
332 | return ret; | 334 | return ret; |
333 | } | 335 | } |
@@ -356,8 +358,8 @@ static int __ocfs2_remove_xattr_range(struct inode *inode, | |||
356 | goto out_commit; | 358 | goto out_commit; |
357 | } | 359 | } |
358 | 360 | ||
359 | ret = ocfs2_remove_extent(inode, root_bh, cpos, len, handle, meta_ac, | 361 | ret = ocfs2_remove_extent(inode, &et, cpos, len, handle, meta_ac, |
360 | dealloc, OCFS2_XATTR_VALUE_EXTENT, xv); | 362 | dealloc); |
361 | if (ret) { | 363 | if (ret) { |
362 | mlog_errno(ret); | 364 | mlog_errno(ret); |
363 | goto out_commit; | 365 | goto out_commit; |
@@ -383,6 +385,7 @@ out: | |||
383 | if (meta_ac) | 385 | if (meta_ac) |
384 | ocfs2_free_alloc_context(meta_ac); | 386 | ocfs2_free_alloc_context(meta_ac); |
385 | 387 | ||
388 | ocfs2_put_extent_tree(&et); | ||
386 | return ret; | 389 | return ret; |
387 | } | 390 | } |
388 | 391 | ||
@@ -3622,26 +3625,24 @@ static int ocfs2_add_new_xattr_cluster(struct inode *inode, | |||
3622 | struct ocfs2_alloc_context *data_ac = NULL; | 3625 | struct ocfs2_alloc_context *data_ac = NULL; |
3623 | struct ocfs2_alloc_context *meta_ac = NULL; | 3626 | struct ocfs2_alloc_context *meta_ac = NULL; |
3624 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 3627 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
3625 | struct ocfs2_xattr_block *xb = | 3628 | struct ocfs2_extent_tree et; |
3626 | (struct ocfs2_xattr_block *)root_bh->b_data; | ||
3627 | struct ocfs2_xattr_tree_root *xb_root = &xb->xb_attrs.xb_root; | ||
3628 | struct ocfs2_extent_list *root_el = &xb_root->xt_list; | ||
3629 | enum ocfs2_extent_tree_type type = OCFS2_XATTR_TREE_EXTENT; | ||
3630 | 3629 | ||
3631 | mlog(0, "Add new xattr cluster for %llu, previous xattr hash = %u, " | 3630 | mlog(0, "Add new xattr cluster for %llu, previous xattr hash = %u, " |
3632 | "previous xattr blkno = %llu\n", | 3631 | "previous xattr blkno = %llu\n", |
3633 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | 3632 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
3634 | prev_cpos, prev_blkno); | 3633 | prev_cpos, prev_blkno); |
3635 | 3634 | ||
3636 | ret = ocfs2_lock_allocators(inode, root_bh, root_el, | 3635 | ocfs2_get_xattr_tree_extent_tree(&et, inode, root_bh); |
3637 | clusters_to_add, 0, &data_ac, | 3636 | |
3638 | &meta_ac, type, NULL); | 3637 | ret = ocfs2_lock_allocators(inode, &et, clusters_to_add, 0, |
3638 | &data_ac, &meta_ac); | ||
3639 | if (ret) { | 3639 | if (ret) { |
3640 | mlog_errno(ret); | 3640 | mlog_errno(ret); |
3641 | goto leave; | 3641 | goto leave; |
3642 | } | 3642 | } |
3643 | 3643 | ||
3644 | credits = ocfs2_calc_extend_credits(osb->sb, root_el, clusters_to_add); | 3644 | credits = ocfs2_calc_extend_credits(osb->sb, et.et_root_el, |
3645 | clusters_to_add); | ||
3645 | handle = ocfs2_start_trans(osb, credits); | 3646 | handle = ocfs2_start_trans(osb, credits); |
3646 | if (IS_ERR(handle)) { | 3647 | if (IS_ERR(handle)) { |
3647 | ret = PTR_ERR(handle); | 3648 | ret = PTR_ERR(handle); |
@@ -3705,9 +3706,8 @@ static int ocfs2_add_new_xattr_cluster(struct inode *inode, | |||
3705 | 3706 | ||
3706 | mlog(0, "Insert %u clusters at block %llu for xattr at %u\n", | 3707 | mlog(0, "Insert %u clusters at block %llu for xattr at %u\n", |
3707 | num_bits, block, v_start); | 3708 | num_bits, block, v_start); |
3708 | ret = ocfs2_xattr_tree_insert_extent(osb, handle, inode, root_bh, | 3709 | ret = ocfs2_insert_extent(osb, handle, inode, &et, v_start, block, |
3709 | v_start, block, num_bits, | 3710 | num_bits, 0, meta_ac); |
3710 | 0, meta_ac); | ||
3711 | if (ret < 0) { | 3711 | if (ret < 0) { |
3712 | mlog_errno(ret); | 3712 | mlog_errno(ret); |
3713 | goto leave; | 3713 | goto leave; |
@@ -3727,6 +3727,7 @@ leave: | |||
3727 | if (meta_ac) | 3727 | if (meta_ac) |
3728 | ocfs2_free_alloc_context(meta_ac); | 3728 | ocfs2_free_alloc_context(meta_ac); |
3729 | 3729 | ||
3730 | ocfs2_put_extent_tree(&et); | ||
3730 | return ret; | 3731 | return ret; |
3731 | } | 3732 | } |
3732 | 3733 | ||
@@ -4331,9 +4332,11 @@ static int ocfs2_rm_xattr_cluster(struct inode *inode, | |||
4331 | handle_t *handle; | 4332 | handle_t *handle; |
4332 | struct ocfs2_xattr_block *xb = | 4333 | struct ocfs2_xattr_block *xb = |
4333 | (struct ocfs2_xattr_block *)root_bh->b_data; | 4334 | (struct ocfs2_xattr_block *)root_bh->b_data; |
4334 | struct ocfs2_extent_list *root_el = &xb->xb_attrs.xb_root.xt_list; | ||
4335 | struct ocfs2_alloc_context *meta_ac = NULL; | 4335 | struct ocfs2_alloc_context *meta_ac = NULL; |
4336 | struct ocfs2_cached_dealloc_ctxt dealloc; | 4336 | struct ocfs2_cached_dealloc_ctxt dealloc; |
4337 | struct ocfs2_extent_tree et; | ||
4338 | |||
4339 | ocfs2_get_xattr_tree_extent_tree(&et, inode, root_bh); | ||
4337 | 4340 | ||
4338 | ocfs2_init_dealloc_ctxt(&dealloc); | 4341 | ocfs2_init_dealloc_ctxt(&dealloc); |
4339 | 4342 | ||
@@ -4342,10 +4345,9 @@ static int ocfs2_rm_xattr_cluster(struct inode *inode, | |||
4342 | 4345 | ||
4343 | ocfs2_remove_xattr_clusters_from_cache(inode, blkno, len); | 4346 | ocfs2_remove_xattr_clusters_from_cache(inode, blkno, len); |
4344 | 4347 | ||
4345 | ret = ocfs2_lock_allocators(inode, root_bh, root_el, | 4348 | ret = ocfs2_lock_allocators(inode, &et, 0, 1, NULL, &meta_ac); |
4346 | 0, 1, NULL, &meta_ac, | ||
4347 | OCFS2_XATTR_TREE_EXTENT, NULL); | ||
4348 | if (ret) { | 4349 | if (ret) { |
4350 | ocfs2_put_extent_tree(&et); | ||
4349 | mlog_errno(ret); | 4351 | mlog_errno(ret); |
4350 | return ret; | 4352 | return ret; |
4351 | } | 4353 | } |
@@ -4374,8 +4376,8 @@ static int ocfs2_rm_xattr_cluster(struct inode *inode, | |||
4374 | goto out_commit; | 4376 | goto out_commit; |
4375 | } | 4377 | } |
4376 | 4378 | ||
4377 | ret = ocfs2_remove_extent(inode, root_bh, cpos, len, handle, meta_ac, | 4379 | ret = ocfs2_remove_extent(inode, &et, cpos, len, handle, meta_ac, |
4378 | &dealloc, OCFS2_XATTR_TREE_EXTENT, NULL); | 4380 | &dealloc); |
4379 | if (ret) { | 4381 | if (ret) { |
4380 | mlog_errno(ret); | 4382 | mlog_errno(ret); |
4381 | goto out_commit; | 4383 | goto out_commit; |
@@ -4405,6 +4407,7 @@ out: | |||
4405 | 4407 | ||
4406 | ocfs2_run_deallocs(osb, &dealloc); | 4408 | ocfs2_run_deallocs(osb, &dealloc); |
4407 | 4409 | ||
4410 | ocfs2_put_extent_tree(&et); | ||
4408 | return ret; | 4411 | return ret; |
4409 | } | 4412 | } |
4410 | 4413 | ||