diff options
author | Jeff Mahoney <jeffm@suse.com> | 2014-04-23 10:00:35 -0400 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2014-05-06 16:51:44 -0400 |
commit | 4cf5f7addf18ecae2ea49b11944976cbd26d5281 (patch) | |
tree | 52aa9ebf68e7951bacbdc708f1d19467736187bc | |
parent | 797d9016ceca69879bb273218810fa0beef46aac (diff) |
reiserfs: cleanup, rename key and item accessors to more friendly names
This patch does a quick search and replace:
B_N_PITEM_HEAD() -> item_head()
B_N_PDELIM_KEY() -> internal_key()
B_N_PKEY() -> leaf_key()
B_N_PITEM() -> item_body()
And the item_head version:
B_I_PITEM() -> ih_item_body()
I_ENTRY_COUNT() -> ih_entry_count()
And the treepath variants:
get_ih() -> tp_item_head()
PATH_PITEM_HEAD() -> tp_item_head()
get_item() -> tp_item_body()
... which makes the code much easier on the eyes.
I've also removed a few unused macros.
Checkpatch will complain about the 80 character limit for do_balan.c.
I've addressed that in a later patchset to split up balance_leaf().
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r-- | fs/reiserfs/bitmap.c | 4 | ||||
-rw-r--r-- | fs/reiserfs/dir.c | 8 | ||||
-rw-r--r-- | fs/reiserfs/do_balan.c | 98 | ||||
-rw-r--r-- | fs/reiserfs/fix_node.c | 20 | ||||
-rw-r--r-- | fs/reiserfs/ibalance.c | 20 | ||||
-rw-r--r-- | fs/reiserfs/inode.c | 36 | ||||
-rw-r--r-- | fs/reiserfs/item_ops.c | 4 | ||||
-rw-r--r-- | fs/reiserfs/lbalance.c | 76 | ||||
-rw-r--r-- | fs/reiserfs/namei.c | 14 | ||||
-rw-r--r-- | fs/reiserfs/prints.c | 10 | ||||
-rw-r--r-- | fs/reiserfs/reiserfs.h | 175 | ||||
-rw-r--r-- | fs/reiserfs/stree.c | 44 | ||||
-rw-r--r-- | fs/reiserfs/super.c | 4 | ||||
-rw-r--r-- | fs/reiserfs/tail_conversion.c | 10 |
14 files changed, 284 insertions, 239 deletions
diff --git a/fs/reiserfs/bitmap.c b/fs/reiserfs/bitmap.c index dc9a6829f7c6..c3de6501a5cb 100644 --- a/fs/reiserfs/bitmap.c +++ b/fs/reiserfs/bitmap.c | |||
@@ -819,9 +819,9 @@ static int get_left_neighbor(reiserfs_blocknr_hint_t * hint) | |||
819 | path = hint->path; | 819 | path = hint->path; |
820 | bh = get_last_bh(path); | 820 | bh = get_last_bh(path); |
821 | RFALSE(!bh, "green-4002: Illegal path specified to get_left_neighbor"); | 821 | RFALSE(!bh, "green-4002: Illegal path specified to get_left_neighbor"); |
822 | ih = get_ih(path); | 822 | ih = tp_item_head(path); |
823 | pos_in_item = path->pos_in_item; | 823 | pos_in_item = path->pos_in_item; |
824 | item = get_item(path); | 824 | item = tp_item_body(path); |
825 | 825 | ||
826 | hint->search_start = bh->b_blocknr; | 826 | hint->search_start = bh->b_blocknr; |
827 | 827 | ||
diff --git a/fs/reiserfs/dir.c b/fs/reiserfs/dir.c index af677353a3f5..1fe5cdeb5862 100644 --- a/fs/reiserfs/dir.c +++ b/fs/reiserfs/dir.c | |||
@@ -110,17 +110,17 @@ int reiserfs_readdir_inode(struct inode *inode, struct dir_context *ctx) | |||
110 | item_num, B_NR_ITEMS(bh)); | 110 | item_num, B_NR_ITEMS(bh)); |
111 | 111 | ||
112 | /* and entry must be not more than number of entries in the item */ | 112 | /* and entry must be not more than number of entries in the item */ |
113 | RFALSE(I_ENTRY_COUNT(ih) < entry_num, | 113 | RFALSE(ih_entry_count(ih) < entry_num, |
114 | "vs-9010: entry number is too big %d (%d)", | 114 | "vs-9010: entry number is too big %d (%d)", |
115 | entry_num, I_ENTRY_COUNT(ih)); | 115 | entry_num, ih_entry_count(ih)); |
116 | 116 | ||
117 | if (search_res == POSITION_FOUND | 117 | if (search_res == POSITION_FOUND |
118 | || entry_num < I_ENTRY_COUNT(ih)) { | 118 | || entry_num < ih_entry_count(ih)) { |
119 | /* go through all entries in the directory item beginning from the entry, that has been found */ | 119 | /* go through all entries in the directory item beginning from the entry, that has been found */ |
120 | struct reiserfs_de_head *deh = | 120 | struct reiserfs_de_head *deh = |
121 | B_I_DEH(bh, ih) + entry_num; | 121 | B_I_DEH(bh, ih) + entry_num; |
122 | 122 | ||
123 | for (; entry_num < I_ENTRY_COUNT(ih); | 123 | for (; entry_num < ih_entry_count(ih); |
124 | entry_num++, deh++) { | 124 | entry_num++, deh++) { |
125 | int d_reclen; | 125 | int d_reclen; |
126 | char *d_name; | 126 | char *d_name; |
diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c index 9a3c68cf6026..80b2b1b37169 100644 --- a/fs/reiserfs/do_balan.c +++ b/fs/reiserfs/do_balan.c | |||
@@ -114,7 +114,7 @@ static int balance_leaf_when_delete(struct tree_balance *tb, int flag) | |||
114 | RFALSE(!tb->blknum[0] && !PATH_H_PPARENT(tb->tb_path, 0), | 114 | RFALSE(!tb->blknum[0] && !PATH_H_PPARENT(tb->tb_path, 0), |
115 | "PAP-12010: tree can not be empty"); | 115 | "PAP-12010: tree can not be empty"); |
116 | 116 | ||
117 | ih = B_N_PITEM_HEAD(tbS0, item_pos); | 117 | ih = item_head(tbS0, item_pos); |
118 | buffer_info_init_tbS0(tb, &bi); | 118 | buffer_info_init_tbS0(tb, &bi); |
119 | 119 | ||
120 | /* Delete or truncate the item */ | 120 | /* Delete or truncate the item */ |
@@ -312,7 +312,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h | |||
312 | /* for indirect item pos_in_item is measured in unformatted node | 312 | /* for indirect item pos_in_item is measured in unformatted node |
313 | pointers. Recalculate to bytes */ | 313 | pointers. Recalculate to bytes */ |
314 | if (flag != M_INSERT | 314 | 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))) |
316 | pos_in_item *= UNFM_P_SIZE; | 316 | pos_in_item *= UNFM_P_SIZE; |
317 | 317 | ||
318 | if (tb->lnum[0] > 0) { | 318 | if (tb->lnum[0] > 0) { |
@@ -378,7 +378,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h | |||
378 | 378 | ||
379 | if (item_pos == tb->lnum[0] - 1 && tb->lbytes != -1) { | 379 | if (item_pos == tb->lnum[0] - 1 && tb->lbytes != -1) { |
380 | /* we must shift the part of the appended item */ | 380 | /* 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))) { |
382 | 382 | ||
383 | RFALSE(zeros_num, | 383 | RFALSE(zeros_num, |
384 | "PAP-12090: invalid parameter in case of a directory"); | 384 | "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 | |||
391 | /* Shift lnum[0] - 1 items in whole. Shift lbytes - 1 entries from given directory item */ | 391 | /* Shift lnum[0] - 1 items in whole. Shift lbytes - 1 entries from given directory item */ |
392 | ret_val = leaf_shift_left(tb, tb->lnum[0], tb->lbytes-1); | 392 | ret_val = leaf_shift_left(tb, tb->lnum[0], tb->lbytes-1); |
393 | if (ret_val && !item_pos) { | 393 | if (ret_val && !item_pos) { |
394 | pasted = B_N_PITEM_HEAD(tb->L[0], B_NR_ITEMS(tb->L[0]) - 1); | 394 | pasted = item_head(tb->L[0], B_NR_ITEMS(tb->L[0]) - 1); |
395 | l_pos_in_item += I_ENTRY_COUNT(pasted) - (tb->lbytes -1); | 395 | l_pos_in_item += ih_entry_count(pasted) - (tb->lbytes -1); |
396 | } | 396 | } |
397 | 397 | ||
398 | /* Append given directory entry to directory item */ | 398 | /* 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 | |||
418 | } else { | 418 | } else { |
419 | /* regular object */ | 419 | /* regular object */ |
420 | RFALSE(tb->lbytes <= 0, "PAP-12095: there is nothing to shift to L[0]. lbytes=%d", tb->lbytes); | 420 | 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)), |
422 | "PAP-12100: incorrect position to paste: item_len=%d, pos_in_item=%d", | 422 | "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); |
424 | 424 | ||
425 | if (tb->lbytes >= pos_in_item) { | 425 | if (tb->lbytes >= pos_in_item) { |
426 | /* appended item will be in L[0] in whole */ | 426 | /* appended item will be in L[0] in whole */ |
@@ -436,12 +436,12 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h | |||
436 | "PAP-12105: there is nothing to paste into L[0]. insert_size=%d", | 436 | "PAP-12105: there is nothing to paste into L[0]. insert_size=%d", |
437 | tb->insert_size[0]); | 437 | tb->insert_size[0]); |
438 | ret_val = leaf_shift_left(tb, tb->lnum[0], ih_item_len | 438 | 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))); |
440 | /* Append to body of item in L[0] */ | 440 | /* Append to body of item in L[0] */ |
441 | buffer_info_init_left(tb, &bi); | 441 | buffer_info_init_left(tb, &bi); |
442 | leaf_paste_in_buffer | 442 | leaf_paste_in_buffer |
443 | (&bi, n + item_pos - ret_val, ih_item_len | 443 | (&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)), |
445 | l_n, body, | 445 | l_n, body, |
446 | zeros_num > l_n ? l_n : zeros_num); | 446 | zeros_num > l_n ? l_n : zeros_num); |
447 | /* 0-th item in S0 can be only of DIRECT type when l_n != 0 */ | 447 | /* 0-th item in S0 can be only of DIRECT type when l_n != 0 */ |
@@ -449,21 +449,21 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h | |||
449 | int version; | 449 | int version; |
450 | int temp_l = l_n; | 450 | int temp_l = l_n; |
451 | 451 | ||
452 | RFALSE(ih_item_len(B_N_PITEM_HEAD(tbS0, 0)), | 452 | RFALSE(ih_item_len(item_head(tbS0, 0)), |
453 | "PAP-12106: item length must be 0"); | 453 | "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 |
455 | (tb->L[0], n + item_pos - ret_val)), | 455 | (tb->L[0], n + item_pos - ret_val)), |
456 | "PAP-12107: items must be of the same file"); | 456 | "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))) { |
458 | temp_l = l_n << (tb->tb_sb-> s_blocksize_bits - UNFM_P_SHIFT); | 458 | temp_l = l_n << (tb->tb_sb-> s_blocksize_bits - UNFM_P_SHIFT); |
459 | } | 459 | } |
460 | /* update key of first item in S0 */ | 460 | /* update key of first item in S0 */ |
461 | version = ih_version(B_N_PITEM_HEAD(tbS0, 0)); | 461 | version = ih_version(item_head(tbS0, 0)); |
462 | set_le_key_k_offset(version, B_N_PKEY(tbS0, 0), | 462 | set_le_key_k_offset(version, leaf_key(tbS0, 0), |
463 | le_key_k_offset(version,B_N_PKEY(tbS0, 0)) + temp_l); | 463 | le_key_k_offset(version,leaf_key(tbS0, 0)) + temp_l); |
464 | /* update left delimiting key */ | 464 | /* update left delimiting key */ |
465 | set_le_key_k_offset(version, B_N_PDELIM_KEY(tb->CFL[0], tb->lkey[0]), | 465 | set_le_key_k_offset(version, internal_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); | 466 | le_key_k_offset(version, internal_key(tb->CFL[0], tb->lkey[0])) + temp_l); |
467 | } | 467 | } |
468 | 468 | ||
469 | /* Calculate new body, position in item and insert_size[0] */ | 469 | /* 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 | |||
474 | zeros_num -= l_n; | 474 | zeros_num -= l_n; |
475 | pos_in_item = 0; | 475 | pos_in_item = 0; |
476 | 476 | ||
477 | RFALSE(comp_short_le_keys(B_N_PKEY(tbS0, 0), B_N_PKEY(tb->L[0], B_NR_ITEMS(tb->L[0]) - 1)) | 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(B_N_PKEY(tbS0, 0), tbS0->b_size) | 478 | || !op_is_left_mergeable(leaf_key(tbS0, 0), tbS0->b_size) |
479 | || !op_is_left_mergeable(B_N_PDELIM_KEY(tb->CFL[0], tb->lkey[0]), tbS0->b_size), | 479 | || !op_is_left_mergeable(internal_key(tb->CFL[0], tb->lkey[0]), tbS0->b_size), |
480 | "PAP-12120: item must be merge-able with left neighboring item"); | 480 | "PAP-12120: item must be merge-able with left neighboring item"); |
481 | } else { /* only part of the appended item will be in L[0] */ | 481 | } else { /* only part of the appended item will be in L[0] */ |
482 | 482 | ||
@@ -493,9 +493,9 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h | |||
493 | 493 | ||
494 | struct item_head *pasted; | 494 | struct item_head *pasted; |
495 | 495 | ||
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 */ |
497 | /* then increment pos_in_item by the size of the last item in L[0] */ | 497 | /* 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); |
499 | if (is_direntry_le_ih(pasted)) | 499 | if (is_direntry_le_ih(pasted)) |
500 | pos_in_item += ih_entry_count(pasted); | 500 | pos_in_item += ih_entry_count(pasted); |
501 | else | 501 | else |
@@ -512,7 +512,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h | |||
512 | body, zeros_num); | 512 | body, zeros_num); |
513 | 513 | ||
514 | /* if appended item is directory, paste entry */ | 514 | /* 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); |
516 | if (is_direntry_le_ih(pasted)) | 516 | if (is_direntry_le_ih(pasted)) |
517 | leaf_paste_entries(&bi, n + item_pos - ret_val, | 517 | leaf_paste_entries(&bi, n + item_pos - ret_val, |
518 | pos_in_item, 1, | 518 | pos_in_item, 1, |
@@ -617,12 +617,12 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h | |||
617 | 617 | ||
618 | if (n - tb->rnum[0] <= item_pos) { /* pasted item or part of it falls to R[0] */ | 618 | if (n - tb->rnum[0] <= item_pos) { /* pasted item or part of it falls to R[0] */ |
619 | if (item_pos == n - tb->rnum[0] && tb->rbytes != -1) { /* we must shift the part of the appended item */ | 619 | 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 */ |
621 | int entry_count; | 621 | int entry_count; |
622 | 622 | ||
623 | RFALSE(zeros_num, | 623 | RFALSE(zeros_num, |
624 | "PAP-12145: invalid parameter in case of a directory"); | 624 | "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 |
626 | (tbS0, item_pos)); | 626 | (tbS0, item_pos)); |
627 | if (entry_count - tb->rbytes < | 627 | if (entry_count - tb->rbytes < |
628 | pos_in_item) | 628 | pos_in_item) |
@@ -665,10 +665,10 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h | |||
665 | n_shift = 0; | 665 | n_shift = 0; |
666 | 666 | ||
667 | RFALSE(pos_in_item != ih_item_len | 667 | RFALSE(pos_in_item != ih_item_len |
668 | (B_N_PITEM_HEAD(tbS0, item_pos)), | 668 | (item_head(tbS0, item_pos)), |
669 | "PAP-12155: invalid position to paste. ih_item_len=%d, pos_in_item=%d", | 669 | "PAP-12155: invalid position to paste. ih_item_len=%d, pos_in_item=%d", |
670 | pos_in_item, ih_item_len | 670 | pos_in_item, ih_item_len |
671 | (B_N_PITEM_HEAD(tbS0, item_pos))); | 671 | (item_head(tbS0, item_pos))); |
672 | 672 | ||
673 | leaf_shift_right(tb, tb->rnum[0], n_shift); | 673 | leaf_shift_right(tb, tb->rnum[0], n_shift); |
674 | /* Calculate number of bytes which must remain in body after appending to R[0] */ | 674 | /* 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 | |||
679 | int version; | 679 | int version; |
680 | unsigned long temp_rem = n_rem; | 680 | unsigned long temp_rem = n_rem; |
681 | 681 | ||
682 | version = ih_version(B_N_PITEM_HEAD(tb->R[0], 0)); | 682 | version = ih_version(item_head(tb->R[0], 0)); |
683 | if (is_indirect_le_key(version, B_N_PKEY(tb->R[0], 0))) { | 683 | if (is_indirect_le_key(version, leaf_key(tb->R[0], 0))) { |
684 | temp_rem = n_rem << (tb->tb_sb->s_blocksize_bits - UNFM_P_SHIFT); | 684 | temp_rem = n_rem << (tb->tb_sb->s_blocksize_bits - UNFM_P_SHIFT); |
685 | } | 685 | } |
686 | set_le_key_k_offset(version, B_N_PKEY(tb->R[0], 0), | 686 | set_le_key_k_offset(version, leaf_key(tb->R[0], 0), |
687 | le_key_k_offset(version, B_N_PKEY(tb->R[0], 0)) + temp_rem); | 687 | le_key_k_offset(version, leaf_key(tb->R[0], 0)) + temp_rem); |
688 | set_le_key_k_offset(version, B_N_PDELIM_KEY(tb->CFR[0], tb->rkey[0]), | 688 | set_le_key_k_offset(version, internal_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); | 689 | le_key_k_offset(version, internal_key(tb->CFR[0], tb->rkey[0])) + temp_rem); |
690 | } | 690 | } |
691 | /* k_offset (B_N_PKEY(tb->R[0],0)) += n_rem; | 691 | /* k_offset (leaf_key(tb->R[0],0)) += n_rem; |
692 | k_offset (B_N_PDELIM_KEY(tb->CFR[0],tb->rkey[0])) += n_rem;*/ | 692 | k_offset (internal_key(tb->CFR[0],tb->rkey[0])) += n_rem;*/ |
693 | do_balance_mark_internal_dirty(tb, tb->CFR[0], 0); | 693 | do_balance_mark_internal_dirty(tb, tb->CFR[0], 0); |
694 | 694 | ||
695 | /* Append part of body into R[0] */ | 695 | /* 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 | |||
707 | tb->insert_size[0] - n_rem, | 707 | tb->insert_size[0] - n_rem, |
708 | r_body, r_zeros_number); | 708 | r_body, r_zeros_number); |
709 | 709 | ||
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))) { |
711 | #if 0 | 711 | #if 0 |
712 | RFALSE(n_rem, | 712 | RFALSE(n_rem, |
713 | "PAP-12160: paste more than one unformatted node pointer"); | 713 | "PAP-12160: paste more than one unformatted node pointer"); |
714 | #endif | 714 | #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); |
716 | } | 716 | } |
717 | tb->insert_size[0] = n_rem; | 717 | tb->insert_size[0] = n_rem; |
718 | if (!n_rem) | 718 | if (!n_rem) |
@@ -731,7 +731,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h | |||
731 | } | 731 | } |
732 | 732 | ||
733 | /* paste new entry, if item is directory item */ | 733 | /* 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]); |
735 | if (is_direntry_le_ih(pasted) && pos_in_item >= 0) { | 735 | if (is_direntry_le_ih(pasted) && pos_in_item >= 0) { |
736 | leaf_paste_entries(&bi, item_pos - n + tb->rnum[0], | 736 | leaf_paste_entries(&bi, item_pos - n + tb->rnum[0], |
737 | pos_in_item, 1, | 737 | pos_in_item, 1, |
@@ -784,8 +784,8 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h | |||
784 | if (!tb->CFR[0]) | 784 | if (!tb->CFR[0]) |
785 | reiserfs_panic(tb->tb_sb, "vs-12195", | 785 | reiserfs_panic(tb->tb_sb, "vs-12195", |
786 | "CFR not initialized"); | 786 | "CFR not initialized"); |
787 | copy_key(B_N_PDELIM_KEY(tb->CFL[0], tb->lkey[0]), | 787 | copy_key(internal_key(tb->CFL[0], tb->lkey[0]), |
788 | B_N_PDELIM_KEY(tb->CFR[0], tb->rkey[0])); | 788 | internal_key(tb->CFR[0], tb->rkey[0])); |
789 | do_balance_mark_internal_dirty(tb, tb->CFL[0], 0); | 789 | do_balance_mark_internal_dirty(tb, tb->CFL[0], 0); |
790 | } | 790 | } |
791 | 791 | ||
@@ -886,7 +886,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h | |||
886 | 886 | ||
887 | RFALSE(ih, "PAP-12210: ih must be 0"); | 887 | RFALSE(ih, "PAP-12210: ih must be 0"); |
888 | 888 | ||
889 | aux_ih = B_N_PITEM_HEAD(tbS0, item_pos); | 889 | aux_ih = item_head(tbS0, item_pos); |
890 | if (is_direntry_le_ih(aux_ih)) { | 890 | if (is_direntry_le_ih(aux_ih)) { |
891 | /* we append to directory item */ | 891 | /* we append to directory item */ |
892 | 892 | ||
@@ -922,7 +922,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h | |||
922 | int n_shift, n_rem, r_zeros_number; | 922 | int n_shift, n_rem, r_zeros_number; |
923 | const char *r_body; | 923 | const char *r_body; |
924 | 924 | ||
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, |
926 | "PAP-12225: item too short or insert_size <= 0"); | 926 | "PAP-12225: item too short or insert_size <= 0"); |
927 | 927 | ||
928 | /* Calculate number of bytes which must be shifted from appended item */ | 928 | /* 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 | |||
952 | { | 952 | { |
953 | struct item_head *tmp; | 953 | struct item_head *tmp; |
954 | 954 | ||
955 | tmp = B_N_PITEM_HEAD(S_new[i], 0); | 955 | tmp = item_head(S_new[i], 0); |
956 | if (is_indirect_le_ih | 956 | if (is_indirect_le_ih |
957 | (tmp)) { | 957 | (tmp)) { |
958 | set_ih_free_space(tmp, 0); | 958 | set_ih_free_space(tmp, 0); |
@@ -973,7 +973,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h | |||
973 | struct item_head *pasted; | 973 | struct item_head *pasted; |
974 | 974 | ||
975 | #ifdef CONFIG_REISERFS_CHECK | 975 | #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); |
977 | 977 | ||
978 | if (!is_direntry_le_ih(ih_check) | 978 | if (!is_direntry_le_ih(ih_check) |
979 | && (pos_in_item != ih_item_len(ih_check) | 979 | && (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 | |||
1002 | tb->insert_size[0], | 1002 | tb->insert_size[0], |
1003 | body, zeros_num); | 1003 | body, zeros_num); |
1004 | 1004 | ||
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]); |
1006 | if (is_direntry_le_ih(pasted)) { | 1006 | if (is_direntry_le_ih(pasted)) { |
1007 | leaf_paste_entries(&bi, | 1007 | leaf_paste_entries(&bi, |
1008 | item_pos - n + snum[i], | 1008 | item_pos - n + snum[i], |
@@ -1032,7 +1032,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h | |||
1032 | (flag == M_DELETE) ? "DELETE" : ((flag == M_CUT) ? "CUT" : "UNKNOWN"), flag); | 1032 | (flag == M_DELETE) ? "DELETE" : ((flag == M_CUT) ? "CUT" : "UNKNOWN"), flag); |
1033 | } | 1033 | } |
1034 | 1034 | ||
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); |
1036 | insert_ptr[i] = S_new[i]; | 1036 | insert_ptr[i] = S_new[i]; |
1037 | 1037 | ||
1038 | RFALSE(!buffer_journaled(S_new[i]) | 1038 | RFALSE(!buffer_journaled(S_new[i]) |
@@ -1061,7 +1061,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h | |||
1061 | case M_PASTE:{ /* append item in S[0] */ | 1061 | case M_PASTE:{ /* append item in S[0] */ |
1062 | struct item_head *pasted; | 1062 | struct item_head *pasted; |
1063 | 1063 | ||
1064 | pasted = B_N_PITEM_HEAD(tbS0, item_pos); | 1064 | pasted = item_head(tbS0, item_pos); |
1065 | /* when directory, may be new entry already pasted */ | 1065 | /* when directory, may be new entry already pasted */ |
1066 | if (is_direntry_le_ih(pasted)) { | 1066 | if (is_direntry_le_ih(pasted)) { |
1067 | if (pos_in_item >= 0 && pos_in_item <= ih_entry_count(pasted)) { | 1067 | 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, | |||
1246 | 1246 | ||
1247 | if (B_IS_ITEMS_LEVEL(src)) | 1247 | if (B_IS_ITEMS_LEVEL(src)) |
1248 | /* source buffer contains leaf node */ | 1248 | /* 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), |
1250 | KEY_SIZE); | 1250 | KEY_SIZE); |
1251 | else | 1251 | 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), |
1253 | KEY_SIZE); | 1253 | KEY_SIZE); |
1254 | 1254 | ||
1255 | do_balance_mark_internal_dirty(tb, dest, 0); | 1255 | do_balance_mark_internal_dirty(tb, dest, 0); |
diff --git a/fs/reiserfs/fix_node.c b/fs/reiserfs/fix_node.c index dc4d41530316..b6a05a7f4658 100644 --- a/fs/reiserfs/fix_node.c +++ b/fs/reiserfs/fix_node.c | |||
@@ -105,7 +105,7 @@ static void create_virtual_node(struct tree_balance *tb, int h) | |||
105 | vn->vn_free_ptr += vn->vn_nr_item * sizeof(struct virtual_item); | 105 | vn->vn_free_ptr += vn->vn_nr_item * sizeof(struct virtual_item); |
106 | 106 | ||
107 | /* first item in the node */ | 107 | /* first item in the node */ |
108 | ih = B_N_PITEM_HEAD(Sh, 0); | 108 | ih = item_head(Sh, 0); |
109 | 109 | ||
110 | /* define the mergeability for 0-th item (if it is not being deleted) */ | 110 | /* define the mergeability for 0-th item (if it is not being deleted) */ |
111 | if (op_is_left_mergeable(&(ih->ih_key), Sh->b_size) | 111 | if (op_is_left_mergeable(&(ih->ih_key), Sh->b_size) |
@@ -128,7 +128,7 @@ static void create_virtual_node(struct tree_balance *tb, int h) | |||
128 | 128 | ||
129 | vi->vi_item_len += ih_item_len(ih + j) + IH_SIZE; | 129 | vi->vi_item_len += ih_item_len(ih + j) + IH_SIZE; |
130 | vi->vi_ih = ih + j; | 130 | vi->vi_ih = ih + j; |
131 | vi->vi_item = B_I_PITEM(Sh, ih + j); | 131 | vi->vi_item = ih_item_body(Sh, ih + j); |
132 | vi->vi_uarea = vn->vn_free_ptr; | 132 | vi->vi_uarea = vn->vn_free_ptr; |
133 | 133 | ||
134 | // FIXME: there is no check, that item operation did not | 134 | // FIXME: there is no check, that item operation did not |
@@ -168,7 +168,7 @@ static void create_virtual_node(struct tree_balance *tb, int h) | |||
168 | if (tb->CFR[0]) { | 168 | if (tb->CFR[0]) { |
169 | struct reiserfs_key *key; | 169 | struct reiserfs_key *key; |
170 | 170 | ||
171 | key = B_N_PDELIM_KEY(tb->CFR[0], tb->rkey[0]); | 171 | key = internal_key(tb->CFR[0], tb->rkey[0]); |
172 | if (op_is_left_mergeable(key, Sh->b_size) | 172 | if (op_is_left_mergeable(key, Sh->b_size) |
173 | && (vn->vn_mode != M_DELETE | 173 | && (vn->vn_mode != M_DELETE |
174 | || vn->vn_affected_item_num != B_NR_ITEMS(Sh) - 1)) | 174 | || vn->vn_affected_item_num != B_NR_ITEMS(Sh) - 1)) |
@@ -182,8 +182,8 @@ static void create_virtual_node(struct tree_balance *tb, int h) | |||
182 | /* we delete last item and it could be merged with right neighbor's first item */ | 182 | /* we delete last item and it could be merged with right neighbor's first item */ |
183 | if (! | 183 | if (! |
184 | (B_NR_ITEMS(Sh) == 1 | 184 | (B_NR_ITEMS(Sh) == 1 |
185 | && is_direntry_le_ih(B_N_PITEM_HEAD(Sh, 0)) | 185 | && is_direntry_le_ih(item_head(Sh, 0)) |
186 | && I_ENTRY_COUNT(B_N_PITEM_HEAD(Sh, 0)) == 1)) { | 186 | && ih_entry_count(item_head(Sh, 0)) == 1)) { |
187 | /* node contains more than 1 item, or item is not directory item, or this item contains more than 1 entry */ | 187 | /* node contains more than 1 item, or item is not directory item, or this item contains more than 1 entry */ |
188 | print_block(Sh, 0, -1, -1); | 188 | print_block(Sh, 0, -1, -1); |
189 | reiserfs_panic(tb->tb_sb, "vs-8045", | 189 | reiserfs_panic(tb->tb_sb, "vs-8045", |
@@ -675,10 +675,10 @@ static int are_leaves_removable(struct tree_balance *tb, int lfree, int rfree) | |||
675 | "vs-8125: item number must be 1: it is %d", | 675 | "vs-8125: item number must be 1: it is %d", |
676 | B_NR_ITEMS(S0)); | 676 | B_NR_ITEMS(S0)); |
677 | 677 | ||
678 | ih = B_N_PITEM_HEAD(S0, 0); | 678 | ih = item_head(S0, 0); |
679 | if (tb->CFR[0] | 679 | if (tb->CFR[0] |
680 | && !comp_short_le_keys(&(ih->ih_key), | 680 | && !comp_short_le_keys(&(ih->ih_key), |
681 | B_N_PDELIM_KEY(tb->CFR[0], | 681 | internal_key(tb->CFR[0], |
682 | tb->rkey[0]))) | 682 | tb->rkey[0]))) |
683 | if (is_direntry_le_ih(ih)) { | 683 | if (is_direntry_le_ih(ih)) { |
684 | /* Directory must be in correct state here: that is | 684 | /* Directory must be in correct state here: that is |
@@ -1036,7 +1036,7 @@ static int get_far_parent(struct tree_balance *tb, | |||
1036 | 1036 | ||
1037 | /* Form key to get parent of the left/right neighbor. */ | 1037 | /* Form key to get parent of the left/right neighbor. */ |
1038 | le_key2cpu_key(&s_lr_father_key, | 1038 | le_key2cpu_key(&s_lr_father_key, |
1039 | B_N_PDELIM_KEY(*pcom_father, | 1039 | internal_key(*pcom_father, |
1040 | (c_lr_par == | 1040 | (c_lr_par == |
1041 | LEFT_PARENTS) ? (tb->lkey[h - 1] = | 1041 | LEFT_PARENTS) ? (tb->lkey[h - 1] = |
1042 | position - | 1042 | position - |
@@ -1175,9 +1175,9 @@ static inline int can_node_be_removed(int mode, int lfree, int sfree, int rfree, | |||
1175 | struct item_head *ih; | 1175 | struct item_head *ih; |
1176 | struct reiserfs_key *r_key = NULL; | 1176 | struct reiserfs_key *r_key = NULL; |
1177 | 1177 | ||
1178 | ih = B_N_PITEM_HEAD(Sh, 0); | 1178 | ih = item_head(Sh, 0); |
1179 | if (tb->CFR[h]) | 1179 | if (tb->CFR[h]) |
1180 | r_key = B_N_PDELIM_KEY(tb->CFR[h], tb->rkey[h]); | 1180 | r_key = internal_key(tb->CFR[h], tb->rkey[h]); |
1181 | 1181 | ||
1182 | if (lfree + rfree + sfree < MAX_CHILD_SIZE(Sh) + levbytes | 1182 | if (lfree + rfree + sfree < MAX_CHILD_SIZE(Sh) + levbytes |
1183 | /* shifting may merge items which might save space */ | 1183 | /* shifting may merge items which might save space */ |
diff --git a/fs/reiserfs/ibalance.c b/fs/reiserfs/ibalance.c index e1978fd895f5..ae26a271da35 100644 --- a/fs/reiserfs/ibalance.c +++ b/fs/reiserfs/ibalance.c | |||
@@ -153,7 +153,7 @@ static void internal_insert_childs(struct buffer_info *cur_bi, | |||
153 | memcpy(dc, new_dc, DC_SIZE * count); | 153 | memcpy(dc, new_dc, DC_SIZE * count); |
154 | 154 | ||
155 | /* prepare space for count items */ | 155 | /* prepare space for count items */ |
156 | ih = B_N_PDELIM_KEY(cur, ((to == -1) ? 0 : to)); | 156 | ih = internal_key(cur, ((to == -1) ? 0 : to)); |
157 | 157 | ||
158 | memmove(ih + count, ih, | 158 | memmove(ih + count, ih, |
159 | (nr - to) * KEY_SIZE + (nr + 1 + count) * DC_SIZE); | 159 | (nr - to) * KEY_SIZE + (nr + 1 + count) * DC_SIZE); |
@@ -233,7 +233,7 @@ static void internal_delete_pointers_items(struct buffer_info *cur_bi, | |||
233 | dc = B_N_CHILD(cur, first_p); | 233 | dc = B_N_CHILD(cur, first_p); |
234 | 234 | ||
235 | memmove(dc, dc + del_num, (nr + 1 - first_p - del_num) * DC_SIZE); | 235 | memmove(dc, dc + del_num, (nr + 1 - first_p - del_num) * DC_SIZE); |
236 | key = B_N_PDELIM_KEY(cur, first_i); | 236 | key = internal_key(cur, first_i); |
237 | memmove(key, key + del_num, | 237 | memmove(key, key + del_num, |
238 | (nr - first_i - del_num) * KEY_SIZE + (nr + 1 - | 238 | (nr - first_i - del_num) * KEY_SIZE + (nr + 1 - |
239 | del_num) * DC_SIZE); | 239 | del_num) * DC_SIZE); |
@@ -330,13 +330,13 @@ static void internal_copy_pointers_items(struct buffer_info *dest_bi, | |||
330 | memcpy(dc, B_N_CHILD(src, src_order), DC_SIZE * cpy_num); | 330 | memcpy(dc, B_N_CHILD(src, src_order), DC_SIZE * cpy_num); |
331 | 331 | ||
332 | /* prepare space for cpy_num - 1 item headers */ | 332 | /* prepare space for cpy_num - 1 item headers */ |
333 | key = B_N_PDELIM_KEY(dest, dest_order); | 333 | key = internal_key(dest, dest_order); |
334 | memmove(key + cpy_num - 1, key, | 334 | memmove(key + cpy_num - 1, key, |
335 | KEY_SIZE * (nr_dest - dest_order) + DC_SIZE * (nr_dest + | 335 | KEY_SIZE * (nr_dest - dest_order) + DC_SIZE * (nr_dest + |
336 | cpy_num)); | 336 | cpy_num)); |
337 | 337 | ||
338 | /* insert headers */ | 338 | /* insert headers */ |
339 | memcpy(key, B_N_PDELIM_KEY(src, src_order), KEY_SIZE * (cpy_num - 1)); | 339 | memcpy(key, internal_key(src, src_order), KEY_SIZE * (cpy_num - 1)); |
340 | 340 | ||
341 | /* sizes, item number */ | 341 | /* sizes, item number */ |
342 | set_blkh_nr_item(blkh, blkh_nr_item(blkh) + (cpy_num - 1)); | 342 | set_blkh_nr_item(blkh, blkh_nr_item(blkh) + (cpy_num - 1)); |
@@ -429,12 +429,12 @@ static void internal_insert_key(struct buffer_info *dest_bi, int dest_position_b | |||
429 | nr = blkh_nr_item(blkh); | 429 | nr = blkh_nr_item(blkh); |
430 | 430 | ||
431 | /* prepare space for inserting key */ | 431 | /* prepare space for inserting key */ |
432 | key = B_N_PDELIM_KEY(dest, dest_position_before); | 432 | key = internal_key(dest, dest_position_before); |
433 | memmove(key + 1, key, | 433 | memmove(key + 1, key, |
434 | (nr - dest_position_before) * KEY_SIZE + (nr + 1) * DC_SIZE); | 434 | (nr - dest_position_before) * KEY_SIZE + (nr + 1) * DC_SIZE); |
435 | 435 | ||
436 | /* insert key */ | 436 | /* insert key */ |
437 | memcpy(key, B_N_PDELIM_KEY(src, src_position), KEY_SIZE); | 437 | memcpy(key, internal_key(src, src_position), KEY_SIZE); |
438 | 438 | ||
439 | /* Change dirt, free space, item number fields. */ | 439 | /* Change dirt, free space, item number fields. */ |
440 | 440 | ||
@@ -717,7 +717,7 @@ static void replace_lkey(struct tree_balance *tb, int h, struct item_head *key) | |||
717 | if (B_NR_ITEMS(PATH_H_PBUFFER(tb->tb_path, h)) == 0) | 717 | if (B_NR_ITEMS(PATH_H_PBUFFER(tb->tb_path, h)) == 0) |
718 | return; | 718 | return; |
719 | 719 | ||
720 | memcpy(B_N_PDELIM_KEY(tb->CFL[h], tb->lkey[h]), key, KEY_SIZE); | 720 | memcpy(internal_key(tb->CFL[h], tb->lkey[h]), key, KEY_SIZE); |
721 | 721 | ||
722 | do_balance_mark_internal_dirty(tb, tb->CFL[h], 0); | 722 | do_balance_mark_internal_dirty(tb, tb->CFL[h], 0); |
723 | } | 723 | } |
@@ -732,7 +732,7 @@ static void replace_rkey(struct tree_balance *tb, int h, struct item_head *key) | |||
732 | "R[h] can not be empty if it exists (item number=%d)", | 732 | "R[h] can not be empty if it exists (item number=%d)", |
733 | B_NR_ITEMS(tb->R[h])); | 733 | B_NR_ITEMS(tb->R[h])); |
734 | 734 | ||
735 | memcpy(B_N_PDELIM_KEY(tb->CFR[h], tb->rkey[h]), key, KEY_SIZE); | 735 | memcpy(internal_key(tb->CFR[h], tb->rkey[h]), key, KEY_SIZE); |
736 | 736 | ||
737 | do_balance_mark_internal_dirty(tb, tb->CFR[h], 0); | 737 | do_balance_mark_internal_dirty(tb, tb->CFR[h], 0); |
738 | } | 738 | } |
@@ -997,7 +997,7 @@ int balance_internal(struct tree_balance *tb, /* tree_balance structure | |||
997 | /* new items don't fall into S_new */ | 997 | /* new items don't fall into S_new */ |
998 | /* store the delimiting key for the next level */ | 998 | /* store the delimiting key for the next level */ |
999 | /* new_insert_key = (n - snum)'th key in S[h] */ | 999 | /* new_insert_key = (n - snum)'th key in S[h] */ |
1000 | memcpy(&new_insert_key, B_N_PDELIM_KEY(tbSh, n - snum), | 1000 | memcpy(&new_insert_key, internal_key(tbSh, n - snum), |
1001 | KEY_SIZE); | 1001 | KEY_SIZE); |
1002 | /* last parameter is del_par */ | 1002 | /* last parameter is del_par */ |
1003 | internal_move_pointers_items(&dest_bi, &src_bi, | 1003 | internal_move_pointers_items(&dest_bi, &src_bi, |
@@ -1008,7 +1008,7 @@ int balance_internal(struct tree_balance *tb, /* tree_balance structure | |||
1008 | /* store the delimiting key for the next level */ | 1008 | /* store the delimiting key for the next level */ |
1009 | /* new_insert_key = (n + insert_item - snum)'th key in S[h] */ | 1009 | /* new_insert_key = (n + insert_item - snum)'th key in S[h] */ |
1010 | memcpy(&new_insert_key, | 1010 | memcpy(&new_insert_key, |
1011 | B_N_PDELIM_KEY(tbSh, n + insert_num - snum), | 1011 | internal_key(tbSh, n + insert_num - snum), |
1012 | KEY_SIZE); | 1012 | KEY_SIZE); |
1013 | /* last parameter is del_par */ | 1013 | /* last parameter is del_par */ |
1014 | internal_move_pointers_items(&dest_bi, &src_bi, | 1014 | internal_move_pointers_items(&dest_bi, &src_bi, |
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c index bc8b8009897d..b8d3ffb1f722 100644 --- a/fs/reiserfs/inode.c +++ b/fs/reiserfs/inode.c | |||
@@ -295,9 +295,9 @@ static int _get_block_create_0(struct inode *inode, sector_t block, | |||
295 | } | 295 | } |
296 | // | 296 | // |
297 | bh = get_last_bh(&path); | 297 | bh = get_last_bh(&path); |
298 | ih = get_ih(&path); | 298 | ih = tp_item_head(&path); |
299 | if (is_indirect_le_ih(ih)) { | 299 | if (is_indirect_le_ih(ih)) { |
300 | __le32 *ind_item = (__le32 *) B_I_PITEM(bh, ih); | 300 | __le32 *ind_item = (__le32 *) ih_item_body(bh, ih); |
301 | 301 | ||
302 | /* FIXME: here we could cache indirect item or part of it in | 302 | /* FIXME: here we could cache indirect item or part of it in |
303 | the inode to avoid search_by_key in case of subsequent | 303 | the inode to avoid search_by_key in case of subsequent |
@@ -383,7 +383,7 @@ static int _get_block_create_0(struct inode *inode, sector_t block, | |||
383 | } else { | 383 | } else { |
384 | chars = ih_item_len(ih) - path.pos_in_item; | 384 | chars = ih_item_len(ih) - path.pos_in_item; |
385 | } | 385 | } |
386 | memcpy(p, B_I_PITEM(bh, ih) + path.pos_in_item, chars); | 386 | memcpy(p, ih_item_body(bh, ih) + path.pos_in_item, chars); |
387 | 387 | ||
388 | if (done) | 388 | if (done) |
389 | break; | 389 | break; |
@@ -404,7 +404,7 @@ static int _get_block_create_0(struct inode *inode, sector_t block, | |||
404 | // i/o error most likely | 404 | // i/o error most likely |
405 | break; | 405 | break; |
406 | bh = get_last_bh(&path); | 406 | bh = get_last_bh(&path); |
407 | ih = get_ih(&path); | 407 | ih = tp_item_head(&path); |
408 | } while (1); | 408 | } while (1); |
409 | 409 | ||
410 | flush_dcache_page(bh_result->b_page); | 410 | flush_dcache_page(bh_result->b_page); |
@@ -684,8 +684,8 @@ int reiserfs_get_block(struct inode *inode, sector_t block, | |||
684 | } | 684 | } |
685 | 685 | ||
686 | bh = get_last_bh(&path); | 686 | bh = get_last_bh(&path); |
687 | ih = get_ih(&path); | 687 | ih = tp_item_head(&path); |
688 | item = get_item(&path); | 688 | item = tp_item_body(&path); |
689 | pos_in_item = path.pos_in_item; | 689 | pos_in_item = path.pos_in_item; |
690 | 690 | ||
691 | fs_gen = get_generation(inode->i_sb); | 691 | fs_gen = get_generation(inode->i_sb); |
@@ -1031,8 +1031,8 @@ int reiserfs_get_block(struct inode *inode, sector_t block, | |||
1031 | goto failure; | 1031 | goto failure; |
1032 | } | 1032 | } |
1033 | bh = get_last_bh(&path); | 1033 | bh = get_last_bh(&path); |
1034 | ih = get_ih(&path); | 1034 | ih = tp_item_head(&path); |
1035 | item = get_item(&path); | 1035 | item = tp_item_body(&path); |
1036 | pos_in_item = path.pos_in_item; | 1036 | pos_in_item = path.pos_in_item; |
1037 | } while (1); | 1037 | } while (1); |
1038 | 1038 | ||
@@ -1133,7 +1133,7 @@ static void init_inode(struct inode *inode, struct treepath *path) | |||
1133 | //int version = ITEM_VERSION_1; | 1133 | //int version = ITEM_VERSION_1; |
1134 | 1134 | ||
1135 | bh = PATH_PLAST_BUFFER(path); | 1135 | bh = PATH_PLAST_BUFFER(path); |
1136 | ih = PATH_PITEM_HEAD(path); | 1136 | ih = tp_item_head(path); |
1137 | 1137 | ||
1138 | copy_key(INODE_PKEY(inode), &(ih->ih_key)); | 1138 | copy_key(INODE_PKEY(inode), &(ih->ih_key)); |
1139 | 1139 | ||
@@ -1147,7 +1147,7 @@ static void init_inode(struct inode *inode, struct treepath *path) | |||
1147 | 1147 | ||
1148 | if (stat_data_v1(ih)) { | 1148 | if (stat_data_v1(ih)) { |
1149 | struct stat_data_v1 *sd = | 1149 | struct stat_data_v1 *sd = |
1150 | (struct stat_data_v1 *)B_I_PITEM(bh, ih); | 1150 | (struct stat_data_v1 *)ih_item_body(bh, ih); |
1151 | unsigned long blocks; | 1151 | unsigned long blocks; |
1152 | 1152 | ||
1153 | set_inode_item_key_version(inode, KEY_FORMAT_3_5); | 1153 | set_inode_item_key_version(inode, KEY_FORMAT_3_5); |
@@ -1195,7 +1195,7 @@ static void init_inode(struct inode *inode, struct treepath *path) | |||
1195 | } else { | 1195 | } else { |
1196 | // new stat data found, but object may have old items | 1196 | // new stat data found, but object may have old items |
1197 | // (directories and symlinks) | 1197 | // (directories and symlinks) |
1198 | struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih); | 1198 | struct stat_data *sd = (struct stat_data *)ih_item_body(bh, ih); |
1199 | 1199 | ||
1200 | inode->i_mode = sd_v2_mode(sd); | 1200 | inode->i_mode = sd_v2_mode(sd); |
1201 | set_nlink(inode, sd_v2_nlink(sd)); | 1201 | set_nlink(inode, sd_v2_nlink(sd)); |
@@ -1307,7 +1307,7 @@ static void update_stat_data(struct treepath *path, struct inode *inode, | |||
1307 | struct item_head *ih; | 1307 | struct item_head *ih; |
1308 | 1308 | ||
1309 | bh = PATH_PLAST_BUFFER(path); | 1309 | bh = PATH_PLAST_BUFFER(path); |
1310 | ih = PATH_PITEM_HEAD(path); | 1310 | ih = tp_item_head(path); |
1311 | 1311 | ||
1312 | if (!is_statdata_le_ih(ih)) | 1312 | if (!is_statdata_le_ih(ih)) |
1313 | reiserfs_panic(inode->i_sb, "vs-13065", "key %k, found item %h", | 1313 | reiserfs_panic(inode->i_sb, "vs-13065", "key %k, found item %h", |
@@ -1315,9 +1315,9 @@ static void update_stat_data(struct treepath *path, struct inode *inode, | |||
1315 | 1315 | ||
1316 | if (stat_data_v1(ih)) { | 1316 | if (stat_data_v1(ih)) { |
1317 | // path points to old stat data | 1317 | // path points to old stat data |
1318 | inode2sd_v1(B_I_PITEM(bh, ih), inode, size); | 1318 | inode2sd_v1(ih_item_body(bh, ih), inode, size); |
1319 | } else { | 1319 | } else { |
1320 | inode2sd(B_I_PITEM(bh, ih), inode, size); | 1320 | inode2sd(ih_item_body(bh, ih), inode, size); |
1321 | } | 1321 | } |
1322 | 1322 | ||
1323 | return; | 1323 | return; |
@@ -1368,7 +1368,7 @@ void reiserfs_update_sd_size(struct reiserfs_transaction_handle *th, | |||
1368 | ** search if the stat data item has moved | 1368 | ** search if the stat data item has moved |
1369 | */ | 1369 | */ |
1370 | bh = get_last_bh(&path); | 1370 | bh = get_last_bh(&path); |
1371 | ih = get_ih(&path); | 1371 | ih = tp_item_head(&path); |
1372 | copy_item_head(&tmp_ih, ih); | 1372 | copy_item_head(&tmp_ih, ih); |
1373 | fs_gen = get_generation(inode->i_sb); | 1373 | fs_gen = get_generation(inode->i_sb); |
1374 | reiserfs_prepare_for_journal(inode->i_sb, bh, 1); | 1374 | reiserfs_prepare_for_journal(inode->i_sb, bh, 1); |
@@ -2232,8 +2232,8 @@ static int map_block_for_writepage(struct inode *inode, | |||
2232 | } | 2232 | } |
2233 | 2233 | ||
2234 | bh = get_last_bh(&path); | 2234 | bh = get_last_bh(&path); |
2235 | ih = get_ih(&path); | 2235 | ih = tp_item_head(&path); |
2236 | item = get_item(&path); | 2236 | item = tp_item_body(&path); |
2237 | pos_in_item = path.pos_in_item; | 2237 | pos_in_item = path.pos_in_item; |
2238 | 2238 | ||
2239 | /* we've found an unformatted node */ | 2239 | /* we've found an unformatted node */ |
@@ -2281,7 +2281,7 @@ static int map_block_for_writepage(struct inode *inode, | |||
2281 | goto research; | 2281 | goto research; |
2282 | } | 2282 | } |
2283 | 2283 | ||
2284 | memcpy(B_I_PITEM(bh, ih) + pos_in_item, p + bytes_copied, | 2284 | memcpy(ih_item_body(bh, ih) + pos_in_item, p + bytes_copied, |
2285 | copy_size); | 2285 | copy_size); |
2286 | 2286 | ||
2287 | journal_mark_dirty(&th, inode->i_sb, bh); | 2287 | journal_mark_dirty(&th, inode->i_sb, bh); |
diff --git a/fs/reiserfs/item_ops.c b/fs/reiserfs/item_ops.c index ee382ef3d300..c9f136527386 100644 --- a/fs/reiserfs/item_ops.c +++ b/fs/reiserfs/item_ops.c | |||
@@ -396,7 +396,7 @@ static void direntry_print_item(struct item_head *ih, char *item) | |||
396 | 396 | ||
397 | deh = (struct reiserfs_de_head *)item; | 397 | deh = (struct reiserfs_de_head *)item; |
398 | 398 | ||
399 | for (i = 0; i < I_ENTRY_COUNT(ih); i++, deh++) { | 399 | for (i = 0; i < ih_entry_count(ih); i++, deh++) { |
400 | namelen = | 400 | namelen = |
401 | (i ? (deh_location(deh - 1)) : ih_item_len(ih)) - | 401 | (i ? (deh_location(deh - 1)) : ih_item_len(ih)) - |
402 | deh_location(deh); | 402 | deh_location(deh); |
@@ -430,7 +430,7 @@ static void direntry_check_item(struct item_head *ih, char *item) | |||
430 | 430 | ||
431 | // FIXME: type something here! | 431 | // FIXME: type something here! |
432 | deh = (struct reiserfs_de_head *)item; | 432 | deh = (struct reiserfs_de_head *)item; |
433 | for (i = 0; i < I_ENTRY_COUNT(ih); i++, deh++) { | 433 | for (i = 0; i < ih_entry_count(ih); i++, deh++) { |
434 | ; | 434 | ; |
435 | } | 435 | } |
436 | } | 436 | } |
diff --git a/fs/reiserfs/lbalance.c b/fs/reiserfs/lbalance.c index 79e5a8b4c226..b46399d98f84 100644 --- a/fs/reiserfs/lbalance.c +++ b/fs/reiserfs/lbalance.c | |||
@@ -35,7 +35,7 @@ static void leaf_copy_dir_entries(struct buffer_info *dest_bi, | |||
35 | int copy_records_len; /* length of all records in item to be copied */ | 35 | int copy_records_len; /* length of all records in item to be copied */ |
36 | char *records; | 36 | char *records; |
37 | 37 | ||
38 | ih = B_N_PITEM_HEAD(source, item_num); | 38 | ih = item_head(source, item_num); |
39 | 39 | ||
40 | RFALSE(!is_direntry_le_ih(ih), "vs-10000: item must be directory item"); | 40 | RFALSE(!is_direntry_le_ih(ih), "vs-10000: item must be directory item"); |
41 | 41 | ||
@@ -64,7 +64,7 @@ static void leaf_copy_dir_entries(struct buffer_info *dest_bi, | |||
64 | (last_first == FIRST_TO_LAST && le_ih_k_offset(ih) == DOT_OFFSET) || | 64 | (last_first == FIRST_TO_LAST && le_ih_k_offset(ih) == DOT_OFFSET) || |
65 | (last_first == LAST_TO_FIRST | 65 | (last_first == LAST_TO_FIRST |
66 | && comp_short_le_keys /*COMP_SHORT_KEYS */ (&ih->ih_key, | 66 | && comp_short_le_keys /*COMP_SHORT_KEYS */ (&ih->ih_key, |
67 | B_N_PKEY(dest, | 67 | leaf_key(dest, |
68 | item_num_in_dest)))) | 68 | item_num_in_dest)))) |
69 | { | 69 | { |
70 | /* create new item in dest */ | 70 | /* create new item in dest */ |
@@ -80,7 +80,7 @@ static void leaf_copy_dir_entries(struct buffer_info *dest_bi, | |||
80 | 80 | ||
81 | if (last_first == LAST_TO_FIRST) { | 81 | if (last_first == LAST_TO_FIRST) { |
82 | /* form key by the following way */ | 82 | /* form key by the following way */ |
83 | if (from < I_ENTRY_COUNT(ih)) { | 83 | if (from < ih_entry_count(ih)) { |
84 | set_le_ih_k_offset(&new_ih, | 84 | set_le_ih_k_offset(&new_ih, |
85 | deh_offset(&(deh[from]))); | 85 | deh_offset(&(deh[from]))); |
86 | /*memcpy (&new_ih.ih_key.k_offset, &deh[from].deh_offset, SHORT_KEY_SIZE); */ | 86 | /*memcpy (&new_ih.ih_key.k_offset, &deh[from].deh_offset, SHORT_KEY_SIZE); */ |
@@ -113,7 +113,7 @@ static void leaf_copy_dir_entries(struct buffer_info *dest_bi, | |||
113 | 113 | ||
114 | leaf_paste_entries(dest_bi, item_num_in_dest, | 114 | leaf_paste_entries(dest_bi, item_num_in_dest, |
115 | (last_first == | 115 | (last_first == |
116 | FIRST_TO_LAST) ? I_ENTRY_COUNT(B_N_PITEM_HEAD(dest, | 116 | FIRST_TO_LAST) ? ih_entry_count(item_head(dest, |
117 | item_num_in_dest)) | 117 | item_num_in_dest)) |
118 | : 0, copy_count, deh + from, records, | 118 | : 0, copy_count, deh + from, records, |
119 | DEH_SIZE * copy_count + copy_records_len); | 119 | DEH_SIZE * copy_count + copy_records_len); |
@@ -138,8 +138,8 @@ static int leaf_copy_boundary_item(struct buffer_info *dest_bi, | |||
138 | /* if ( DEST is empty or first item of SOURCE and last item of DEST are the items of different objects | 138 | /* if ( DEST is empty or first item of SOURCE and last item of DEST are the items of different objects |
139 | or of different types ) then there is no need to treat this item differently from the other items | 139 | or of different types ) then there is no need to treat this item differently from the other items |
140 | that we copy, so we return */ | 140 | that we copy, so we return */ |
141 | ih = B_N_PITEM_HEAD(src, 0); | 141 | ih = item_head(src, 0); |
142 | dih = B_N_PITEM_HEAD(dest, dest_nr_item - 1); | 142 | dih = item_head(dest, dest_nr_item - 1); |
143 | if (!dest_nr_item | 143 | if (!dest_nr_item |
144 | || (!op_is_left_mergeable(&(ih->ih_key), src->b_size))) | 144 | || (!op_is_left_mergeable(&(ih->ih_key), src->b_size))) |
145 | /* there is nothing to merge */ | 145 | /* there is nothing to merge */ |
@@ -180,7 +180,7 @@ static int leaf_copy_boundary_item(struct buffer_info *dest_bi, | |||
180 | item of dest buffer. Both are of the same file */ | 180 | item of dest buffer. Both are of the same file */ |
181 | leaf_paste_in_buffer(dest_bi, | 181 | leaf_paste_in_buffer(dest_bi, |
182 | dest_nr_item - 1, ih_item_len(dih), | 182 | dest_nr_item - 1, ih_item_len(dih), |
183 | bytes_or_entries, B_I_PITEM(src, ih), 0); | 183 | bytes_or_entries, ih_item_body(src, ih), 0); |
184 | 184 | ||
185 | if (is_indirect_le_ih(dih)) { | 185 | if (is_indirect_le_ih(dih)) { |
186 | RFALSE(get_ih_free_space(dih), | 186 | RFALSE(get_ih_free_space(dih), |
@@ -199,8 +199,8 @@ static int leaf_copy_boundary_item(struct buffer_info *dest_bi, | |||
199 | are the items of different object or of different types ) | 199 | are the items of different object or of different types ) |
200 | */ | 200 | */ |
201 | src_nr_item = B_NR_ITEMS(src); | 201 | src_nr_item = B_NR_ITEMS(src); |
202 | ih = B_N_PITEM_HEAD(src, src_nr_item - 1); | 202 | ih = item_head(src, src_nr_item - 1); |
203 | dih = B_N_PITEM_HEAD(dest, 0); | 203 | dih = item_head(dest, 0); |
204 | 204 | ||
205 | if (!dest_nr_item || !op_is_left_mergeable(&(dih->ih_key), src->b_size)) | 205 | if (!dest_nr_item || !op_is_left_mergeable(&(dih->ih_key), src->b_size)) |
206 | return 0; | 206 | return 0; |
@@ -270,7 +270,7 @@ static int leaf_copy_boundary_item(struct buffer_info *dest_bi, | |||
270 | } | 270 | } |
271 | 271 | ||
272 | leaf_paste_in_buffer(dest_bi, 0, 0, bytes_or_entries, | 272 | leaf_paste_in_buffer(dest_bi, 0, 0, bytes_or_entries, |
273 | B_I_PITEM(src, | 273 | ih_item_body(src, |
274 | ih) + ih_item_len(ih) - bytes_or_entries, | 274 | ih) + ih_item_len(ih) - bytes_or_entries, |
275 | 0); | 275 | 0); |
276 | return 1; | 276 | return 1; |
@@ -315,7 +315,7 @@ static void leaf_copy_items_entirely(struct buffer_info *dest_bi, | |||
315 | dest_before = (last_first == LAST_TO_FIRST) ? 0 : nr; | 315 | dest_before = (last_first == LAST_TO_FIRST) ? 0 : nr; |
316 | 316 | ||
317 | /* location of head of first new item */ | 317 | /* location of head of first new item */ |
318 | ih = B_N_PITEM_HEAD(dest, dest_before); | 318 | ih = item_head(dest, dest_before); |
319 | 319 | ||
320 | RFALSE(blkh_free_space(blkh) < cpy_num * IH_SIZE, | 320 | RFALSE(blkh_free_space(blkh) < cpy_num * IH_SIZE, |
321 | "vs-10140: not enough free space for headers %d (needed %d)", | 321 | "vs-10140: not enough free space for headers %d (needed %d)", |
@@ -325,7 +325,7 @@ static void leaf_copy_items_entirely(struct buffer_info *dest_bi, | |||
325 | memmove(ih + cpy_num, ih, (nr - dest_before) * IH_SIZE); | 325 | memmove(ih + cpy_num, ih, (nr - dest_before) * IH_SIZE); |
326 | 326 | ||
327 | /* copy item headers */ | 327 | /* copy item headers */ |
328 | memcpy(ih, B_N_PITEM_HEAD(src, first), cpy_num * IH_SIZE); | 328 | memcpy(ih, item_head(src, first), cpy_num * IH_SIZE); |
329 | 329 | ||
330 | free_space -= (IH_SIZE * cpy_num); | 330 | free_space -= (IH_SIZE * cpy_num); |
331 | set_blkh_free_space(blkh, free_space); | 331 | set_blkh_free_space(blkh, free_space); |
@@ -352,7 +352,8 @@ static void leaf_copy_items_entirely(struct buffer_info *dest_bi, | |||
352 | 352 | ||
353 | /* copy items */ | 353 | /* copy items */ |
354 | memcpy(dest->b_data + last_inserted_loc, | 354 | memcpy(dest->b_data + last_inserted_loc, |
355 | B_N_PITEM(src, (first + cpy_num - 1)), j - last_inserted_loc); | 355 | item_body(src, (first + cpy_num - 1)), |
356 | j - last_inserted_loc); | ||
356 | 357 | ||
357 | /* sizes, item number */ | 358 | /* sizes, item number */ |
358 | set_blkh_nr_item(blkh, nr + cpy_num); | 359 | set_blkh_nr_item(blkh, nr + cpy_num); |
@@ -390,7 +391,7 @@ static void leaf_item_bottle(struct buffer_info *dest_bi, | |||
390 | 391 | ||
391 | if (last_first == FIRST_TO_LAST) { | 392 | if (last_first == FIRST_TO_LAST) { |
392 | /* if ( if item in position item_num in buffer SOURCE is directory item ) */ | 393 | /* if ( if item in position item_num in buffer SOURCE is directory item ) */ |
393 | ih = B_N_PITEM_HEAD(src, item_num); | 394 | ih = item_head(src, item_num); |
394 | if (is_direntry_le_ih(ih)) | 395 | if (is_direntry_le_ih(ih)) |
395 | leaf_copy_dir_entries(dest_bi, src, FIRST_TO_LAST, | 396 | leaf_copy_dir_entries(dest_bi, src, FIRST_TO_LAST, |
396 | item_num, 0, cpy_bytes); | 397 | item_num, 0, cpy_bytes); |
@@ -415,15 +416,15 @@ static void leaf_item_bottle(struct buffer_info *dest_bi, | |||
415 | "vs-10190: bad mergeability of item %h", ih); | 416 | "vs-10190: bad mergeability of item %h", ih); |
416 | n_ih.ih_version = ih->ih_version; /* JDM Endian safe, both le */ | 417 | n_ih.ih_version = ih->ih_version; /* JDM Endian safe, both le */ |
417 | leaf_insert_into_buf(dest_bi, B_NR_ITEMS(dest), &n_ih, | 418 | leaf_insert_into_buf(dest_bi, B_NR_ITEMS(dest), &n_ih, |
418 | B_N_PITEM(src, item_num), 0); | 419 | item_body(src, item_num), 0); |
419 | } | 420 | } |
420 | } else { | 421 | } else { |
421 | /* if ( if item in position item_num in buffer SOURCE is directory item ) */ | 422 | /* if ( if item in position item_num in buffer SOURCE is directory item ) */ |
422 | ih = B_N_PITEM_HEAD(src, item_num); | 423 | ih = item_head(src, item_num); |
423 | if (is_direntry_le_ih(ih)) | 424 | if (is_direntry_le_ih(ih)) |
424 | leaf_copy_dir_entries(dest_bi, src, LAST_TO_FIRST, | 425 | leaf_copy_dir_entries(dest_bi, src, LAST_TO_FIRST, |
425 | item_num, | 426 | item_num, |
426 | I_ENTRY_COUNT(ih) - cpy_bytes, | 427 | ih_entry_count(ih) - cpy_bytes, |
427 | cpy_bytes); | 428 | cpy_bytes); |
428 | else { | 429 | else { |
429 | struct item_head n_ih; | 430 | struct item_head n_ih; |
@@ -461,9 +462,8 @@ static void leaf_item_bottle(struct buffer_info *dest_bi, | |||
461 | n_ih.ih_version = ih->ih_version; /* JDM Endian safe, both le */ | 462 | n_ih.ih_version = ih->ih_version; /* JDM Endian safe, both le */ |
462 | 463 | ||
463 | leaf_insert_into_buf(dest_bi, 0, &n_ih, | 464 | leaf_insert_into_buf(dest_bi, 0, &n_ih, |
464 | B_N_PITEM(src, | 465 | item_body(src, item_num) + |
465 | item_num) + | 466 | ih_item_len(ih) - cpy_bytes, 0); |
466 | ih_item_len(ih) - cpy_bytes, 0); | ||
467 | } | 467 | } |
468 | } | 468 | } |
469 | } | 469 | } |
@@ -691,10 +691,10 @@ int leaf_shift_left(struct tree_balance *tb, int shift_num, int shift_bytes) | |||
691 | replace_key(tb, tb->CFL[0], tb->lkey[0], S0, 0); | 691 | replace_key(tb, tb->CFL[0], tb->lkey[0], S0, 0); |
692 | 692 | ||
693 | RFALSE((shift_bytes != -1 && | 693 | RFALSE((shift_bytes != -1 && |
694 | !(is_direntry_le_ih(B_N_PITEM_HEAD(S0, 0)) | 694 | !(is_direntry_le_ih(item_head(S0, 0)) |
695 | && !I_ENTRY_COUNT(B_N_PITEM_HEAD(S0, 0)))) && | 695 | && !ih_entry_count(item_head(S0, 0)))) && |
696 | (!op_is_left_mergeable | 696 | (!op_is_left_mergeable |
697 | (B_N_PKEY(S0, 0), S0->b_size)), | 697 | (leaf_key(S0, 0), S0->b_size)), |
698 | "vs-10280: item must be mergeable"); | 698 | "vs-10280: item must be mergeable"); |
699 | } | 699 | } |
700 | } | 700 | } |
@@ -776,7 +776,7 @@ void leaf_delete_items(struct buffer_info *cur_bi, int last_first, | |||
776 | leaf_delete_items_entirely(cur_bi, first + 1, | 776 | leaf_delete_items_entirely(cur_bi, first + 1, |
777 | del_num - 1); | 777 | del_num - 1); |
778 | 778 | ||
779 | ih = B_N_PITEM_HEAD(bh, B_NR_ITEMS(bh) - 1); | 779 | ih = item_head(bh, B_NR_ITEMS(bh) - 1); |
780 | if (is_direntry_le_ih(ih)) | 780 | if (is_direntry_le_ih(ih)) |
781 | /* the last item is directory */ | 781 | /* the last item is directory */ |
782 | /* len = numbers of directory entries in this item */ | 782 | /* len = numbers of directory entries in this item */ |
@@ -820,7 +820,7 @@ void leaf_insert_into_buf(struct buffer_info *bi, int before, | |||
820 | zeros_number, ih_item_len(inserted_item_ih)); | 820 | zeros_number, ih_item_len(inserted_item_ih)); |
821 | 821 | ||
822 | /* get item new item must be inserted before */ | 822 | /* get item new item must be inserted before */ |
823 | ih = B_N_PITEM_HEAD(bh, before); | 823 | ih = item_head(bh, before); |
824 | 824 | ||
825 | /* prepare space for the body of new item */ | 825 | /* prepare space for the body of new item */ |
826 | last_loc = nr ? ih_location(&(ih[nr - before - 1])) : bh->b_size; | 826 | last_loc = nr ? ih_location(&(ih[nr - before - 1])) : bh->b_size; |
@@ -902,7 +902,7 @@ void leaf_paste_in_buffer(struct buffer_info *bi, int affected_item_num, | |||
902 | #endif /* CONFIG_REISERFS_CHECK */ | 902 | #endif /* CONFIG_REISERFS_CHECK */ |
903 | 903 | ||
904 | /* item to be appended */ | 904 | /* item to be appended */ |
905 | ih = B_N_PITEM_HEAD(bh, affected_item_num); | 905 | ih = item_head(bh, affected_item_num); |
906 | 906 | ||
907 | last_loc = ih_location(&(ih[nr - affected_item_num - 1])); | 907 | last_loc = ih_location(&(ih[nr - affected_item_num - 1])); |
908 | unmoved_loc = affected_item_num ? ih_location(ih - 1) : bh->b_size; | 908 | unmoved_loc = affected_item_num ? ih_location(ih - 1) : bh->b_size; |
@@ -974,9 +974,9 @@ static int leaf_cut_entries(struct buffer_head *bh, | |||
974 | /* make sure, that item is directory and there are enough entries to | 974 | /* make sure, that item is directory and there are enough entries to |
975 | remove */ | 975 | remove */ |
976 | RFALSE(!is_direntry_le_ih(ih), "10180: item is not directory item"); | 976 | RFALSE(!is_direntry_le_ih(ih), "10180: item is not directory item"); |
977 | RFALSE(I_ENTRY_COUNT(ih) < from + del_count, | 977 | RFALSE(ih_entry_count(ih) < from + del_count, |
978 | "10185: item contains not enough entries: entry_count = %d, from = %d, to delete = %d", | 978 | "10185: item contains not enough entries: entry_count = %d, from = %d, to delete = %d", |
979 | I_ENTRY_COUNT(ih), from, del_count); | 979 | ih_entry_count(ih), from, del_count); |
980 | 980 | ||
981 | if (del_count == 0) | 981 | if (del_count == 0) |
982 | return 0; | 982 | return 0; |
@@ -996,7 +996,7 @@ static int leaf_cut_entries(struct buffer_head *bh, | |||
996 | prev_record = item + prev_record_offset; | 996 | prev_record = item + prev_record_offset; |
997 | 997 | ||
998 | /* adjust locations of remaining entries */ | 998 | /* adjust locations of remaining entries */ |
999 | for (i = I_ENTRY_COUNT(ih) - 1; i > from + del_count - 1; i--) | 999 | for (i = ih_entry_count(ih) - 1; i > from + del_count - 1; i--) |
1000 | put_deh_location(&(deh[i]), | 1000 | put_deh_location(&(deh[i]), |
1001 | deh_location(&deh[i]) - | 1001 | deh_location(&deh[i]) - |
1002 | (DEH_SIZE * del_count)); | 1002 | (DEH_SIZE * del_count)); |
@@ -1043,7 +1043,7 @@ void leaf_cut_from_buffer(struct buffer_info *bi, int cut_item_num, | |||
1043 | nr = blkh_nr_item(blkh); | 1043 | nr = blkh_nr_item(blkh); |
1044 | 1044 | ||
1045 | /* item head of truncated item */ | 1045 | /* item head of truncated item */ |
1046 | ih = B_N_PITEM_HEAD(bh, cut_item_num); | 1046 | ih = item_head(bh, cut_item_num); |
1047 | 1047 | ||
1048 | if (is_direntry_le_ih(ih)) { | 1048 | if (is_direntry_le_ih(ih)) { |
1049 | /* first cut entry () */ | 1049 | /* first cut entry () */ |
@@ -1156,7 +1156,7 @@ static void leaf_delete_items_entirely(struct buffer_info *bi, | |||
1156 | return; | 1156 | return; |
1157 | } | 1157 | } |
1158 | 1158 | ||
1159 | ih = B_N_PITEM_HEAD(bh, first); | 1159 | ih = item_head(bh, first); |
1160 | 1160 | ||
1161 | /* location of unmovable item */ | 1161 | /* location of unmovable item */ |
1162 | j = (first == 0) ? bh->b_size : ih_location(ih - 1); | 1162 | j = (first == 0) ? bh->b_size : ih_location(ih - 1); |
@@ -1213,13 +1213,13 @@ void leaf_paste_entries(struct buffer_info *bi, | |||
1213 | if (new_entry_count == 0) | 1213 | if (new_entry_count == 0) |
1214 | return; | 1214 | return; |
1215 | 1215 | ||
1216 | ih = B_N_PITEM_HEAD(bh, item_num); | 1216 | ih = item_head(bh, item_num); |
1217 | 1217 | ||
1218 | /* make sure, that item is directory, and there are enough records in it */ | 1218 | /* make sure, that item is directory, and there are enough records in it */ |
1219 | RFALSE(!is_direntry_le_ih(ih), "10225: item is not directory item"); | 1219 | RFALSE(!is_direntry_le_ih(ih), "10225: item is not directory item"); |
1220 | RFALSE(I_ENTRY_COUNT(ih) < before, | 1220 | RFALSE(ih_entry_count(ih) < before, |
1221 | "10230: there are no entry we paste entries before. entry_count = %d, before = %d", | 1221 | "10230: there are no entry we paste entries before. entry_count = %d, before = %d", |
1222 | I_ENTRY_COUNT(ih), before); | 1222 | ih_entry_count(ih), before); |
1223 | 1223 | ||
1224 | /* first byte of dest item */ | 1224 | /* first byte of dest item */ |
1225 | item = bh->b_data + ih_location(ih); | 1225 | item = bh->b_data + ih_location(ih); |
@@ -1234,7 +1234,7 @@ void leaf_paste_entries(struct buffer_info *bi, | |||
1234 | : (ih_item_len(ih) - paste_size)); | 1234 | : (ih_item_len(ih) - paste_size)); |
1235 | 1235 | ||
1236 | /* adjust locations of records that will be AFTER new records */ | 1236 | /* adjust locations of records that will be AFTER new records */ |
1237 | for (i = I_ENTRY_COUNT(ih) - 1; i >= before; i--) | 1237 | for (i = ih_entry_count(ih) - 1; i >= before; i--) |
1238 | put_deh_location(&(deh[i]), | 1238 | put_deh_location(&(deh[i]), |
1239 | deh_location(&(deh[i])) + | 1239 | deh_location(&(deh[i])) + |
1240 | (DEH_SIZE * new_entry_count)); | 1240 | (DEH_SIZE * new_entry_count)); |
@@ -1244,7 +1244,7 @@ void leaf_paste_entries(struct buffer_info *bi, | |||
1244 | put_deh_location(&(deh[i]), | 1244 | put_deh_location(&(deh[i]), |
1245 | deh_location(&(deh[i])) + paste_size); | 1245 | deh_location(&(deh[i])) + paste_size); |
1246 | 1246 | ||
1247 | old_entry_num = I_ENTRY_COUNT(ih); | 1247 | old_entry_num = ih_entry_count(ih); |
1248 | put_ih_entry_count(ih, ih_entry_count(ih) + new_entry_count); | 1248 | put_ih_entry_count(ih, ih_entry_count(ih) + new_entry_count); |
1249 | 1249 | ||
1250 | /* prepare space for pasted records */ | 1250 | /* prepare space for pasted records */ |
@@ -1285,10 +1285,10 @@ void leaf_paste_entries(struct buffer_info *bi, | |||
1285 | int prev, next; | 1285 | int prev, next; |
1286 | /* check record locations */ | 1286 | /* check record locations */ |
1287 | deh = B_I_DEH(bh, ih); | 1287 | deh = B_I_DEH(bh, ih); |
1288 | for (i = 0; i < I_ENTRY_COUNT(ih); i++) { | 1288 | for (i = 0; i < ih_entry_count(ih); i++) { |
1289 | next = | 1289 | next = |
1290 | (i < | 1290 | (i < |
1291 | I_ENTRY_COUNT(ih) - | 1291 | ih_entry_count(ih) - |
1292 | 1) ? deh_location(&(deh[i + 1])) : 0; | 1292 | 1) ? deh_location(&(deh[i + 1])) : 0; |
1293 | prev = (i != 0) ? deh_location(&(deh[i - 1])) : 0; | 1293 | prev = (i != 0) ? deh_location(&(deh[i - 1])) : 0; |
1294 | 1294 | ||
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c index e825f8b63e6b..1ce8fbea4749 100644 --- a/fs/reiserfs/namei.c +++ b/fs/reiserfs/namei.c | |||
@@ -31,7 +31,7 @@ static int bin_search_in_dir_item(struct reiserfs_dir_entry *de, loff_t off) | |||
31 | int rbound, lbound, j; | 31 | int rbound, lbound, j; |
32 | 32 | ||
33 | lbound = 0; | 33 | lbound = 0; |
34 | rbound = I_ENTRY_COUNT(ih) - 1; | 34 | rbound = ih_entry_count(ih) - 1; |
35 | 35 | ||
36 | for (j = (rbound + lbound) / 2; lbound <= rbound; | 36 | for (j = (rbound + lbound) / 2; lbound <= rbound; |
37 | j = (rbound + lbound) / 2) { | 37 | j = (rbound + lbound) / 2) { |
@@ -57,7 +57,7 @@ static inline void set_de_item_location(struct reiserfs_dir_entry *de, | |||
57 | struct treepath *path) | 57 | struct treepath *path) |
58 | { | 58 | { |
59 | de->de_bh = get_last_bh(path); | 59 | de->de_bh = get_last_bh(path); |
60 | de->de_ih = get_ih(path); | 60 | de->de_ih = tp_item_head(path); |
61 | de->de_deh = B_I_DEH(de->de_bh, de->de_ih); | 61 | de->de_deh = B_I_DEH(de->de_bh, de->de_ih); |
62 | de->de_item_num = PATH_LAST_POSITION(path); | 62 | de->de_item_num = PATH_LAST_POSITION(path); |
63 | } | 63 | } |
@@ -71,7 +71,7 @@ inline void set_de_name_and_namelen(struct reiserfs_dir_entry *de) | |||
71 | 71 | ||
72 | de->de_entrylen = entry_length(de->de_bh, de->de_ih, de->de_entry_num); | 72 | de->de_entrylen = entry_length(de->de_bh, de->de_ih, de->de_entry_num); |
73 | de->de_namelen = de->de_entrylen - (de_with_sd(deh) ? SD_SIZE : 0); | 73 | de->de_namelen = de->de_entrylen - (de_with_sd(deh) ? SD_SIZE : 0); |
74 | de->de_name = B_I_PITEM(de->de_bh, de->de_ih) + deh_location(deh); | 74 | de->de_name = ih_item_body(de->de_bh, de->de_ih) + deh_location(deh); |
75 | if (de->de_name[de->de_namelen - 1] == 0) | 75 | if (de->de_name[de->de_namelen - 1] == 0) |
76 | de->de_namelen = strlen(de->de_name); | 76 | de->de_namelen = strlen(de->de_name); |
77 | } | 77 | } |
@@ -220,7 +220,7 @@ static int linear_search_in_dir_item(struct cpu_key *key, | |||
220 | 220 | ||
221 | i = de->de_entry_num; | 221 | i = de->de_entry_num; |
222 | 222 | ||
223 | if (i == I_ENTRY_COUNT(de->de_ih) || | 223 | if (i == ih_entry_count(de->de_ih) || |
224 | GET_HASH_VALUE(deh_offset(deh + i)) != | 224 | GET_HASH_VALUE(deh_offset(deh + i)) != |
225 | GET_HASH_VALUE(cpu_key_k_offset(key))) { | 225 | GET_HASH_VALUE(cpu_key_k_offset(key))) { |
226 | i--; | 226 | i--; |
@@ -1331,7 +1331,7 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1331 | return -EIO; | 1331 | return -EIO; |
1332 | } | 1332 | } |
1333 | 1333 | ||
1334 | copy_item_head(&old_entry_ih, get_ih(&old_entry_path)); | 1334 | copy_item_head(&old_entry_ih, tp_item_head(&old_entry_path)); |
1335 | 1335 | ||
1336 | reiserfs_prepare_for_journal(old_inode->i_sb, old_de.de_bh, 1); | 1336 | reiserfs_prepare_for_journal(old_inode->i_sb, old_de.de_bh, 1); |
1337 | 1337 | ||
@@ -1351,7 +1351,7 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1351 | return -EIO; | 1351 | return -EIO; |
1352 | } | 1352 | } |
1353 | 1353 | ||
1354 | copy_item_head(&new_entry_ih, get_ih(&new_entry_path)); | 1354 | copy_item_head(&new_entry_ih, tp_item_head(&new_entry_path)); |
1355 | 1355 | ||
1356 | reiserfs_prepare_for_journal(old_inode->i_sb, new_de.de_bh, 1); | 1356 | reiserfs_prepare_for_journal(old_inode->i_sb, new_de.de_bh, 1); |
1357 | 1357 | ||
@@ -1369,7 +1369,7 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1369 | return -EIO; | 1369 | return -EIO; |
1370 | } | 1370 | } |
1371 | copy_item_head(&dot_dot_ih, | 1371 | copy_item_head(&dot_dot_ih, |
1372 | get_ih(&dot_dot_entry_path)); | 1372 | tp_item_head(&dot_dot_entry_path)); |
1373 | // node containing ".." gets into transaction | 1373 | // node containing ".." gets into transaction |
1374 | reiserfs_prepare_for_journal(old_inode->i_sb, | 1374 | reiserfs_prepare_for_journal(old_inode->i_sb, |
1375 | dot_dot_de.de_bh, 1); | 1375 | dot_dot_de.de_bh, 1); |
diff --git a/fs/reiserfs/prints.c b/fs/reiserfs/prints.c index 54944d5a4a6e..41f788148d44 100644 --- a/fs/reiserfs/prints.c +++ b/fs/reiserfs/prints.c | |||
@@ -439,7 +439,7 @@ static int print_internal(struct buffer_head *bh, int first, int last) | |||
439 | dc = B_N_CHILD(bh, from); | 439 | dc = B_N_CHILD(bh, from); |
440 | reiserfs_printk("PTR %d: %y ", from, dc); | 440 | reiserfs_printk("PTR %d: %y ", from, dc); |
441 | 441 | ||
442 | for (i = from, key = B_N_PDELIM_KEY(bh, from), dc++; i < to; | 442 | for (i = from, key = internal_key(bh, from), dc++; i < to; |
443 | i++, key++, dc++) { | 443 | i++, key++, dc++) { |
444 | reiserfs_printk("KEY %d: %k PTR %d: %y ", i, key, i + 1, dc); | 444 | reiserfs_printk("KEY %d: %k PTR %d: %y ", i, key, i + 1, dc); |
445 | if (i && i % 4 == 0) | 445 | if (i && i % 4 == 0) |
@@ -463,7 +463,7 @@ static int print_leaf(struct buffer_head *bh, int print_mode, int first, | |||
463 | check_leaf(bh); | 463 | check_leaf(bh); |
464 | 464 | ||
465 | blkh = B_BLK_HEAD(bh); | 465 | blkh = B_BLK_HEAD(bh); |
466 | ih = B_N_PITEM_HEAD(bh, 0); | 466 | ih = item_head(bh, 0); |
467 | nr = blkh_nr_item(blkh); | 467 | nr = blkh_nr_item(blkh); |
468 | 468 | ||
469 | printk | 469 | printk |
@@ -496,7 +496,7 @@ static int print_leaf(struct buffer_head *bh, int print_mode, int first, | |||
496 | ("-------------------------------------------------------------------------------\n"); | 496 | ("-------------------------------------------------------------------------------\n"); |
497 | reiserfs_printk("|%2d| %h |\n", i, ih); | 497 | reiserfs_printk("|%2d| %h |\n", i, ih); |
498 | if (print_mode & PRINT_LEAF_ITEMS) | 498 | if (print_mode & PRINT_LEAF_ITEMS) |
499 | op_print_item(ih, B_I_PITEM(bh, ih)); | 499 | op_print_item(ih, ih_item_body(bh, ih)); |
500 | } | 500 | } |
501 | 501 | ||
502 | printk | 502 | printk |
@@ -744,8 +744,8 @@ void check_leaf(struct buffer_head *bh) | |||
744 | if (!bh) | 744 | if (!bh) |
745 | return; | 745 | return; |
746 | check_leaf_block_head(bh); | 746 | check_leaf_block_head(bh); |
747 | for (i = 0, ih = B_N_PITEM_HEAD(bh, 0); i < B_NR_ITEMS(bh); i++, ih++) | 747 | for (i = 0, ih = item_head(bh, 0); i < B_NR_ITEMS(bh); i++, ih++) |
748 | op_check_item(ih, B_I_PITEM(bh, ih)); | 748 | op_check_item(ih, ih_item_body(bh, ih)); |
749 | } | 749 | } |
750 | 750 | ||
751 | void check_internal(struct buffer_head *bh) | 751 | void check_internal(struct buffer_head *bh) |
diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h index 3f56746f0237..35bfde10ca0f 100644 --- a/fs/reiserfs/reiserfs.h +++ b/fs/reiserfs/reiserfs.h | |||
@@ -1277,9 +1277,11 @@ static inline loff_t le_ih_k_offset(const struct item_head *ih) | |||
1277 | 1277 | ||
1278 | static inline loff_t le_key_k_type(int version, const struct reiserfs_key *key) | 1278 | static inline loff_t le_key_k_type(int version, const struct reiserfs_key *key) |
1279 | { | 1279 | { |
1280 | return (version == KEY_FORMAT_3_5) ? | 1280 | if (version == KEY_FORMAT_3_5) { |
1281 | uniqueness2type(le32_to_cpu(key->u.k_offset_v1.k_uniqueness)) : | 1281 | loff_t val = le32_to_cpu(key->u.k_offset_v1.k_uniqueness); |
1282 | offset_v2_k_type(&(key->u.k_offset_v2)); | 1282 | return uniqueness2type(val); |
1283 | } else | ||
1284 | return offset_v2_k_type(&(key->u.k_offset_v2)); | ||
1283 | } | 1285 | } |
1284 | 1286 | ||
1285 | static inline loff_t le_ih_k_type(const struct item_head *ih) | 1287 | static inline loff_t le_ih_k_type(const struct item_head *ih) |
@@ -1290,8 +1292,22 @@ static inline loff_t le_ih_k_type(const struct item_head *ih) | |||
1290 | static inline void set_le_key_k_offset(int version, struct reiserfs_key *key, | 1292 | static inline void set_le_key_k_offset(int version, struct reiserfs_key *key, |
1291 | loff_t offset) | 1293 | loff_t offset) |
1292 | { | 1294 | { |
1293 | (version == KEY_FORMAT_3_5) ? (void)(key->u.k_offset_v1.k_offset = cpu_to_le32(offset)) : /* jdm check */ | 1295 | if (version == KEY_FORMAT_3_5) |
1294 | (void)(set_offset_v2_k_offset(&(key->u.k_offset_v2), offset)); | 1296 | key->u.k_offset_v1.k_offset = cpu_to_le32(offset); |
1297 | else | ||
1298 | set_offset_v2_k_offset(&key->u.k_offset_v2, offset); | ||
1299 | } | ||
1300 | |||
1301 | static inline void add_le_key_k_offset(int version, struct reiserfs_key *key, | ||
1302 | loff_t offset) | ||
1303 | { | ||
1304 | set_le_key_k_offset(version, key, | ||
1305 | le_key_k_offset(version, key) + offset); | ||
1306 | } | ||
1307 | |||
1308 | static inline void add_le_ih_k_offset(struct item_head *ih, loff_t offset) | ||
1309 | { | ||
1310 | add_le_key_k_offset(ih_version(ih), &(ih->ih_key), offset); | ||
1295 | } | 1311 | } |
1296 | 1312 | ||
1297 | static inline void set_le_ih_k_offset(struct item_head *ih, loff_t offset) | 1313 | static inline void set_le_ih_k_offset(struct item_head *ih, loff_t offset) |
@@ -1302,10 +1318,11 @@ static inline void set_le_ih_k_offset(struct item_head *ih, loff_t offset) | |||
1302 | static inline void set_le_key_k_type(int version, struct reiserfs_key *key, | 1318 | static inline void set_le_key_k_type(int version, struct reiserfs_key *key, |
1303 | int type) | 1319 | int type) |
1304 | { | 1320 | { |
1305 | (version == KEY_FORMAT_3_5) ? | 1321 | if (version == KEY_FORMAT_3_5) { |
1306 | (void)(key->u.k_offset_v1.k_uniqueness = | 1322 | type = type2uniqueness(type); |
1307 | cpu_to_le32(type2uniqueness(type))) | 1323 | key->u.k_offset_v1.k_uniqueness = cpu_to_le32(type); |
1308 | : (void)(set_offset_v2_k_type(&(key->u.k_offset_v2), type)); | 1324 | } else |
1325 | set_offset_v2_k_type(&key->u.k_offset_v2, type); | ||
1309 | } | 1326 | } |
1310 | 1327 | ||
1311 | static inline void set_le_ih_k_type(struct item_head *ih, int type) | 1328 | static inline void set_le_ih_k_type(struct item_head *ih, int type) |
@@ -1723,39 +1740,6 @@ extern void make_empty_dir_item_v1(char *body, __le32 dirid, __le32 objid, | |||
1723 | extern void make_empty_dir_item(char *body, __le32 dirid, __le32 objid, | 1740 | extern void make_empty_dir_item(char *body, __le32 dirid, __le32 objid, |
1724 | __le32 par_dirid, __le32 par_objid); | 1741 | __le32 par_dirid, __le32 par_objid); |
1725 | 1742 | ||
1726 | /* array of the entry headers */ | ||
1727 | /* get item body */ | ||
1728 | #define B_I_PITEM(bh,ih) ( (bh)->b_data + ih_location(ih) ) | ||
1729 | #define B_I_DEH(bh,ih) ((struct reiserfs_de_head *)(B_I_PITEM(bh,ih))) | ||
1730 | |||
1731 | /* length of the directory entry in directory item. This define | ||
1732 | calculates length of i-th directory entry using directory entry | ||
1733 | locations from dir entry head. When it calculates length of 0-th | ||
1734 | directory entry, it uses length of whole item in place of entry | ||
1735 | location of the non-existent following entry in the calculation. | ||
1736 | See picture above.*/ | ||
1737 | /* | ||
1738 | #define I_DEH_N_ENTRY_LENGTH(ih,deh,i) \ | ||
1739 | ((i) ? (deh_location((deh)-1) - deh_location((deh))) : (ih_item_len((ih)) - deh_location((deh)))) | ||
1740 | */ | ||
1741 | static inline int entry_length(const struct buffer_head *bh, | ||
1742 | const struct item_head *ih, int pos_in_item) | ||
1743 | { | ||
1744 | struct reiserfs_de_head *deh; | ||
1745 | |||
1746 | deh = B_I_DEH(bh, ih) + pos_in_item; | ||
1747 | if (pos_in_item) | ||
1748 | return deh_location(deh - 1) - deh_location(deh); | ||
1749 | |||
1750 | return ih_item_len(ih) - deh_location(deh); | ||
1751 | } | ||
1752 | |||
1753 | /* number of entries in the directory item, depends on ENTRY_COUNT being at the start of directory dynamic data. */ | ||
1754 | #define I_ENTRY_COUNT(ih) (ih_entry_count((ih))) | ||
1755 | |||
1756 | /* name by bh, ih and entry_num */ | ||
1757 | #define B_I_E_NAME(bh,ih,entry_num) ((char *)(bh->b_data + ih_location(ih) + deh_location(B_I_DEH(bh,ih)+(entry_num)))) | ||
1758 | |||
1759 | // two entries per block (at least) | 1743 | // two entries per block (at least) |
1760 | #define REISERFS_MAX_NAME(block_size) 255 | 1744 | #define REISERFS_MAX_NAME(block_size) 255 |
1761 | 1745 | ||
@@ -1783,7 +1767,8 @@ struct reiserfs_dir_entry { | |||
1783 | /* these defines are useful when a particular member of a reiserfs_dir_entry is needed */ | 1767 | /* these defines are useful when a particular member of a reiserfs_dir_entry is needed */ |
1784 | 1768 | ||
1785 | /* pointer to file name, stored in entry */ | 1769 | /* pointer to file name, stored in entry */ |
1786 | #define B_I_DEH_ENTRY_FILE_NAME(bh,ih,deh) (B_I_PITEM (bh, ih) + deh_location(deh)) | 1770 | #define B_I_DEH_ENTRY_FILE_NAME(bh, ih, deh) \ |
1771 | (ih_item_body(bh, ih) + deh_location(deh)) | ||
1787 | 1772 | ||
1788 | /* length of name */ | 1773 | /* length of name */ |
1789 | #define I_DEH_N_ENTRY_FILE_NAME_LENGTH(ih,deh,entry_num) \ | 1774 | #define I_DEH_N_ENTRY_FILE_NAME_LENGTH(ih,deh,entry_num) \ |
@@ -1918,8 +1903,6 @@ struct treepath var = {.path_length = ILLEGAL_PATH_ELEMENT_OFFSET, .reada = 0,} | |||
1918 | dumping paths... -Hans */ | 1903 | dumping paths... -Hans */ |
1919 | #define PATH_LAST_POSITION(path) (PATH_OFFSET_POSITION((path), (path)->path_length)) | 1904 | #define PATH_LAST_POSITION(path) (PATH_OFFSET_POSITION((path), (path)->path_length)) |
1920 | 1905 | ||
1921 | #define PATH_PITEM_HEAD(path) B_N_PITEM_HEAD(PATH_PLAST_BUFFER(path), PATH_LAST_POSITION(path)) | ||
1922 | |||
1923 | /* in do_balance leaf has h == 0 in contrast with path structure, | 1906 | /* in do_balance leaf has h == 0 in contrast with path structure, |
1924 | where root has level == 0. That is why we need these defines */ | 1907 | where root has level == 0. That is why we need these defines */ |
1925 | #define PATH_H_PBUFFER(path, h) PATH_OFFSET_PBUFFER (path, path->path_length - (h)) /* tb->S[h] */ | 1908 | #define PATH_H_PBUFFER(path, h) PATH_OFFSET_PBUFFER (path, path->path_length - (h)) /* tb->S[h] */ |
@@ -1929,13 +1912,89 @@ struct treepath var = {.path_length = ILLEGAL_PATH_ELEMENT_OFFSET, .reada = 0,} | |||
1929 | 1912 | ||
1930 | #define PATH_H_PATH_OFFSET(path, n_h) ((path)->path_length - (n_h)) | 1913 | #define PATH_H_PATH_OFFSET(path, n_h) ((path)->path_length - (n_h)) |
1931 | 1914 | ||
1915 | static inline void *reiserfs_node_data(const struct buffer_head *bh) | ||
1916 | { | ||
1917 | return bh->b_data + sizeof(struct block_head); | ||
1918 | } | ||
1919 | |||
1920 | /* get key from internal node */ | ||
1921 | static inline struct reiserfs_key *internal_key(struct buffer_head *bh, | ||
1922 | int item_num) | ||
1923 | { | ||
1924 | struct reiserfs_key *key = reiserfs_node_data(bh); | ||
1925 | |||
1926 | return &key[item_num]; | ||
1927 | } | ||
1928 | |||
1929 | /* get the item header from leaf node */ | ||
1930 | static inline struct item_head *item_head(const struct buffer_head *bh, | ||
1931 | int item_num) | ||
1932 | { | ||
1933 | struct item_head *ih = reiserfs_node_data(bh); | ||
1934 | |||
1935 | return &ih[item_num]; | ||
1936 | } | ||
1937 | |||
1938 | /* get the key from leaf node */ | ||
1939 | static inline struct reiserfs_key *leaf_key(const struct buffer_head *bh, | ||
1940 | int item_num) | ||
1941 | { | ||
1942 | return &item_head(bh, item_num)->ih_key; | ||
1943 | } | ||
1944 | |||
1945 | static inline void *ih_item_body(const struct buffer_head *bh, | ||
1946 | const struct item_head *ih) | ||
1947 | { | ||
1948 | return bh->b_data + ih_location(ih); | ||
1949 | } | ||
1950 | |||
1951 | /* get item body from leaf node */ | ||
1952 | static inline void *item_body(const struct buffer_head *bh, int item_num) | ||
1953 | { | ||
1954 | return ih_item_body(bh, item_head(bh, item_num)); | ||
1955 | } | ||
1956 | |||
1957 | static inline struct item_head *tp_item_head(const struct treepath *path) | ||
1958 | { | ||
1959 | return item_head(PATH_PLAST_BUFFER(path), PATH_LAST_POSITION(path)); | ||
1960 | } | ||
1961 | |||
1962 | static inline void *tp_item_body(const struct treepath *path) | ||
1963 | { | ||
1964 | return item_body(PATH_PLAST_BUFFER(path), PATH_LAST_POSITION(path)); | ||
1965 | } | ||
1966 | |||
1932 | #define get_last_bh(path) PATH_PLAST_BUFFER(path) | 1967 | #define get_last_bh(path) PATH_PLAST_BUFFER(path) |
1933 | #define get_ih(path) PATH_PITEM_HEAD(path) | ||
1934 | #define get_item_pos(path) PATH_LAST_POSITION(path) | 1968 | #define get_item_pos(path) PATH_LAST_POSITION(path) |
1935 | #define get_item(path) ((void *)B_N_PITEM(PATH_PLAST_BUFFER(path), PATH_LAST_POSITION (path))) | ||
1936 | #define item_moved(ih,path) comp_items(ih, path) | 1969 | #define item_moved(ih,path) comp_items(ih, path) |
1937 | #define path_changed(ih,path) comp_items (ih, path) | 1970 | #define path_changed(ih,path) comp_items (ih, path) |
1938 | 1971 | ||
1972 | /* array of the entry headers */ | ||
1973 | /* get item body */ | ||
1974 | #define B_I_DEH(bh, ih) ((struct reiserfs_de_head *)(ih_item_body(bh, ih))) | ||
1975 | |||
1976 | /* length of the directory entry in directory item. This define | ||
1977 | calculates length of i-th directory entry using directory entry | ||
1978 | locations from dir entry head. When it calculates length of 0-th | ||
1979 | directory entry, it uses length of whole item in place of entry | ||
1980 | location of the non-existent following entry in the calculation. | ||
1981 | See picture above.*/ | ||
1982 | /* | ||
1983 | #define I_DEH_N_ENTRY_LENGTH(ih,deh,i) \ | ||
1984 | ((i) ? (deh_location((deh)-1) - deh_location((deh))) : (ih_item_len((ih)) - deh_location((deh)))) | ||
1985 | */ | ||
1986 | static inline int entry_length(const struct buffer_head *bh, | ||
1987 | const struct item_head *ih, int pos_in_item) | ||
1988 | { | ||
1989 | struct reiserfs_de_head *deh; | ||
1990 | |||
1991 | deh = B_I_DEH(bh, ih) + pos_in_item; | ||
1992 | if (pos_in_item) | ||
1993 | return deh_location(deh - 1) - deh_location(deh); | ||
1994 | |||
1995 | return ih_item_len(ih) - deh_location(deh); | ||
1996 | } | ||
1997 | |||
1939 | /***************************************************************************/ | 1998 | /***************************************************************************/ |
1940 | /* MISC */ | 1999 | /* MISC */ |
1941 | /***************************************************************************/ | 2000 | /***************************************************************************/ |
@@ -2226,22 +2285,6 @@ extern struct item_operations *item_ops[TYPE_ANY + 1]; | |||
2226 | 2285 | ||
2227 | /* number of bytes contained by the direct item or the unformatted nodes the indirect item points to */ | 2286 | /* number of bytes contained by the direct item or the unformatted nodes the indirect item points to */ |
2228 | 2287 | ||
2229 | /* get the item header */ | ||
2230 | #define B_N_PITEM_HEAD(bh,item_num) ( (struct item_head * )((bh)->b_data + BLKH_SIZE) + (item_num) ) | ||
2231 | |||
2232 | /* get key */ | ||
2233 | #define B_N_PDELIM_KEY(bh,item_num) ( (struct reiserfs_key * )((bh)->b_data + BLKH_SIZE) + (item_num) ) | ||
2234 | |||
2235 | /* get the key */ | ||
2236 | #define B_N_PKEY(bh,item_num) ( &(B_N_PITEM_HEAD(bh,item_num)->ih_key) ) | ||
2237 | |||
2238 | /* get item body */ | ||
2239 | #define B_N_PITEM(bh,item_num) ( (bh)->b_data + ih_location(B_N_PITEM_HEAD((bh),(item_num)))) | ||
2240 | |||
2241 | /* get the stat data by the buffer header and the item order */ | ||
2242 | #define B_N_STAT_DATA(bh,nr) \ | ||
2243 | ( (struct stat_data *)((bh)->b_data + ih_location(B_N_PITEM_HEAD((bh),(nr))) ) ) | ||
2244 | |||
2245 | /* following defines use reiserfs buffer header and item header */ | 2288 | /* following defines use reiserfs buffer header and item header */ |
2246 | 2289 | ||
2247 | /* get stat-data */ | 2290 | /* get stat-data */ |
@@ -2253,8 +2296,10 @@ extern struct item_operations *item_ops[TYPE_ANY + 1]; | |||
2253 | /* indirect items consist of entries which contain blocknrs, pos | 2296 | /* indirect items consist of entries which contain blocknrs, pos |
2254 | indicates which entry, and B_I_POS_UNFM_POINTER resolves to the | 2297 | indicates which entry, and B_I_POS_UNFM_POINTER resolves to the |
2255 | blocknr contained by the entry pos points to */ | 2298 | blocknr contained by the entry pos points to */ |
2256 | #define B_I_POS_UNFM_POINTER(bh,ih,pos) le32_to_cpu(*(((unp_t *)B_I_PITEM(bh,ih)) + (pos))) | 2299 | #define B_I_POS_UNFM_POINTER(bh, ih, pos) \ |
2257 | #define PUT_B_I_POS_UNFM_POINTER(bh,ih,pos, val) do {*(((unp_t *)B_I_PITEM(bh,ih)) + (pos)) = cpu_to_le32(val); } while (0) | 2300 | le32_to_cpu(*(((unp_t *)ih_item_body(bh, ih)) + (pos))) |
2301 | #define PUT_B_I_POS_UNFM_POINTER(bh, ih, pos, val) \ | ||
2302 | (*(((unp_t *)ih_item_body(bh, ih)) + (pos)) = cpu_to_le32(val)) | ||
2258 | 2303 | ||
2259 | struct reiserfs_iget_args { | 2304 | struct reiserfs_iget_args { |
2260 | __u32 objectid; | 2305 | __u32 objectid; |
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c index b14706a05d52..40b3e77c8ff3 100644 --- a/fs/reiserfs/stree.c +++ b/fs/reiserfs/stree.c | |||
@@ -272,7 +272,7 @@ static inline const struct reiserfs_key *get_lkey(const struct treepath *chk_pat | |||
272 | return &MAX_KEY; | 272 | return &MAX_KEY; |
273 | /* Return delimiting key if position in the parent is not equal to zero. */ | 273 | /* Return delimiting key if position in the parent is not equal to zero. */ |
274 | if (position) | 274 | if (position) |
275 | return B_N_PDELIM_KEY(parent, position - 1); | 275 | return internal_key(parent, position - 1); |
276 | } | 276 | } |
277 | /* Return MIN_KEY if we are in the root of the buffer tree. */ | 277 | /* Return MIN_KEY if we are in the root of the buffer tree. */ |
278 | if (PATH_OFFSET_PBUFFER(chk_path, FIRST_PATH_ELEMENT_OFFSET)-> | 278 | if (PATH_OFFSET_PBUFFER(chk_path, FIRST_PATH_ELEMENT_OFFSET)-> |
@@ -315,7 +315,7 @@ inline const struct reiserfs_key *get_rkey(const struct treepath *chk_path, | |||
315 | return &MIN_KEY; | 315 | return &MIN_KEY; |
316 | /* Return delimiting key if position in the parent is not the last one. */ | 316 | /* Return delimiting key if position in the parent is not the last one. */ |
317 | if (position != B_NR_ITEMS(parent)) | 317 | if (position != B_NR_ITEMS(parent)) |
318 | return B_N_PDELIM_KEY(parent, position); | 318 | return internal_key(parent, position); |
319 | } | 319 | } |
320 | /* Return MAX_KEY if we are in the root of the buffer tree. */ | 320 | /* Return MAX_KEY if we are in the root of the buffer tree. */ |
321 | if (PATH_OFFSET_PBUFFER(chk_path, FIRST_PATH_ELEMENT_OFFSET)-> | 321 | if (PATH_OFFSET_PBUFFER(chk_path, FIRST_PATH_ELEMENT_OFFSET)-> |
@@ -732,7 +732,7 @@ int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to s | |||
732 | "vs-5152: tree level (%d) is less than stop level (%d)", | 732 | "vs-5152: tree level (%d) is less than stop level (%d)", |
733 | node_level, stop_level); | 733 | node_level, stop_level); |
734 | 734 | ||
735 | retval = bin_search(key, B_N_PITEM_HEAD(bh, 0), | 735 | retval = bin_search(key, item_head(bh, 0), |
736 | B_NR_ITEMS(bh), | 736 | B_NR_ITEMS(bh), |
737 | (node_level == | 737 | (node_level == |
738 | DISK_LEAF_NODE_LEVEL) ? IH_SIZE : | 738 | DISK_LEAF_NODE_LEVEL) ? IH_SIZE : |
@@ -779,7 +779,7 @@ int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to s | |||
779 | /* | 779 | /* |
780 | * check to make sure we're in the same object | 780 | * check to make sure we're in the same object |
781 | */ | 781 | */ |
782 | le_key = B_N_PDELIM_KEY(bh, pos); | 782 | le_key = internal_key(bh, pos); |
783 | if (le32_to_cpu(le_key->k_objectid) != | 783 | if (le32_to_cpu(le_key->k_objectid) != |
784 | key->on_disk_key.k_objectid) { | 784 | key->on_disk_key.k_objectid) { |
785 | break; | 785 | break; |
@@ -830,7 +830,7 @@ int search_for_position_by_key(struct super_block *sb, /* Pointer to the super b | |||
830 | if (retval == ITEM_FOUND) { | 830 | if (retval == ITEM_FOUND) { |
831 | 831 | ||
832 | RFALSE(!ih_item_len | 832 | RFALSE(!ih_item_len |
833 | (B_N_PITEM_HEAD | 833 | (item_head |
834 | (PATH_PLAST_BUFFER(search_path), | 834 | (PATH_PLAST_BUFFER(search_path), |
835 | PATH_LAST_POSITION(search_path))), | 835 | PATH_LAST_POSITION(search_path))), |
836 | "PAP-5165: item length equals zero"); | 836 | "PAP-5165: item length equals zero"); |
@@ -844,7 +844,7 @@ int search_for_position_by_key(struct super_block *sb, /* Pointer to the super b | |||
844 | 844 | ||
845 | /* Item is not found. Set path to the previous item. */ | 845 | /* Item is not found. Set path to the previous item. */ |
846 | p_le_ih = | 846 | p_le_ih = |
847 | B_N_PITEM_HEAD(PATH_PLAST_BUFFER(search_path), | 847 | item_head(PATH_PLAST_BUFFER(search_path), |
848 | --PATH_LAST_POSITION(search_path)); | 848 | --PATH_LAST_POSITION(search_path)); |
849 | blk_size = sb->s_blocksize; | 849 | blk_size = sb->s_blocksize; |
850 | 850 | ||
@@ -892,7 +892,7 @@ int comp_items(const struct item_head *stored_ih, const struct treepath *path) | |||
892 | return 1; | 892 | return 1; |
893 | 893 | ||
894 | /* we need only to know, whether it is the same item */ | 894 | /* we need only to know, whether it is the same item */ |
895 | ih = get_ih(path); | 895 | ih = tp_item_head(path); |
896 | return memcmp(stored_ih, ih, IH_SIZE); | 896 | return memcmp(stored_ih, ih, IH_SIZE); |
897 | } | 897 | } |
898 | 898 | ||
@@ -987,7 +987,7 @@ static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, st | |||
987 | ) | 987 | ) |
988 | { | 988 | { |
989 | struct super_block *sb = inode->i_sb; | 989 | struct super_block *sb = inode->i_sb; |
990 | struct item_head *p_le_ih = PATH_PITEM_HEAD(path); | 990 | struct item_head *p_le_ih = tp_item_head(path); |
991 | struct buffer_head *bh = PATH_PLAST_BUFFER(path); | 991 | struct buffer_head *bh = PATH_PLAST_BUFFER(path); |
992 | 992 | ||
993 | BUG_ON(!th->t_trans_id); | 993 | BUG_ON(!th->t_trans_id); |
@@ -1033,7 +1033,7 @@ static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, st | |||
1033 | need_re_search = 0; | 1033 | need_re_search = 0; |
1034 | *cut_size = 0; | 1034 | *cut_size = 0; |
1035 | bh = PATH_PLAST_BUFFER(path); | 1035 | bh = PATH_PLAST_BUFFER(path); |
1036 | copy_item_head(&s_ih, PATH_PITEM_HEAD(path)); | 1036 | copy_item_head(&s_ih, tp_item_head(path)); |
1037 | pos = I_UNFM_NUM(&s_ih); | 1037 | pos = I_UNFM_NUM(&s_ih); |
1038 | 1038 | ||
1039 | while (le_ih_k_offset (&s_ih) + (pos - 1) * blk_size > new_file_length) { | 1039 | while (le_ih_k_offset (&s_ih) + (pos - 1) * blk_size > new_file_length) { |
@@ -1047,7 +1047,7 @@ static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, st | |||
1047 | reiserfs_transaction_free_space(th) < JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD) | 1047 | reiserfs_transaction_free_space(th) < JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD) |
1048 | break; | 1048 | break; |
1049 | 1049 | ||
1050 | unfm = (__le32 *)B_I_PITEM(bh, &s_ih) + pos - 1; | 1050 | unfm = (__le32 *)ih_item_body(bh, &s_ih) + pos - 1; |
1051 | block = get_block_num(unfm, 0); | 1051 | block = get_block_num(unfm, 0); |
1052 | 1052 | ||
1053 | if (block != 0) { | 1053 | if (block != 0) { |
@@ -1095,7 +1095,7 @@ static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, st | |||
1095 | static int calc_deleted_bytes_number(struct tree_balance *tb, char mode) | 1095 | static int calc_deleted_bytes_number(struct tree_balance *tb, char mode) |
1096 | { | 1096 | { |
1097 | int del_size; | 1097 | int del_size; |
1098 | struct item_head *p_le_ih = PATH_PITEM_HEAD(tb->tb_path); | 1098 | struct item_head *p_le_ih = tp_item_head(tb->tb_path); |
1099 | 1099 | ||
1100 | if (is_statdata_le_ih(p_le_ih)) | 1100 | if (is_statdata_le_ih(p_le_ih)) |
1101 | return 0; | 1101 | return 0; |
@@ -1212,7 +1212,7 @@ int reiserfs_delete_item(struct reiserfs_transaction_handle *th, | |||
1212 | 1212 | ||
1213 | RFALSE(mode != M_DELETE, "PAP-5320: mode must be M_DELETE"); | 1213 | RFALSE(mode != M_DELETE, "PAP-5320: mode must be M_DELETE"); |
1214 | 1214 | ||
1215 | copy_item_head(&s_ih, PATH_PITEM_HEAD(path)); | 1215 | copy_item_head(&s_ih, tp_item_head(path)); |
1216 | s_del_balance.insert_size[0] = del_size; | 1216 | s_del_balance.insert_size[0] = del_size; |
1217 | 1217 | ||
1218 | ret_value = fix_nodes(M_DELETE, &s_del_balance, NULL, NULL); | 1218 | ret_value = fix_nodes(M_DELETE, &s_del_balance, NULL, NULL); |
@@ -1240,7 +1240,7 @@ int reiserfs_delete_item(struct reiserfs_transaction_handle *th, | |||
1240 | } | 1240 | } |
1241 | // reiserfs_delete_item returns item length when success | 1241 | // reiserfs_delete_item returns item length when success |
1242 | ret_value = calc_deleted_bytes_number(&s_del_balance, M_DELETE); | 1242 | ret_value = calc_deleted_bytes_number(&s_del_balance, M_DELETE); |
1243 | q_ih = get_ih(path); | 1243 | q_ih = tp_item_head(path); |
1244 | quota_cut_bytes = ih_item_len(q_ih); | 1244 | quota_cut_bytes = ih_item_len(q_ih); |
1245 | 1245 | ||
1246 | /* hack so the quota code doesn't have to guess if the file | 1246 | /* hack so the quota code doesn't have to guess if the file |
@@ -1284,7 +1284,7 @@ int reiserfs_delete_item(struct reiserfs_transaction_handle *th, | |||
1284 | data = kmap_atomic(un_bh->b_page); | 1284 | data = kmap_atomic(un_bh->b_page); |
1285 | off = ((le_ih_k_offset(&s_ih) - 1) & (PAGE_CACHE_SIZE - 1)); | 1285 | off = ((le_ih_k_offset(&s_ih) - 1) & (PAGE_CACHE_SIZE - 1)); |
1286 | memcpy(data + off, | 1286 | memcpy(data + off, |
1287 | B_I_PITEM(PATH_PLAST_BUFFER(path), &s_ih), | 1287 | ih_item_body(PATH_PLAST_BUFFER(path), &s_ih), |
1288 | ret_value); | 1288 | ret_value); |
1289 | kunmap_atomic(data); | 1289 | kunmap_atomic(data); |
1290 | } | 1290 | } |
@@ -1362,11 +1362,11 @@ void reiserfs_delete_solid_item(struct reiserfs_transaction_handle *th, | |||
1362 | } | 1362 | } |
1363 | if (!tb_init) { | 1363 | if (!tb_init) { |
1364 | tb_init = 1; | 1364 | tb_init = 1; |
1365 | item_len = ih_item_len(PATH_PITEM_HEAD(&path)); | 1365 | item_len = ih_item_len(tp_item_head(&path)); |
1366 | init_tb_struct(th, &tb, th->t_super, &path, | 1366 | init_tb_struct(th, &tb, th->t_super, &path, |
1367 | -(IH_SIZE + item_len)); | 1367 | -(IH_SIZE + item_len)); |
1368 | } | 1368 | } |
1369 | quota_cut_bytes = ih_item_len(PATH_PITEM_HEAD(&path)); | 1369 | quota_cut_bytes = ih_item_len(tp_item_head(&path)); |
1370 | 1370 | ||
1371 | retval = fix_nodes(M_DELETE, &tb, NULL, NULL); | 1371 | retval = fix_nodes(M_DELETE, &tb, NULL, NULL); |
1372 | if (retval == REPEAT_SEARCH) { | 1372 | if (retval == REPEAT_SEARCH) { |
@@ -1521,7 +1521,7 @@ static void indirect_to_direct_roll_back(struct reiserfs_transaction_handle *th, | |||
1521 | reiserfs_panic(inode->i_sb, "vs-5615", | 1521 | reiserfs_panic(inode->i_sb, "vs-5615", |
1522 | "found invalid item"); | 1522 | "found invalid item"); |
1523 | RFALSE(path->pos_in_item != | 1523 | RFALSE(path->pos_in_item != |
1524 | ih_item_len(PATH_PITEM_HEAD(path)) - 1, | 1524 | ih_item_len(tp_item_head(path)) - 1, |
1525 | "vs-5616: appended bytes found"); | 1525 | "vs-5616: appended bytes found"); |
1526 | PATH_LAST_POSITION(path)--; | 1526 | PATH_LAST_POSITION(path)--; |
1527 | 1527 | ||
@@ -1671,7 +1671,7 @@ int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th, | |||
1671 | /* Calculate number of bytes that need to be cut from the item. */ | 1671 | /* Calculate number of bytes that need to be cut from the item. */ |
1672 | quota_cut_bytes = | 1672 | quota_cut_bytes = |
1673 | (mode == | 1673 | (mode == |
1674 | M_DELETE) ? ih_item_len(get_ih(path)) : -s_cut_balance. | 1674 | M_DELETE) ? ih_item_len(tp_item_head(path)) : -s_cut_balance. |
1675 | insert_size[0]; | 1675 | insert_size[0]; |
1676 | if (retval2 == -1) | 1676 | if (retval2 == -1) |
1677 | ret_value = calc_deleted_bytes_number(&s_cut_balance, mode); | 1677 | ret_value = calc_deleted_bytes_number(&s_cut_balance, mode); |
@@ -1681,7 +1681,7 @@ int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th, | |||
1681 | /* For direct items, we only change the quota when deleting the last | 1681 | /* For direct items, we only change the quota when deleting the last |
1682 | ** item. | 1682 | ** item. |
1683 | */ | 1683 | */ |
1684 | p_le_ih = PATH_PITEM_HEAD(s_cut_balance.tb_path); | 1684 | p_le_ih = tp_item_head(s_cut_balance.tb_path); |
1685 | if (!S_ISLNK(inode->i_mode) && is_direct_le_ih(p_le_ih)) { | 1685 | if (!S_ISLNK(inode->i_mode) && is_direct_le_ih(p_le_ih)) { |
1686 | if (mode == M_DELETE && | 1686 | if (mode == M_DELETE && |
1687 | (le_ih_k_offset(p_le_ih) & (sb->s_blocksize - 1)) == | 1687 | (le_ih_k_offset(p_le_ih) & (sb->s_blocksize - 1)) == |
@@ -1696,7 +1696,7 @@ int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th, | |||
1696 | #ifdef CONFIG_REISERFS_CHECK | 1696 | #ifdef CONFIG_REISERFS_CHECK |
1697 | if (is_inode_locked) { | 1697 | if (is_inode_locked) { |
1698 | struct item_head *le_ih = | 1698 | struct item_head *le_ih = |
1699 | PATH_PITEM_HEAD(s_cut_balance.tb_path); | 1699 | tp_item_head(s_cut_balance.tb_path); |
1700 | /* we are going to complete indirect2direct conversion. Make | 1700 | /* we are going to complete indirect2direct conversion. Make |
1701 | sure, that we exactly remove last unformatted node pointer | 1701 | sure, that we exactly remove last unformatted node pointer |
1702 | of the item */ | 1702 | of the item */ |
@@ -1819,7 +1819,7 @@ int reiserfs_do_truncate(struct reiserfs_transaction_handle *th, | |||
1819 | s_search_path.pos_in_item--; | 1819 | s_search_path.pos_in_item--; |
1820 | 1820 | ||
1821 | /* Get real file size (total length of all file items) */ | 1821 | /* Get real file size (total length of all file items) */ |
1822 | p_le_ih = PATH_PITEM_HEAD(&s_search_path); | 1822 | p_le_ih = tp_item_head(&s_search_path); |
1823 | if (is_statdata_le_ih(p_le_ih)) | 1823 | if (is_statdata_le_ih(p_le_ih)) |
1824 | file_size = 0; | 1824 | file_size = 0; |
1825 | else { | 1825 | else { |
@@ -1922,7 +1922,7 @@ int reiserfs_do_truncate(struct reiserfs_transaction_handle *th, | |||
1922 | static void check_research_for_paste(struct treepath *path, | 1922 | static void check_research_for_paste(struct treepath *path, |
1923 | const struct cpu_key *key) | 1923 | const struct cpu_key *key) |
1924 | { | 1924 | { |
1925 | struct item_head *found_ih = get_ih(path); | 1925 | struct item_head *found_ih = tp_item_head(path); |
1926 | 1926 | ||
1927 | if (is_direct_le_ih(found_ih)) { | 1927 | if (is_direct_le_ih(found_ih)) { |
1928 | if (le_ih_k_offset(found_ih) + | 1928 | if (le_ih_k_offset(found_ih) + |
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index 16927b800562..c02b6b07508d 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c | |||
@@ -258,7 +258,7 @@ static int finish_unfinished(struct super_block *s) | |||
258 | break; | 258 | break; |
259 | } | 259 | } |
260 | item_pos--; | 260 | item_pos--; |
261 | ih = B_N_PITEM_HEAD(bh, item_pos); | 261 | ih = item_head(bh, item_pos); |
262 | 262 | ||
263 | if (le32_to_cpu(ih->ih_key.k_dir_id) != MAX_KEY_OBJECTID) | 263 | if (le32_to_cpu(ih->ih_key.k_dir_id) != MAX_KEY_OBJECTID) |
264 | /* there are no "save" links anymore */ | 264 | /* there are no "save" links anymore */ |
@@ -271,7 +271,7 @@ static int finish_unfinished(struct super_block *s) | |||
271 | truncate = 0; | 271 | truncate = 0; |
272 | 272 | ||
273 | /* reiserfs_iget needs k_dirid and k_objectid only */ | 273 | /* reiserfs_iget needs k_dirid and k_objectid only */ |
274 | item = B_I_PITEM(bh, ih); | 274 | item = ih_item_body(bh, ih); |
275 | obj_key.on_disk_key.k_dir_id = le32_to_cpu(*(__le32 *) item); | 275 | obj_key.on_disk_key.k_dir_id = le32_to_cpu(*(__le32 *) item); |
276 | obj_key.on_disk_key.k_objectid = | 276 | obj_key.on_disk_key.k_objectid = |
277 | le32_to_cpu(ih->ih_key.k_objectid); | 277 | le32_to_cpu(ih->ih_key.k_objectid); |
diff --git a/fs/reiserfs/tail_conversion.c b/fs/reiserfs/tail_conversion.c index 5e2624d12f70..fc1981d858dc 100644 --- a/fs/reiserfs/tail_conversion.c +++ b/fs/reiserfs/tail_conversion.c | |||
@@ -20,7 +20,7 @@ int direct2indirect(struct reiserfs_transaction_handle *th, struct inode *inode, | |||
20 | { | 20 | { |
21 | struct super_block *sb = inode->i_sb; | 21 | struct super_block *sb = inode->i_sb; |
22 | struct buffer_head *up_to_date_bh; | 22 | struct buffer_head *up_to_date_bh; |
23 | struct item_head *p_le_ih = PATH_PITEM_HEAD(path); | 23 | struct item_head *p_le_ih = tp_item_head(path); |
24 | unsigned long total_tail = 0; | 24 | unsigned long total_tail = 0; |
25 | struct cpu_key end_key; /* Key to search for the last byte of the | 25 | struct cpu_key end_key; /* Key to search for the last byte of the |
26 | converted item. */ | 26 | converted item. */ |
@@ -55,7 +55,7 @@ int direct2indirect(struct reiserfs_transaction_handle *th, struct inode *inode, | |||
55 | return -EIO; | 55 | return -EIO; |
56 | } | 56 | } |
57 | 57 | ||
58 | p_le_ih = PATH_PITEM_HEAD(path); | 58 | p_le_ih = tp_item_head(path); |
59 | 59 | ||
60 | unfm_ptr = cpu_to_le32(unbh->b_blocknr); | 60 | unfm_ptr = cpu_to_le32(unbh->b_blocknr); |
61 | 61 | ||
@@ -94,7 +94,7 @@ int direct2indirect(struct reiserfs_transaction_handle *th, struct inode *inode, | |||
94 | POSITION_FOUND) | 94 | POSITION_FOUND) |
95 | reiserfs_panic(sb, "PAP-14050", | 95 | reiserfs_panic(sb, "PAP-14050", |
96 | "direct item (%K) not found", &end_key); | 96 | "direct item (%K) not found", &end_key); |
97 | p_le_ih = PATH_PITEM_HEAD(path); | 97 | p_le_ih = tp_item_head(path); |
98 | RFALSE(!is_direct_le_ih(p_le_ih), | 98 | RFALSE(!is_direct_le_ih(p_le_ih), |
99 | "vs-14055: direct item expected(%K), found %h", | 99 | "vs-14055: direct item expected(%K), found %h", |
100 | &end_key, p_le_ih); | 100 | &end_key, p_le_ih); |
@@ -194,7 +194,7 @@ int indirect2direct(struct reiserfs_transaction_handle *th, | |||
194 | *mode = M_SKIP_BALANCING; | 194 | *mode = M_SKIP_BALANCING; |
195 | 195 | ||
196 | /* store item head path points to. */ | 196 | /* store item head path points to. */ |
197 | copy_item_head(&s_ih, PATH_PITEM_HEAD(path)); | 197 | copy_item_head(&s_ih, tp_item_head(path)); |
198 | 198 | ||
199 | tail_len = (n_new_file_size & (block_size - 1)); | 199 | tail_len = (n_new_file_size & (block_size - 1)); |
200 | if (get_inode_sd_version(inode) == STAT_DATA_V2) | 200 | if (get_inode_sd_version(inode) == STAT_DATA_V2) |
@@ -220,7 +220,7 @@ int indirect2direct(struct reiserfs_transaction_handle *th, | |||
220 | reiserfs_panic(sb, "PAP-5520", | 220 | reiserfs_panic(sb, "PAP-5520", |
221 | "item to be converted %K does not exist", | 221 | "item to be converted %K does not exist", |
222 | item_key); | 222 | item_key); |
223 | copy_item_head(&s_ih, PATH_PITEM_HEAD(path)); | 223 | copy_item_head(&s_ih, tp_item_head(path)); |
224 | #ifdef CONFIG_REISERFS_CHECK | 224 | #ifdef CONFIG_REISERFS_CHECK |
225 | pos = le_ih_k_offset(&s_ih) - 1 + | 225 | pos = le_ih_k_offset(&s_ih) - 1 + |
226 | (ih_item_len(&s_ih) / UNFM_P_SIZE - | 226 | (ih_item_len(&s_ih) / UNFM_P_SIZE - |