aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2013-08-12 11:11:23 -0400
committerJeff Mahoney <jeffm@suse.com>2013-08-26 17:15:33 -0400
commit867cfbbb3e53c8711a3dd61f22ff94a939957211 (patch)
tree522640ad090549d54ca95aa75c11538100669126
parentc1ff1d5d2d9019bfe62436e767ca2be6d2a4d553 (diff)
downloadreiserfsprogs-867cfbbb3e53c8711a3dd61f22ff94a939957211.tar.gz
cleanup: factor out buffer_info initialization into helpers
We open code buffer_info initialization all over the place. Let's factor that out so we don't reproduce the code everywhere. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
-rw-r--r--include/reiserfs_fs.h54
-rw-r--r--reiserfscore/do_balan.c110
-rw-r--r--reiserfscore/ibalance.c79
-rw-r--r--reiserfscore/lbalance.c52
4 files changed, 109 insertions, 186 deletions
diff --git a/include/reiserfs_fs.h b/include/reiserfs_fs.h
index 7cf4161..1f2acbc 100644
--- a/include/reiserfs_fs.h
+++ b/include/reiserfs_fs.h
@@ -1330,12 +1330,12 @@ struct tree_balance {
/* used in do_balance for passing parent of node information that has been
gotten from tb struct */
struct buffer_info {
+ reiserfs_filsys_t *bi_fs;
struct buffer_head * bi_bh;
struct buffer_head * bi_parent;
int bi_position;
};
-
/* there are 4 types of items: stat data, directory item, indirect, direct.
FIXME: This table does not describe new key format
+-------------------+------------+--------------+------------+
@@ -1534,6 +1534,58 @@ extern unsigned int get_journal_new_start_must (reiserfs_filsys_t *fs);
extern unsigned int get_journal_start_must (reiserfs_filsys_t *fs);
/*extern hashf_t hashes [];*/
+static inline void buffer_info_init_left(struct tree_balance *tb,
+ struct buffer_info *bi, int h)
+{
+ bi->bi_fs = tb->tb_fs;
+ bi->bi_bh = tb->L[h];
+ bi->bi_parent = tb->FL[h];
+ bi->bi_position = get_left_neighbor_position(tb, h);
+}
+
+static inline void buffer_info_init_right(struct tree_balance *tb,
+ struct buffer_info *bi, int h)
+{
+ bi->bi_fs = tb->tb_fs;
+ bi->bi_bh = tb->R[h];
+ bi->bi_parent = tb->FR[h];
+ bi->bi_position = get_right_neighbor_position(tb, h);
+}
+
+static inline void buffer_info_init_last(struct tree_balance *tb,
+ struct buffer_info *bi)
+{
+ bi->bi_fs = tb->tb_fs;
+ bi->bi_bh = PATH_PLAST_BUFFER(tb->tb_path);
+ bi->bi_parent = PATH_H_PPARENT(tb->tb_path, 0);
+ bi->bi_position = PATH_H_B_ITEM_ORDER(tb->tb_path, 0);
+}
+
+static inline void buffer_info_init_tbSh(struct tree_balance *tb,
+ struct buffer_info *bi, int h)
+{
+ bi->bi_fs = tb->tb_fs;
+ bi->bi_bh = PATH_H_PBUFFER(tb->tb_path, h);
+ bi->bi_parent = PATH_H_PPARENT(tb->tb_path, h);
+ bi->bi_position = PATH_H_POSITION(tb->tb_path, h + 1);
+}
+
+static inline void buffer_info_init_tbS0(struct tree_balance *tb,
+ struct buffer_info *bi)
+{
+ buffer_info_init_tbSh(tb, bi, 0);
+}
+
+static inline void buffer_info_init_bh(struct tree_balance *tb,
+ struct buffer_info *bi,
+ struct buffer_head *bh)
+{
+ bi->bi_fs = tb->tb_fs;
+ bi->bi_bh = bh;
+ bi->bi_parent = NULL;
+ bi->bi_position = 0;
+}
+
#endif
/*
diff --git a/reiserfscore/do_balan.c b/reiserfscore/do_balan.c
index d1b0273..3453380 100644
--- a/reiserfscore/do_balan.c
+++ b/reiserfscore/do_balan.c
@@ -59,15 +59,13 @@ static int balance_leaf_when_delete( /*struct reiserfs_transaction_handle *th, *
struct item_head *ih;
ih = item_head(tbS0, item_pos);
+ buffer_info_init_tbS0(tb, &bi);
/* Delete or truncate the item */
switch (flag) {
case M_DELETE: /* delete item in S[0] */
- bi.bi_bh = tbS0;
- bi.bi_parent = PATH_H_PPARENT(tb->tb_path, 0);
- bi.bi_position = PATH_H_POSITION(tb->tb_path, 1);
leaf_delete_items(tb->tb_fs, &bi, 0, item_pos, 1, -1);
if (!item_pos) {
@@ -87,9 +85,6 @@ static int balance_leaf_when_delete( /*struct reiserfs_transaction_handle *th, *
break;
case M_CUT:{ /* cut item in S[0] */
- bi.bi_bh = tbS0;
- bi.bi_parent = PATH_H_PPARENT(tb->tb_path, 0);
- bi.bi_position = PATH_H_POSITION(tb->tb_path, 1);
if (I_IS_DIRECTORY_ITEM(ih)) {
/* UFS unlink semantics are such that you can only delete
one directory entry at a time. */
@@ -270,10 +265,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
get_ih_item_len(ih) -
new_item_len);
/* Insert new item into L[0] */
- bi.bi_bh = tb->L[0];
- bi.bi_parent = tb->FL[0];
- bi.bi_position =
- get_left_neighbor_position(tb, 0);
+ buffer_info_init_left(tb, &bi, 0);
leaf_insert_into_buf(tb->tb_fs, &bi,
n + item_pos -
ret_val, ih, body,
@@ -307,10 +299,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
tb->lbytes);
/* Insert new item into L[0] */
- bi.bi_bh = tb->L[0];
- bi.bi_parent = tb->FL[0];
- bi.bi_position =
- get_left_neighbor_position(tb, 0);
+ buffer_info_init_left(tb, &bi, 0);
leaf_insert_into_buf(tb->tb_fs, &bi,
n + item_pos -
ret_val, ih, body,
@@ -364,12 +353,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
}
/* Append given directory entry to directory item */
- bi.bi_bh = tb->L[0];
- bi.bi_parent =
- tb->FL[0];
- bi.bi_position =
- get_left_neighbor_position
- (tb, 0);
+ buffer_info_init_left(tb, &bi, 0);
leaf_paste_in_buffer
(tb->tb_fs, &bi,
n + item_pos -
@@ -442,12 +426,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
(tbS0,
item_pos)));
/* Append to body of item in L[0] */
- bi.bi_bh = tb->L[0];
- bi.bi_parent =
- tb->FL[0];
- bi.bi_position =
- get_left_neighbor_position
- (tb, 0);
+ buffer_info_init_left(tb, &bi, 0);
leaf_paste_in_buffer
(tb->tb_fs, &bi,
n + item_pos -
@@ -548,10 +527,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
leaf_shift_left(tb, tb->lnum[0],
tb->lbytes);
/* Append to body of item in L[0] */
- bi.bi_bh = tb->L[0];
- bi.bi_parent = tb->FL[0];
- bi.bi_position =
- get_left_neighbor_position(tb, 0);
+ buffer_info_init_left(tb, &bi, 0);
leaf_paste_in_buffer(tb->tb_fs, &bi,
n + item_pos -
ret_val,
@@ -643,10 +619,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
set_ih_item_len(ih, tb->rbytes);
/* Insert part of the item into R[0] */
- bi.bi_bh = tb->R[0];
- bi.bi_parent = tb->FR[0];
- bi.bi_position =
- get_right_neighbor_position(tb, 0);
+ buffer_info_init_right(tb, &bi, 0);
if (old_len - tb->rbytes > zeros_number) {
r_zeros_number = 0;
r_body =
@@ -688,10 +661,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
tb->rbytes);
/* Insert new item into R[0] */
- bi.bi_bh = tb->R[0];
- bi.bi_parent = tb->FR[0];
- bi.bi_position =
- get_right_neighbor_position(tb, 0);
+ buffer_info_init_right(tb, &bi, 0);
leaf_insert_into_buf(tb->tb_fs, &bi,
item_pos - n +
tb->rnum[0] - 1,
@@ -748,12 +718,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
entry_count +
tb->rbytes - 1;
- bi.bi_bh = tb->R[0];
- bi.bi_parent =
- tb->FR[0];
- bi.bi_position =
- get_right_neighbor_position
- (tb, 0);
+ buffer_info_init_right(tb, &bi, 0);
leaf_paste_in_buffer
(tb->tb_fs, &bi, 0,
paste_entry_position,
@@ -872,11 +837,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
mark_buffer_dirty(tb->CFR[0]);
/* Append part of body into R[0] */
- bi.bi_bh = tb->R[0];
- bi.bi_parent = tb->FR[0];
- bi.bi_position =
- get_right_neighbor_position
- (tb, 0);
+ buffer_info_init_right(tb, &bi, 0);
if (n_rem > zeros_number) {
r_zeros_number = 0;
r_body =
@@ -924,11 +885,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
/* append item in R[0] */
if (pos_in_item >= 0) {
- bi.bi_bh = tb->R[0];
- bi.bi_parent = tb->FR[0];
- bi.bi_position =
- get_right_neighbor_position
- (tb, 0);
+ buffer_info_init_right(tb, &bi, 0);
leaf_paste_in_buffer(tb->tb_fs,
&bi,
item_pos -
@@ -1067,9 +1024,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
set_ih_item_len(ih, sbytes[i]);
/* Insert part of the item into S_new[i] before 0-th item */
- bi.bi_bh = S_new[i];
- bi.bi_parent = 0;
- bi.bi_position = 0;
+ buffer_info_init_bh(tb, &bi, S_new[i]);
if (old_len - sbytes[i] > zeros_number) {
r_zeros_number = 0;
@@ -1104,9 +1059,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
S_new[i]);
/* Insert new item into S_new[i] */
- bi.bi_bh = S_new[i];
- bi.bi_parent = 0;
- bi.bi_position = 0;
+ buffer_info_init_bh(tb, &bi, S_new[i]);
leaf_insert_into_buf(tb->tb_fs, &bi,
item_pos - n +
snum[i] - 1, ih,
@@ -1153,9 +1106,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
S_new[i]);
/* Paste given directory entry to directory item */
- bi.bi_bh = S_new[i];
- bi.bi_parent = 0;
- bi.bi_position = 0;
+ buffer_info_init_bh(tb, &bi, S_new[i]);
leaf_paste_in_buffer
(tb->tb_fs, &bi, 0,
pos_in_item -
@@ -1220,9 +1171,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
if (n_rem < 0)
n_rem = 0;
/* Append part of body into S_new[0] */
- bi.bi_bh = S_new[i];
- bi.bi_parent = 0;
- bi.bi_position = 0;
+ buffer_info_init_bh(tb, &bi, S_new[i]);
if (n_rem > zeros_number) {
r_zeros_number = 0;
@@ -1296,9 +1245,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
snum[i], sbytes[i],
S_new[i]);
/* paste into item */
- bi.bi_bh = S_new[i];
- bi.bi_parent = 0;
- bi.bi_position = 0;
+ buffer_info_init_bh(tb, &bi, S_new[i]);
leaf_paste_in_buffer(tb->tb_fs, &bi,
item_pos - n +
snum[i],
@@ -1360,9 +1307,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
switch (flag) {
case M_INSERT: /* insert item into S[0] */
- bi.bi_bh = tbS0;
- bi.bi_parent = PATH_H_PPARENT(tb->tb_path, 0);
- bi.bi_position = PATH_H_POSITION(tb->tb_path, 1);
+ buffer_info_init_tbS0(tb, &bi);
leaf_insert_into_buf(tb->tb_fs, &bi, item_pos, ih, body,
zeros_number);
@@ -1384,13 +1329,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
&& pos_in_item <=
get_ih_entry_count(pasted)) {
/* prepare space */
- bi.bi_bh = tbS0;
- bi.bi_parent =
- PATH_H_PPARENT(tb->tb_path,
- 0);
- bi.bi_position =
- PATH_H_POSITION(tb->tb_path,
- 1);
+ buffer_info_init_tbS0(tb, &bi);
leaf_paste_in_buffer(tb->tb_fs,
&bi,
item_pos,
@@ -1431,13 +1370,7 @@ static int balance_leaf( /*struct reiserfs_transaction_handle *th, */
} else { /* regular object */
if (pos_in_item ==
get_ih_item_len(pasted)) {
- bi.bi_bh = tbS0;
- bi.bi_parent =
- PATH_H_PPARENT(tb->tb_path,
- 0);
- bi.bi_position =
- PATH_H_POSITION(tb->tb_path,
- 1);
+ buffer_info_init_tbS0(tb, &bi);
leaf_paste_in_buffer(tb->tb_fs,
&bi,
item_pos,
@@ -1491,9 +1424,8 @@ struct buffer_head *get_FEB(struct tree_balance *tb)
if (i == MAX_FEB_SIZE)
reiserfs_panic("vs-12300: get_FEB: FEB list is empty");
- bi.bi_bh = first_b = tb->FEB[i];
- bi.bi_parent = 0;
- bi.bi_position = 0;
+ first_b = tb->FEB[i];
+ buffer_info_init_bh(tb, &bi, first_b);
make_empty_node(&bi);
misc_set_bit(BH_Uptodate, &first_b->b_state);
diff --git a/reiserfscore/ibalance.c b/reiserfscore/ibalance.c
index 8d48ea8..00dd300 100644
--- a/reiserfscore/ibalance.c
+++ b/reiserfscore/ibalance.c
@@ -24,63 +24,41 @@ static void internal_define_dest_src_infos(int shift_mode,
/* define dest, src, dest parent, dest position */
switch (shift_mode) {
case INTERNAL_SHIFT_FROM_S_TO_L: /* used in internal_shift_left */
- src_bi->bi_bh = PATH_H_PBUFFER(tb->tb_path, h);
- src_bi->bi_parent = PATH_H_PPARENT(tb->tb_path, h);
- src_bi->bi_position = PATH_H_POSITION(tb->tb_path, h + 1);
- dest_bi->bi_bh = tb->L[h];
- dest_bi->bi_parent = tb->FL[h];
- dest_bi->bi_position = get_left_neighbor_position(tb, h);
+ buffer_info_init_tbSh(tb, src_bi, h);
+ buffer_info_init_left(tb, dest_bi, h);
*d_key = tb->lkey[h];
*cf = tb->CFL[h];
break;
case INTERNAL_SHIFT_FROM_L_TO_S:
- src_bi->bi_bh = tb->L[h];
- src_bi->bi_parent = tb->FL[h];
- src_bi->bi_position = get_left_neighbor_position(tb, h);
- dest_bi->bi_bh = PATH_H_PBUFFER(tb->tb_path, h);
- dest_bi->bi_parent = PATH_H_PPARENT(tb->tb_path, h);
- dest_bi->bi_position = PATH_H_POSITION(tb->tb_path, h + 1); /* dest position is analog of dest->b_item_order */
+ buffer_info_init_left(tb, src_bi, h);
+ buffer_info_init_tbSh(tb, dest_bi, h);
*d_key = tb->lkey[h];
*cf = tb->CFL[h];
break;
case INTERNAL_SHIFT_FROM_R_TO_S: /* used in internal_shift_left */
- src_bi->bi_bh = tb->R[h];
- src_bi->bi_parent = tb->FR[h];
- src_bi->bi_position = get_right_neighbor_position(tb, h);
- dest_bi->bi_bh = PATH_H_PBUFFER(tb->tb_path, h);
- dest_bi->bi_parent = PATH_H_PPARENT(tb->tb_path, h);
- dest_bi->bi_position = PATH_H_POSITION(tb->tb_path, h + 1);
+ buffer_info_init_right(tb, src_bi, h);
+ buffer_info_init_tbSh(tb, dest_bi, h);
*d_key = tb->rkey[h];
*cf = tb->CFR[h];
break;
case INTERNAL_SHIFT_FROM_S_TO_R:
- src_bi->bi_bh = PATH_H_PBUFFER(tb->tb_path, h);
- src_bi->bi_parent = PATH_H_PPARENT(tb->tb_path, h);
- src_bi->bi_position = PATH_H_POSITION(tb->tb_path, h + 1);
- dest_bi->bi_bh = tb->R[h];
- dest_bi->bi_parent = tb->FR[h];
- dest_bi->bi_position = get_right_neighbor_position(tb, h);
+ buffer_info_init_tbSh(tb, src_bi, h);
+ buffer_info_init_right(tb, dest_bi, h);
*d_key = tb->rkey[h];
*cf = tb->CFR[h];
break;
case INTERNAL_INSERT_TO_L:
- dest_bi->bi_bh = tb->L[h];
- dest_bi->bi_parent = tb->FL[h];
- dest_bi->bi_position = get_left_neighbor_position(tb, h);
+ buffer_info_init_left(tb, dest_bi, h);
break;
case INTERNAL_INSERT_TO_S:
- dest_bi->bi_bh = PATH_H_PBUFFER(tb->tb_path, h);
- dest_bi->bi_parent = PATH_H_PPARENT(tb->tb_path, h);
- dest_bi->bi_position = PATH_H_POSITION(tb->tb_path, h + 1);
+ buffer_info_init_tbSh(tb, dest_bi, h);
break;
case INTERNAL_INSERT_TO_R:
- dest_bi->bi_bh = tb->R[h];
- dest_bi->bi_parent = tb->FR[h];
- dest_bi->bi_position = get_right_neighbor_position(tb, h);
+ buffer_info_init_right(tb, dest_bi, h);
break;
default:
@@ -505,12 +483,7 @@ static void balance_internal_when_delete(struct tree_balance *tb,
insert_num = tb->insert_size[h] / ((int)(DC_SIZE + KEY_SIZE));
/* delete child-node-pointer(s) together with their left item(s) */
- bi.bi_bh = tbSh;
-
- bi.bi_parent = PATH_H_PPARENT(tb->tb_path, h);
-
- bi.bi_position = PATH_H_POSITION(tb->tb_path, h + 1);
-
+ buffer_info_init_tbSh(tb, &bi, h);
internal_delete_childs(tb->tb_fs, &bi, child_pos, -insert_num);
n = B_NR_ITEMS(tbSh);
@@ -657,9 +630,7 @@ int balance_internal(struct tree_balance *tb, /* tree_balance structure
tb->lnum[h] - insert_num);
/* insert insert_num keys and node-pointers into L[h] */
- bi.bi_bh = tb->L[h];
- bi.bi_parent = tb->FL[h];
- bi.bi_position = get_left_neighbor_position(tb, h);
+ buffer_info_init_left(tb, &bi, h);
internal_insert_childs(tb->tb_fs, &bi,
/*tb->L[h], tb->S[h-1]->b_next */
n + child_pos + 1,
@@ -675,9 +646,7 @@ int balance_internal(struct tree_balance *tb, /* tree_balance structure
/* calculate number of new items that fall into L[h] */
k = tb->lnum[h] - child_pos - 1;
- bi.bi_bh = tb->L[h];
- bi.bi_parent = tb->FL[h];
- bi.bi_position = get_left_neighbor_position(tb, h);
+ buffer_info_init_left(tb, &bi, h);
internal_insert_childs(tb->tb_fs, &bi,
/*tb->L[h], tb->S[h-1]->b_next, */
n + child_pos + 1, k,
@@ -721,9 +690,7 @@ int balance_internal(struct tree_balance *tb, /* tree_balance structure
tb->rnum[h] - insert_num);
/* insert insert_num keys and node-pointers into R[h] */
- bi.bi_bh = tb->R[h];
- bi.bi_parent = tb->FR[h];
- bi.bi_position = get_right_neighbor_position(tb, h);
+ buffer_info_init_right(tb, &bi, h);
internal_insert_childs(tb->tb_fs, &bi,
/*tb->R[h],tb->S[h-1]->b_next */
child_pos - n - insert_num +
@@ -739,9 +706,7 @@ int balance_internal(struct tree_balance *tb, /* tree_balance structure
/* calculate number of new items that fall into R[h] */
k = tb->rnum[h] - n + child_pos - 1;
- bi.bi_bh = tb->R[h];
- bi.bi_parent = tb->FR[h];
- bi.bi_position = get_right_neighbor_position(tb, h);
+ buffer_info_init_right(tb, &bi, h);
internal_insert_childs(tb->tb_fs, &bi,
/*tb->R[h], tb->R[h]->b_child, */
0, k, insert_key + 1,
@@ -829,12 +794,8 @@ int balance_internal(struct tree_balance *tb, /* tree_balance structure
set_blkh_level(B_BLK_HEAD(S_new), h + 1);
- dest_bi.bi_bh = S_new;
- dest_bi.bi_parent = 0;
- dest_bi.bi_position = 0;
- src_bi.bi_bh = tbSh;
- src_bi.bi_parent = PATH_H_PPARENT(tb->tb_path, h);
- src_bi.bi_position = PATH_H_POSITION(tb->tb_path, h + 1);
+ buffer_info_init_bh(tb, &dest_bi, S_new);
+ buffer_info_init_tbSh(tb, &src_bi, h);
n = get_blkh_nr_items(B_BLK_HEAD(tbSh)); /* number of items in S[h] */
snum = (insert_num + n + 1) / 2;
@@ -919,9 +880,7 @@ int balance_internal(struct tree_balance *tb, /* tree_balance structure
n = get_blkh_nr_items(B_BLK_HEAD(tbSh)); /*number of items in S[h] */
if (-1 <= child_pos && child_pos <= n && insert_num > 0) {
- bi.bi_bh = tbSh;
- bi.bi_parent = PATH_H_PPARENT(tb->tb_path, h);
- bi.bi_position = PATH_H_POSITION(tb->tb_path, h + 1);
+ buffer_info_init_tbSh(tb, &bi, h);
if (child_pos == -1) {
/* this is a little different from original do_balance:
here we insert the minimal keys in the tree, that has never happened when file system works */
diff --git a/reiserfscore/lbalance.c b/reiserfscore/lbalance.c
index 493b302..fe89a65 100644
--- a/reiserfscore/lbalance.c
+++ b/reiserfscore/lbalance.c
@@ -508,52 +508,32 @@ static void leaf_define_dest_src_infos(int shift_mode, struct tree_balance *tb,
/* define dest, src, dest parent, dest position */
switch (shift_mode) {
case LEAF_FROM_S_TO_L: /* it is used in leaf_shift_left */
- src_bi->bi_bh = PATH_PLAST_BUFFER(tb->tb_path);
- src_bi->bi_parent = PATH_H_PPARENT(tb->tb_path, 0);
- src_bi->bi_position = PATH_H_B_ITEM_ORDER(tb->tb_path, 0); /* src->b_item_order */
- dest_bi->bi_bh = tb->L[0];
- dest_bi->bi_parent = tb->FL[0];
- dest_bi->bi_position = get_left_neighbor_position(tb, 0);
+ buffer_info_init_last(tb, src_bi);
+ buffer_info_init_left(tb, dest_bi, 0);
*first_last = FIRST_TO_LAST;
break;
case LEAF_FROM_S_TO_R: /* it is used in leaf_shift_right */
- src_bi->bi_bh = PATH_PLAST_BUFFER(tb->tb_path);
- src_bi->bi_parent = PATH_H_PPARENT(tb->tb_path, 0);
- src_bi->bi_position = PATH_H_B_ITEM_ORDER(tb->tb_path, 0);
- dest_bi->bi_bh = tb->R[0];
- dest_bi->bi_parent = tb->FR[0];
- dest_bi->bi_position = get_right_neighbor_position(tb, 0);
+ buffer_info_init_last(tb, src_bi);
+ buffer_info_init_right(tb, dest_bi, 0);
*first_last = LAST_TO_FIRST;
break;
case LEAF_FROM_R_TO_L: /* it is used in balance_leaf_when_delete */
- src_bi->bi_bh = tb->R[0];
- src_bi->bi_parent = tb->FR[0];
- src_bi->bi_position = get_right_neighbor_position(tb, 0);
- dest_bi->bi_bh = tb->L[0];
- dest_bi->bi_parent = tb->FL[0];
- dest_bi->bi_position = get_left_neighbor_position(tb, 0);
+ buffer_info_init_right(tb, src_bi, 0);
+ buffer_info_init_left(tb, dest_bi, 0);
*first_last = FIRST_TO_LAST;
break;
case LEAF_FROM_L_TO_R: /* it is used in balance_leaf_when_delete */
- src_bi->bi_bh = tb->L[0];
- src_bi->bi_parent = tb->FL[0];
- src_bi->bi_position = get_left_neighbor_position(tb, 0);
- dest_bi->bi_bh = tb->R[0];
- dest_bi->bi_parent = tb->FR[0];
- dest_bi->bi_position = get_right_neighbor_position(tb, 0);
+ buffer_info_init_left(tb, src_bi, 0);
+ buffer_info_init_right(tb, dest_bi, 0);
*first_last = LAST_TO_FIRST;
break;
case LEAF_FROM_S_TO_SNEW:
- src_bi->bi_bh = PATH_PLAST_BUFFER(tb->tb_path);
- src_bi->bi_parent = PATH_H_PPARENT(tb->tb_path, 0);
- src_bi->bi_position = PATH_H_B_ITEM_ORDER(tb->tb_path, 0);
- dest_bi->bi_bh = Snew;
- dest_bi->bi_parent = 0;
- dest_bi->bi_position = 0;
+ buffer_info_init_last(tb, src_bi);
+ buffer_info_init_bh(tb, dest_bi, Snew);
*first_last = LAST_TO_FIRST;
break;
@@ -1187,9 +1167,9 @@ void delete_item(reiserfs_filsys_t *fs, struct buffer_head *bh, int item_num)
{
struct buffer_info bi;
- bi.bi_bh = bh;
- bi.bi_parent = 0;
- bi.bi_position = 0;
+ buffer_info_init_bh(NULL, &bi, bh);
+ bi.bi_fs = fs;
+
leaf_delete_items_entirely(fs, &bi, item_num, 1);
}
@@ -1198,8 +1178,8 @@ void cut_entry(reiserfs_filsys_t *fs, struct buffer_head *bh,
{
struct buffer_info bi;
- bi.bi_bh = bh;
- bi.bi_parent = 0;
- bi.bi_position = 0;
+ buffer_info_init_bh(NULL, &bi, bh);
+ bi.bi_fs = fs;
+
leaf_cut_from_buffer(fs, &bi, item_num, entry_num, del_count);
}