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/extent.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 /*      $NetBSD: extent.h,v 1.11 2003/02/01 06:23:50 thorpej Exp $      */
    2 
    3 /*-
    4  * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Jason R. Thorpe.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  * 3. All advertising materials mentioning features or use of this software
   19  *    must display the following acknowledgement:
   20  *      This product includes software developed by the NetBSD
   21  *      Foundation, Inc. and its contributors.
   22  * 4. Neither the name of The NetBSD Foundation nor the names of its
   23  *    contributors may be used to endorse or promote products derived
   24  *    from this software without specific prior written permission.
   25  *
   26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   36  * POSSIBILITY OF SUCH DAMAGE.
   37  */
   38 
   39 #ifndef _SYS_EXTENT_H_
   40 #define _SYS_EXTENT_H_
   41 
   42 #include <sys/lock.h>
   43 #include <sys/queue.h>
   44 
   45 struct extent_region {
   46         LIST_ENTRY(extent_region) er_link;      /* link in region list */
   47         u_long  er_start;               /* start of region */
   48         u_long  er_end;                 /* end of region */
   49         int     er_flags;               /* misc. flags */
   50 };
   51 
   52 /* er_flags */
   53 #define ER_ALLOC        0x01    /* region descriptor dynamically allocated */
   54 
   55 struct extent {
   56         const char *ex_name;            /* name of extent */
   57         struct simplelock ex_slock;     /* lock on this extent */
   58                                         /* allocated regions in extent */
   59         LIST_HEAD(, extent_region) ex_regions;
   60         u_long  ex_start;               /* start of extent */
   61         u_long  ex_end;                 /* end of extent */
   62         struct malloc_type *ex_mtype;   /* memory type */
   63         int     ex_flags;               /* misc. information */
   64 };
   65 
   66 struct extent_fixed {
   67         struct extent   fex_extent;     /* MUST BE FIRST */
   68                                         /* freelist of region descriptors */
   69         LIST_HEAD(, extent_region) fex_freelist;
   70         caddr_t         fex_storage;    /* storage space for descriptors */
   71         size_t          fex_storagesize; /* size of storage space */
   72 };
   73 
   74 /* ex_flags; for internal use only */
   75 #define EXF_FIXED       0x01            /* extent uses fixed storage */
   76 #define EXF_NOCOALESCE  0x02            /* coalescing of regions not allowed */
   77 #define EXF_WANTED      0x04            /* someone asleep on extent */
   78 #define EXF_FLWANTED    0x08            /* someone asleep on freelist */
   79 
   80 #define EXF_BITS        "\2\4FLWANTED\3WANTED\2NOCOALESCE\1FIXED"
   81 
   82 /* misc. flags passed to extent functions */
   83 #define EX_NOWAIT       0x00            /* not safe to sleep */
   84 #define EX_WAITOK       0x01            /* safe to sleep */
   85 #define EX_FAST         0x02            /* take first fit in extent_alloc() */
   86 #define EX_CATCH        0x04            /* catch signals while sleeping */
   87 #define EX_NOCOALESCE   0x08            /* create a non-coalescing extent */
   88 #define EX_MALLOCOK     0x10            /* safe to call malloc() */
   89 #define EX_WAITSPACE    0x20            /* wait for space to become free */
   90 #define EX_BOUNDZERO    0x40            /* boundary lines start at 0 */
   91 
   92 /*
   93  * Special place holders for "alignment" and "boundary" arguments,
   94  * in the event the caller doesn't wish to use those features.
   95  */
   96 #define EX_NOALIGN      1               /* don't do alignment */
   97 #define EX_NOBOUNDARY   0               /* don't do boundary checking */
   98 
   99 #if defined(_KERNEL) || defined(_EXTENT_TESTING)
  100 #define EXTENT_FIXED_STORAGE_SIZE(_nregions)            \
  101         (ALIGN(sizeof(struct extent_fixed)) +           \
  102         ((ALIGN(sizeof(struct extent_region))) *        \
  103          (_nregions)))
  104 
  105 struct malloc_type;
  106 
  107 struct  extent *extent_create __P((const char *, u_long, u_long,
  108             struct malloc_type *, caddr_t, size_t, int));
  109 void    extent_destroy __P((struct extent *));
  110 int     extent_alloc_subregion1 __P((struct extent *, u_long, u_long,
  111             u_long, u_long, u_long, u_long, int, u_long *));
  112 int     extent_alloc_region __P((struct extent *, u_long, u_long, int));
  113 int     extent_free __P((struct extent *, u_long, u_long, int));
  114 void    extent_print __P((struct extent *));
  115 
  116 /* Simple case of extent_alloc_subregion() */
  117 #define extent_alloc(_ex, _size, _alignment, _boundary, _flags, _result) \
  118         extent_alloc_subregion1((_ex), (_ex)->ex_start, (_ex)->ex_end,  \
  119         (_size), (_alignment), 0, (_boundary), (_flags), (_result))
  120 #define extent_alloc1(_ex, _size, _alignment, _skew, _boundary, \
  121                         _flags, _result) \
  122         extent_alloc_subregion1((_ex), (_ex)->ex_start, (_ex)->ex_end,  \
  123         (_size), (_alignment), (_skew), (_boundary), (_flags), (_result))
  124 /* Compat version of extent_alloc_subregion() */
  125 #define extent_alloc_subregion(_ex, _start, _end, _size, _alignment, \
  126                                 _boundary, _flags, _result) \
  127         extent_alloc_subregion1((_ex), (_start), (_end),        \
  128         (_size), (_alignment), 0, (_boundary), (_flags), (_result))
  129 #endif /* _KERNEL || _EXTENT_TESTING */
  130 
  131 #endif /* ! _SYS_EXTENT_H_ */

Cache object: 182b38a6a15ac9133b23f68e8485589f


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