Commit 3c5e1068 authored by Tao Ma's avatar Tao Ma Committed by Joel Becker

ocfs2: Add extra credits and access the modified bh in update_edge_lengths.

In normal tree rotation left process, we will never touch the tree
branch above subtree_index and ocfs2_extend_rotate_transaction doesn't
reserve the credits for them either.

But when we want to delete the rightmost extent block, we have to update
the rightmost records for all the rightmost branch(See
ocfs2_update_edge_lengths), so we have to allocate extra credits for them.
What's more, we have to access them also.
Signed-off-by: default avatarTao Ma <tao.ma@oracle.com>
Signed-off-by: default avatarJoel Becker <joel.becker@oracle.com>
parent 1f4cea37
...@@ -2476,15 +2476,37 @@ static int ocfs2_rotate_tree_right(struct inode *inode, ...@@ -2476,15 +2476,37 @@ static int ocfs2_rotate_tree_right(struct inode *inode,
return ret; return ret;
} }
static void ocfs2_update_edge_lengths(struct inode *inode, handle_t *handle, static int ocfs2_update_edge_lengths(struct inode *inode, handle_t *handle,
struct ocfs2_path *path) int subtree_index, struct ocfs2_path *path)
{ {
int i, idx; int i, idx, ret;
struct ocfs2_extent_rec *rec; struct ocfs2_extent_rec *rec;
struct ocfs2_extent_list *el; struct ocfs2_extent_list *el;
struct ocfs2_extent_block *eb; struct ocfs2_extent_block *eb;
u32 range; u32 range;
/*
* In normal tree rotation process, we will never touch the
* tree branch above subtree_index and ocfs2_extend_rotate_transaction
* doesn't reserve the credits for them either.
*
* But we do have a special case here which will update the rightmost
* records for all the bh in the path.
* So we have to allocate extra credits and access them.
*/
ret = ocfs2_extend_trans(handle,
handle->h_buffer_credits + subtree_index);
if (ret) {
mlog_errno(ret);
goto out;
}
ret = ocfs2_journal_access_path(inode, handle, path);
if (ret) {
mlog_errno(ret);
goto out;
}
/* Path should always be rightmost. */ /* Path should always be rightmost. */
eb = (struct ocfs2_extent_block *)path_leaf_bh(path)->b_data; eb = (struct ocfs2_extent_block *)path_leaf_bh(path)->b_data;
BUG_ON(eb->h_next_leaf_blk != 0ULL); BUG_ON(eb->h_next_leaf_blk != 0ULL);
...@@ -2505,6 +2527,8 @@ static void ocfs2_update_edge_lengths(struct inode *inode, handle_t *handle, ...@@ -2505,6 +2527,8 @@ static void ocfs2_update_edge_lengths(struct inode *inode, handle_t *handle,
ocfs2_journal_dirty(handle, path->p_node[i].bh); ocfs2_journal_dirty(handle, path->p_node[i].bh);
} }
out:
return ret;
} }
static void ocfs2_unlink_path(struct inode *inode, handle_t *handle, static void ocfs2_unlink_path(struct inode *inode, handle_t *handle,
...@@ -2717,7 +2741,12 @@ static int ocfs2_rotate_subtree_left(struct inode *inode, handle_t *handle, ...@@ -2717,7 +2741,12 @@ static int ocfs2_rotate_subtree_left(struct inode *inode, handle_t *handle,
if (del_right_subtree) { if (del_right_subtree) {
ocfs2_unlink_subtree(inode, handle, left_path, right_path, ocfs2_unlink_subtree(inode, handle, left_path, right_path,
subtree_index, dealloc); subtree_index, dealloc);
ocfs2_update_edge_lengths(inode, handle, left_path); ret = ocfs2_update_edge_lengths(inode, handle, subtree_index,
left_path);
if (ret) {
mlog_errno(ret);
goto out;
}
eb = (struct ocfs2_extent_block *)path_leaf_bh(left_path)->b_data; eb = (struct ocfs2_extent_block *)path_leaf_bh(left_path)->b_data;
ocfs2_et_set_last_eb_blk(et, le64_to_cpu(eb->h_blkno)); ocfs2_et_set_last_eb_blk(et, le64_to_cpu(eb->h_blkno));
...@@ -3034,7 +3063,12 @@ static int ocfs2_remove_rightmost_path(struct inode *inode, handle_t *handle, ...@@ -3034,7 +3063,12 @@ static int ocfs2_remove_rightmost_path(struct inode *inode, handle_t *handle,
ocfs2_unlink_subtree(inode, handle, left_path, path, ocfs2_unlink_subtree(inode, handle, left_path, path,
subtree_index, dealloc); subtree_index, dealloc);
ocfs2_update_edge_lengths(inode, handle, left_path); ret = ocfs2_update_edge_lengths(inode, handle, subtree_index,
left_path);
if (ret) {
mlog_errno(ret);
goto out;
}
eb = (struct ocfs2_extent_block *)path_leaf_bh(left_path)->b_data; eb = (struct ocfs2_extent_block *)path_leaf_bh(left_path)->b_data;
ocfs2_et_set_last_eb_blk(et, le64_to_cpu(eb->h_blkno)); ocfs2_et_set_last_eb_blk(et, le64_to_cpu(eb->h_blkno));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment