MCPcopy Create free account
hub / github.com/F-Stack/f-stack / blst_copy

Function blst_copy

freebsd/kern/subr_blist.c:933–980  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

931 * tree. The space may not already be free in the destination.
932 */
933static void
934blst_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

Callers 1

blist_resizeFunction · 0.85

Calls 2

blist_freeFunction · 0.85
radix_to_skipFunction · 0.85

Tested by

no test coverage detected