alloc.c (debc6a6927dcd833a30750b07a4c2b456b71f1be) alloc.c (3c5e10683e684ef45614c9071847e48f633d9806)
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.

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

2471
2472out:
2473 ocfs2_free_path(left_path);
2474
2475out_ret_path:
2476 return ret;
2477}
2478
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.

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

2471
2472out:
2473 ocfs2_free_path(left_path);
2474
2475out_ret_path:
2476 return ret;
2477}
2478
2479static void ocfs2_update_edge_lengths(struct inode *inode, handle_t *handle,
2480 struct ocfs2_path *path)
2479static int ocfs2_update_edge_lengths(struct inode *inode, handle_t *handle,
2480 int subtree_index, struct ocfs2_path *path)
2481{
2481{
2482 int i, idx;
2482 int i, idx, ret;
2483 struct ocfs2_extent_rec *rec;
2484 struct ocfs2_extent_list *el;
2485 struct ocfs2_extent_block *eb;
2486 u32 range;
2487
2483 struct ocfs2_extent_rec *rec;
2484 struct ocfs2_extent_list *el;
2485 struct ocfs2_extent_block *eb;
2486 u32 range;
2487
2488 /*
2489 * In normal tree rotation process, we will never touch the
2490 * tree branch above subtree_index and ocfs2_extend_rotate_transaction
2491 * doesn't reserve the credits for them either.
2492 *
2493 * But we do have a special case here which will update the rightmost
2494 * records for all the bh in the path.
2495 * So we have to allocate extra credits and access them.
2496 */
2497 ret = ocfs2_extend_trans(handle,
2498 handle->h_buffer_credits + subtree_index);
2499 if (ret) {
2500 mlog_errno(ret);
2501 goto out;
2502 }
2503
2504 ret = ocfs2_journal_access_path(inode, handle, path);
2505 if (ret) {
2506 mlog_errno(ret);
2507 goto out;
2508 }
2509
2488 /* Path should always be rightmost. */
2489 eb = (struct ocfs2_extent_block *)path_leaf_bh(path)->b_data;
2490 BUG_ON(eb->h_next_leaf_blk != 0ULL);
2491
2492 el = &eb->h_list;
2493 BUG_ON(le16_to_cpu(el->l_next_free_rec) == 0);
2494 idx = le16_to_cpu(el->l_next_free_rec) - 1;
2495 rec = &el->l_recs[idx];

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

2500 idx = le16_to_cpu(el->l_next_free_rec) - 1;
2501 rec = &el->l_recs[idx];
2502
2503 rec->e_int_clusters = cpu_to_le32(range);
2504 le32_add_cpu(&rec->e_int_clusters, -le32_to_cpu(rec->e_cpos));
2505
2506 ocfs2_journal_dirty(handle, path->p_node[i].bh);
2507 }
2510 /* Path should always be rightmost. */
2511 eb = (struct ocfs2_extent_block *)path_leaf_bh(path)->b_data;
2512 BUG_ON(eb->h_next_leaf_blk != 0ULL);
2513
2514 el = &eb->h_list;
2515 BUG_ON(le16_to_cpu(el->l_next_free_rec) == 0);
2516 idx = le16_to_cpu(el->l_next_free_rec) - 1;
2517 rec = &el->l_recs[idx];

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

2522 idx = le16_to_cpu(el->l_next_free_rec) - 1;
2523 rec = &el->l_recs[idx];
2524
2525 rec->e_int_clusters = cpu_to_le32(range);
2526 le32_add_cpu(&rec->e_int_clusters, -le32_to_cpu(rec->e_cpos));
2527
2528 ocfs2_journal_dirty(handle, path->p_node[i].bh);
2529 }
2530out:
2531 return ret;
2508}
2509
2510static void ocfs2_unlink_path(struct inode *inode, handle_t *handle,
2511 struct ocfs2_cached_dealloc_ctxt *dealloc,
2512 struct ocfs2_path *path, int unlink_start)
2513{
2514 int ret, i;
2515 struct ocfs2_extent_block *eb;

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

2712 mlog_errno(ret);
2713 ret = ocfs2_journal_dirty(handle, path_leaf_bh(right_path));
2714 if (ret)
2715 mlog_errno(ret);
2716
2717 if (del_right_subtree) {
2718 ocfs2_unlink_subtree(inode, handle, left_path, right_path,
2719 subtree_index, dealloc);
2532}
2533
2534static void ocfs2_unlink_path(struct inode *inode, handle_t *handle,
2535 struct ocfs2_cached_dealloc_ctxt *dealloc,
2536 struct ocfs2_path *path, int unlink_start)
2537{
2538 int ret, i;
2539 struct ocfs2_extent_block *eb;

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

2736 mlog_errno(ret);
2737 ret = ocfs2_journal_dirty(handle, path_leaf_bh(right_path));
2738 if (ret)
2739 mlog_errno(ret);
2740
2741 if (del_right_subtree) {
2742 ocfs2_unlink_subtree(inode, handle, left_path, right_path,
2743 subtree_index, dealloc);
2720 ocfs2_update_edge_lengths(inode, handle, left_path);
2744 ret = ocfs2_update_edge_lengths(inode, handle, subtree_index,
2745 left_path);
2746 if (ret) {
2747 mlog_errno(ret);
2748 goto out;
2749 }
2721
2722 eb = (struct ocfs2_extent_block *)path_leaf_bh(left_path)->b_data;
2723 ocfs2_et_set_last_eb_blk(et, le64_to_cpu(eb->h_blkno));
2724
2725 /*
2726 * Removal of the extent in the left leaf was skipped
2727 * above so we could delete the right path
2728 * 1st.

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

3029 mlog_errno(ret);
3030 goto out;
3031 }
3032
3033 subtree_index = ocfs2_find_subtree_root(inode, left_path, path);
3034
3035 ocfs2_unlink_subtree(inode, handle, left_path, path,
3036 subtree_index, dealloc);
2750
2751 eb = (struct ocfs2_extent_block *)path_leaf_bh(left_path)->b_data;
2752 ocfs2_et_set_last_eb_blk(et, le64_to_cpu(eb->h_blkno));
2753
2754 /*
2755 * Removal of the extent in the left leaf was skipped
2756 * above so we could delete the right path
2757 * 1st.

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

3058 mlog_errno(ret);
3059 goto out;
3060 }
3061
3062 subtree_index = ocfs2_find_subtree_root(inode, left_path, path);
3063
3064 ocfs2_unlink_subtree(inode, handle, left_path, path,
3065 subtree_index, dealloc);
3037 ocfs2_update_edge_lengths(inode, handle, left_path);
3066 ret = ocfs2_update_edge_lengths(inode, handle, subtree_index,
3067 left_path);
3068 if (ret) {
3069 mlog_errno(ret);
3070 goto out;
3071 }
3038
3039 eb = (struct ocfs2_extent_block *)path_leaf_bh(left_path)->b_data;
3040 ocfs2_et_set_last_eb_blk(et, le64_to_cpu(eb->h_blkno));
3041 } else {
3042 /*
3043 * 'path' is also the leftmost path which
3044 * means it must be the only one. This gets
3045 * handled differently because we want to

--- 4479 unchanged lines hidden ---
3072
3073 eb = (struct ocfs2_extent_block *)path_leaf_bh(left_path)->b_data;
3074 ocfs2_et_set_last_eb_blk(et, le64_to_cpu(eb->h_blkno));
3075 } else {
3076 /*
3077 * 'path' is also the leftmost path which
3078 * means it must be the only one. This gets
3079 * handled differently because we want to

--- 4479 unchanged lines hidden ---