alloc.c (92295d8054289eff0d52b4d12349f9b9df0f58e4) alloc.c (e8aed3450c0afd6fdb79ec233f806e3e69454dfe)
1/* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
3 *
4 * alloc.c
5 *
6 * Extent allocs and frees
7 *
8 * Copyright (C) 2002, 2004 Oracle. All rights reserved.

--- 2375 unchanged lines hidden (view full) ---

2384
2385 ret = ocfs2_extend_rotate_transaction(handle, subtree_root,
2386 orig_credits, left_path);
2387 if (ret) {
2388 mlog_errno(ret);
2389 goto out;
2390 }
2391
1/* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
3 *
4 * alloc.c
5 *
6 * Extent allocs and frees
7 *
8 * Copyright (C) 2002, 2004 Oracle. All rights reserved.

--- 2375 unchanged lines hidden (view full) ---

2384
2385 ret = ocfs2_extend_rotate_transaction(handle, subtree_root,
2386 orig_credits, left_path);
2387 if (ret) {
2388 mlog_errno(ret);
2389 goto out;
2390 }
2391
2392 /*
2393 * Caller might still want to make changes to the
2394 * tree root, so re-add it to the journal here.
2395 */
2396 ret = ocfs2_journal_access(handle, inode,
2397 path_root_bh(left_path),
2398 OCFS2_JOURNAL_ACCESS_WRITE);
2399 if (ret) {
2400 mlog_errno(ret);
2401 goto out;
2402 }
2403
2392 ret = ocfs2_rotate_subtree_left(inode, handle, left_path,
2393 right_path, subtree_root,
2394 dealloc, &deleted);
2395 if (ret == -EAGAIN) {
2396 /*
2397 * The rotation has to temporarily stop due to
2398 * the right subtree having an empty
2399 * extent. Pass it back to the caller for a

--- 884 unchanged lines hidden (view full) ---

3284 struct ocfs2_path *left_path,
3285 struct ocfs2_path *right_path,
3286 struct ocfs2_extent_rec *insert_rec,
3287 struct ocfs2_insert_type *insert)
3288{
3289 int ret, subtree_index;
3290 struct buffer_head *leaf_bh = path_leaf_bh(right_path);
3291
2404 ret = ocfs2_rotate_subtree_left(inode, handle, left_path,
2405 right_path, subtree_root,
2406 dealloc, &deleted);
2407 if (ret == -EAGAIN) {
2408 /*
2409 * The rotation has to temporarily stop due to
2410 * the right subtree having an empty
2411 * extent. Pass it back to the caller for a

--- 884 unchanged lines hidden (view full) ---

3296 struct ocfs2_path *left_path,
3297 struct ocfs2_path *right_path,
3298 struct ocfs2_extent_rec *insert_rec,
3299 struct ocfs2_insert_type *insert)
3300{
3301 int ret, subtree_index;
3302 struct buffer_head *leaf_bh = path_leaf_bh(right_path);
3303
3292 /*
3293 * Pass both paths to the journal. The majority of inserts
3294 * will be touching all components anyway.
3295 */
3296 ret = ocfs2_journal_access_path(inode, handle, right_path);
3297 if (ret < 0) {
3298 mlog_errno(ret);
3299 goto out;
3300 }
3301
3302 if (left_path) {
3303 int credits = handle->h_buffer_credits;
3304
3305 /*
3306 * There's a chance that left_path got passed back to
3307 * us without being accounted for in the
3308 * journal. Extend our transaction here to be sure we
3309 * can change those blocks.

--- 8 unchanged lines hidden (view full) ---

3318
3319 ret = ocfs2_journal_access_path(inode, handle, left_path);
3320 if (ret < 0) {
3321 mlog_errno(ret);
3322 goto out;
3323 }
3324 }
3325
3304 if (left_path) {
3305 int credits = handle->h_buffer_credits;
3306
3307 /*
3308 * There's a chance that left_path got passed back to
3309 * us without being accounted for in the
3310 * journal. Extend our transaction here to be sure we
3311 * can change those blocks.

--- 8 unchanged lines hidden (view full) ---

3320
3321 ret = ocfs2_journal_access_path(inode, handle, left_path);
3322 if (ret < 0) {
3323 mlog_errno(ret);
3324 goto out;
3325 }
3326 }
3327
3328 /*
3329 * Pass both paths to the journal. The majority of inserts
3330 * will be touching all components anyway.
3331 */
3332 ret = ocfs2_journal_access_path(inode, handle, right_path);
3333 if (ret < 0) {
3334 mlog_errno(ret);
3335 goto out;
3336 }
3337
3326 if (insert->ins_split != SPLIT_NONE) {
3327 /*
3328 * We could call ocfs2_insert_at_leaf() for some types
3329 * of splits, but it's easier to just let one seperate
3330 * function sort it all out.
3331 */
3332 ocfs2_split_record(inode, left_path, right_path,
3333 insert_rec, insert->ins_split);
3338 if (insert->ins_split != SPLIT_NONE) {
3339 /*
3340 * We could call ocfs2_insert_at_leaf() for some types
3341 * of splits, but it's easier to just let one seperate
3342 * function sort it all out.
3343 */
3344 ocfs2_split_record(inode, left_path, right_path,
3345 insert_rec, insert->ins_split);
3346
3347 /*
3348 * Split might have modified either leaf and we don't
3349 * have a guarantee that the later edge insert will
3350 * dirty this for us.
3351 */
3352 if (left_path)
3353 ret = ocfs2_journal_dirty(handle,
3354 path_leaf_bh(left_path));
3355 if (ret)
3356 mlog_errno(ret);
3334 } else
3335 ocfs2_insert_at_leaf(insert_rec, path_leaf_el(right_path),
3336 insert, inode);
3337
3338 ret = ocfs2_journal_dirty(handle, leaf_bh);
3339 if (ret)
3340 mlog_errno(ret);
3341

--- 83 unchanged lines hidden (view full) ---

3425 if (rotate) {
3426 ret = ocfs2_rotate_tree_right(inode, handle, type->ins_split,
3427 le32_to_cpu(insert_rec->e_cpos),
3428 right_path, &left_path);
3429 if (ret) {
3430 mlog_errno(ret);
3431 goto out;
3432 }
3357 } else
3358 ocfs2_insert_at_leaf(insert_rec, path_leaf_el(right_path),
3359 insert, inode);
3360
3361 ret = ocfs2_journal_dirty(handle, leaf_bh);
3362 if (ret)
3363 mlog_errno(ret);
3364

--- 83 unchanged lines hidden (view full) ---

3448 if (rotate) {
3449 ret = ocfs2_rotate_tree_right(inode, handle, type->ins_split,
3450 le32_to_cpu(insert_rec->e_cpos),
3451 right_path, &left_path);
3452 if (ret) {
3453 mlog_errno(ret);
3454 goto out;
3455 }
3456
3457 /*
3458 * ocfs2_rotate_tree_right() might have extended the
3459 * transaction without re-journaling our tree root.
3460 */
3461 ret = ocfs2_journal_access(handle, inode, di_bh,
3462 OCFS2_JOURNAL_ACCESS_WRITE);
3463 if (ret) {
3464 mlog_errno(ret);
3465 goto out;
3466 }
3433 } else if (type->ins_appending == APPEND_TAIL
3434 && type->ins_contig != CONTIG_LEFT) {
3435 ret = ocfs2_append_rec_to_path(inode, handle, insert_rec,
3436 right_path, &left_path);
3437 if (ret) {
3438 mlog_errno(ret);
3439 goto out;
3440 }

--- 495 unchanged lines hidden (view full) ---

3936 struct ocfs2_path *path,
3937 int split_index,
3938 struct ocfs2_extent_rec *split_rec,
3939 struct ocfs2_alloc_context *meta_ac,
3940 struct ocfs2_cached_dealloc_ctxt *dealloc)
3941{
3942 int ret = 0;
3943 struct ocfs2_extent_list *el = path_leaf_el(path);
3467 } else if (type->ins_appending == APPEND_TAIL
3468 && type->ins_contig != CONTIG_LEFT) {
3469 ret = ocfs2_append_rec_to_path(inode, handle, insert_rec,
3470 right_path, &left_path);
3471 if (ret) {
3472 mlog_errno(ret);
3473 goto out;
3474 }

--- 495 unchanged lines hidden (view full) ---

3970 struct ocfs2_path *path,
3971 int split_index,
3972 struct ocfs2_extent_rec *split_rec,
3973 struct ocfs2_alloc_context *meta_ac,
3974 struct ocfs2_cached_dealloc_ctxt *dealloc)
3975{
3976 int ret = 0;
3977 struct ocfs2_extent_list *el = path_leaf_el(path);
3944 struct buffer_head *eb_bh, *last_eb_bh = NULL;
3978 struct buffer_head *last_eb_bh = NULL;
3945 struct ocfs2_extent_rec *rec = &el->l_recs[split_index];
3946 struct ocfs2_merge_ctxt ctxt;
3947 struct ocfs2_extent_list *rightmost_el;
3948
3949 if (!(rec->e_flags & OCFS2_EXT_UNWRITTEN)) {
3950 ret = -EIO;
3951 mlog_errno(ret);
3952 goto out;
3953 }
3954
3955 if (le32_to_cpu(rec->e_cpos) > le32_to_cpu(split_rec->e_cpos) ||
3956 ((le32_to_cpu(rec->e_cpos) + le16_to_cpu(rec->e_leaf_clusters)) <
3957 (le32_to_cpu(split_rec->e_cpos) + le16_to_cpu(split_rec->e_leaf_clusters)))) {
3958 ret = -EIO;
3959 mlog_errno(ret);
3960 goto out;
3961 }
3962
3979 struct ocfs2_extent_rec *rec = &el->l_recs[split_index];
3980 struct ocfs2_merge_ctxt ctxt;
3981 struct ocfs2_extent_list *rightmost_el;
3982
3983 if (!(rec->e_flags & OCFS2_EXT_UNWRITTEN)) {
3984 ret = -EIO;
3985 mlog_errno(ret);
3986 goto out;
3987 }
3988
3989 if (le32_to_cpu(rec->e_cpos) > le32_to_cpu(split_rec->e_cpos) ||
3990 ((le32_to_cpu(rec->e_cpos) + le16_to_cpu(rec->e_leaf_clusters)) <
3991 (le32_to_cpu(split_rec->e_cpos) + le16_to_cpu(split_rec->e_leaf_clusters)))) {
3992 ret = -EIO;
3993 mlog_errno(ret);
3994 goto out;
3995 }
3996
3963 eb_bh = path_leaf_bh(path);
3964 ret = ocfs2_journal_access(handle, inode, eb_bh,
3965 OCFS2_JOURNAL_ACCESS_WRITE);
3966 if (ret) {
3967 mlog_errno(ret);
3968 goto out;
3969 }
3970
3971 ctxt.c_contig_type = ocfs2_figure_merge_contig_type(inode, el,
3972 split_index,
3973 split_rec);
3974
3975 /*
3976 * The core merge / split code wants to know how much room is
3977 * left in this inodes allocation tree, so we pass the
3978 * rightmost extent list.

--- 45 unchanged lines hidden (view full) ---

4024 } else {
4025 ret = ocfs2_try_to_merge_extent(inode, handle, path,
4026 split_index, split_rec,
4027 dealloc, &ctxt);
4028 if (ret)
4029 mlog_errno(ret);
4030 }
4031
3997 ctxt.c_contig_type = ocfs2_figure_merge_contig_type(inode, el,
3998 split_index,
3999 split_rec);
4000
4001 /*
4002 * The core merge / split code wants to know how much room is
4003 * left in this inodes allocation tree, so we pass the
4004 * rightmost extent list.

--- 45 unchanged lines hidden (view full) ---

4050 } else {
4051 ret = ocfs2_try_to_merge_extent(inode, handle, path,
4052 split_index, split_rec,
4053 dealloc, &ctxt);
4054 if (ret)
4055 mlog_errno(ret);
4056 }
4057
4032 ocfs2_journal_dirty(handle, eb_bh);
4033
4034out:
4035 brelse(last_eb_bh);
4036 return ret;
4037}
4038
4039/*
4040 * Mark the already-existing extent at cpos as written for len clusters.
4041 *

--- 2274 unchanged lines hidden ---
4058out:
4059 brelse(last_eb_bh);
4060 return ret;
4061}
4062
4063/*
4064 * Mark the already-existing extent at cpos as written for len clusters.
4065 *

--- 2274 unchanged lines hidden ---