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.18 2008/04/28 20:24:10 martin 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  *
   19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   29  * POSSIBILITY OF SUCH DAMAGE.
   30  */
   31 
   32 #ifndef _SYS_EXTENT_H_
   33 #define _SYS_EXTENT_H_
   34 
   35 #include <sys/queue.h>
   36 #include <sys/mutex.h>
   37 #include <sys/condvar.h>
   38 
   39 struct extent_region {
   40         LIST_ENTRY(extent_region) er_link;      /* link in region list */
   41         u_long  er_start;               /* start of region */
   42         u_long  er_end;                 /* end of region */
   43         int     er_flags;               /* misc. flags */
   44 };
   45 
   46 /* er_flags */
   47 #define ER_ALLOC        0x01    /* region descriptor dynamically allocated */
   48 
   49 struct extent {
   50         const char *ex_name;            /* name of extent */
   51         kmutex_t ex_lock;               /* lock on this extent */
   52         kcondvar_t ex_cv;               /* synchronization */
   53                                         /* allocated regions in extent */
   54         LIST_HEAD(, extent_region) ex_regions;
   55         u_long  ex_start;               /* start of extent */
   56         u_long  ex_end;                 /* end of extent */
   57         struct malloc_type *ex_mtype;   /* memory type */
   58         int     ex_flags;               /* misc. information */
   59 };
   60 
   61 struct extent_fixed {
   62         struct extent   fex_extent;     /* MUST BE FIRST */
   63                                         /* freelist of region descriptors */
   64         LIST_HEAD(, extent_region) fex_freelist;
   65         void *          fex_storage;    /* storage space for descriptors */
   66         size_t          fex_storagesize; /* size of storage space */
   67 };
   68 
   69 /* ex_flags; for internal use only */
   70 #define EXF_FIXED       0x01            /* extent uses fixed storage */
   71 #define EXF_NOCOALESCE  0x02            /* coalescing of regions not allowed */
   72 #define EXF_FLWANTED    0x08            /* someone asleep on freelist */
   73 
   74 #define EXF_BITS        "\2\4FLWANTED\2NOCOALESCE\1FIXED"
   75 
   76 /* misc. flags passed to extent functions */
   77 #define EX_NOWAIT       0x00            /* not safe to sleep */
   78 #define EX_WAITOK       0x01            /* safe to sleep */
   79 #define EX_FAST         0x02            /* take first fit in extent_alloc() */
   80 #define EX_CATCH        0x04            /* catch signals while sleeping */
   81 #define EX_NOCOALESCE   0x08            /* create a non-coalescing extent */
   82 #define EX_MALLOCOK     0x10            /* safe to call malloc() */
   83 #define EX_WAITSPACE    0x20            /* wait for space to become free */
   84 #define EX_BOUNDZERO    0x40            /* boundary lines start at 0 */
   85 
   86 /*
   87  * Special place holders for "alignment" and "boundary" arguments,
   88  * in the event the caller doesn't wish to use those features.
   89  */
   90 #define EX_NOALIGN      1               /* don't do alignment */
   91 #define EX_NOBOUNDARY   0               /* don't do boundary checking */
   92 
   93 #if defined(_KERNEL) || defined(_EXTENT_TESTING)
   94 #define EXTENT_FIXED_STORAGE_SIZE(_nregions)            \
   95         (ALIGN(sizeof(struct extent_fixed)) +           \
   96         ((ALIGN(sizeof(struct extent_region))) *        \
   97          (_nregions)))
   98 
   99 struct malloc_type;
  100 
  101 struct  extent *extent_create(const char *, u_long, u_long,
  102             struct malloc_type *, void *, size_t, int);
  103 void    extent_destroy(struct extent *);
  104 int     extent_alloc_subregion1(struct extent *, u_long, u_long,
  105             u_long, u_long, u_long, u_long, int, u_long *);
  106 int     extent_alloc_subregion(struct extent *, u_long, u_long,
  107             u_long, u_long, u_long, int, u_long *);
  108 int     extent_alloc_region(struct extent *, u_long, u_long, int);
  109 int     extent_alloc1(struct extent *, u_long, u_long, u_long, u_long, int,
  110             u_long *);
  111 int     extent_alloc(struct extent *, u_long, u_long, u_long, int, u_long *);
  112 int     extent_free(struct extent *, u_long, u_long, int);
  113 void    extent_print(struct extent *);
  114 void    extent_init(void);
  115 
  116 #endif /* _KERNEL || _EXTENT_TESTING */
  117 
  118 #endif /* ! _SYS_EXTENT_H_ */

Cache object: 801eb7f7433e9deffa6af6f4858b1aff


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