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/bufq.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: bufq.h,v 1.2.10.1 2005/04/06 11:56:25 tron Exp $       */
    2 /*      NetBSD: buf.h,v 1.75 2004/09/18 16:40:11 yamt Exp       */
    3 
    4 /*-
    5  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
    6  * All rights reserved.
    7  *
    8  * This code is derived from software contributed to The NetBSD Foundation
    9  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
   10  * NASA Ames Research Center.
   11  *
   12  * Redistribution and use in source and binary forms, with or without
   13  * modification, are permitted provided that the following conditions
   14  * are met:
   15  * 1. Redistributions of source code must retain the above copyright
   16  *    notice, this list of conditions and the following disclaimer.
   17  * 2. Redistributions in binary form must reproduce the above copyright
   18  *    notice, this list of conditions and the following disclaimer in the
   19  *    documentation and/or other materials provided with the distribution.
   20  * 3. All advertising materials mentioning features or use of this software
   21  *    must display the following acknowledgement:
   22  *      This product includes software developed by the NetBSD
   23  *      Foundation, Inc. and its contributors.
   24  * 4. Neither the name of The NetBSD Foundation nor the names of its
   25  *    contributors may be used to endorse or promote products derived
   26  *    from this software without specific prior written permission.
   27  *
   28  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   29  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   31  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   32  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   33  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   34  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   35  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   36  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   37  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   38  * POSSIBILITY OF SUCH DAMAGE.
   39  */
   40 
   41 /*
   42  * Copyright (c) 1982, 1986, 1989, 1993
   43  *      The Regents of the University of California.  All rights reserved.
   44  * (c) UNIX System Laboratories, Inc.
   45  * All or some portions of this file are derived from material licensed
   46  * to the University of California by American Telephone and Telegraph
   47  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
   48  * the permission of UNIX System Laboratories, Inc.
   49  *
   50  * Redistribution and use in source and binary forms, with or without
   51  * modification, are permitted provided that the following conditions
   52  * are met:
   53  * 1. Redistributions of source code must retain the above copyright
   54  *    notice, this list of conditions and the following disclaimer.
   55  * 2. Redistributions in binary form must reproduce the above copyright
   56  *    notice, this list of conditions and the following disclaimer in the
   57  *    documentation and/or other materials provided with the distribution.
   58  * 3. Neither the name of the University nor the names of its contributors
   59  *    may be used to endorse or promote products derived from this software
   60  *    without specific prior written permission.
   61  *
   62  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   63  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   64  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   65  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   66  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   67  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   68  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   69  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   70  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   71  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   72  * SUCH DAMAGE.
   73  *
   74  *      @(#)buf.h       8.9 (Berkeley) 3/30/95
   75  */
   76 
   77 #if !defined(_KERNEL)
   78 #error not supposed to be exposed to userland.
   79 #endif
   80 
   81 struct buf;
   82 
   83 /*
   84  * Device driver buffer queue.
   85  */
   86 struct bufq_state {
   87         void (*bq_put)(struct bufq_state *, struct buf *);
   88         struct buf *(*bq_get)(struct bufq_state *, int);
   89         void *bq_private;
   90         int bq_flags;                   /* Flags from bufq_alloc() */
   91 };
   92 
   93 /*
   94  * Flags for bufq_alloc.
   95  */
   96 #define BUFQ_SORT_RAWBLOCK      0x0001  /* Sort by b_rawblkno */
   97 #define BUFQ_SORT_CYLINDER      0x0002  /* Sort by b_cylinder, b_rawblkno */
   98 
   99 #define _BUFQ_DEFAULT           0x00f0  /* Let bufq_alloc() choose strategy */
  100 #define BUFQ_FCFS               0x0010  /* First-come first-serve */
  101 #define BUFQ_DISKSORT           0x0020  /* Min seek sort */
  102 #define BUFQ_READ_PRIO          0x0030  /* Min seek and read priority */
  103 #define BUFQ_PRIOCSCAN          0x0040  /* Per-priority CSCAN */
  104 
  105 #define BUFQ_SORT_MASK          0x000f
  106 #define BUFQ_METHOD_MASK        0x00f0
  107 
  108 extern int bufq_disk_default_strat;
  109 #define BUFQ_DISK_DEFAULT_STRAT()       bufq_disk_default_strat
  110 void    bufq_alloc(struct bufq_state *, int);
  111 void    bufq_drain(struct bufq_state *);
  112 void    bufq_free(struct bufq_state *);
  113 
  114 #define BUFQ_PUT(bufq, bp) \
  115         (*(bufq)->bq_put)((bufq), (bp)) /* Put buffer in queue */
  116 #define BUFQ_GET(bufq) \
  117         (*(bufq)->bq_get)((bufq), 1)    /* Get and remove buffer from queue */
  118 #define BUFQ_PEEK(bufq) \
  119         (*(bufq)->bq_get)((bufq), 0)    /* Get buffer from queue */
  120 
  121 static __inline int buf_inorder(const struct buf *, const struct buf *, int)
  122     __unused;
  123 
  124 #include <sys/null.h> /* for NULL */
  125 
  126 /*
  127  * Check if two buf's are in ascending order.
  128  */
  129 static __inline int
  130 buf_inorder(const struct buf *bp, const struct buf *bq, int sortby)
  131 {
  132 
  133         if (bp == NULL || bq == NULL)
  134                 return (bq == NULL);
  135 
  136         if (sortby == BUFQ_SORT_CYLINDER) {
  137                 if (bp->b_cylinder != bq->b_cylinder)
  138                         return bp->b_cylinder < bq->b_cylinder;
  139                 else
  140                         return bp->b_rawblkno < bq->b_rawblkno;
  141         } else
  142                 return bp->b_rawblkno < bq->b_rawblkno;
  143 }
  144 
  145 struct bufq_strat {
  146         const char *bs_name;
  147         void (*bs_initfn)(struct bufq_state *);
  148         int bs_id;
  149 };
  150 
  151 #define BUFQ_DEFINE(name, id, initfn)                   \
  152 static const struct bufq_strat bufq_strat_##name = {    \
  153         .bs_name = #name,                               \
  154         .bs_id = id,                                    \
  155         .bs_initfn = initfn                             \
  156 };                                                      \
  157 __link_set_add_rodata(bufq_strats, bufq_strat_##name)
  158 

Cache object: 34fdf5b19e4e2c26df2ff7a4dfcf9b03


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