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

Function blst_meta_free

freebsd/kern/subr_blist.c:889–925  ·  view source on GitHub ↗

* BLST_META_FREE() - free allocated blocks from radix tree meta info * * This support routine frees a range of blocks from the bitmap. * The range must be entirely enclosed by this radix node. If a * meta node, we break the range down recursively to free blocks * in subnodes (which means that this code can free an arbitrary * range whereas the allocation code cannot allocate an arbitrary *

Source from the content-addressed store, hash-verified

887 * range).
888 */
889static void
890blst_meta_free(blmeta_t *scan, daddr_t freeBlk, daddr_t count, u_daddr_t radix)
891{
892 daddr_t blk, endBlk, i, skip;
893 int digit, endDigit;
894
895 /*
896 * We could probably do a better job here. We are required to make
897 * bighint at least as large as the biggest allocable block of data.
898 * If we just shoehorn it, a little extra overhead will be incurred
899 * on the next allocation (but only that one typically).
900 */
901 scan->bm_bighint = BLIST_MAX_ALLOC;
902
903 if (radix == 1)
904 return (blst_leaf_free(scan, freeBlk, count));
905
906 endBlk = freeBlk + count;
907 blk = (freeBlk + radix * BLIST_RADIX) & -(radix * BLIST_RADIX);
908 /*
909 * blk is first block past the end of the range of this meta node,
910 * or 0 in case of overflow.
911 */
912 if (blk != 0)
913 endBlk = ummin(endBlk, blk);
914 skip = radix_to_skip(radix);
915 blk = freeBlk & -radix;
916 digit = (blk / radix) & BLIST_MASK;
917 endDigit = 1 + (((endBlk - 1) / radix) & BLIST_MASK);
918 scan->bm_bitmap |= bitrange(digit, endDigit - digit);
919 for (i = 1 + digit * skip; blk < endBlk; i += skip) {
920 blk += radix;
921 count = ummin(blk, endBlk) - freeBlk;
922 blst_meta_free(&scan[i], freeBlk, count, radix / BLIST_RADIX);
923 freeBlk = blk;
924 }
925}
926
927/*
928 * BLST_COPY() - copy one radix tree to another

Callers 1

blist_freeFunction · 0.85

Calls 4

blst_leaf_freeFunction · 0.85
umminFunction · 0.85
radix_to_skipFunction · 0.85
bitrangeFunction · 0.85

Tested by

no test coverage detected