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/kern/bufq_fcfs.c

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_fcfs.c,v 1.3 2004/11/25 04:52:24 yamt Exp $       */
    2 /*      NetBSD: subr_disk.c,v 1.61 2004/09/25 03:30:44 thorpej Exp      */
    3 
    4 /*-
    5  * Copyright (c) 1996, 1997, 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, 1988, 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  *      @(#)ufs_disksubr.c      8.5 (Berkeley) 1/21/94
   75  */
   76 
   77 #include <sys/cdefs.h>
   78 __KERNEL_RCSID(0, "$NetBSD: bufq_fcfs.c,v 1.3 2004/11/25 04:52:24 yamt Exp $");
   79 
   80 #include <sys/param.h>
   81 #include <sys/systm.h>
   82 #include <sys/buf.h>
   83 #include <sys/bufq.h>
   84 #include <sys/malloc.h>
   85 
   86 /*
   87  * First-come first-served sort for disks.
   88  *
   89  * Requests are appended to the queue without any reordering.
   90  */
   91 
   92 struct bufq_fcfs {
   93         TAILQ_HEAD(, buf) bq_head;      /* actual list of buffers */
   94 };
   95 
   96 static void bufq_fcfs_init(struct bufq_state *);
   97 static void bufq_fcfs_put(struct bufq_state *, struct buf *);
   98 static struct buf *bufq_fcfs_get(struct bufq_state *, int);
   99 
  100 BUFQ_DEFINE(fcfs, BUFQ_FCFS, bufq_fcfs_init);
  101 
  102 static void
  103 bufq_fcfs_put(struct bufq_state *bufq, struct buf *bp)
  104 {
  105         struct bufq_fcfs *fcfs = bufq->bq_private;
  106 
  107         TAILQ_INSERT_TAIL(&fcfs->bq_head, bp, b_actq);
  108 }
  109 
  110 static struct buf *
  111 bufq_fcfs_get(struct bufq_state *bufq, int remove)
  112 {
  113         struct bufq_fcfs *fcfs = bufq->bq_private;
  114         struct buf *bp;
  115 
  116         bp = TAILQ_FIRST(&fcfs->bq_head);
  117 
  118         if (bp != NULL && remove)
  119                 TAILQ_REMOVE(&fcfs->bq_head, bp, b_actq);
  120 
  121         return (bp);
  122 }
  123 
  124 static void
  125 bufq_fcfs_init(struct bufq_state *bufq)
  126 {
  127         struct bufq_fcfs *fcfs;
  128 
  129         bufq->bq_get = bufq_fcfs_get;
  130         bufq->bq_put = bufq_fcfs_put;
  131         MALLOC(bufq->bq_private, struct bufq_fcfs *,
  132             sizeof(struct bufq_fcfs), M_DEVBUF, M_ZERO);
  133         fcfs = (struct bufq_fcfs *)bufq->bq_private;
  134         TAILQ_INIT(&fcfs->bq_head);
  135 }

Cache object: f28255308d4bf6f61b10b1cf5d012d42


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