aboutsummaryrefslogtreecommitdiffstats
path: root/fs/reiserfs/lbalance.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/reiserfs/lbalance.c')
-rw-r--r--fs/reiserfs/lbalance.c66
1 files changed, 37 insertions, 29 deletions
diff --git a/fs/reiserfs/lbalance.c b/fs/reiserfs/lbalance.c
index 6de060a6aa7f..381750a155f6 100644
--- a/fs/reiserfs/lbalance.c
+++ b/fs/reiserfs/lbalance.c
@@ -111,7 +111,7 @@ static void leaf_copy_dir_entries(struct buffer_info *dest_bi,
111 item_num_in_dest = 111 item_num_in_dest =
112 (last_first == FIRST_TO_LAST) ? (B_NR_ITEMS(dest) - 1) : 0; 112 (last_first == FIRST_TO_LAST) ? (B_NR_ITEMS(dest) - 1) : 0;
113 113
114 leaf_paste_entries(dest_bi->bi_bh, 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) ? I_ENTRY_COUNT(B_N_PITEM_HEAD(dest,
117 item_num_in_dest)) 117 item_num_in_dest))
@@ -119,8 +119,8 @@ static void leaf_copy_dir_entries(struct buffer_info *dest_bi,
119 DEH_SIZE * copy_count + copy_records_len); 119 DEH_SIZE * copy_count + copy_records_len);
120} 120}
121 121
122/* Copy the first (if last_first == FIRST_TO_LAST) or last (last_first == LAST_TO_FIRST) item or 122/* Copy the first (if last_first == FIRST_TO_LAST) or last (last_first == LAST_TO_FIRST) item or
123 part of it or nothing (see the return 0 below) from SOURCE to the end 123 part of it or nothing (see the return 0 below) from SOURCE to the end
124 (if last_first) or beginning (!last_first) of the DEST */ 124 (if last_first) or beginning (!last_first) of the DEST */
125/* returns 1 if anything was copied, else 0 */ 125/* returns 1 if anything was copied, else 0 */
126static int leaf_copy_boundary_item(struct buffer_info *dest_bi, 126static int leaf_copy_boundary_item(struct buffer_info *dest_bi,
@@ -168,10 +168,11 @@ static int leaf_copy_boundary_item(struct buffer_info *dest_bi,
168 if (bytes_or_entries == ih_item_len(ih) 168 if (bytes_or_entries == ih_item_len(ih)
169 && is_indirect_le_ih(ih)) 169 && is_indirect_le_ih(ih))
170 if (get_ih_free_space(ih)) 170 if (get_ih_free_space(ih))
171 reiserfs_panic(NULL, 171 reiserfs_panic(sb_from_bi(dest_bi),
172 "vs-10020: leaf_copy_boundary_item: " 172 "vs-10020",
173 "last unformatted node must be filled entirely (%h)", 173 "last unformatted node "
174 ih); 174 "must be filled "
175 "entirely (%h)", ih);
175 } 176 }
176#endif 177#endif
177 178
@@ -395,7 +396,7 @@ static void leaf_item_bottle(struct buffer_info *dest_bi,
395 else { 396 else {
396 struct item_head n_ih; 397 struct item_head n_ih;
397 398
398 /* copy part of the body of the item number 'item_num' of SOURCE to the end of the DEST 399 /* copy part of the body of the item number 'item_num' of SOURCE to the end of the DEST
399 part defined by 'cpy_bytes'; create new item header; change old item_header (????); 400 part defined by 'cpy_bytes'; create new item header; change old item_header (????);
400 n_ih = new item_header; 401 n_ih = new item_header;
401 */ 402 */
@@ -425,7 +426,7 @@ static void leaf_item_bottle(struct buffer_info *dest_bi,
425 else { 426 else {
426 struct item_head n_ih; 427 struct item_head n_ih;
427 428
428 /* copy part of the body of the item number 'item_num' of SOURCE to the begin of the DEST 429 /* copy part of the body of the item number 'item_num' of SOURCE to the begin of the DEST
429 part defined by 'cpy_bytes'; create new item header; 430 part defined by 'cpy_bytes'; create new item header;
430 n_ih = new item_header; 431 n_ih = new item_header;
431 */ 432 */
@@ -622,9 +623,8 @@ static void leaf_define_dest_src_infos(int shift_mode, struct tree_balance *tb,
622 break; 623 break;
623 624
624 default: 625 default:
625 reiserfs_panic(NULL, 626 reiserfs_panic(sb_from_bi(src_bi), "vs-10250",
626 "vs-10250: leaf_define_dest_src_infos: shift type is unknown (%d)", 627 "shift type is unknown (%d)", shift_mode);
627 shift_mode);
628 } 628 }
629 RFALSE(!src_bi->bi_bh || !dest_bi->bi_bh, 629 RFALSE(!src_bi->bi_bh || !dest_bi->bi_bh,
630 "vs-10260: mode==%d, source (%p) or dest (%p) buffer is initialized incorrectly", 630 "vs-10260: mode==%d, source (%p) or dest (%p) buffer is initialized incorrectly",
@@ -674,9 +674,9 @@ int leaf_shift_left(struct tree_balance *tb, int shift_num, int shift_bytes)
674#ifdef CONFIG_REISERFS_CHECK 674#ifdef CONFIG_REISERFS_CHECK
675 if (tb->tb_mode == M_PASTE || tb->tb_mode == M_INSERT) { 675 if (tb->tb_mode == M_PASTE || tb->tb_mode == M_INSERT) {
676 print_cur_tb("vs-10275"); 676 print_cur_tb("vs-10275");
677 reiserfs_panic(tb->tb_sb, 677 reiserfs_panic(tb->tb_sb, "vs-10275",
678 "vs-10275: leaf_shift_left: balance condition corrupted (%c)", 678 "balance condition corrupted "
679 tb->tb_mode); 679 "(%c)", tb->tb_mode);
680 } 680 }
681#endif 681#endif
682 682
@@ -724,7 +724,7 @@ int leaf_shift_right(struct tree_balance *tb, int shift_num, int shift_bytes)
724static void leaf_delete_items_entirely(struct buffer_info *bi, 724static void leaf_delete_items_entirely(struct buffer_info *bi,
725 int first, int del_num); 725 int first, int del_num);
726/* If del_bytes == -1, starting from position 'first' delete del_num items in whole in buffer CUR. 726/* If del_bytes == -1, starting from position 'first' delete del_num items in whole in buffer CUR.
727 If not. 727 If not.
728 If last_first == 0. Starting from position 'first' delete del_num-1 items in whole. Delete part of body of 728 If last_first == 0. Starting from position 'first' delete del_num-1 items in whole. Delete part of body of
729 the first item. Part defined by del_bytes. Don't delete first item header 729 the first item. Part defined by del_bytes. Don't delete first item header
730 If last_first == 1. Starting from position 'first+1' delete del_num-1 items in whole. Delete part of body of 730 If last_first == 1. Starting from position 'first+1' delete del_num-1 items in whole. Delete part of body of
@@ -783,7 +783,7 @@ void leaf_delete_items(struct buffer_info *cur_bi, int last_first,
783 /* len = body len of item */ 783 /* len = body len of item */
784 len = ih_item_len(ih); 784 len = ih_item_len(ih);
785 785
786 /* delete the part of the last item of the bh 786 /* delete the part of the last item of the bh
787 do not delete item header 787 do not delete item header
788 */ 788 */
789 leaf_cut_from_buffer(cur_bi, B_NR_ITEMS(bh) - 1, 789 leaf_cut_from_buffer(cur_bi, B_NR_ITEMS(bh) - 1,
@@ -865,7 +865,7 @@ void leaf_insert_into_buf(struct buffer_info *bi, int before,
865 } 865 }
866} 866}
867 867
868/* paste paste_size bytes to affected_item_num-th item. 868/* paste paste_size bytes to affected_item_num-th item.
869 When item is a directory, this only prepare space for new entries */ 869 When item is a directory, this only prepare space for new entries */
870void leaf_paste_in_buffer(struct buffer_info *bi, int affected_item_num, 870void leaf_paste_in_buffer(struct buffer_info *bi, int affected_item_num,
871 int pos_in_item, int paste_size, 871 int pos_in_item, int paste_size,
@@ -889,9 +889,12 @@ void leaf_paste_in_buffer(struct buffer_info *bi, int affected_item_num,
889 889
890#ifdef CONFIG_REISERFS_CHECK 890#ifdef CONFIG_REISERFS_CHECK
891 if (zeros_number > paste_size) { 891 if (zeros_number > paste_size) {
892 struct super_block *sb = NULL;
893 if (bi && bi->tb)
894 sb = bi->tb->tb_sb;
892 print_cur_tb("10177"); 895 print_cur_tb("10177");
893 reiserfs_panic(NULL, 896 reiserfs_panic(sb, "vs-10177",
894 "vs-10177: leaf_paste_in_buffer: ero number == %d, paste_size == %d", 897 "zeros_number == %d, paste_size == %d",
895 zeros_number, paste_size); 898 zeros_number, paste_size);
896 } 899 }
897#endif /* CONFIG_REISERFS_CHECK */ 900#endif /* CONFIG_REISERFS_CHECK */
@@ -1019,7 +1022,7 @@ static int leaf_cut_entries(struct buffer_head *bh,
1019/* when cut item is part of regular file 1022/* when cut item is part of regular file
1020 pos_in_item - first byte that must be cut 1023 pos_in_item - first byte that must be cut
1021 cut_size - number of bytes to be cut beginning from pos_in_item 1024 cut_size - number of bytes to be cut beginning from pos_in_item
1022 1025
1023 when cut item is part of directory 1026 when cut item is part of directory
1024 pos_in_item - number of first deleted entry 1027 pos_in_item - number of first deleted entry
1025 cut_size - count of deleted entries 1028 cut_size - count of deleted entries
@@ -1191,7 +1194,7 @@ static void leaf_delete_items_entirely(struct buffer_info *bi,
1191} 1194}
1192 1195
1193/* paste new_entry_count entries (new_dehs, records) into position before to item_num-th item */ 1196/* paste new_entry_count entries (new_dehs, records) into position before to item_num-th item */
1194void leaf_paste_entries(struct buffer_head *bh, 1197void leaf_paste_entries(struct buffer_info *bi,
1195 int item_num, 1198 int item_num,
1196 int before, 1199 int before,
1197 int new_entry_count, 1200 int new_entry_count,
@@ -1203,6 +1206,7 @@ void leaf_paste_entries(struct buffer_head *bh,
1203 struct reiserfs_de_head *deh; 1206 struct reiserfs_de_head *deh;
1204 char *insert_point; 1207 char *insert_point;
1205 int i, old_entry_num; 1208 int i, old_entry_num;
1209 struct buffer_head *bh = bi->bi_bh;
1206 1210
1207 if (new_entry_count == 0) 1211 if (new_entry_count == 0)
1208 return; 1212 return;
@@ -1271,7 +1275,7 @@ void leaf_paste_entries(struct buffer_head *bh,
1271 /* change item key if necessary (when we paste before 0-th entry */ 1275 /* change item key if necessary (when we paste before 0-th entry */
1272 if (!before) { 1276 if (!before) {
1273 set_le_ih_k_offset(ih, deh_offset(new_dehs)); 1277 set_le_ih_k_offset(ih, deh_offset(new_dehs));
1274/* memcpy (&ih->ih_key.k_offset, 1278/* memcpy (&ih->ih_key.k_offset,
1275 &new_dehs->deh_offset, SHORT_KEY_SIZE);*/ 1279 &new_dehs->deh_offset, SHORT_KEY_SIZE);*/
1276 } 1280 }
1277#ifdef CONFIG_REISERFS_CHECK 1281#ifdef CONFIG_REISERFS_CHECK
@@ -1287,13 +1291,17 @@ void leaf_paste_entries(struct buffer_head *bh,
1287 prev = (i != 0) ? deh_location(&(deh[i - 1])) : 0; 1291 prev = (i != 0) ? deh_location(&(deh[i - 1])) : 0;
1288 1292
1289 if (prev && prev <= deh_location(&(deh[i]))) 1293 if (prev && prev <= deh_location(&(deh[i])))
1290 reiserfs_warning(NULL, 1294 reiserfs_error(sb_from_bi(bi), "vs-10240",
1291 "vs-10240: leaf_paste_entries: directory item (%h) corrupted (prev %a, cur(%d) %a)", 1295 "directory item (%h) "
1292 ih, deh + i - 1, i, deh + i); 1296 "corrupted (prev %a, "
1297 "cur(%d) %a)",
1298 ih, deh + i - 1, i, deh + i);
1293 if (next && next >= deh_location(&(deh[i]))) 1299 if (next && next >= deh_location(&(deh[i])))
1294 reiserfs_warning(NULL, 1300 reiserfs_error(sb_from_bi(bi), "vs-10250",
1295 "vs-10250: leaf_paste_entries: directory item (%h) corrupted (cur(%d) %a, next %a)", 1301 "directory item (%h) "
1296 ih, i, deh + i, deh + i + 1); 1302 "corrupted (cur(%d) %a, "
1303 "next %a)",
1304 ih, i, deh + i, deh + i + 1);
1297 } 1305 }
1298 } 1306 }
1299#endif 1307#endif