diff options
-rw-r--r-- | fs/nilfs2/btree.c | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c index 420c9ecbca15..c9aab29ea1f6 100644 --- a/fs/nilfs2/btree.c +++ b/fs/nilfs2/btree.c | |||
@@ -652,13 +652,11 @@ static void nilfs_btree_promote_key(struct nilfs_btree *btree, | |||
652 | { | 652 | { |
653 | if (level < nilfs_btree_height(btree) - 1) { | 653 | if (level < nilfs_btree_height(btree) - 1) { |
654 | do { | 654 | do { |
655 | lock_buffer(path[level].bp_bh); | ||
656 | nilfs_btree_node_set_key( | 655 | nilfs_btree_node_set_key( |
657 | nilfs_btree_get_nonroot_node(path, level), | 656 | nilfs_btree_get_nonroot_node(path, level), |
658 | path[level].bp_index, key); | 657 | path[level].bp_index, key); |
659 | if (!buffer_dirty(path[level].bp_bh)) | 658 | if (!buffer_dirty(path[level].bp_bh)) |
660 | nilfs_btnode_mark_dirty(path[level].bp_bh); | 659 | nilfs_btnode_mark_dirty(path[level].bp_bh); |
661 | unlock_buffer(path[level].bp_bh); | ||
662 | } while ((path[level].bp_index == 0) && | 660 | } while ((path[level].bp_index == 0) && |
663 | (++level < nilfs_btree_height(btree) - 1)); | 661 | (++level < nilfs_btree_height(btree) - 1)); |
664 | } | 662 | } |
@@ -677,13 +675,11 @@ static void nilfs_btree_do_insert(struct nilfs_btree *btree, | |||
677 | struct nilfs_btree_node *node; | 675 | struct nilfs_btree_node *node; |
678 | 676 | ||
679 | if (level < nilfs_btree_height(btree) - 1) { | 677 | if (level < nilfs_btree_height(btree) - 1) { |
680 | lock_buffer(path[level].bp_bh); | ||
681 | node = nilfs_btree_get_nonroot_node(path, level); | 678 | node = nilfs_btree_get_nonroot_node(path, level); |
682 | nilfs_btree_node_insert(btree, node, *keyp, *ptrp, | 679 | nilfs_btree_node_insert(btree, node, *keyp, *ptrp, |
683 | path[level].bp_index); | 680 | path[level].bp_index); |
684 | if (!buffer_dirty(path[level].bp_bh)) | 681 | if (!buffer_dirty(path[level].bp_bh)) |
685 | nilfs_btnode_mark_dirty(path[level].bp_bh); | 682 | nilfs_btnode_mark_dirty(path[level].bp_bh); |
686 | unlock_buffer(path[level].bp_bh); | ||
687 | 683 | ||
688 | if (path[level].bp_index == 0) | 684 | if (path[level].bp_index == 0) |
689 | nilfs_btree_promote_key(btree, path, level + 1, | 685 | nilfs_btree_promote_key(btree, path, level + 1, |
@@ -703,9 +699,6 @@ static void nilfs_btree_carry_left(struct nilfs_btree *btree, | |||
703 | struct nilfs_btree_node *node, *left; | 699 | struct nilfs_btree_node *node, *left; |
704 | int nchildren, lnchildren, n, move; | 700 | int nchildren, lnchildren, n, move; |
705 | 701 | ||
706 | lock_buffer(path[level].bp_bh); | ||
707 | lock_buffer(path[level].bp_sib_bh); | ||
708 | |||
709 | node = nilfs_btree_get_nonroot_node(path, level); | 702 | node = nilfs_btree_get_nonroot_node(path, level); |
710 | left = nilfs_btree_get_sib_node(path, level); | 703 | left = nilfs_btree_get_sib_node(path, level); |
711 | nchildren = nilfs_btree_node_get_nchildren(node); | 704 | nchildren = nilfs_btree_node_get_nchildren(node); |
@@ -726,9 +719,6 @@ static void nilfs_btree_carry_left(struct nilfs_btree *btree, | |||
726 | if (!buffer_dirty(path[level].bp_sib_bh)) | 719 | if (!buffer_dirty(path[level].bp_sib_bh)) |
727 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); | 720 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); |
728 | 721 | ||
729 | unlock_buffer(path[level].bp_bh); | ||
730 | unlock_buffer(path[level].bp_sib_bh); | ||
731 | |||
732 | nilfs_btree_promote_key(btree, path, level + 1, | 722 | nilfs_btree_promote_key(btree, path, level + 1, |
733 | nilfs_btree_node_get_key(node, 0)); | 723 | nilfs_btree_node_get_key(node, 0)); |
734 | 724 | ||
@@ -754,9 +744,6 @@ static void nilfs_btree_carry_right(struct nilfs_btree *btree, | |||
754 | struct nilfs_btree_node *node, *right; | 744 | struct nilfs_btree_node *node, *right; |
755 | int nchildren, rnchildren, n, move; | 745 | int nchildren, rnchildren, n, move; |
756 | 746 | ||
757 | lock_buffer(path[level].bp_bh); | ||
758 | lock_buffer(path[level].bp_sib_bh); | ||
759 | |||
760 | node = nilfs_btree_get_nonroot_node(path, level); | 747 | node = nilfs_btree_get_nonroot_node(path, level); |
761 | right = nilfs_btree_get_sib_node(path, level); | 748 | right = nilfs_btree_get_sib_node(path, level); |
762 | nchildren = nilfs_btree_node_get_nchildren(node); | 749 | nchildren = nilfs_btree_node_get_nchildren(node); |
@@ -777,9 +764,6 @@ static void nilfs_btree_carry_right(struct nilfs_btree *btree, | |||
777 | if (!buffer_dirty(path[level].bp_sib_bh)) | 764 | if (!buffer_dirty(path[level].bp_sib_bh)) |
778 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); | 765 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); |
779 | 766 | ||
780 | unlock_buffer(path[level].bp_bh); | ||
781 | unlock_buffer(path[level].bp_sib_bh); | ||
782 | |||
783 | path[level + 1].bp_index++; | 767 | path[level + 1].bp_index++; |
784 | nilfs_btree_promote_key(btree, path, level + 1, | 768 | nilfs_btree_promote_key(btree, path, level + 1, |
785 | nilfs_btree_node_get_key(right, 0)); | 769 | nilfs_btree_node_get_key(right, 0)); |
@@ -808,9 +792,6 @@ static void nilfs_btree_split(struct nilfs_btree *btree, | |||
808 | __u64 newptr; | 792 | __u64 newptr; |
809 | int nchildren, n, move; | 793 | int nchildren, n, move; |
810 | 794 | ||
811 | lock_buffer(path[level].bp_bh); | ||
812 | lock_buffer(path[level].bp_sib_bh); | ||
813 | |||
814 | node = nilfs_btree_get_nonroot_node(path, level); | 795 | node = nilfs_btree_get_nonroot_node(path, level); |
815 | right = nilfs_btree_get_sib_node(path, level); | 796 | right = nilfs_btree_get_sib_node(path, level); |
816 | nchildren = nilfs_btree_node_get_nchildren(node); | 797 | nchildren = nilfs_btree_node_get_nchildren(node); |
@@ -829,9 +810,6 @@ static void nilfs_btree_split(struct nilfs_btree *btree, | |||
829 | if (!buffer_dirty(path[level].bp_sib_bh)) | 810 | if (!buffer_dirty(path[level].bp_sib_bh)) |
830 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); | 811 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); |
831 | 812 | ||
832 | unlock_buffer(path[level].bp_bh); | ||
833 | unlock_buffer(path[level].bp_sib_bh); | ||
834 | |||
835 | newkey = nilfs_btree_node_get_key(right, 0); | 813 | newkey = nilfs_btree_node_get_key(right, 0); |
836 | newptr = path[level].bp_newreq.bpr_ptr; | 814 | newptr = path[level].bp_newreq.bpr_ptr; |
837 | 815 | ||
@@ -866,8 +844,6 @@ static void nilfs_btree_grow(struct nilfs_btree *btree, | |||
866 | struct nilfs_btree_node *root, *child; | 844 | struct nilfs_btree_node *root, *child; |
867 | int n; | 845 | int n; |
868 | 846 | ||
869 | lock_buffer(path[level].bp_sib_bh); | ||
870 | |||
871 | root = nilfs_btree_get_root(btree); | 847 | root = nilfs_btree_get_root(btree); |
872 | child = nilfs_btree_get_sib_node(path, level); | 848 | child = nilfs_btree_get_sib_node(path, level); |
873 | 849 | ||
@@ -879,8 +855,6 @@ static void nilfs_btree_grow(struct nilfs_btree *btree, | |||
879 | if (!buffer_dirty(path[level].bp_sib_bh)) | 855 | if (!buffer_dirty(path[level].bp_sib_bh)) |
880 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); | 856 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); |
881 | 857 | ||
882 | unlock_buffer(path[level].bp_sib_bh); | ||
883 | |||
884 | path[level].bp_bh = path[level].bp_sib_bh; | 858 | path[level].bp_bh = path[level].bp_sib_bh; |
885 | path[level].bp_sib_bh = NULL; | 859 | path[level].bp_sib_bh = NULL; |
886 | 860 | ||
@@ -1037,11 +1011,9 @@ static int nilfs_btree_prepare_insert(struct nilfs_btree *btree, | |||
1037 | 1011 | ||
1038 | stats->bs_nblocks++; | 1012 | stats->bs_nblocks++; |
1039 | 1013 | ||
1040 | lock_buffer(bh); | ||
1041 | nilfs_btree_node_init(btree, | 1014 | nilfs_btree_node_init(btree, |
1042 | (struct nilfs_btree_node *)bh->b_data, | 1015 | (struct nilfs_btree_node *)bh->b_data, |
1043 | 0, level, 0, NULL, NULL); | 1016 | 0, level, 0, NULL, NULL); |
1044 | unlock_buffer(bh); | ||
1045 | path[level].bp_sib_bh = bh; | 1017 | path[level].bp_sib_bh = bh; |
1046 | path[level].bp_op = nilfs_btree_split; | 1018 | path[level].bp_op = nilfs_btree_split; |
1047 | } | 1019 | } |
@@ -1066,10 +1038,8 @@ static int nilfs_btree_prepare_insert(struct nilfs_btree *btree, | |||
1066 | if (ret < 0) | 1038 | if (ret < 0) |
1067 | goto err_out_curr_node; | 1039 | goto err_out_curr_node; |
1068 | 1040 | ||
1069 | lock_buffer(bh); | ||
1070 | nilfs_btree_node_init(btree, (struct nilfs_btree_node *)bh->b_data, | 1041 | nilfs_btree_node_init(btree, (struct nilfs_btree_node *)bh->b_data, |
1071 | 0, level, 0, NULL, NULL); | 1042 | 0, level, 0, NULL, NULL); |
1072 | unlock_buffer(bh); | ||
1073 | path[level].bp_sib_bh = bh; | 1043 | path[level].bp_sib_bh = bh; |
1074 | path[level].bp_op = nilfs_btree_grow; | 1044 | path[level].bp_op = nilfs_btree_grow; |
1075 | 1045 | ||
@@ -1168,13 +1138,11 @@ static void nilfs_btree_do_delete(struct nilfs_btree *btree, | |||
1168 | struct nilfs_btree_node *node; | 1138 | struct nilfs_btree_node *node; |
1169 | 1139 | ||
1170 | if (level < nilfs_btree_height(btree) - 1) { | 1140 | if (level < nilfs_btree_height(btree) - 1) { |
1171 | lock_buffer(path[level].bp_bh); | ||
1172 | node = nilfs_btree_get_nonroot_node(path, level); | 1141 | node = nilfs_btree_get_nonroot_node(path, level); |
1173 | nilfs_btree_node_delete(btree, node, keyp, ptrp, | 1142 | nilfs_btree_node_delete(btree, node, keyp, ptrp, |
1174 | path[level].bp_index); | 1143 | path[level].bp_index); |
1175 | if (!buffer_dirty(path[level].bp_bh)) | 1144 | if (!buffer_dirty(path[level].bp_bh)) |
1176 | nilfs_btnode_mark_dirty(path[level].bp_bh); | 1145 | nilfs_btnode_mark_dirty(path[level].bp_bh); |
1177 | unlock_buffer(path[level].bp_bh); | ||
1178 | if (path[level].bp_index == 0) | 1146 | if (path[level].bp_index == 0) |
1179 | nilfs_btree_promote_key(btree, path, level + 1, | 1147 | nilfs_btree_promote_key(btree, path, level + 1, |
1180 | nilfs_btree_node_get_key(node, 0)); | 1148 | nilfs_btree_node_get_key(node, 0)); |
@@ -1194,9 +1162,6 @@ static void nilfs_btree_borrow_left(struct nilfs_btree *btree, | |||
1194 | 1162 | ||
1195 | nilfs_btree_do_delete(btree, path, level, keyp, ptrp); | 1163 | nilfs_btree_do_delete(btree, path, level, keyp, ptrp); |
1196 | 1164 | ||
1197 | lock_buffer(path[level].bp_bh); | ||
1198 | lock_buffer(path[level].bp_sib_bh); | ||
1199 | |||
1200 | node = nilfs_btree_get_nonroot_node(path, level); | 1165 | node = nilfs_btree_get_nonroot_node(path, level); |
1201 | left = nilfs_btree_get_sib_node(path, level); | 1166 | left = nilfs_btree_get_sib_node(path, level); |
1202 | nchildren = nilfs_btree_node_get_nchildren(node); | 1167 | nchildren = nilfs_btree_node_get_nchildren(node); |
@@ -1211,9 +1176,6 @@ static void nilfs_btree_borrow_left(struct nilfs_btree *btree, | |||
1211 | if (!buffer_dirty(path[level].bp_sib_bh)) | 1176 | if (!buffer_dirty(path[level].bp_sib_bh)) |
1212 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); | 1177 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); |
1213 | 1178 | ||
1214 | unlock_buffer(path[level].bp_bh); | ||
1215 | unlock_buffer(path[level].bp_sib_bh); | ||
1216 | |||
1217 | nilfs_btree_promote_key(btree, path, level + 1, | 1179 | nilfs_btree_promote_key(btree, path, level + 1, |
1218 | nilfs_btree_node_get_key(node, 0)); | 1180 | nilfs_btree_node_get_key(node, 0)); |
1219 | 1181 | ||
@@ -1231,9 +1193,6 @@ static void nilfs_btree_borrow_right(struct nilfs_btree *btree, | |||
1231 | 1193 | ||
1232 | nilfs_btree_do_delete(btree, path, level, keyp, ptrp); | 1194 | nilfs_btree_do_delete(btree, path, level, keyp, ptrp); |
1233 | 1195 | ||
1234 | lock_buffer(path[level].bp_bh); | ||
1235 | lock_buffer(path[level].bp_sib_bh); | ||
1236 | |||
1237 | node = nilfs_btree_get_nonroot_node(path, level); | 1196 | node = nilfs_btree_get_nonroot_node(path, level); |
1238 | right = nilfs_btree_get_sib_node(path, level); | 1197 | right = nilfs_btree_get_sib_node(path, level); |
1239 | nchildren = nilfs_btree_node_get_nchildren(node); | 1198 | nchildren = nilfs_btree_node_get_nchildren(node); |
@@ -1248,9 +1207,6 @@ static void nilfs_btree_borrow_right(struct nilfs_btree *btree, | |||
1248 | if (!buffer_dirty(path[level].bp_sib_bh)) | 1207 | if (!buffer_dirty(path[level].bp_sib_bh)) |
1249 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); | 1208 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); |
1250 | 1209 | ||
1251 | unlock_buffer(path[level].bp_bh); | ||
1252 | unlock_buffer(path[level].bp_sib_bh); | ||
1253 | |||
1254 | path[level + 1].bp_index++; | 1210 | path[level + 1].bp_index++; |
1255 | nilfs_btree_promote_key(btree, path, level + 1, | 1211 | nilfs_btree_promote_key(btree, path, level + 1, |
1256 | nilfs_btree_node_get_key(right, 0)); | 1212 | nilfs_btree_node_get_key(right, 0)); |
@@ -1269,9 +1225,6 @@ static void nilfs_btree_concat_left(struct nilfs_btree *btree, | |||
1269 | 1225 | ||
1270 | nilfs_btree_do_delete(btree, path, level, keyp, ptrp); | 1226 | nilfs_btree_do_delete(btree, path, level, keyp, ptrp); |
1271 | 1227 | ||
1272 | lock_buffer(path[level].bp_bh); | ||
1273 | lock_buffer(path[level].bp_sib_bh); | ||
1274 | |||
1275 | node = nilfs_btree_get_nonroot_node(path, level); | 1228 | node = nilfs_btree_get_nonroot_node(path, level); |
1276 | left = nilfs_btree_get_sib_node(path, level); | 1229 | left = nilfs_btree_get_sib_node(path, level); |
1277 | 1230 | ||
@@ -1282,9 +1235,6 @@ static void nilfs_btree_concat_left(struct nilfs_btree *btree, | |||
1282 | if (!buffer_dirty(path[level].bp_sib_bh)) | 1235 | if (!buffer_dirty(path[level].bp_sib_bh)) |
1283 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); | 1236 | nilfs_btnode_mark_dirty(path[level].bp_sib_bh); |
1284 | 1237 | ||
1285 | unlock_buffer(path[level].bp_bh); | ||
1286 | unlock_buffer(path[level].bp_sib_bh); | ||
1287 | |||
1288 | nilfs_btnode_delete(path[level].bp_bh); | 1238 | nilfs_btnode_delete(path[level].bp_bh); |
1289 | path[level].bp_bh = path[level].bp_sib_bh; | 1239 | path[level].bp_bh = path[level].bp_sib_bh; |
1290 | path[level].bp_sib_bh = NULL; | 1240 | path[level].bp_sib_bh = NULL; |
@@ -1300,9 +1250,6 @@ static void nilfs_btree_concat_right(struct nilfs_btree *btree, | |||
1300 | 1250 | ||
1301 | nilfs_btree_do_delete(btree, path, level, keyp, ptrp); | 1251 | nilfs_btree_do_delete(btree, path, level, keyp, ptrp); |
1302 | 1252 | ||
1303 | lock_buffer(path[level].bp_bh); | ||
1304 | lock_buffer(path[level].bp_sib_bh); | ||
1305 | |||
1306 | node = nilfs_btree_get_nonroot_node(path, level); | 1253 | node = nilfs_btree_get_nonroot_node(path, level); |
1307 | right = nilfs_btree_get_sib_node(path, level); | 1254 | right = nilfs_btree_get_sib_node(path, level); |
1308 | 1255 | ||
@@ -1313,9 +1260,6 @@ static void nilfs_btree_concat_right(struct nilfs_btree *btree, | |||
1313 | if (!buffer_dirty(path[level].bp_bh)) | 1260 | if (!buffer_dirty(path[level].bp_bh)) |
1314 | nilfs_btnode_mark_dirty(path[level].bp_bh); | 1261 | nilfs_btnode_mark_dirty(path[level].bp_bh); |
1315 | 1262 | ||
1316 | unlock_buffer(path[level].bp_bh); | ||
1317 | unlock_buffer(path[level].bp_sib_bh); | ||
1318 | |||
1319 | nilfs_btnode_delete(path[level].bp_sib_bh); | 1263 | nilfs_btnode_delete(path[level].bp_sib_bh); |
1320 | path[level].bp_sib_bh = NULL; | 1264 | path[level].bp_sib_bh = NULL; |
1321 | path[level + 1].bp_index++; | 1265 | path[level + 1].bp_index++; |
@@ -1330,7 +1274,6 @@ static void nilfs_btree_shrink(struct nilfs_btree *btree, | |||
1330 | 1274 | ||
1331 | nilfs_btree_do_delete(btree, path, level, keyp, ptrp); | 1275 | nilfs_btree_do_delete(btree, path, level, keyp, ptrp); |
1332 | 1276 | ||
1333 | lock_buffer(path[level].bp_bh); | ||
1334 | root = nilfs_btree_get_root(btree); | 1277 | root = nilfs_btree_get_root(btree); |
1335 | child = nilfs_btree_get_nonroot_node(path, level); | 1278 | child = nilfs_btree_get_nonroot_node(path, level); |
1336 | 1279 | ||
@@ -1338,7 +1281,6 @@ static void nilfs_btree_shrink(struct nilfs_btree *btree, | |||
1338 | nilfs_btree_node_set_level(root, level); | 1281 | nilfs_btree_node_set_level(root, level); |
1339 | n = nilfs_btree_node_get_nchildren(child); | 1282 | n = nilfs_btree_node_get_nchildren(child); |
1340 | nilfs_btree_node_move_left(btree, root, child, n); | 1283 | nilfs_btree_node_move_left(btree, root, child, n); |
1341 | unlock_buffer(path[level].bp_bh); | ||
1342 | 1284 | ||
1343 | nilfs_btnode_delete(path[level].bp_bh); | 1285 | nilfs_btnode_delete(path[level].bp_bh); |
1344 | path[level].bp_bh = NULL; | 1286 | path[level].bp_bh = NULL; |
@@ -1713,7 +1655,6 @@ nilfs_btree_commit_convert_and_insert(struct nilfs_bmap *bmap, | |||
1713 | nilfs_bmap_commit_alloc_ptr(bmap, nreq, dat); | 1655 | nilfs_bmap_commit_alloc_ptr(bmap, nreq, dat); |
1714 | 1656 | ||
1715 | /* create child node at level 1 */ | 1657 | /* create child node at level 1 */ |
1716 | lock_buffer(bh); | ||
1717 | node = (struct nilfs_btree_node *)bh->b_data; | 1658 | node = (struct nilfs_btree_node *)bh->b_data; |
1718 | nilfs_btree_node_init(btree, node, 0, 1, n, keys, ptrs); | 1659 | nilfs_btree_node_init(btree, node, 0, 1, n, keys, ptrs); |
1719 | nilfs_btree_node_insert(btree, node, | 1660 | nilfs_btree_node_insert(btree, node, |
@@ -1723,7 +1664,6 @@ nilfs_btree_commit_convert_and_insert(struct nilfs_bmap *bmap, | |||
1723 | if (!nilfs_bmap_dirty(bmap)) | 1664 | if (!nilfs_bmap_dirty(bmap)) |
1724 | nilfs_bmap_set_dirty(bmap); | 1665 | nilfs_bmap_set_dirty(bmap); |
1725 | 1666 | ||
1726 | unlock_buffer(bh); | ||
1727 | brelse(bh); | 1667 | brelse(bh); |
1728 | 1668 | ||
1729 | /* create root node at level 2 */ | 1669 | /* create root node at level 2 */ |