diff options
author | Chris Mason <chris.mason@oracle.com> | 2011-07-19 12:04:14 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2011-07-27 12:46:45 -0400 |
commit | a65917156e345946dbde3d7effd28124c6d6a8c2 (patch) | |
tree | dc5478189be0f6a321bfc23ee0545f71de67763b /fs/btrfs/ctree.c | |
parent | 199c36eaa95077a47ae1bc55532fc0fbeb80cc95 (diff) |
Btrfs: stop using highmem for extent_buffers
The extent_buffers have a very complex interface where
we use HIGHMEM for metadata and try to cache a kmap mapping
to access the memory.
The next commit adds reader/writer locks, and concurrent use
of this kmap cache would make it even more complex.
This commit drops the ability to use HIGHMEM with extent buffers,
and rips out all of the related code.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.c')
-rw-r--r-- | fs/btrfs/ctree.c | 189 |
1 files changed, 2 insertions, 187 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 2e667868e0d2..d2431284b913 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -626,14 +626,6 @@ int btrfs_realloc_node(struct btrfs_trans_handle *trans, | |||
626 | for (i = start_slot; i < end_slot; i++) { | 626 | for (i = start_slot; i < end_slot; i++) { |
627 | int close = 1; | 627 | int close = 1; |
628 | 628 | ||
629 | if (!parent->map_token) { | ||
630 | map_extent_buffer(parent, | ||
631 | btrfs_node_key_ptr_offset(i), | ||
632 | sizeof(struct btrfs_key_ptr), | ||
633 | &parent->map_token, &parent->kaddr, | ||
634 | &parent->map_start, &parent->map_len, | ||
635 | KM_USER1); | ||
636 | } | ||
637 | btrfs_node_key(parent, &disk_key, i); | 629 | btrfs_node_key(parent, &disk_key, i); |
638 | if (!progress_passed && comp_keys(&disk_key, progress) < 0) | 630 | if (!progress_passed && comp_keys(&disk_key, progress) < 0) |
639 | continue; | 631 | continue; |
@@ -656,11 +648,6 @@ int btrfs_realloc_node(struct btrfs_trans_handle *trans, | |||
656 | last_block = blocknr; | 648 | last_block = blocknr; |
657 | continue; | 649 | continue; |
658 | } | 650 | } |
659 | if (parent->map_token) { | ||
660 | unmap_extent_buffer(parent, parent->map_token, | ||
661 | KM_USER1); | ||
662 | parent->map_token = NULL; | ||
663 | } | ||
664 | 651 | ||
665 | cur = btrfs_find_tree_block(root, blocknr, blocksize); | 652 | cur = btrfs_find_tree_block(root, blocknr, blocksize); |
666 | if (cur) | 653 | if (cur) |
@@ -701,11 +688,6 @@ int btrfs_realloc_node(struct btrfs_trans_handle *trans, | |||
701 | btrfs_tree_unlock(cur); | 688 | btrfs_tree_unlock(cur); |
702 | free_extent_buffer(cur); | 689 | free_extent_buffer(cur); |
703 | } | 690 | } |
704 | if (parent->map_token) { | ||
705 | unmap_extent_buffer(parent, parent->map_token, | ||
706 | KM_USER1); | ||
707 | parent->map_token = NULL; | ||
708 | } | ||
709 | return err; | 691 | return err; |
710 | } | 692 | } |
711 | 693 | ||
@@ -746,7 +728,6 @@ static noinline int generic_bin_search(struct extent_buffer *eb, | |||
746 | struct btrfs_disk_key *tmp = NULL; | 728 | struct btrfs_disk_key *tmp = NULL; |
747 | struct btrfs_disk_key unaligned; | 729 | struct btrfs_disk_key unaligned; |
748 | unsigned long offset; | 730 | unsigned long offset; |
749 | char *map_token = NULL; | ||
750 | char *kaddr = NULL; | 731 | char *kaddr = NULL; |
751 | unsigned long map_start = 0; | 732 | unsigned long map_start = 0; |
752 | unsigned long map_len = 0; | 733 | unsigned long map_len = 0; |
@@ -756,18 +737,13 @@ static noinline int generic_bin_search(struct extent_buffer *eb, | |||
756 | mid = (low + high) / 2; | 737 | mid = (low + high) / 2; |
757 | offset = p + mid * item_size; | 738 | offset = p + mid * item_size; |
758 | 739 | ||
759 | if (!map_token || offset < map_start || | 740 | if (!kaddr || offset < map_start || |
760 | (offset + sizeof(struct btrfs_disk_key)) > | 741 | (offset + sizeof(struct btrfs_disk_key)) > |
761 | map_start + map_len) { | 742 | map_start + map_len) { |
762 | if (map_token) { | ||
763 | unmap_extent_buffer(eb, map_token, KM_USER0); | ||
764 | map_token = NULL; | ||
765 | } | ||
766 | 743 | ||
767 | err = map_private_extent_buffer(eb, offset, | 744 | err = map_private_extent_buffer(eb, offset, |
768 | sizeof(struct btrfs_disk_key), | 745 | sizeof(struct btrfs_disk_key), |
769 | &map_token, &kaddr, | 746 | &kaddr, &map_start, &map_len); |
770 | &map_start, &map_len, KM_USER0); | ||
771 | 747 | ||
772 | if (!err) { | 748 | if (!err) { |
773 | tmp = (struct btrfs_disk_key *)(kaddr + offset - | 749 | tmp = (struct btrfs_disk_key *)(kaddr + offset - |
@@ -790,14 +766,10 @@ static noinline int generic_bin_search(struct extent_buffer *eb, | |||
790 | high = mid; | 766 | high = mid; |
791 | else { | 767 | else { |
792 | *slot = mid; | 768 | *slot = mid; |
793 | if (map_token) | ||
794 | unmap_extent_buffer(eb, map_token, KM_USER0); | ||
795 | return 0; | 769 | return 0; |
796 | } | 770 | } |
797 | } | 771 | } |
798 | *slot = low; | 772 | *slot = low; |
799 | if (map_token) | ||
800 | unmap_extent_buffer(eb, map_token, KM_USER0); | ||
801 | return 1; | 773 | return 1; |
802 | } | 774 | } |
803 | 775 | ||
@@ -1228,7 +1200,6 @@ static void reada_for_search(struct btrfs_root *root, | |||
1228 | u32 nr; | 1200 | u32 nr; |
1229 | u32 blocksize; | 1201 | u32 blocksize; |
1230 | u32 nscan = 0; | 1202 | u32 nscan = 0; |
1231 | bool map = true; | ||
1232 | 1203 | ||
1233 | if (level != 1) | 1204 | if (level != 1) |
1234 | return; | 1205 | return; |
@@ -1250,19 +1221,8 @@ static void reada_for_search(struct btrfs_root *root, | |||
1250 | 1221 | ||
1251 | nritems = btrfs_header_nritems(node); | 1222 | nritems = btrfs_header_nritems(node); |
1252 | nr = slot; | 1223 | nr = slot; |
1253 | if (node->map_token || path->skip_locking) | ||
1254 | map = false; | ||
1255 | 1224 | ||
1256 | while (1) { | 1225 | while (1) { |
1257 | if (map && !node->map_token) { | ||
1258 | unsigned long offset = btrfs_node_key_ptr_offset(nr); | ||
1259 | map_private_extent_buffer(node, offset, | ||
1260 | sizeof(struct btrfs_key_ptr), | ||
1261 | &node->map_token, | ||
1262 | &node->kaddr, | ||
1263 | &node->map_start, | ||
1264 | &node->map_len, KM_USER1); | ||
1265 | } | ||
1266 | if (direction < 0) { | 1226 | if (direction < 0) { |
1267 | if (nr == 0) | 1227 | if (nr == 0) |
1268 | break; | 1228 | break; |
@@ -1281,11 +1241,6 @@ static void reada_for_search(struct btrfs_root *root, | |||
1281 | if ((search <= target && target - search <= 65536) || | 1241 | if ((search <= target && target - search <= 65536) || |
1282 | (search > target && search - target <= 65536)) { | 1242 | (search > target && search - target <= 65536)) { |
1283 | gen = btrfs_node_ptr_generation(node, nr); | 1243 | gen = btrfs_node_ptr_generation(node, nr); |
1284 | if (map && node->map_token) { | ||
1285 | unmap_extent_buffer(node, node->map_token, | ||
1286 | KM_USER1); | ||
1287 | node->map_token = NULL; | ||
1288 | } | ||
1289 | readahead_tree_block(root, search, blocksize, gen); | 1244 | readahead_tree_block(root, search, blocksize, gen); |
1290 | nread += blocksize; | 1245 | nread += blocksize; |
1291 | } | 1246 | } |
@@ -1293,10 +1248,6 @@ static void reada_for_search(struct btrfs_root *root, | |||
1293 | if ((nread > 65536 || nscan > 32)) | 1248 | if ((nread > 65536 || nscan > 32)) |
1294 | break; | 1249 | break; |
1295 | } | 1250 | } |
1296 | if (map && node->map_token) { | ||
1297 | unmap_extent_buffer(node, node->map_token, KM_USER1); | ||
1298 | node->map_token = NULL; | ||
1299 | } | ||
1300 | } | 1251 | } |
1301 | 1252 | ||
1302 | /* | 1253 | /* |
@@ -2253,14 +2204,6 @@ static noinline int __push_leaf_right(struct btrfs_trans_handle *trans, | |||
2253 | if (path->slots[0] == i) | 2204 | if (path->slots[0] == i) |
2254 | push_space += data_size; | 2205 | push_space += data_size; |
2255 | 2206 | ||
2256 | if (!left->map_token) { | ||
2257 | map_extent_buffer(left, (unsigned long)item, | ||
2258 | sizeof(struct btrfs_item), | ||
2259 | &left->map_token, &left->kaddr, | ||
2260 | &left->map_start, &left->map_len, | ||
2261 | KM_USER1); | ||
2262 | } | ||
2263 | |||
2264 | this_item_size = btrfs_item_size(left, item); | 2207 | this_item_size = btrfs_item_size(left, item); |
2265 | if (this_item_size + sizeof(*item) + push_space > free_space) | 2208 | if (this_item_size + sizeof(*item) + push_space > free_space) |
2266 | break; | 2209 | break; |
@@ -2271,10 +2214,6 @@ static noinline int __push_leaf_right(struct btrfs_trans_handle *trans, | |||
2271 | break; | 2214 | break; |
2272 | i--; | 2215 | i--; |
2273 | } | 2216 | } |
2274 | if (left->map_token) { | ||
2275 | unmap_extent_buffer(left, left->map_token, KM_USER1); | ||
2276 | left->map_token = NULL; | ||
2277 | } | ||
2278 | 2217 | ||
2279 | if (push_items == 0) | 2218 | if (push_items == 0) |
2280 | goto out_unlock; | 2219 | goto out_unlock; |
@@ -2316,21 +2255,10 @@ static noinline int __push_leaf_right(struct btrfs_trans_handle *trans, | |||
2316 | push_space = BTRFS_LEAF_DATA_SIZE(root); | 2255 | push_space = BTRFS_LEAF_DATA_SIZE(root); |
2317 | for (i = 0; i < right_nritems; i++) { | 2256 | for (i = 0; i < right_nritems; i++) { |
2318 | item = btrfs_item_nr(right, i); | 2257 | item = btrfs_item_nr(right, i); |
2319 | if (!right->map_token) { | ||
2320 | map_extent_buffer(right, (unsigned long)item, | ||
2321 | sizeof(struct btrfs_item), | ||
2322 | &right->map_token, &right->kaddr, | ||
2323 | &right->map_start, &right->map_len, | ||
2324 | KM_USER1); | ||
2325 | } | ||
2326 | push_space -= btrfs_item_size(right, item); | 2258 | push_space -= btrfs_item_size(right, item); |
2327 | btrfs_set_item_offset(right, item, push_space); | 2259 | btrfs_set_item_offset(right, item, push_space); |
2328 | } | 2260 | } |
2329 | 2261 | ||
2330 | if (right->map_token) { | ||
2331 | unmap_extent_buffer(right, right->map_token, KM_USER1); | ||
2332 | right->map_token = NULL; | ||
2333 | } | ||
2334 | left_nritems -= push_items; | 2262 | left_nritems -= push_items; |
2335 | btrfs_set_header_nritems(left, left_nritems); | 2263 | btrfs_set_header_nritems(left, left_nritems); |
2336 | 2264 | ||
@@ -2467,13 +2395,6 @@ static noinline int __push_leaf_left(struct btrfs_trans_handle *trans, | |||
2467 | 2395 | ||
2468 | for (i = 0; i < nr; i++) { | 2396 | for (i = 0; i < nr; i++) { |
2469 | item = btrfs_item_nr(right, i); | 2397 | item = btrfs_item_nr(right, i); |
2470 | if (!right->map_token) { | ||
2471 | map_extent_buffer(right, (unsigned long)item, | ||
2472 | sizeof(struct btrfs_item), | ||
2473 | &right->map_token, &right->kaddr, | ||
2474 | &right->map_start, &right->map_len, | ||
2475 | KM_USER1); | ||
2476 | } | ||
2477 | 2398 | ||
2478 | if (!empty && push_items > 0) { | 2399 | if (!empty && push_items > 0) { |
2479 | if (path->slots[0] < i) | 2400 | if (path->slots[0] < i) |
@@ -2496,11 +2417,6 @@ static noinline int __push_leaf_left(struct btrfs_trans_handle *trans, | |||
2496 | push_space += this_item_size + sizeof(*item); | 2417 | push_space += this_item_size + sizeof(*item); |
2497 | } | 2418 | } |
2498 | 2419 | ||
2499 | if (right->map_token) { | ||
2500 | unmap_extent_buffer(right, right->map_token, KM_USER1); | ||
2501 | right->map_token = NULL; | ||
2502 | } | ||
2503 | |||
2504 | if (push_items == 0) { | 2420 | if (push_items == 0) { |
2505 | ret = 1; | 2421 | ret = 1; |
2506 | goto out; | 2422 | goto out; |
@@ -2530,23 +2446,12 @@ static noinline int __push_leaf_left(struct btrfs_trans_handle *trans, | |||
2530 | u32 ioff; | 2446 | u32 ioff; |
2531 | 2447 | ||
2532 | item = btrfs_item_nr(left, i); | 2448 | item = btrfs_item_nr(left, i); |
2533 | if (!left->map_token) { | ||
2534 | map_extent_buffer(left, (unsigned long)item, | ||
2535 | sizeof(struct btrfs_item), | ||
2536 | &left->map_token, &left->kaddr, | ||
2537 | &left->map_start, &left->map_len, | ||
2538 | KM_USER1); | ||
2539 | } | ||
2540 | 2449 | ||
2541 | ioff = btrfs_item_offset(left, item); | 2450 | ioff = btrfs_item_offset(left, item); |
2542 | btrfs_set_item_offset(left, item, | 2451 | btrfs_set_item_offset(left, item, |
2543 | ioff - (BTRFS_LEAF_DATA_SIZE(root) - old_left_item_size)); | 2452 | ioff - (BTRFS_LEAF_DATA_SIZE(root) - old_left_item_size)); |
2544 | } | 2453 | } |
2545 | btrfs_set_header_nritems(left, old_left_nritems + push_items); | 2454 | btrfs_set_header_nritems(left, old_left_nritems + push_items); |
2546 | if (left->map_token) { | ||
2547 | unmap_extent_buffer(left, left->map_token, KM_USER1); | ||
2548 | left->map_token = NULL; | ||
2549 | } | ||
2550 | 2455 | ||
2551 | /* fixup right node */ | 2456 | /* fixup right node */ |
2552 | if (push_items > right_nritems) { | 2457 | if (push_items > right_nritems) { |
@@ -2574,21 +2479,9 @@ static noinline int __push_leaf_left(struct btrfs_trans_handle *trans, | |||
2574 | for (i = 0; i < right_nritems; i++) { | 2479 | for (i = 0; i < right_nritems; i++) { |
2575 | item = btrfs_item_nr(right, i); | 2480 | item = btrfs_item_nr(right, i); |
2576 | 2481 | ||
2577 | if (!right->map_token) { | ||
2578 | map_extent_buffer(right, (unsigned long)item, | ||
2579 | sizeof(struct btrfs_item), | ||
2580 | &right->map_token, &right->kaddr, | ||
2581 | &right->map_start, &right->map_len, | ||
2582 | KM_USER1); | ||
2583 | } | ||
2584 | |||
2585 | push_space = push_space - btrfs_item_size(right, item); | 2482 | push_space = push_space - btrfs_item_size(right, item); |
2586 | btrfs_set_item_offset(right, item, push_space); | 2483 | btrfs_set_item_offset(right, item, push_space); |
2587 | } | 2484 | } |
2588 | if (right->map_token) { | ||
2589 | unmap_extent_buffer(right, right->map_token, KM_USER1); | ||
2590 | right->map_token = NULL; | ||
2591 | } | ||
2592 | 2485 | ||
2593 | btrfs_mark_buffer_dirty(left); | 2486 | btrfs_mark_buffer_dirty(left); |
2594 | if (right_nritems) | 2487 | if (right_nritems) |
@@ -2729,23 +2622,10 @@ static noinline int copy_for_split(struct btrfs_trans_handle *trans, | |||
2729 | struct btrfs_item *item = btrfs_item_nr(right, i); | 2622 | struct btrfs_item *item = btrfs_item_nr(right, i); |
2730 | u32 ioff; | 2623 | u32 ioff; |
2731 | 2624 | ||
2732 | if (!right->map_token) { | ||
2733 | map_extent_buffer(right, (unsigned long)item, | ||
2734 | sizeof(struct btrfs_item), | ||
2735 | &right->map_token, &right->kaddr, | ||
2736 | &right->map_start, &right->map_len, | ||
2737 | KM_USER1); | ||
2738 | } | ||
2739 | |||
2740 | ioff = btrfs_item_offset(right, item); | 2625 | ioff = btrfs_item_offset(right, item); |
2741 | btrfs_set_item_offset(right, item, ioff + rt_data_off); | 2626 | btrfs_set_item_offset(right, item, ioff + rt_data_off); |
2742 | } | 2627 | } |
2743 | 2628 | ||
2744 | if (right->map_token) { | ||
2745 | unmap_extent_buffer(right, right->map_token, KM_USER1); | ||
2746 | right->map_token = NULL; | ||
2747 | } | ||
2748 | |||
2749 | btrfs_set_header_nritems(l, mid); | 2629 | btrfs_set_header_nritems(l, mid); |
2750 | ret = 0; | 2630 | ret = 0; |
2751 | btrfs_item_key(right, &disk_key, 0); | 2631 | btrfs_item_key(right, &disk_key, 0); |
@@ -3264,23 +3144,10 @@ int btrfs_truncate_item(struct btrfs_trans_handle *trans, | |||
3264 | u32 ioff; | 3144 | u32 ioff; |
3265 | item = btrfs_item_nr(leaf, i); | 3145 | item = btrfs_item_nr(leaf, i); |
3266 | 3146 | ||
3267 | if (!leaf->map_token) { | ||
3268 | map_extent_buffer(leaf, (unsigned long)item, | ||
3269 | sizeof(struct btrfs_item), | ||
3270 | &leaf->map_token, &leaf->kaddr, | ||
3271 | &leaf->map_start, &leaf->map_len, | ||
3272 | KM_USER1); | ||
3273 | } | ||
3274 | |||
3275 | ioff = btrfs_item_offset(leaf, item); | 3147 | ioff = btrfs_item_offset(leaf, item); |
3276 | btrfs_set_item_offset(leaf, item, ioff + size_diff); | 3148 | btrfs_set_item_offset(leaf, item, ioff + size_diff); |
3277 | } | 3149 | } |
3278 | 3150 | ||
3279 | if (leaf->map_token) { | ||
3280 | unmap_extent_buffer(leaf, leaf->map_token, KM_USER1); | ||
3281 | leaf->map_token = NULL; | ||
3282 | } | ||
3283 | |||
3284 | /* shift the data */ | 3151 | /* shift the data */ |
3285 | if (from_end) { | 3152 | if (from_end) { |
3286 | memmove_extent_buffer(leaf, btrfs_leaf_data(leaf) + | 3153 | memmove_extent_buffer(leaf, btrfs_leaf_data(leaf) + |
@@ -3377,22 +3244,10 @@ int btrfs_extend_item(struct btrfs_trans_handle *trans, | |||
3377 | u32 ioff; | 3244 | u32 ioff; |
3378 | item = btrfs_item_nr(leaf, i); | 3245 | item = btrfs_item_nr(leaf, i); |
3379 | 3246 | ||
3380 | if (!leaf->map_token) { | ||
3381 | map_extent_buffer(leaf, (unsigned long)item, | ||
3382 | sizeof(struct btrfs_item), | ||
3383 | &leaf->map_token, &leaf->kaddr, | ||
3384 | &leaf->map_start, &leaf->map_len, | ||
3385 | KM_USER1); | ||
3386 | } | ||
3387 | ioff = btrfs_item_offset(leaf, item); | 3247 | ioff = btrfs_item_offset(leaf, item); |
3388 | btrfs_set_item_offset(leaf, item, ioff - data_size); | 3248 | btrfs_set_item_offset(leaf, item, ioff - data_size); |
3389 | } | 3249 | } |
3390 | 3250 | ||
3391 | if (leaf->map_token) { | ||
3392 | unmap_extent_buffer(leaf, leaf->map_token, KM_USER1); | ||
3393 | leaf->map_token = NULL; | ||
3394 | } | ||
3395 | |||
3396 | /* shift the data */ | 3251 | /* shift the data */ |
3397 | memmove_extent_buffer(leaf, btrfs_leaf_data(leaf) + | 3252 | memmove_extent_buffer(leaf, btrfs_leaf_data(leaf) + |
3398 | data_end - data_size, btrfs_leaf_data(leaf) + | 3253 | data_end - data_size, btrfs_leaf_data(leaf) + |
@@ -3494,27 +3349,13 @@ int btrfs_insert_some_items(struct btrfs_trans_handle *trans, | |||
3494 | * item0..itemN ... dataN.offset..dataN.size .. data0.size | 3349 | * item0..itemN ... dataN.offset..dataN.size .. data0.size |
3495 | */ | 3350 | */ |
3496 | /* first correct the data pointers */ | 3351 | /* first correct the data pointers */ |
3497 | WARN_ON(leaf->map_token); | ||
3498 | for (i = slot; i < nritems; i++) { | 3352 | for (i = slot; i < nritems; i++) { |
3499 | u32 ioff; | 3353 | u32 ioff; |
3500 | 3354 | ||
3501 | item = btrfs_item_nr(leaf, i); | 3355 | item = btrfs_item_nr(leaf, i); |
3502 | if (!leaf->map_token) { | ||
3503 | map_extent_buffer(leaf, (unsigned long)item, | ||
3504 | sizeof(struct btrfs_item), | ||
3505 | &leaf->map_token, &leaf->kaddr, | ||
3506 | &leaf->map_start, &leaf->map_len, | ||
3507 | KM_USER1); | ||
3508 | } | ||
3509 | |||
3510 | ioff = btrfs_item_offset(leaf, item); | 3356 | ioff = btrfs_item_offset(leaf, item); |
3511 | btrfs_set_item_offset(leaf, item, ioff - total_data); | 3357 | btrfs_set_item_offset(leaf, item, ioff - total_data); |
3512 | } | 3358 | } |
3513 | if (leaf->map_token) { | ||
3514 | unmap_extent_buffer(leaf, leaf->map_token, KM_USER1); | ||
3515 | leaf->map_token = NULL; | ||
3516 | } | ||
3517 | |||
3518 | /* shift the items */ | 3359 | /* shift the items */ |
3519 | memmove_extent_buffer(leaf, btrfs_item_nr_offset(slot + nr), | 3360 | memmove_extent_buffer(leaf, btrfs_item_nr_offset(slot + nr), |
3520 | btrfs_item_nr_offset(slot), | 3361 | btrfs_item_nr_offset(slot), |
@@ -3608,27 +3449,13 @@ int setup_items_for_insert(struct btrfs_trans_handle *trans, | |||
3608 | * item0..itemN ... dataN.offset..dataN.size .. data0.size | 3449 | * item0..itemN ... dataN.offset..dataN.size .. data0.size |
3609 | */ | 3450 | */ |
3610 | /* first correct the data pointers */ | 3451 | /* first correct the data pointers */ |
3611 | WARN_ON(leaf->map_token); | ||
3612 | for (i = slot; i < nritems; i++) { | 3452 | for (i = slot; i < nritems; i++) { |
3613 | u32 ioff; | 3453 | u32 ioff; |
3614 | 3454 | ||
3615 | item = btrfs_item_nr(leaf, i); | 3455 | item = btrfs_item_nr(leaf, i); |
3616 | if (!leaf->map_token) { | ||
3617 | map_extent_buffer(leaf, (unsigned long)item, | ||
3618 | sizeof(struct btrfs_item), | ||
3619 | &leaf->map_token, &leaf->kaddr, | ||
3620 | &leaf->map_start, &leaf->map_len, | ||
3621 | KM_USER1); | ||
3622 | } | ||
3623 | |||
3624 | ioff = btrfs_item_offset(leaf, item); | 3456 | ioff = btrfs_item_offset(leaf, item); |
3625 | btrfs_set_item_offset(leaf, item, ioff - total_data); | 3457 | btrfs_set_item_offset(leaf, item, ioff - total_data); |
3626 | } | 3458 | } |
3627 | if (leaf->map_token) { | ||
3628 | unmap_extent_buffer(leaf, leaf->map_token, KM_USER1); | ||
3629 | leaf->map_token = NULL; | ||
3630 | } | ||
3631 | |||
3632 | /* shift the items */ | 3459 | /* shift the items */ |
3633 | memmove_extent_buffer(leaf, btrfs_item_nr_offset(slot + nr), | 3460 | memmove_extent_buffer(leaf, btrfs_item_nr_offset(slot + nr), |
3634 | btrfs_item_nr_offset(slot), | 3461 | btrfs_item_nr_offset(slot), |
@@ -3840,22 +3667,10 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root, | |||
3840 | u32 ioff; | 3667 | u32 ioff; |
3841 | 3668 | ||
3842 | item = btrfs_item_nr(leaf, i); | 3669 | item = btrfs_item_nr(leaf, i); |
3843 | if (!leaf->map_token) { | ||
3844 | map_extent_buffer(leaf, (unsigned long)item, | ||
3845 | sizeof(struct btrfs_item), | ||
3846 | &leaf->map_token, &leaf->kaddr, | ||
3847 | &leaf->map_start, &leaf->map_len, | ||
3848 | KM_USER1); | ||
3849 | } | ||
3850 | ioff = btrfs_item_offset(leaf, item); | 3670 | ioff = btrfs_item_offset(leaf, item); |
3851 | btrfs_set_item_offset(leaf, item, ioff + dsize); | 3671 | btrfs_set_item_offset(leaf, item, ioff + dsize); |
3852 | } | 3672 | } |
3853 | 3673 | ||
3854 | if (leaf->map_token) { | ||
3855 | unmap_extent_buffer(leaf, leaf->map_token, KM_USER1); | ||
3856 | leaf->map_token = NULL; | ||
3857 | } | ||
3858 | |||
3859 | memmove_extent_buffer(leaf, btrfs_item_nr_offset(slot), | 3674 | memmove_extent_buffer(leaf, btrfs_item_nr_offset(slot), |
3860 | btrfs_item_nr_offset(slot + nr), | 3675 | btrfs_item_nr_offset(slot + nr), |
3861 | sizeof(struct btrfs_item) * | 3676 | sizeof(struct btrfs_item) * |