* BLST_COPY() - copy one radix tree to another * * Locates free space in the source tree and frees it in the destination * tree. The space may not already be free in the destination. */
| 931 | * tree. The space may not already be free in the destination. |
| 932 | */ |
| 933 | static void |
| 934 | blst_copy(blmeta_t *scan, daddr_t blk, daddr_t radix, blist_t dest, |
| 935 | daddr_t count) |
| 936 | { |
| 937 | daddr_t endBlk, i, skip; |
| 938 | |
| 939 | /* |
| 940 | * Leaf node |
| 941 | */ |
| 942 | |
| 943 | if (radix == 1) { |
| 944 | u_daddr_t v = scan->bm_bitmap; |
| 945 | |
| 946 | if (v == (u_daddr_t)-1) { |
| 947 | blist_free(dest, blk, count); |
| 948 | } else if (v != 0) { |
| 949 | int i; |
| 950 | |
| 951 | for (i = 0; i < count; ++i) { |
| 952 | if (v & ((u_daddr_t)1 << i)) |
| 953 | blist_free(dest, blk + i, 1); |
| 954 | } |
| 955 | } |
| 956 | return; |
| 957 | } |
| 958 | |
| 959 | /* |
| 960 | * Meta node |
| 961 | */ |
| 962 | |
| 963 | if (scan->bm_bitmap == 0) { |
| 964 | /* |
| 965 | * Source all allocated, leave dest allocated |
| 966 | */ |
| 967 | return; |
| 968 | } |
| 969 | |
| 970 | endBlk = blk + count; |
| 971 | skip = radix_to_skip(radix); |
| 972 | for (i = 1; blk < endBlk; i += skip) { |
| 973 | blk += radix; |
| 974 | count = radix; |
| 975 | if (blk >= endBlk) |
| 976 | count -= blk - endBlk; |
| 977 | blst_copy(&scan[i], blk - radix, |
| 978 | radix / BLIST_RADIX, dest, count); |
| 979 | } |
| 980 | } |
| 981 | |
| 982 | /* |
| 983 | * BLST_LEAF_FILL() - allocate specific blocks in leaf bitmap |
no test coverage detected