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  -  FREEBSD11  -  FREEBSD10  -  FREEBSD9  -  FREEBSD92  -  FREEBSD91  -  FREEBSD90  -  FREEBSD8  -  FREEBSD82  -  FREEBSD81  -  FREEBSD80  -  FREEBSD7  -  FREEBSD74  -  FREEBSD73  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1998 Matthew Dillon.  All Rights Reserved.
    3  * Redistribution and use in source and binary forms, with or without
    4  * modification, are permitted provided that the following conditions
    5  * are met:
    6  * 1. Redistributions of source code must retain the above copyright
    7  *    notice, this list of conditions and the following disclaimer.
    8  * 2. Redistributions in binary form must reproduce the above copyright
    9  *    notice, this list of conditions and the following disclaimer in the
   10  *    documentation and/or other materials provided with the distribution.
   11  * 4. Neither the name of the University nor the names of its contributors
   12  *    may be used to endorse or promote products derived from this software
   13  *    without specific prior written permission.
   14  *
   15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
   16  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
   17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
   19  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
   21  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
   23  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   24  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   26  *
   27  * Implements bitmap resource lists.
   28  *
   29  *      Usage:
   30  *              blist = blist_create(blocks)
   31  *              (void)  blist_destroy(blist)
   32  *              blkno = blist_alloc(blist, count)
   33  *              (void)  blist_free(blist, blkno, count)
   34  *              nblks = blist_fill(blist, blkno, count)
   35  *              (void)  blist_resize(&blist, count, freeextra)
   36  *              
   37  *
   38  *      Notes:
   39  *              on creation, the entire list is marked reserved.  You should
   40  *              first blist_free() the sections you want to make available
   41  *              for allocation before doing general blist_alloc()/free()
   42  *              ops.
   43  *
   44  *              SWAPBLK_NONE is returned on failure.  This module is typically
   45  *              capable of managing up to (2^31) blocks per blist, though
   46  *              the memory utilization would be insane if you actually did
   47  *              that.  Managing something like 512MB worth of 4K blocks 
   48  *              eats around 32 KBytes of memory. 
   49  *
   50  * $FreeBSD: src/sys/sys/blist.h,v 1.7 2003/08/12 23:24:05 imp Exp $
   51  */
   52 
   53 #ifndef _SYS_BLIST_H_
   54 #define _SYS_BLIST_H_
   55 
   56 typedef u_int32_t       u_daddr_t;      /* unsigned disk address */
   57 
   58 /*
   59  * blmeta and bl_bitmap_t MUST be a power of 2 in size.
   60  */
   61 
   62 typedef struct blmeta {
   63         union {
   64             daddr_t     bmu_avail;      /* space available under us     */
   65             u_daddr_t   bmu_bitmap;     /* bitmap if we are a leaf      */
   66         } u;
   67         daddr_t         bm_bighint;     /* biggest contiguous block hint*/
   68 } blmeta_t;
   69 
   70 typedef struct blist {
   71         daddr_t         bl_blocks;      /* area of coverage             */
   72         daddr_t         bl_radix;       /* coverage radix               */
   73         daddr_t         bl_skip;        /* starting skip                */
   74         daddr_t         bl_free;        /* number of free blocks        */
   75         blmeta_t        *bl_root;       /* root of radix tree           */
   76         daddr_t         bl_rootblks;    /* daddr_t blks allocated for tree */
   77 } *blist_t;
   78 
   79 #define BLIST_META_RADIX        16
   80 #define BLIST_BMAP_RADIX        (sizeof(u_daddr_t)*8)
   81 
   82 #define BLIST_MAX_ALLOC         BLIST_BMAP_RADIX
   83 
   84 extern blist_t blist_create(daddr_t blocks);
   85 extern void blist_destroy(blist_t blist);
   86 extern daddr_t blist_alloc(blist_t blist, daddr_t count);
   87 extern void blist_free(blist_t blist, daddr_t blkno, daddr_t count);
   88 extern int blist_fill(blist_t bl, daddr_t blkno, daddr_t count);
   89 extern void blist_print(blist_t blist);
   90 extern void blist_resize(blist_t *pblist, daddr_t count, int freenew);
   91 
   92 #endif  /* _SYS_BLIST_H_ */
   93 

Cache object: 10b4e807f3bf1c4c3da34a289dc215b9


[ 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.