@@ -114,7 +114,7 @@ static int balance_leaf_when_delete(struct tree_balance *tb, int flag)
114114 RFALSE (!tb -> blknum [0 ] && !PATH_H_PPARENT (tb -> tb_path , 0 ),
115115 "PAP-12010: tree can not be empty" );
116116
117- ih = B_N_PITEM_HEAD (tbS0 , item_pos );
117+ ih = item_head (tbS0 , item_pos );
118118 buffer_info_init_tbS0 (tb , & bi );
119119
120120 /* Delete or truncate the item */
@@ -312,7 +312,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
312312 /* for indirect item pos_in_item is measured in unformatted node
313313 pointers. Recalculate to bytes */
314314 if (flag != M_INSERT
315- && is_indirect_le_ih (B_N_PITEM_HEAD (tbS0 , item_pos )))
315+ && is_indirect_le_ih (item_head (tbS0 , item_pos )))
316316 pos_in_item *= UNFM_P_SIZE ;
317317
318318 if (tb -> lnum [0 ] > 0 ) {
@@ -378,7 +378,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
378378
379379 if (item_pos == tb -> lnum [0 ] - 1 && tb -> lbytes != -1 ) {
380380 /* we must shift the part of the appended item */
381- if (is_direntry_le_ih (B_N_PITEM_HEAD (tbS0 , item_pos ))) {
381+ if (is_direntry_le_ih (item_head (tbS0 , item_pos ))) {
382382
383383 RFALSE (zeros_num ,
384384 "PAP-12090: invalid parameter in case of a directory" );
@@ -391,8 +391,8 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
391391 /* Shift lnum[0] - 1 items in whole. Shift lbytes - 1 entries from given directory item */
392392 ret_val = leaf_shift_left (tb , tb -> lnum [0 ], tb -> lbytes - 1 );
393393 if (ret_val && !item_pos ) {
394- pasted = B_N_PITEM_HEAD (tb -> L [0 ], B_NR_ITEMS (tb -> L [0 ]) - 1 );
395- l_pos_in_item += I_ENTRY_COUNT (pasted ) - (tb -> lbytes - 1 );
394+ pasted = item_head (tb -> L [0 ], B_NR_ITEMS (tb -> L [0 ]) - 1 );
395+ l_pos_in_item += ih_entry_count (pasted ) - (tb -> lbytes - 1 );
396396 }
397397
398398 /* Append given directory entry to directory item */
@@ -418,9 +418,9 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
418418 } else {
419419 /* regular object */
420420 RFALSE (tb -> lbytes <= 0 , "PAP-12095: there is nothing to shift to L[0]. lbytes=%d" , tb -> lbytes );
421- RFALSE (pos_in_item != ih_item_len (B_N_PITEM_HEAD (tbS0 , item_pos )),
421+ RFALSE (pos_in_item != ih_item_len (item_head (tbS0 , item_pos )),
422422 "PAP-12100: incorrect position to paste: item_len=%d, pos_in_item=%d" ,
423- ih_item_len (B_N_PITEM_HEAD (tbS0 , item_pos )),pos_in_item );
423+ ih_item_len (item_head (tbS0 , item_pos )),pos_in_item );
424424
425425 if (tb -> lbytes >= pos_in_item ) {
426426 /* appended item will be in L[0] in whole */
@@ -436,34 +436,34 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
436436 "PAP-12105: there is nothing to paste into L[0]. insert_size=%d" ,
437437 tb -> insert_size [0 ]);
438438 ret_val = leaf_shift_left (tb , tb -> lnum [0 ], ih_item_len
439- (B_N_PITEM_HEAD (tbS0 , item_pos )));
439+ (item_head (tbS0 , item_pos )));
440440 /* Append to body of item in L[0] */
441441 buffer_info_init_left (tb , & bi );
442442 leaf_paste_in_buffer
443443 (& bi , n + item_pos - ret_val , ih_item_len
444- (B_N_PITEM_HEAD (tb -> L [0 ], n + item_pos - ret_val )),
444+ (item_head (tb -> L [0 ], n + item_pos - ret_val )),
445445 l_n , body ,
446446 zeros_num > l_n ? l_n : zeros_num );
447447 /* 0-th item in S0 can be only of DIRECT type when l_n != 0 */
448448 {
449449 int version ;
450450 int temp_l = l_n ;
451451
452- RFALSE (ih_item_len (B_N_PITEM_HEAD (tbS0 , 0 )),
452+ RFALSE (ih_item_len (item_head (tbS0 , 0 )),
453453 "PAP-12106: item length must be 0" );
454- RFALSE (comp_short_le_keys (B_N_PKEY (tbS0 , 0 ), B_N_PKEY
454+ RFALSE (comp_short_le_keys (leaf_key (tbS0 , 0 ), leaf_key
455455 (tb -> L [0 ], n + item_pos - ret_val )),
456456 "PAP-12107: items must be of the same file" );
457- if (is_indirect_le_ih (B_N_PITEM_HEAD (tb -> L [0 ], n + item_pos - ret_val ))) {
457+ if (is_indirect_le_ih (item_head (tb -> L [0 ], n + item_pos - ret_val ))) {
458458 temp_l = l_n << (tb -> tb_sb -> s_blocksize_bits - UNFM_P_SHIFT );
459459 }
460460 /* update key of first item in S0 */
461- version = ih_version (B_N_PITEM_HEAD (tbS0 , 0 ));
462- set_le_key_k_offset (version , B_N_PKEY (tbS0 , 0 ),
463- le_key_k_offset (version ,B_N_PKEY (tbS0 , 0 )) + temp_l );
461+ version = ih_version (item_head (tbS0 , 0 ));
462+ set_le_key_k_offset (version , leaf_key (tbS0 , 0 ),
463+ le_key_k_offset (version ,leaf_key (tbS0 , 0 )) + temp_l );
464464 /* update left delimiting key */
465- set_le_key_k_offset (version , B_N_PDELIM_KEY (tb -> CFL [0 ], tb -> lkey [0 ]),
466- le_key_k_offset (version , B_N_PDELIM_KEY (tb -> CFL [0 ], tb -> lkey [0 ])) + temp_l );
465+ set_le_key_k_offset (version , internal_key (tb -> CFL [0 ], tb -> lkey [0 ]),
466+ le_key_k_offset (version , internal_key (tb -> CFL [0 ], tb -> lkey [0 ])) + temp_l );
467467 }
468468
469469 /* Calculate new body, position in item and insert_size[0] */
@@ -474,9 +474,9 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
474474 zeros_num -= l_n ;
475475 pos_in_item = 0 ;
476476
477- RFALSE (comp_short_le_keys (B_N_PKEY (tbS0 , 0 ), B_N_PKEY (tb -> L [0 ], B_NR_ITEMS (tb -> L [0 ]) - 1 ))
478- || !op_is_left_mergeable (B_N_PKEY (tbS0 , 0 ), tbS0 -> b_size )
479- || !op_is_left_mergeable (B_N_PDELIM_KEY (tb -> CFL [0 ], tb -> lkey [0 ]), tbS0 -> b_size ),
477+ RFALSE (comp_short_le_keys (leaf_key (tbS0 , 0 ), leaf_key (tb -> L [0 ], B_NR_ITEMS (tb -> L [0 ]) - 1 ))
478+ || !op_is_left_mergeable (leaf_key (tbS0 , 0 ), tbS0 -> b_size )
479+ || !op_is_left_mergeable (internal_key (tb -> CFL [0 ], tb -> lkey [0 ]), tbS0 -> b_size ),
480480 "PAP-12120: item must be merge-able with left neighboring item" );
481481 } else { /* only part of the appended item will be in L[0] */
482482
@@ -493,9 +493,9 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
493493
494494 struct item_head * pasted ;
495495
496- if (!item_pos && op_is_left_mergeable (B_N_PKEY (tbS0 , 0 ), tbS0 -> b_size )) { /* if we paste into first item of S[0] and it is left mergable */
496+ if (!item_pos && op_is_left_mergeable (leaf_key (tbS0 , 0 ), tbS0 -> b_size )) { /* if we paste into first item of S[0] and it is left mergable */
497497 /* then increment pos_in_item by the size of the last item in L[0] */
498- pasted = B_N_PITEM_HEAD (tb -> L [0 ], n - 1 );
498+ pasted = item_head (tb -> L [0 ], n - 1 );
499499 if (is_direntry_le_ih (pasted ))
500500 pos_in_item += ih_entry_count (pasted );
501501 else
@@ -512,7 +512,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
512512 body , zeros_num );
513513
514514 /* if appended item is directory, paste entry */
515- pasted = B_N_PITEM_HEAD (tb -> L [0 ], n + item_pos - ret_val );
515+ pasted = item_head (tb -> L [0 ], n + item_pos - ret_val );
516516 if (is_direntry_le_ih (pasted ))
517517 leaf_paste_entries (& bi , n + item_pos - ret_val ,
518518 pos_in_item , 1 ,
@@ -617,12 +617,12 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
617617
618618 if (n - tb -> rnum [0 ] <= item_pos ) { /* pasted item or part of it falls to R[0] */
619619 if (item_pos == n - tb -> rnum [0 ] && tb -> rbytes != -1 ) { /* we must shift the part of the appended item */
620- if (is_direntry_le_ih (B_N_PITEM_HEAD (tbS0 , item_pos ))) { /* we append to directory item */
620+ if (is_direntry_le_ih (item_head (tbS0 , item_pos ))) { /* we append to directory item */
621621 int entry_count ;
622622
623623 RFALSE (zeros_num ,
624624 "PAP-12145: invalid parameter in case of a directory" );
625- entry_count = I_ENTRY_COUNT ( B_N_PITEM_HEAD
625+ entry_count = ih_entry_count ( item_head
626626 (tbS0 , item_pos ));
627627 if (entry_count - tb -> rbytes <
628628 pos_in_item )
@@ -665,10 +665,10 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
665665 n_shift = 0 ;
666666
667667 RFALSE (pos_in_item != ih_item_len
668- (B_N_PITEM_HEAD (tbS0 , item_pos )),
668+ (item_head (tbS0 , item_pos )),
669669 "PAP-12155: invalid position to paste. ih_item_len=%d, pos_in_item=%d" ,
670670 pos_in_item , ih_item_len
671- (B_N_PITEM_HEAD (tbS0 , item_pos )));
671+ (item_head (tbS0 , item_pos )));
672672
673673 leaf_shift_right (tb , tb -> rnum [0 ], n_shift );
674674 /* Calculate number of bytes which must remain in body after appending to R[0] */
@@ -679,17 +679,17 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
679679 int version ;
680680 unsigned long temp_rem = n_rem ;
681681
682- version = ih_version (B_N_PITEM_HEAD (tb -> R [0 ], 0 ));
683- if (is_indirect_le_key (version , B_N_PKEY (tb -> R [0 ], 0 ))) {
682+ version = ih_version (item_head (tb -> R [0 ], 0 ));
683+ if (is_indirect_le_key (version , leaf_key (tb -> R [0 ], 0 ))) {
684684 temp_rem = n_rem << (tb -> tb_sb -> s_blocksize_bits - UNFM_P_SHIFT );
685685 }
686- set_le_key_k_offset (version , B_N_PKEY (tb -> R [0 ], 0 ),
687- le_key_k_offset (version , B_N_PKEY (tb -> R [0 ], 0 )) + temp_rem );
688- set_le_key_k_offset (version , B_N_PDELIM_KEY (tb -> CFR [0 ], tb -> rkey [0 ]),
689- le_key_k_offset (version , B_N_PDELIM_KEY (tb -> CFR [0 ], tb -> rkey [0 ])) + temp_rem );
686+ set_le_key_k_offset (version , leaf_key (tb -> R [0 ], 0 ),
687+ le_key_k_offset (version , leaf_key (tb -> R [0 ], 0 )) + temp_rem );
688+ set_le_key_k_offset (version , internal_key (tb -> CFR [0 ], tb -> rkey [0 ]),
689+ le_key_k_offset (version , internal_key (tb -> CFR [0 ], tb -> rkey [0 ])) + temp_rem );
690690 }
691- /* k_offset (B_N_PKEY (tb->R[0],0)) += n_rem;
692- k_offset (B_N_PDELIM_KEY (tb->CFR[0],tb->rkey[0])) += n_rem;*/
691+ /* k_offset (leaf_key (tb->R[0],0)) += n_rem;
692+ k_offset (internal_key (tb->CFR[0],tb->rkey[0])) += n_rem;*/
693693 do_balance_mark_internal_dirty (tb , tb -> CFR [0 ], 0 );
694694
695695 /* Append part of body into R[0] */
@@ -707,12 +707,12 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
707707 tb -> insert_size [0 ] - n_rem ,
708708 r_body , r_zeros_number );
709709
710- if (is_indirect_le_ih (B_N_PITEM_HEAD (tb -> R [0 ], 0 ))) {
710+ if (is_indirect_le_ih (item_head (tb -> R [0 ], 0 ))) {
711711#if 0
712712 RFALSE (n_rem ,
713713 "PAP-12160: paste more than one unformatted node pointer" );
714714#endif
715- set_ih_free_space (B_N_PITEM_HEAD (tb -> R [0 ], 0 ), 0 );
715+ set_ih_free_space (item_head (tb -> R [0 ], 0 ), 0 );
716716 }
717717 tb -> insert_size [0 ] = n_rem ;
718718 if (!n_rem )
@@ -731,7 +731,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
731731 }
732732
733733 /* paste new entry, if item is directory item */
734- pasted = B_N_PITEM_HEAD (tb -> R [0 ], item_pos - n + tb -> rnum [0 ]);
734+ pasted = item_head (tb -> R [0 ], item_pos - n + tb -> rnum [0 ]);
735735 if (is_direntry_le_ih (pasted ) && pos_in_item >= 0 ) {
736736 leaf_paste_entries (& bi , item_pos - n + tb -> rnum [0 ],
737737 pos_in_item , 1 ,
@@ -784,8 +784,8 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
784784 if (!tb -> CFR [0 ])
785785 reiserfs_panic (tb -> tb_sb , "vs-12195" ,
786786 "CFR not initialized" );
787- copy_key (B_N_PDELIM_KEY (tb -> CFL [0 ], tb -> lkey [0 ]),
788- B_N_PDELIM_KEY (tb -> CFR [0 ], tb -> rkey [0 ]));
787+ copy_key (internal_key (tb -> CFL [0 ], tb -> lkey [0 ]),
788+ internal_key (tb -> CFR [0 ], tb -> rkey [0 ]));
789789 do_balance_mark_internal_dirty (tb , tb -> CFL [0 ], 0 );
790790 }
791791
@@ -886,7 +886,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
886886
887887 RFALSE (ih , "PAP-12210: ih must be 0" );
888888
889- aux_ih = B_N_PITEM_HEAD (tbS0 , item_pos );
889+ aux_ih = item_head (tbS0 , item_pos );
890890 if (is_direntry_le_ih (aux_ih )) {
891891 /* we append to directory item */
892892
@@ -922,7 +922,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
922922 int n_shift , n_rem , r_zeros_number ;
923923 const char * r_body ;
924924
925- RFALSE (pos_in_item != ih_item_len (B_N_PITEM_HEAD (tbS0 , item_pos )) || tb -> insert_size [0 ] <= 0 ,
925+ RFALSE (pos_in_item != ih_item_len (item_head (tbS0 , item_pos )) || tb -> insert_size [0 ] <= 0 ,
926926 "PAP-12225: item too short or insert_size <= 0" );
927927
928928 /* Calculate number of bytes which must be shifted from appended item */
@@ -952,7 +952,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
952952 {
953953 struct item_head * tmp ;
954954
955- tmp = B_N_PITEM_HEAD (S_new [i ], 0 );
955+ tmp = item_head (S_new [i ], 0 );
956956 if (is_indirect_le_ih
957957 (tmp )) {
958958 set_ih_free_space (tmp , 0 );
@@ -973,7 +973,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
973973 struct item_head * pasted ;
974974
975975#ifdef CONFIG_REISERFS_CHECK
976- struct item_head * ih_check = B_N_PITEM_HEAD (tbS0 , item_pos );
976+ struct item_head * ih_check = item_head (tbS0 , item_pos );
977977
978978 if (!is_direntry_le_ih (ih_check )
979979 && (pos_in_item != ih_item_len (ih_check )
@@ -1002,7 +1002,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
10021002 tb -> insert_size [0 ],
10031003 body , zeros_num );
10041004
1005- pasted = B_N_PITEM_HEAD (S_new [i ], item_pos - n + snum [i ]);
1005+ pasted = item_head (S_new [i ], item_pos - n + snum [i ]);
10061006 if (is_direntry_le_ih (pasted )) {
10071007 leaf_paste_entries (& bi ,
10081008 item_pos - n + snum [i ],
@@ -1032,7 +1032,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
10321032 (flag == M_DELETE ) ? "DELETE" : ((flag == M_CUT ) ? "CUT" : "UNKNOWN" ), flag );
10331033 }
10341034
1035- memcpy (insert_key + i , B_N_PKEY (S_new [i ], 0 ), KEY_SIZE );
1035+ memcpy (insert_key + i , leaf_key (S_new [i ], 0 ), KEY_SIZE );
10361036 insert_ptr [i ] = S_new [i ];
10371037
10381038 RFALSE (!buffer_journaled (S_new [i ])
@@ -1061,7 +1061,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
10611061 case M_PASTE :{ /* append item in S[0] */
10621062 struct item_head * pasted ;
10631063
1064- pasted = B_N_PITEM_HEAD (tbS0 , item_pos );
1064+ pasted = item_head (tbS0 , item_pos );
10651065 /* when directory, may be new entry already pasted */
10661066 if (is_direntry_le_ih (pasted )) {
10671067 if (pos_in_item >= 0 && pos_in_item <= ih_entry_count (pasted )) {
@@ -1246,10 +1246,10 @@ void replace_key(struct tree_balance *tb, struct buffer_head *dest, int n_dest,
12461246
12471247 if (B_IS_ITEMS_LEVEL (src ))
12481248 /* source buffer contains leaf node */
1249- memcpy (B_N_PDELIM_KEY (dest , n_dest ), B_N_PITEM_HEAD (src , n_src ),
1249+ memcpy (internal_key (dest , n_dest ), item_head (src , n_src ),
12501250 KEY_SIZE );
12511251 else
1252- memcpy (B_N_PDELIM_KEY (dest , n_dest ), B_N_PDELIM_KEY (src , n_src ),
1252+ memcpy (internal_key (dest , n_dest ), internal_key (src , n_src ),
12531253 KEY_SIZE );
12541254
12551255 do_balance_mark_internal_dirty (tb , dest , 0 );
0 commit comments