The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/blist.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 1998 Matthew Dillon.  Terms of use and redistribution in all
    3  * forms are covered by the BSD copyright in the file "/usr/src/COPYRIGHT".
    4  *
    5  * Implements bitmap resource lists.
    6  *
    7  *      Usage:
    8  *              blist = blist_create(blocks)
    9  *              (void)  blist_destroy(blist)
   10  *              blkno = blist_alloc(blist, count)
   11  *              (void)  blist_free(blist, blkno, count)
   12  *              nblks = blist_fill(blist, blkno, count)
   13  *              (void)  blist_resize(&blist, count, freeextra)
   14  *              
   15  *
   16  *      Notes:
   17  *              on creation, the entire list is marked reserved.  You should
   18  *              first blist_free() the sections you want to make available
   19  *              for allocation before doing general blist_alloc()/free()
   20  *              ops.
   21  *
   22  *              SWAPBLK_NONE is returned on failure.  This module is typically
   23  *              capable of managing up to (2^31) blocks per blist, though
   24  *              the memory utilization would be insane if you actually did
   25  *              that.  Managing something like 512MB worth of 4K blocks 
   26  *              eats around 32 KBytes of memory. 
   27  *
   28  * $FreeBSD: releng/5.1/sys/sys/blist.h 109086 2003-01-11 01:09:51Z dillon $
   29  */
   30 
   31 #ifndef _SYS_BLIST_H_
   32 #define _SYS_BLIST_H_
   33 
   34 typedef u_int32_t       u_daddr_t;      /* unsigned disk address */
   35 
   36 /*
   37  * blmeta and bl_bitmap_t MUST be a power of 2 in size.
   38  */
   39 
   40 typedef struct blmeta {
   41         union {
   42             daddr_t     bmu_avail;      /* space available under us     */
   43             u_daddr_t   bmu_bitmap;     /* bitmap if we are a leaf      */
   44         } u;
   45         daddr_t         bm_bighint;     /* biggest contiguous block hint*/
   46 } blmeta_t;
   47 
   48 typedef struct blist {
   49         daddr_t         bl_blocks;      /* area of coverage             */
   50         daddr_t         bl_radix;       /* coverage radix               */
   51         daddr_t         bl_skip;        /* starting skip                */
   52         daddr_t         bl_free;        /* number of free blocks        */
   53         blmeta_t        *bl_root;       /* root of radix tree           */
   54         daddr_t         bl_rootblks;    /* daddr_t blks allocated for tree */
   55 } *blist_t;
   56 
   57 #define BLIST_META_RADIX        16
   58 #define BLIST_BMAP_RADIX        (sizeof(u_daddr_t)*8)
   59 
   60 #define BLIST_MAX_ALLOC         BLIST_BMAP_RADIX
   61 
   62 extern blist_t blist_create(daddr_t blocks);
   63 extern void blist_destroy(blist_t blist);
   64 extern daddr_t blist_alloc(blist_t blist, daddr_t count);
   65 extern void blist_free(blist_t blist, daddr_t blkno, daddr_t count);
   66 extern int blist_fill(blist_t bl, daddr_t blkno, daddr_t count);
   67 extern void blist_print(blist_t blist);
   68 extern void blist_resize(blist_t *pblist, daddr_t count, int freenew);
   69 
   70 #endif  /* _SYS_BLIST_H_ */
   71 

Cache object: ee159da340b59accf20ac1857dbba8c2


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.