diff options
author | Jeff Mahoney <jeffm@suse.com> | 2014-04-23 10:00:58 -0400 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2014-05-07 13:14:22 -0400 |
commit | 8dbf0d8c9ba6df7e8437244b5fa9648dca55ef11 (patch) | |
tree | 4b90a947a842563587b752f47f5eec6d78e60c48 /fs/reiserfs | |
parent | 3fade9377f44586845e82d542368cbf78471653c (diff) |
reiserfs: balance_leaf refactor, format balance_leaf_insert_right
Reformat balance_leaf_insert_right to adhere to CodingStyle.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/reiserfs')
-rw-r--r-- | fs/reiserfs/do_balan.c | 117 |
1 files changed, 65 insertions, 52 deletions
diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c index 843c4023ad36..fcebfca0bbb8 100644 --- a/fs/reiserfs/do_balan.c +++ b/fs/reiserfs/do_balan.c | |||
@@ -626,71 +626,84 @@ static void balance_leaf_insert_right(struct tree_balance *tb, | |||
626 | struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path); | 626 | struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path); |
627 | int n = B_NR_ITEMS(tbS0); | 627 | int n = B_NR_ITEMS(tbS0); |
628 | struct buffer_info bi; | 628 | struct buffer_info bi; |
629 | int ret_val; | 629 | int ret; |
630 | if (n - tb->rnum[0] < tb->item_pos) { /* new item or its part falls to R[0] */ | ||
631 | if (tb->item_pos == n - tb->rnum[0] + 1 && tb->rbytes != -1) { /* part of new item falls into R[0] */ | ||
632 | loff_t old_key_comp, old_len, r_zeroes_number; | ||
633 | const char *r_body; | ||
634 | int version; | ||
635 | loff_t offset; | ||
636 | 630 | ||
637 | leaf_shift_right(tb, tb->rnum[0] - 1, -1); | 631 | /* new item or part of it doesn't fall into R[0] */ |
632 | if (n - tb->rnum[0] >= tb->item_pos) { | ||
633 | leaf_shift_right(tb, tb->rnum[0], tb->rbytes); | ||
634 | return; | ||
635 | } | ||
638 | 636 | ||
639 | version = ih_version(ih); | 637 | /* new item or its part falls to R[0] */ |
640 | /* Remember key component and item length */ | ||
641 | old_key_comp = le_ih_k_offset(ih); | ||
642 | old_len = ih_item_len(ih); | ||
643 | 638 | ||
644 | /* Calculate key component and item length to insert into R[0] */ | 639 | /* part of new item falls into R[0] */ |
645 | offset = le_ih_k_offset(ih) + ((old_len - tb->rbytes) << (is_indirect_le_ih(ih) ? tb->tb_sb->s_blocksize_bits - UNFM_P_SHIFT : 0)); | 640 | if (tb->item_pos == n - tb->rnum[0] + 1 && tb->rbytes != -1) { |
646 | set_le_ih_k_offset(ih, offset); | 641 | loff_t old_key_comp, old_len, r_zeroes_number; |
647 | put_ih_item_len(ih, tb->rbytes); | 642 | const char *r_body; |
648 | /* Insert part of the item into R[0] */ | 643 | int version, shift; |
649 | buffer_info_init_right(tb, &bi); | 644 | loff_t offset; |
650 | if ((old_len - tb->rbytes) > tb->zeroes_num) { | 645 | |
651 | r_zeroes_number = 0; | 646 | leaf_shift_right(tb, tb->rnum[0] - 1, -1); |
652 | r_body = body + (old_len - tb->rbytes) - tb->zeroes_num; | ||
653 | } else { | ||
654 | r_body = body; | ||
655 | r_zeroes_number = tb->zeroes_num - (old_len - tb->rbytes); | ||
656 | tb->zeroes_num -= r_zeroes_number; | ||
657 | } | ||
658 | 647 | ||
659 | leaf_insert_into_buf(&bi, 0, ih, r_body, | 648 | version = ih_version(ih); |
660 | r_zeroes_number); | ||
661 | 649 | ||
662 | /* Replace right delimiting key by first key in R[0] */ | 650 | /* Remember key component and item length */ |
663 | replace_key(tb, tb->CFR[0], tb->rkey[0], | 651 | old_key_comp = le_ih_k_offset(ih); |
664 | tb->R[0], 0); | 652 | old_len = ih_item_len(ih); |
665 | 653 | ||
666 | /* Calculate key component and item length to insert into S[0] */ | 654 | /* |
667 | set_le_ih_k_offset(ih, old_key_comp); | 655 | * Calculate key component and item length to insert |
668 | put_ih_item_len(ih, old_len - tb->rbytes); | 656 | * into R[0] |
657 | */ | ||
658 | shift = 0; | ||
659 | if (is_indirect_le_ih(ih)) | ||
660 | shift = tb->tb_sb->s_blocksize_bits - UNFM_P_SHIFT; | ||
661 | offset = le_ih_k_offset(ih) + ((old_len - tb->rbytes) << shift); | ||
662 | set_le_ih_k_offset(ih, offset); | ||
663 | put_ih_item_len(ih, tb->rbytes); | ||
664 | |||
665 | /* Insert part of the item into R[0] */ | ||
666 | buffer_info_init_right(tb, &bi); | ||
667 | if ((old_len - tb->rbytes) > tb->zeroes_num) { | ||
668 | r_zeroes_number = 0; | ||
669 | r_body = body + (old_len - tb->rbytes) - tb->zeroes_num; | ||
670 | } else { | ||
671 | r_body = body; | ||
672 | r_zeroes_number = tb->zeroes_num - | ||
673 | (old_len - tb->rbytes); | ||
674 | tb->zeroes_num -= r_zeroes_number; | ||
675 | } | ||
669 | 676 | ||
670 | tb->insert_size[0] -= tb->rbytes; | 677 | leaf_insert_into_buf(&bi, 0, ih, r_body, r_zeroes_number); |
671 | 678 | ||
672 | } else { /* whole new item falls into R[0] */ | 679 | /* Replace right delimiting key by first key in R[0] */ |
680 | replace_key(tb, tb->CFR[0], tb->rkey[0], tb->R[0], 0); | ||
673 | 681 | ||
674 | /* Shift rnum[0]-1 items to R[0] */ | 682 | /* |
675 | ret_val = leaf_shift_right(tb, tb->rnum[0] - 1, tb->rbytes); | 683 | * Calculate key component and item length to |
676 | /* Insert new item into R[0] */ | 684 | * insert into S[0] |
677 | buffer_info_init_right(tb, &bi); | 685 | */ |
678 | leaf_insert_into_buf(&bi, tb->item_pos - n + tb->rnum[0] - 1, | 686 | set_le_ih_k_offset(ih, old_key_comp); |
679 | ih, body, tb->zeroes_num); | 687 | put_ih_item_len(ih, old_len - tb->rbytes); |
680 | 688 | ||
681 | if (tb->item_pos - n + tb->rnum[0] - 1 == 0) { | 689 | tb->insert_size[0] -= tb->rbytes; |
682 | replace_key(tb, tb->CFR[0], | ||
683 | tb->rkey[0], | ||
684 | tb->R[0], 0); | ||
685 | 690 | ||
686 | } | 691 | } else { |
687 | tb->zeroes_num = tb->insert_size[0] = 0; | 692 | /* whole new item falls into R[0] */ |
688 | } | ||
689 | } else { /* new item or part of it doesn't fall into R[0] */ | ||
690 | 693 | ||
691 | leaf_shift_right(tb, tb->rnum[0], tb->rbytes); | 694 | /* Shift rnum[0]-1 items to R[0] */ |
692 | } | 695 | ret = leaf_shift_right(tb, tb->rnum[0] - 1, tb->rbytes); |
696 | |||
697 | /* Insert new item into R[0] */ | ||
698 | buffer_info_init_right(tb, &bi); | ||
699 | leaf_insert_into_buf(&bi, tb->item_pos - n + tb->rnum[0] - 1, | ||
700 | ih, body, tb->zeroes_num); | ||
693 | 701 | ||
702 | if (tb->item_pos - n + tb->rnum[0] - 1 == 0) | ||
703 | replace_key(tb, tb->CFR[0], tb->rkey[0], tb->R[0], 0); | ||
704 | |||
705 | tb->zeroes_num = tb->insert_size[0] = 0; | ||
706 | } | ||
694 | } | 707 | } |
695 | 708 | ||
696 | static void balance_leaf_paste_right(struct tree_balance *tb, | 709 | static void balance_leaf_paste_right(struct tree_balance *tb, |