@@ -55,6 +55,16 @@ kmem_cache_t *zfs_btree_leaf_cache;
55
55
*/
56
56
int zfs_btree_verify_intensity = 0 ;
57
57
58
+ /*
59
+ * A convenience function to silence warnings from memmove's return value and
60
+ * change argument order to src, dest.
61
+ */
62
+ void
63
+ bmov (const void * src , const void * dest , size_t size )
64
+ {
65
+ (void ) memmove (dest , src , size );
66
+ }
67
+
58
68
#ifdef _ILP32
59
69
#define BTREE_POISON 0xabadb10c
60
70
#else
@@ -367,14 +377,14 @@ bt_shift_core(zfs_btree_t *tree, zfs_btree_core_t *node, uint64_t idx,
367
377
int sign = (dir == BSD_LEFT ? -1 : +1 );
368
378
uint8_t * e_out = e_start + sign * off * size ;
369
379
uint64_t e_count = count ;
370
- bcopy (e_start , e_out , e_count * size );
380
+ bmov (e_start , e_out , e_count * size );
371
381
372
382
zfs_btree_hdr_t * * c_start = node -> btc_children + idx +
373
383
(shape == BSS_TRAPEZOID ? 0 : 1 );
374
384
zfs_btree_hdr_t * * c_out = (dir == BSD_LEFT ? c_start - off :
375
385
c_start + off );
376
386
uint64_t c_count = count + (shape == BSS_TRAPEZOID ? 1 : 0 );
377
- bcopy (c_start , c_out , c_count * sizeof (* c_start ));
387
+ bmov (c_start , c_out , c_count * sizeof (* c_start ));
378
388
}
379
389
380
390
/*
@@ -416,7 +426,7 @@ bt_shift_leaf(zfs_btree_t *tree, zfs_btree_leaf_t *node, uint64_t idx,
416
426
uint8_t * start = node -> btl_elems + idx * size ;
417
427
int sign = (dir == BSD_LEFT ? -1 : +1 );
418
428
uint8_t * out = start + sign * off * size ;
419
- bcopy (start , out , count * size );
429
+ bmov (start , out , count * size );
420
430
}
421
431
422
432
static inline void
@@ -446,11 +456,11 @@ bt_transfer_core(zfs_btree_t *tree, zfs_btree_core_t *source, uint64_t sidx,
446
456
ASSERT (source -> btc_hdr .bth_core );
447
457
ASSERT (dest -> btc_hdr .bth_core );
448
458
449
- bcopy (source -> btc_elems + sidx * size , dest -> btc_elems + didx * size ,
459
+ bmov (source -> btc_elems + sidx * size , dest -> btc_elems + didx * size ,
450
460
count * size );
451
461
452
462
uint64_t c_count = count + (shape == BSS_TRAPEZOID ? 1 : 0 );
453
- bcopy (source -> btc_children + sidx + (shape == BSS_TRAPEZOID ? 0 : 1 ),
463
+ bmov (source -> btc_children + sidx + (shape == BSS_TRAPEZOID ? 0 : 1 ),
454
464
dest -> btc_children + didx + (shape == BSS_TRAPEZOID ? 0 : 1 ),
455
465
c_count * sizeof (* source -> btc_children ));
456
466
}
@@ -463,7 +473,7 @@ bt_transfer_leaf(zfs_btree_t *tree, zfs_btree_leaf_t *source, uint64_t sidx,
463
473
ASSERT (!source -> btl_hdr .bth_core );
464
474
ASSERT (!dest -> btl_hdr .bth_core );
465
475
466
- bcopy (source -> btl_elems + sidx * size , dest -> btl_elems + didx * size ,
476
+ bmov (source -> btl_elems + sidx * size , dest -> btl_elems + didx * size ,
467
477
count * size );
468
478
}
469
479
@@ -511,7 +521,7 @@ zfs_btree_insert_core_impl(zfs_btree_t *tree, zfs_btree_core_t *parent,
511
521
512
522
/* Insert new values */
513
523
parent -> btc_children [offset + 1 ] = new_node ;
514
- bcopy (buf , parent -> btc_elems + offset * size , size );
524
+ bmov (buf , parent -> btc_elems + offset * size , size );
515
525
par_hdr -> bth_count ++ ;
516
526
}
517
527
@@ -546,7 +556,7 @@ zfs_btree_insert_into_parent(zfs_btree_t *tree, zfs_btree_hdr_t *old_node,
546
556
old_node -> bth_parent = new_node -> bth_parent = new_root ;
547
557
new_root -> btc_children [0 ] = old_node ;
548
558
new_root -> btc_children [1 ] = new_node ;
549
- bcopy (buf , new_root -> btc_elems , size );
559
+ bmov (buf , new_root -> btc_elems , size );
550
560
551
561
tree -> bt_height ++ ;
552
562
tree -> bt_root = new_root_hdr ;
@@ -614,7 +624,7 @@ zfs_btree_insert_into_parent(zfs_btree_t *tree, zfs_btree_hdr_t *old_node,
614
624
615
625
/* Store the new separator in a buffer. */
616
626
uint8_t * tmp_buf = kmem_alloc (size , KM_SLEEP );
617
- bcopy (parent -> btc_elems + keep_count * size , tmp_buf ,
627
+ bmov (parent -> btc_elems + keep_count * size , tmp_buf ,
618
628
size );
619
629
zfs_btree_poison_node (tree , par_hdr );
620
630
@@ -626,7 +636,7 @@ zfs_btree_insert_into_parent(zfs_btree_t *tree, zfs_btree_hdr_t *old_node,
626
636
/*
627
637
* Move the new separator to the existing buffer.
628
638
*/
629
- bcopy (tmp_buf , buf , size );
639
+ bmov (tmp_buf , buf , size );
630
640
} else if (offset > keep_count ) {
631
641
/* Insert the new node into the right half */
632
642
new_node -> bth_parent = new_parent ;
@@ -636,7 +646,7 @@ zfs_btree_insert_into_parent(zfs_btree_t *tree, zfs_btree_hdr_t *old_node,
636
646
/*
637
647
* Move the new separator to the existing buffer.
638
648
*/
639
- bcopy (tmp_buf , buf , size );
649
+ bmov (tmp_buf , buf , size );
640
650
} else {
641
651
/*
642
652
* Move the new separator into the right half, and replace it
@@ -646,7 +656,7 @@ zfs_btree_insert_into_parent(zfs_btree_t *tree, zfs_btree_hdr_t *old_node,
646
656
bt_shift_core_right (tree , new_parent , 0 , move_count ,
647
657
BSS_TRAPEZOID );
648
658
new_parent -> btc_children [0 ] = new_node ;
649
- bcopy (tmp_buf , new_parent -> btc_elems , size );
659
+ bmov (tmp_buf , new_parent -> btc_elems , size );
650
660
new_par_hdr -> bth_count ++ ;
651
661
}
652
662
kmem_free (tmp_buf , size );
@@ -685,7 +695,7 @@ zfs_btree_insert_leaf_impl(zfs_btree_t *tree, zfs_btree_leaf_t *leaf,
685
695
}
686
696
687
697
bt_shift_leaf_right (tree , leaf , idx , count );
688
- bcopy (value , start , size );
698
+ bmov (value , start , size );
689
699
hdr -> bth_count ++ ;
690
700
}
691
701
@@ -745,7 +755,7 @@ zfs_btree_insert_into_leaf(zfs_btree_t *tree, zfs_btree_leaf_t *leaf,
745
755
746
756
/* We store the new separator in a buffer we control for simplicity. */
747
757
uint8_t * buf = kmem_alloc (size , KM_SLEEP );
748
- bcopy (leaf -> btl_elems + (keep_count * size ), buf , size );
758
+ bmov (leaf -> btl_elems + (keep_count * size ), buf , size );
749
759
zfs_btree_poison_node (tree , & leaf -> btl_hdr );
750
760
751
761
if (idx < keep_count ) {
@@ -761,8 +771,8 @@ zfs_btree_insert_into_leaf(zfs_btree_t *tree, zfs_btree_leaf_t *leaf,
761
771
* separator, and use the new value as the new separator.
762
772
*/
763
773
bt_shift_leaf_right (tree , new_leaf , 0 , move_count );
764
- bcopy (buf , new_leaf -> btl_elems , size );
765
- bcopy (value , buf , size );
774
+ bmov (buf , new_leaf -> btl_elems , size );
775
+ bmov (value , buf , size );
766
776
new_hdr -> bth_count ++ ;
767
777
}
768
778
@@ -864,7 +874,7 @@ zfs_btree_bulk_finish(zfs_btree_t *tree)
864
874
/* Next, move the separator from the common ancestor to leaf. */
865
875
uint8_t * separator = common -> btc_elems + (common_idx * size );
866
876
uint8_t * out = leaf -> btl_elems + ((move_count - 1 ) * size );
867
- bcopy (separator , out , size );
877
+ bmov (separator , out , size );
868
878
move_count -- ;
869
879
870
880
/*
@@ -878,7 +888,7 @@ zfs_btree_bulk_finish(zfs_btree_t *tree)
878
888
* Finally, move the new last element in the left neighbor to
879
889
* the separator.
880
890
*/
881
- bcopy (l_neighbor -> btl_elems + (l_hdr -> bth_count -
891
+ bmov (l_neighbor -> btl_elems + (l_hdr -> bth_count -
882
892
move_count - 1 ) * size , separator , size );
883
893
884
894
/* Adjust the node's counts, and we're done. */
@@ -933,7 +943,7 @@ zfs_btree_bulk_finish(zfs_btree_t *tree)
933
943
uint8_t * separator = parent -> btc_elems + ((parent_idx - 1 ) *
934
944
size );
935
945
uint8_t * e_out = cur -> btc_elems + ((move_count - 1 ) * size );
936
- bcopy (separator , e_out , size );
946
+ bmov (separator , e_out , size );
937
947
938
948
/*
939
949
* Now, move elements and children from the left node to the
@@ -949,7 +959,7 @@ zfs_btree_bulk_finish(zfs_btree_t *tree)
949
959
* separator's position.
950
960
*/
951
961
move_idx -- ;
952
- bcopy (l_neighbor -> btc_elems + move_idx * size , separator , size );
962
+ bmov (l_neighbor -> btc_elems + move_idx * size , separator , size );
953
963
954
964
l_neighbor -> btc_hdr .bth_count -= move_count + 1 ;
955
965
hdr -> bth_count += move_count + 1 ;
@@ -1036,8 +1046,8 @@ zfs_btree_insert(zfs_btree_t *tree, const void *value,
1036
1046
zfs_btree_hdr_t * subtree = node -> btc_children [off + 1 ];
1037
1047
size_t size = tree -> bt_elem_size ;
1038
1048
uint8_t * buf = kmem_alloc (size , KM_SLEEP );
1039
- bcopy (node -> btc_elems + off * size , buf , size );
1040
- bcopy (value , node -> btc_elems + off * size , size );
1049
+ bmov (node -> btc_elems + off * size , buf , size );
1050
+ bmov (value , node -> btc_elems + off * size , size );
1041
1051
1042
1052
/*
1043
1053
* Find the first slot in the subtree to the right, insert
@@ -1389,18 +1399,18 @@ zfs_btree_remove_from_node(zfs_btree_t *tree, zfs_btree_core_t *node,
1389
1399
*/
1390
1400
uint8_t * separator = parent -> btc_elems + (parent_idx - 1 ) *
1391
1401
size ;
1392
- bcopy (separator , node -> btc_elems , size );
1402
+ bmov (separator , node -> btc_elems , size );
1393
1403
1394
1404
/* Move the last child of neighbor to our first child slot. */
1395
1405
zfs_btree_hdr_t * * take_child = neighbor -> btc_children +
1396
1406
l_hdr -> bth_count ;
1397
- bcopy (take_child , node -> btc_children , sizeof (* take_child ));
1407
+ bmov (take_child , node -> btc_children , sizeof (* take_child ));
1398
1408
node -> btc_children [0 ]-> bth_parent = node ;
1399
1409
1400
1410
/* Move the last element of neighbor to the separator spot. */
1401
1411
uint8_t * take_elem = neighbor -> btc_elems +
1402
1412
(l_hdr -> bth_count - 1 ) * size ;
1403
- bcopy (take_elem , separator , size );
1413
+ bmov (take_elem , separator , size );
1404
1414
l_hdr -> bth_count -- ;
1405
1415
zfs_btree_poison_node_at (tree , l_hdr , l_hdr -> bth_count );
1406
1416
return ;
@@ -1425,21 +1435,21 @@ zfs_btree_remove_from_node(zfs_btree_t *tree, zfs_btree_core_t *node,
1425
1435
* element spot in node.
1426
1436
*/
1427
1437
uint8_t * separator = parent -> btc_elems + parent_idx * size ;
1428
- bcopy (separator , node -> btc_elems + (hdr -> bth_count - 1 ) * size ,
1438
+ bmov (separator , node -> btc_elems + (hdr -> bth_count - 1 ) * size ,
1429
1439
size );
1430
1440
1431
1441
/*
1432
1442
* Move the first child of neighbor to the last child spot in
1433
1443
* node.
1434
1444
*/
1435
1445
zfs_btree_hdr_t * * take_child = neighbor -> btc_children ;
1436
- bcopy (take_child , node -> btc_children + hdr -> bth_count ,
1446
+ bmov (take_child , node -> btc_children + hdr -> bth_count ,
1437
1447
sizeof (* take_child ));
1438
1448
node -> btc_children [hdr -> bth_count ]-> bth_parent = node ;
1439
1449
1440
1450
/* Move the first element of neighbor to the separator spot. */
1441
1451
uint8_t * take_elem = neighbor -> btc_elems ;
1442
- bcopy (take_elem , separator , size );
1452
+ bmov (take_elem , separator , size );
1443
1453
r_hdr -> bth_count -- ;
1444
1454
1445
1455
/*
@@ -1492,7 +1502,7 @@ zfs_btree_remove_from_node(zfs_btree_t *tree, zfs_btree_core_t *node,
1492
1502
uint8_t * e_out = keep -> btc_elems + keep_hdr -> bth_count * size ;
1493
1503
uint8_t * separator = parent -> btc_elems + (parent_idx - 1 ) *
1494
1504
size ;
1495
- bcopy (separator , e_out , size );
1505
+ bmov (separator , e_out , size );
1496
1506
keep_hdr -> bth_count ++ ;
1497
1507
1498
1508
/* Move all our elements and children into the left node. */
@@ -1550,7 +1560,7 @@ zfs_btree_remove_from(zfs_btree_t *tree, zfs_btree_index_t *where)
1550
1560
*/
1551
1561
uint8_t * value = zfs_btree_get (tree , where );
1552
1562
uint8_t * tmp = kmem_alloc (size , KM_SLEEP );
1553
- bcopy (value , tmp , size );
1563
+ bmov (value , tmp , size );
1554
1564
zfs_btree_bulk_finish (tree );
1555
1565
VERIFY3P (zfs_btree_find (tree , tmp , where ), != , NULL );
1556
1566
kmem_free (tmp , size );
@@ -1572,7 +1582,7 @@ zfs_btree_remove_from(zfs_btree_t *tree, zfs_btree_index_t *where)
1572
1582
where );
1573
1583
ASSERT3P (new_value , != , NULL );
1574
1584
1575
- bcopy (new_value , node -> btc_elems + idx * size , size );
1585
+ bmov (new_value , node -> btc_elems + idx * size , size );
1576
1586
1577
1587
hdr = where -> bti_node ;
1578
1588
idx = where -> bti_offset ;
@@ -1644,10 +1654,10 @@ zfs_btree_remove_from(zfs_btree_t *tree, zfs_btree_index_t *where)
1644
1654
uint8_t * take_elem = ((zfs_btree_leaf_t * )l_hdr )-> btl_elems +
1645
1655
(l_hdr -> bth_count - 1 ) * size ;
1646
1656
/* Move the separator to our first spot. */
1647
- bcopy (separator , leaf -> btl_elems , size );
1657
+ bmov (separator , leaf -> btl_elems , size );
1648
1658
1649
1659
/* Move our neighbor's last element to the separator. */
1650
- bcopy (take_elem , separator , size );
1660
+ bmov (take_elem , separator , size );
1651
1661
1652
1662
/* Update the bookkeeping. */
1653
1663
l_hdr -> bth_count -- ;
@@ -1675,11 +1685,11 @@ zfs_btree_remove_from(zfs_btree_t *tree, zfs_btree_index_t *where)
1675
1685
uint8_t * separator = parent -> btc_elems + parent_idx * size ;
1676
1686
uint8_t * take_elem = ((zfs_btree_leaf_t * )r_hdr )-> btl_elems ;
1677
1687
/* Move the separator between us to our last spot. */
1678
- bcopy (separator , leaf -> btl_elems + (hdr -> bth_count - 1 ) * size ,
1688
+ bmov (separator , leaf -> btl_elems + (hdr -> bth_count - 1 ) * size ,
1679
1689
size );
1680
1690
1681
1691
/* Move our neighbor's first element to the separator. */
1682
- bcopy (take_elem , separator , size );
1692
+ bmov (take_elem , separator , size );
1683
1693
1684
1694
/* Update the bookkeeping. */
1685
1695
r_hdr -> bth_count -- ;
@@ -1738,7 +1748,7 @@ zfs_btree_remove_from(zfs_btree_t *tree, zfs_btree_index_t *where)
1738
1748
uint8_t * out = keep -> btl_elems + keep_hdr -> bth_count * size ;
1739
1749
uint8_t * separator = parent -> btc_elems + (parent_idx - 1 ) *
1740
1750
size ;
1741
- bcopy (separator , out , size );
1751
+ bmov (separator , out , size );
1742
1752
keep_hdr -> bth_count ++ ;
1743
1753
1744
1754
/* Move our elements to the left neighbor. */
0 commit comments