Commit 4bf4de6b authored by Jeff Mahoney's avatar Jeff Mahoney Committed by Jan Kara

reiserfs: balance_leaf refactor, format balance_leaf_insert_left

Reformat balance_leaf_insert_left to adhere to CodingStyle.
Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent 0080e9f9
...@@ -293,37 +293,43 @@ static int balance_leaf_when_delete(struct tree_balance *tb, int flag) ...@@ -293,37 +293,43 @@ static int balance_leaf_when_delete(struct tree_balance *tb, int flag)
static void balance_leaf_insert_left(struct tree_balance *tb, static void balance_leaf_insert_left(struct tree_balance *tb,
struct item_head *ih, const char *body) struct item_head *ih, const char *body)
{ {
int ret_val; int ret;
struct buffer_info bi; struct buffer_info bi;
int n = B_NR_ITEMS(tb->L[0]); int n = B_NR_ITEMS(tb->L[0]);
if (tb->item_pos == tb->lnum[0] - 1 && tb->lbytes != -1) { if (tb->item_pos == tb->lnum[0] - 1 && tb->lbytes != -1) {
/* part of new item falls into L[0] */ /* part of new item falls into L[0] */
int new_item_len; int new_item_len, shift;
int version; int version;
ret_val = leaf_shift_left(tb, tb->lnum[0] - 1, -1); ret = leaf_shift_left(tb, tb->lnum[0] - 1, -1);
/* Calculate item length to insert to S[0] */ /* Calculate item length to insert to S[0] */
new_item_len = ih_item_len(ih) - tb->lbytes; new_item_len = ih_item_len(ih) - tb->lbytes;
/* Calculate and check item length to insert to L[0] */ /* Calculate and check item length to insert to L[0] */
put_ih_item_len(ih, ih_item_len(ih) - new_item_len); put_ih_item_len(ih, ih_item_len(ih) - new_item_len);
RFALSE(ih_item_len(ih) <= 0, RFALSE(ih_item_len(ih) <= 0,
"PAP-12080: there is nothing to insert into L[0]: ih_item_len=%d", "PAP-12080: there is nothing to insert into L[0]: "
ih_item_len(ih)); "ih_item_len=%d", ih_item_len(ih));
/* Insert new item into L[0] */ /* Insert new item into L[0] */
buffer_info_init_left(tb, &bi); buffer_info_init_left(tb, &bi);
leaf_insert_into_buf(&bi, leaf_insert_into_buf(&bi, n + tb->item_pos - ret, ih, body,
n + tb->item_pos - ret_val, ih, body, min_t(int, tb->zeroes_num, ih_item_len(ih)));
tb->zeroes_num > ih_item_len(ih) ? ih_item_len(ih) : tb->zeroes_num);
version = ih_version(ih); version = ih_version(ih);
/* Calculate key component, item length and body to insert into S[0] */ /*
set_le_ih_k_offset(ih, le_ih_k_offset(ih) + * Calculate key component, item length and body to
(tb->lbytes << (is_indirect_le_ih(ih) ? tb->tb_sb->s_blocksize_bits - UNFM_P_SHIFT : 0))); * insert into S[0]
*/
shift = 0;
if (is_indirect_le_ih(ih))
shift = tb->tb_sb->s_blocksize_bits - UNFM_P_SHIFT;
add_le_ih_k_offset(ih, tb->lbytes << shift);
put_ih_item_len(ih, new_item_len); put_ih_item_len(ih, new_item_len);
if (tb->lbytes > tb->zeroes_num) { if (tb->lbytes > tb->zeroes_num) {
...@@ -333,19 +339,20 @@ static void balance_leaf_insert_left(struct tree_balance *tb, ...@@ -333,19 +339,20 @@ static void balance_leaf_insert_left(struct tree_balance *tb,
tb->zeroes_num -= tb->lbytes; tb->zeroes_num -= tb->lbytes;
RFALSE(ih_item_len(ih) <= 0, RFALSE(ih_item_len(ih) <= 0,
"PAP-12085: there is nothing to insert into S[0]: ih_item_len=%d", "PAP-12085: there is nothing to insert into S[0]: "
ih_item_len(ih)); "ih_item_len=%d", ih_item_len(ih));
} else { } else {
/* new item in whole falls into L[0] */ /* new item in whole falls into L[0] */
/* Shift lnum[0]-1 items to L[0] */ /* Shift lnum[0]-1 items to L[0] */
ret_val = leaf_shift_left(tb, tb->lnum[0] - 1, tb->lbytes); ret = leaf_shift_left(tb, tb->lnum[0] - 1, tb->lbytes);
/* Insert new item into L[0] */ /* Insert new item into L[0] */
buffer_info_init_left(tb, &bi); buffer_info_init_left(tb, &bi);
leaf_insert_into_buf(&bi, n + tb->item_pos - ret_val, ih, body, tb->zeroes_num); leaf_insert_into_buf(&bi, n + tb->item_pos - ret, ih, body,
tb->zeroes_num);
tb->insert_size[0] = 0; tb->insert_size[0] = 0;
tb->zeroes_num = 0; tb->zeroes_num = 0;
} }
} }
static void balance_leaf_paste_left(struct tree_balance *tb, static void balance_leaf_paste_left(struct tree_balance *tb,
......
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