diff options
Diffstat (limited to 'fs/nilfs2/btree.c')
-rw-r--r-- | fs/nilfs2/btree.c | 106 |
1 files changed, 37 insertions, 69 deletions
diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c index e25b507a474f..7cdd98b8d514 100644 --- a/fs/nilfs2/btree.c +++ b/fs/nilfs2/btree.c | |||
@@ -114,7 +114,18 @@ static int nilfs_btree_get_block(const struct nilfs_btree *btree, __u64 ptr, | |||
114 | { | 114 | { |
115 | struct address_space *btnc = | 115 | struct address_space *btnc = |
116 | &NILFS_BMAP_I((struct nilfs_bmap *)btree)->i_btnode_cache; | 116 | &NILFS_BMAP_I((struct nilfs_bmap *)btree)->i_btnode_cache; |
117 | return nilfs_btnode_get(btnc, ptr, 0, bhp, 0); | 117 | int err; |
118 | |||
119 | err = nilfs_btnode_submit_block(btnc, ptr, 0, bhp); | ||
120 | if (err) | ||
121 | return err == -EEXIST ? 0 : err; | ||
122 | |||
123 | wait_on_buffer(*bhp); | ||
124 | if (!buffer_uptodate(*bhp)) { | ||
125 | brelse(*bhp); | ||
126 | return -EIO; | ||
127 | } | ||
128 | return 0; | ||
118 | } | 129 | } |
119 | 130 | ||
120 | static int nilfs_btree_get_new_block(const struct nilfs_btree *btree, | 131 | static int nilfs_btree_get_new_block(const struct nilfs_btree *btree, |
@@ -122,12 +133,15 @@ static int nilfs_btree_get_new_block(const struct nilfs_btree *btree, | |||
122 | { | 133 | { |
123 | struct address_space *btnc = | 134 | struct address_space *btnc = |
124 | &NILFS_BMAP_I((struct nilfs_bmap *)btree)->i_btnode_cache; | 135 | &NILFS_BMAP_I((struct nilfs_bmap *)btree)->i_btnode_cache; |
125 | int ret; | 136 | struct buffer_head *bh; |
126 | 137 | ||
127 | ret = nilfs_btnode_get(btnc, ptr, 0, bhp, 1); | 138 | bh = nilfs_btnode_create_block(btnc, ptr); |
128 | if (!ret) | 139 | if (!bh) |
129 | set_buffer_nilfs_volatile(*bhp); | 140 | return -ENOMEM; |
130 | return ret; | 141 | |
142 | set_buffer_nilfs_volatile(bh); | ||
143 | *bhp = bh; | ||
144 | return 0; | ||
131 | } | 145 | } |
132 | 146 | ||
133 | static inline int | 147 | static inline int |
@@ -444,6 +458,18 @@ nilfs_btree_get_node(const struct nilfs_btree *btree, | |||
444 | nilfs_btree_get_nonroot_node(path, level); | 458 | nilfs_btree_get_nonroot_node(path, level); |
445 | } | 459 | } |
446 | 460 | ||
461 | static inline int | ||
462 | nilfs_btree_bad_node(struct nilfs_btree_node *node, int level) | ||
463 | { | ||
464 | if (unlikely(nilfs_btree_node_get_level(node) != level)) { | ||
465 | dump_stack(); | ||
466 | printk(KERN_CRIT "NILFS: btree level mismatch: %d != %d\n", | ||
467 | nilfs_btree_node_get_level(node), level); | ||
468 | return 1; | ||
469 | } | ||
470 | return 0; | ||
471 | } | ||
472 | |||
447 | static int nilfs_btree_do_lookup(const struct nilfs_btree *btree, | 473 | static int nilfs_btree_do_lookup(const struct nilfs_btree *btree, |
448 | struct nilfs_btree_path *path, | 474 | struct nilfs_btree_path *path, |
449 | __u64 key, __u64 *ptrp, int minlevel) | 475 | __u64 key, __u64 *ptrp, int minlevel) |
@@ -467,7 +493,8 @@ static int nilfs_btree_do_lookup(const struct nilfs_btree *btree, | |||
467 | if (ret < 0) | 493 | if (ret < 0) |
468 | return ret; | 494 | return ret; |
469 | node = nilfs_btree_get_nonroot_node(path, level); | 495 | node = nilfs_btree_get_nonroot_node(path, level); |
470 | BUG_ON(level != nilfs_btree_node_get_level(node)); | 496 | if (nilfs_btree_bad_node(node, level)) |
497 | return -EINVAL; | ||
471 | if (!found) | 498 | if (!found) |
472 | found = nilfs_btree_node_lookup(node, key, &index); | 499 | found = nilfs_btree_node_lookup(node, key, &index); |
473 | else | 500 | else |
@@ -512,7 +539,8 @@ static int nilfs_btree_do_lookup_last(const struct nilfs_btree *btree, | |||
512 | if (ret < 0) | 539 | if (ret < 0) |
513 | return ret; | 540 | return ret; |
514 | node = nilfs_btree_get_nonroot_node(path, level); | 541 | node = nilfs_btree_get_nonroot_node(path, level); |
515 | BUG_ON(level != nilfs_btree_node_get_level(node)); | 542 | if (nilfs_btree_bad_node(node, level)) |
543 | return -EINVAL; | ||
516 | index = nilfs_btree_node_get_nchildren(node) - 1; | 544 | index = nilfs_btree_node_get_nchildren(node) - 1; |
517 | ptr = nilfs_btree_node_get_ptr(btree, node, index); | 545 | ptr = nilfs_btree_node_get_ptr(btree, node, index); |
518 | path[level].bp_index = index; | 546 | path[level].bp_index = index; |
@@ -638,13 +666,11 @@ static void nilfs_btree_promote_key(struct nilfs_btree *btree, | |||
638 | { | 666 | { |
639 | if (level < nilfs_btree_height(btree) - 1) { | 667 | if (level < nilfs_btree_height(btree) - 1) { |
640 | do { | 668 | do { |
641 | lock_buffer(path[level].bp_bh); | ||
642 | nilfs_btree_node_set_key( | 669 | nilfs_btree_node_set_key( |
643 | nilfs_btree_get_nonroot_node(path, level), | 670 | nilfs_btree_get_nonroot_node(path, level), |
644 | path[level].bp_index, key); | 671 | path[level].bp_index, key); |
645 | if (!buffer_dirty(path[level].bp_bh)) | 672 | if (!buffer_dirty(path[level].bp_bh)) |
646 | nilfs_btnode_mark_dirty(path[level].bp_bh); | 673 | nilfs_btnode_mark_dirty(path[level].bp_bh); |
647 | unlock_buffer(path[level].bp_bh); | ||
648 | } while ((path[level].bp_index == 0) && | 674 | } while ((path[level].bp_index == 0) && |
649 | (++level < nilfs_btree_height(btree) - 1)); | 675 | (++level < nilfs_btree_height(btree) - 1)); |
650 | } | 676 | } |
@@ -663,13 +689,11 @@ static void nilfs_btree_do_insert(struct nilfs_btree *btree, | |||
663 | struct nilfs_btree_node *node; | 689 | struct nilfs_btree_node *node; |
664 | 690 | ||
665 | if (level < nilfs_btree_height(btree) - 1) { | 691 | if (level < nilfs_btree_height(btree) - 1) { |
666 | lock_buffer(path[level].bp_bh); | ||
667 | node = nilfs_btree_get_nonroot_node(path, level); | 692 | node = nilfs_btree_get_nonroot_node(path, level); |
668 | nilfs_btree_node_insert(btree, node, *keyp, *ptrp, | 693 | nilfs_btree_node_insert(btree, node, *keyp, *ptrp, |
669 | path[level].bp_index); | 694 | path[level].bp_index); |
670 | if (!buffer_dirty(path[level].bp_bh)) | 695 | if (!buffer_dirty(path[level].bp_bh)) |
671 | nilfs_btnode_mark_dirty(path[level].bp_bh); | 696 | nilfs_btnode_mark_dirty(path[level].bp_bh); |
672 | unlock_buffer(path[level].bp_bh); | ||
673 | 697 | ||
674 | if (path[level].bp_index == 0) | 698 | if (path[level].bp_index == 0) |
675 | nilfs_btree_promote_key(btree, path, level + 1, | 699 | nilfs_btree_promote_key(btree, path, level + 1, |
@@ -689,9 +713,6 @@ static void nilfs_btree_carry_left(struct nilfs_btree *btree, | |||
689 | struct nilfs_btree_node *node, *left; | 713 | struct nilfs_btree_node *node, *left; |
690 | int nchildren, lnchildren, n, move; | 714 | int nchildren, lnchildren, n, move; |
691 | 715 | ||
692 | lock_buffer(path[level].bp_bh); | ||
693 | lock_buffer(path[level].bp_sib_bh); | ||
694 | |||
695 | node = nilfs_btree_get_nonroot_node(path, level); | 716 | node = nilfs_btree_get_nonroot_node(path, level); |
696 | left = nilfs_btree_get_sib_node(path, level); | 717 | left = nilfs_btree_get_sib_node(path, level); |
697 | nchildren = nilfs_btree_node_get_nchildren(node); | 718 | nchildren = nilfs_btree_node_get_nchildren(node); |
@@ -712,9 +733,6 @@ static void nilfs_btree_carry_left(struct nilfs_btree *btree, | |||
712 | if (!buffer_dirty(path[level].bp_sib_bh)) | 733 | if (!buffer_dirty(path[level].bp_sib_bh)) |
713 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); | 734 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); |
714 | 735 | ||
715 | unlock_buffer(path[level].bp_bh); | ||
716 | unlock_buffer(path[level].bp_sib_bh); | ||
717 | |||
718 | nilfs_btree_promote_key(btree, path, level + 1, | 736 | nilfs_btree_promote_key(btree, path, level + 1, |
719 | nilfs_btree_node_get_key(node, 0)); | 737 | nilfs_btree_node_get_key(node, 0)); |
720 | 738 | ||
@@ -740,9 +758,6 @@ static void nilfs_btree_carry_right(struct nilfs_btree *btree, | |||
740 | struct nilfs_btree_node *node, *right; | 758 | struct nilfs_btree_node *node, *right; |
741 | int nchildren, rnchildren, n, move; | 759 | int nchildren, rnchildren, n, move; |
742 | 760 | ||
743 | lock_buffer(path[level].bp_bh); | ||
744 | lock_buffer(path[level].bp_sib_bh); | ||
745 | |||
746 | node = nilfs_btree_get_nonroot_node(path, level); | 761 | node = nilfs_btree_get_nonroot_node(path, level); |
747 | right = nilfs_btree_get_sib_node(path, level); | 762 | right = nilfs_btree_get_sib_node(path, level); |
748 | nchildren = nilfs_btree_node_get_nchildren(node); | 763 | nchildren = nilfs_btree_node_get_nchildren(node); |
@@ -763,9 +778,6 @@ static void nilfs_btree_carry_right(struct nilfs_btree *btree, | |||
763 | if (!buffer_dirty(path[level].bp_sib_bh)) | 778 | if (!buffer_dirty(path[level].bp_sib_bh)) |
764 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); | 779 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); |
765 | 780 | ||
766 | unlock_buffer(path[level].bp_bh); | ||
767 | unlock_buffer(path[level].bp_sib_bh); | ||
768 | |||
769 | path[level + 1].bp_index++; | 781 | path[level + 1].bp_index++; |
770 | nilfs_btree_promote_key(btree, path, level + 1, | 782 | nilfs_btree_promote_key(btree, path, level + 1, |
771 | nilfs_btree_node_get_key(right, 0)); | 783 | nilfs_btree_node_get_key(right, 0)); |
@@ -794,9 +806,6 @@ static void nilfs_btree_split(struct nilfs_btree *btree, | |||
794 | __u64 newptr; | 806 | __u64 newptr; |
795 | int nchildren, n, move; | 807 | int nchildren, n, move; |
796 | 808 | ||
797 | lock_buffer(path[level].bp_bh); | ||
798 | lock_buffer(path[level].bp_sib_bh); | ||
799 | |||
800 | node = nilfs_btree_get_nonroot_node(path, level); | 809 | node = nilfs_btree_get_nonroot_node(path, level); |
801 | right = nilfs_btree_get_sib_node(path, level); | 810 | right = nilfs_btree_get_sib_node(path, level); |
802 | nchildren = nilfs_btree_node_get_nchildren(node); | 811 | nchildren = nilfs_btree_node_get_nchildren(node); |
@@ -815,9 +824,6 @@ static void nilfs_btree_split(struct nilfs_btree *btree, | |||
815 | if (!buffer_dirty(path[level].bp_sib_bh)) | 824 | if (!buffer_dirty(path[level].bp_sib_bh)) |
816 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); | 825 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); |
817 | 826 | ||
818 | unlock_buffer(path[level].bp_bh); | ||
819 | unlock_buffer(path[level].bp_sib_bh); | ||
820 | |||
821 | newkey = nilfs_btree_node_get_key(right, 0); | 827 | newkey = nilfs_btree_node_get_key(right, 0); |
822 | newptr = path[level].bp_newreq.bpr_ptr; | 828 | newptr = path[level].bp_newreq.bpr_ptr; |
823 | 829 | ||
@@ -852,8 +858,6 @@ static void nilfs_btree_grow(struct nilfs_btree *btree, | |||
852 | struct nilfs_btree_node *root, *child; | 858 | struct nilfs_btree_node *root, *child; |
853 | int n; | 859 | int n; |
854 | 860 | ||
855 | lock_buffer(path[level].bp_sib_bh); | ||
856 | |||
857 | root = nilfs_btree_get_root(btree); | 861 | root = nilfs_btree_get_root(btree); |
858 | child = nilfs_btree_get_sib_node(path, level); | 862 | child = nilfs_btree_get_sib_node(path, level); |
859 | 863 | ||
@@ -865,8 +869,6 @@ static void nilfs_btree_grow(struct nilfs_btree *btree, | |||
865 | if (!buffer_dirty(path[level].bp_sib_bh)) | 869 | if (!buffer_dirty(path[level].bp_sib_bh)) |
866 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); | 870 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); |
867 | 871 | ||
868 | unlock_buffer(path[level].bp_sib_bh); | ||
869 | |||
870 | path[level].bp_bh = path[level].bp_sib_bh; | 872 | path[level].bp_bh = path[level].bp_sib_bh; |
871 | path[level].bp_sib_bh = NULL; | 873 | path[level].bp_sib_bh = NULL; |
872 | 874 | ||
@@ -1023,11 +1025,9 @@ static int nilfs_btree_prepare_insert(struct nilfs_btree *btree, | |||
1023 | 1025 | ||
1024 | stats->bs_nblocks++; | 1026 | stats->bs_nblocks++; |
1025 | 1027 | ||
1026 | lock_buffer(bh); | ||
1027 | nilfs_btree_node_init(btree, | 1028 | nilfs_btree_node_init(btree, |
1028 | (struct nilfs_btree_node *)bh->b_data, | 1029 | (struct nilfs_btree_node *)bh->b_data, |
1029 | 0, level, 0, NULL, NULL); | 1030 | 0, level, 0, NULL, NULL); |
1030 | unlock_buffer(bh); | ||
1031 | path[level].bp_sib_bh = bh; | 1031 | path[level].bp_sib_bh = bh; |
1032 | path[level].bp_op = nilfs_btree_split; | 1032 | path[level].bp_op = nilfs_btree_split; |
1033 | } | 1033 | } |
@@ -1052,10 +1052,8 @@ static int nilfs_btree_prepare_insert(struct nilfs_btree *btree, | |||
1052 | if (ret < 0) | 1052 | if (ret < 0) |
1053 | goto err_out_curr_node; | 1053 | goto err_out_curr_node; |
1054 | 1054 | ||
1055 | lock_buffer(bh); | ||
1056 | nilfs_btree_node_init(btree, (struct nilfs_btree_node *)bh->b_data, | 1055 | nilfs_btree_node_init(btree, (struct nilfs_btree_node *)bh->b_data, |
1057 | 0, level, 0, NULL, NULL); | 1056 | 0, level, 0, NULL, NULL); |
1058 | unlock_buffer(bh); | ||
1059 | path[level].bp_sib_bh = bh; | 1057 | path[level].bp_sib_bh = bh; |
1060 | path[level].bp_op = nilfs_btree_grow; | 1058 | path[level].bp_op = nilfs_btree_grow; |
1061 | 1059 | ||
@@ -1154,13 +1152,11 @@ static void nilfs_btree_do_delete(struct nilfs_btree *btree, | |||
1154 | struct nilfs_btree_node *node; | 1152 | struct nilfs_btree_node *node; |
1155 | 1153 | ||
1156 | if (level < nilfs_btree_height(btree) - 1) { | 1154 | if (level < nilfs_btree_height(btree) - 1) { |
1157 | lock_buffer(path[level].bp_bh); | ||
1158 | node = nilfs_btree_get_nonroot_node(path, level); | 1155 | node = nilfs_btree_get_nonroot_node(path, level); |
1159 | nilfs_btree_node_delete(btree, node, keyp, ptrp, | 1156 | nilfs_btree_node_delete(btree, node, keyp, ptrp, |
1160 | path[level].bp_index); | 1157 | path[level].bp_index); |
1161 | if (!buffer_dirty(path[level].bp_bh)) | 1158 | if (!buffer_dirty(path[level].bp_bh)) |
1162 | nilfs_btnode_mark_dirty(path[level].bp_bh); | 1159 | nilfs_btnode_mark_dirty(path[level].bp_bh); |
1163 | unlock_buffer(path[level].bp_bh); | ||
1164 | if (path[level].bp_index == 0) | 1160 | if (path[level].bp_index == 0) |
1165 | nilfs_btree_promote_key(btree, path, level + 1, | 1161 | nilfs_btree_promote_key(btree, path, level + 1, |
1166 | nilfs_btree_node_get_key(node, 0)); | 1162 | nilfs_btree_node_get_key(node, 0)); |
@@ -1180,9 +1176,6 @@ static void nilfs_btree_borrow_left(struct nilfs_btree *btree, | |||
1180 | 1176 | ||
1181 | nilfs_btree_do_delete(btree, path, level, keyp, ptrp); | 1177 | nilfs_btree_do_delete(btree, path, level, keyp, ptrp); |
1182 | 1178 | ||
1183 | lock_buffer(path[level].bp_bh); | ||
1184 | lock_buffer(path[level].bp_sib_bh); | ||
1185 | |||
1186 | node = nilfs_btree_get_nonroot_node(path, level); | 1179 | node = nilfs_btree_get_nonroot_node(path, level); |
1187 | left = nilfs_btree_get_sib_node(path, level); | 1180 | left = nilfs_btree_get_sib_node(path, level); |
1188 | nchildren = nilfs_btree_node_get_nchildren(node); | 1181 | nchildren = nilfs_btree_node_get_nchildren(node); |
@@ -1197,9 +1190,6 @@ static void nilfs_btree_borrow_left(struct nilfs_btree *btree, | |||
1197 | if (!buffer_dirty(path[level].bp_sib_bh)) | 1190 | if (!buffer_dirty(path[level].bp_sib_bh)) |
1198 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); | 1191 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); |
1199 | 1192 | ||
1200 | unlock_buffer(path[level].bp_bh); | ||
1201 | unlock_buffer(path[level].bp_sib_bh); | ||
1202 | |||
1203 | nilfs_btree_promote_key(btree, path, level + 1, | 1193 | nilfs_btree_promote_key(btree, path, level + 1, |
1204 | nilfs_btree_node_get_key(node, 0)); | 1194 | nilfs_btree_node_get_key(node, 0)); |
1205 | 1195 | ||
@@ -1217,9 +1207,6 @@ static void nilfs_btree_borrow_right(struct nilfs_btree *btree, | |||
1217 | 1207 | ||
1218 | nilfs_btree_do_delete(btree, path, level, keyp, ptrp); | 1208 | nilfs_btree_do_delete(btree, path, level, keyp, ptrp); |
1219 | 1209 | ||
1220 | lock_buffer(path[level].bp_bh); | ||
1221 | lock_buffer(path[level].bp_sib_bh); | ||
1222 | |||
1223 | node = nilfs_btree_get_nonroot_node(path, level); | 1210 | node = nilfs_btree_get_nonroot_node(path, level); |
1224 | right = nilfs_btree_get_sib_node(path, level); | 1211 | right = nilfs_btree_get_sib_node(path, level); |
1225 | nchildren = nilfs_btree_node_get_nchildren(node); | 1212 | nchildren = nilfs_btree_node_get_nchildren(node); |
@@ -1234,9 +1221,6 @@ static void nilfs_btree_borrow_right(struct nilfs_btree *btree, | |||
1234 | if (!buffer_dirty(path[level].bp_sib_bh)) | 1221 | if (!buffer_dirty(path[level].bp_sib_bh)) |
1235 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); | 1222 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); |
1236 | 1223 | ||
1237 | unlock_buffer(path[level].bp_bh); | ||
1238 | unlock_buffer(path[level].bp_sib_bh); | ||
1239 | |||
1240 | path[level + 1].bp_index++; | 1224 | path[level + 1].bp_index++; |
1241 | nilfs_btree_promote_key(btree, path, level + 1, | 1225 | nilfs_btree_promote_key(btree, path, level + 1, |
1242 | nilfs_btree_node_get_key(right, 0)); | 1226 | nilfs_btree_node_get_key(right, 0)); |
@@ -1255,9 +1239,6 @@ static void nilfs_btree_concat_left(struct nilfs_btree *btree, | |||
1255 | 1239 | ||
1256 | nilfs_btree_do_delete(btree, path, level, keyp, ptrp); | 1240 | nilfs_btree_do_delete(btree, path, level, keyp, ptrp); |
1257 | 1241 | ||
1258 | lock_buffer(path[level].bp_bh); | ||
1259 | lock_buffer(path[level].bp_sib_bh); | ||
1260 | |||
1261 | node = nilfs_btree_get_nonroot_node(path, level); | 1242 | node = nilfs_btree_get_nonroot_node(path, level); |
1262 | left = nilfs_btree_get_sib_node(path, level); | 1243 | left = nilfs_btree_get_sib_node(path, level); |
1263 | 1244 | ||
@@ -1268,9 +1249,6 @@ static void nilfs_btree_concat_left(struct nilfs_btree *btree, | |||
1268 | if (!buffer_dirty(path[level].bp_sib_bh)) | 1249 | if (!buffer_dirty(path[level].bp_sib_bh)) |
1269 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); | 1250 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); |
1270 | 1251 | ||
1271 | unlock_buffer(path[level].bp_bh); | ||
1272 | unlock_buffer(path[level].bp_sib_bh); | ||
1273 | |||
1274 | nilfs_btnode_delete(path[level].bp_bh); | 1252 | nilfs_btnode_delete(path[level].bp_bh); |
1275 | path[level].bp_bh = path[level].bp_sib_bh; | 1253 | path[level].bp_bh = path[level].bp_sib_bh; |
1276 | path[level].bp_sib_bh = NULL; | 1254 | path[level].bp_sib_bh = NULL; |
@@ -1286,9 +1264,6 @@ static void nilfs_btree_concat_right(struct nilfs_btree *btree, | |||
1286 | 1264 | ||
1287 | nilfs_btree_do_delete(btree, path, level, keyp, ptrp); | 1265 | nilfs_btree_do_delete(btree, path, level, keyp, ptrp); |
1288 | 1266 | ||
1289 | lock_buffer(path[level].bp_bh); | ||
1290 | lock_buffer(path[level].bp_sib_bh); | ||
1291 | |||
1292 | node = nilfs_btree_get_nonroot_node(path, level); | 1267 | node = nilfs_btree_get_nonroot_node(path, level); |
1293 | right = nilfs_btree_get_sib_node(path, level); | 1268 | right = nilfs_btree_get_sib_node(path, level); |
1294 | 1269 | ||
@@ -1299,9 +1274,6 @@ static void nilfs_btree_concat_right(struct nilfs_btree *btree, | |||
1299 | if (!buffer_dirty(path[level].bp_bh)) | 1274 | if (!buffer_dirty(path[level].bp_bh)) |
1300 | nilfs_btnode_mark_dirty(path[level].bp_bh); | 1275 | nilfs_btnode_mark_dirty(path[level].bp_bh); |
1301 | 1276 | ||
1302 | unlock_buffer(path[level].bp_bh); | ||
1303 | unlock_buffer(path[level].bp_sib_bh); | ||
1304 | |||
1305 | nilfs_btnode_delete(path[level].bp_sib_bh); | 1277 | nilfs_btnode_delete(path[level].bp_sib_bh); |
1306 | path[level].bp_sib_bh = NULL; | 1278 | path[level].bp_sib_bh = NULL; |
1307 | path[level + 1].bp_index++; | 1279 | path[level + 1].bp_index++; |
@@ -1316,7 +1288,6 @@ static void nilfs_btree_shrink(struct nilfs_btree *btree, | |||
1316 | 1288 | ||
1317 | nilfs_btree_do_delete(btree, path, level, keyp, ptrp); | 1289 | nilfs_btree_do_delete(btree, path, level, keyp, ptrp); |
1318 | 1290 | ||
1319 | lock_buffer(path[level].bp_bh); | ||
1320 | root = nilfs_btree_get_root(btree); | 1291 | root = nilfs_btree_get_root(btree); |
1321 | child = nilfs_btree_get_nonroot_node(path, level); | 1292 | child = nilfs_btree_get_nonroot_node(path, level); |
1322 | 1293 | ||
@@ -1324,7 +1295,6 @@ static void nilfs_btree_shrink(struct nilfs_btree *btree, | |||
1324 | nilfs_btree_node_set_level(root, level); | 1295 | nilfs_btree_node_set_level(root, level); |
1325 | n = nilfs_btree_node_get_nchildren(child); | 1296 | n = nilfs_btree_node_get_nchildren(child); |
1326 | nilfs_btree_node_move_left(btree, root, child, n); | 1297 | nilfs_btree_node_move_left(btree, root, child, n); |
1327 | unlock_buffer(path[level].bp_bh); | ||
1328 | 1298 | ||
1329 | nilfs_btnode_delete(path[level].bp_bh); | 1299 | nilfs_btnode_delete(path[level].bp_bh); |
1330 | path[level].bp_bh = NULL; | 1300 | path[level].bp_bh = NULL; |
@@ -1699,7 +1669,6 @@ nilfs_btree_commit_convert_and_insert(struct nilfs_bmap *bmap, | |||
1699 | nilfs_bmap_commit_alloc_ptr(bmap, nreq, dat); | 1669 | nilfs_bmap_commit_alloc_ptr(bmap, nreq, dat); |
1700 | 1670 | ||
1701 | /* create child node at level 1 */ | 1671 | /* create child node at level 1 */ |
1702 | lock_buffer(bh); | ||
1703 | node = (struct nilfs_btree_node *)bh->b_data; | 1672 | node = (struct nilfs_btree_node *)bh->b_data; |
1704 | nilfs_btree_node_init(btree, node, 0, 1, n, keys, ptrs); | 1673 | nilfs_btree_node_init(btree, node, 0, 1, n, keys, ptrs); |
1705 | nilfs_btree_node_insert(btree, node, | 1674 | nilfs_btree_node_insert(btree, node, |
@@ -1709,7 +1678,6 @@ nilfs_btree_commit_convert_and_insert(struct nilfs_bmap *bmap, | |||
1709 | if (!nilfs_bmap_dirty(bmap)) | 1678 | if (!nilfs_bmap_dirty(bmap)) |
1710 | nilfs_bmap_set_dirty(bmap); | 1679 | nilfs_bmap_set_dirty(bmap); |
1711 | 1680 | ||
1712 | unlock_buffer(bh); | ||
1713 | brelse(bh); | 1681 | brelse(bh); |
1714 | 1682 | ||
1715 | /* create root node at level 2 */ | 1683 | /* create root node at level 2 */ |
@@ -2050,7 +2018,7 @@ static void nilfs_btree_lookup_dirty_buffers(struct nilfs_bmap *bmap, | |||
2050 | for (level = NILFS_BTREE_LEVEL_NODE_MIN; | 2018 | for (level = NILFS_BTREE_LEVEL_NODE_MIN; |
2051 | level < NILFS_BTREE_LEVEL_MAX; | 2019 | level < NILFS_BTREE_LEVEL_MAX; |
2052 | level++) | 2020 | level++) |
2053 | list_splice(&lists[level], listp->prev); | 2021 | list_splice_tail(&lists[level], listp); |
2054 | } | 2022 | } |
2055 | 2023 | ||
2056 | static int nilfs_btree_assign_p(struct nilfs_btree *btree, | 2024 | static int nilfs_btree_assign_p(struct nilfs_btree *btree, |