Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Rename bufq_init() to bufq_alloc().



details:   https://anonhg.NetBSD.org/src/rev/78c422303e07
branches:  trunk
changeset: 534313:78c422303e07
user:      hannken <hannken%NetBSD.org@localhost>
date:      Sun Jul 21 15:32:17 2002 +0000

description:
Rename bufq_init() to bufq_alloc().
Add bufq_free() to remove a buffer queue.
Avoid MALLOC while holding a spinlock.

>From Chuck Silvers.

diffstat:

 share/man/man9/bufq.9              |  17 +++++++++++----
 sys/dev/ata/wd.c                   |   8 ++++--
 sys/dev/ld.c                       |   7 +++--
 sys/dev/mca/ed_mca.c               |   6 ++--
 sys/dev/md.c                       |   6 ++--
 sys/dev/raidframe/rf_netbsdkintf.c |   6 ++--
 sys/dev/scsipi/sd.c                |   8 ++++--
 sys/dev/vnd.c                      |  11 +++++++--
 sys/kern/subr_disk.c               |  40 ++++++++++++++++++++++++++-----------
 sys/sys/buf.h                      |   9 ++++---
 sys/ufs/mfs/mfs_vfsops.c           |  10 +++++---
 sys/uvm/uvm_swap.c                 |   9 +++++--
 12 files changed, 88 insertions(+), 49 deletions(-)

diffs (truncated from 511 to 300 lines):

diff -r 5c55b768bbdb -r 78c422303e07 share/man/man9/bufq.9
--- a/share/man/man9/bufq.9     Sun Jul 21 14:26:05 2002 +0000
+++ b/share/man/man9/bufq.9     Sun Jul 21 15:32:17 2002 +0000
@@ -1,4 +1,4 @@
-.\"     $NetBSD: bufq.9,v 1.1 2002/07/17 15:53:50 hannken Exp $
+.\"     $NetBSD: bufq.9,v 1.2 2002/07/21 15:32:17 hannken Exp $
 .\"
 .\" Copyright (c) 2002 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -40,7 +40,8 @@
 .Sh NAME
 .Nm bufq ,
 .Nm bufq_state ,
-.Nm bufq_init ,
+.Nm bufq_alloc ,
+.Nm bufq_free ,
 .Nm BUFQ_PUT ,
 .Nm BUFQ_GET ,
 .Nm BUFQ_PEEK
@@ -48,7 +49,9 @@
 .Sh SYNOPSIS
 .Fd #include \*[Lt]buf.h\*[Gt]
 .Ft void
-.Fn bufq_init "struct bufq_state *bufq" "int flags"
+.Fn bufq_alloc "struct bufq_state *bufq" "int flags"
+.Ft void
+.Fn bufq_free "struct bufq_state *bufq"
 .Ft void
 .Fn BUFQ_PUT "struct bufq_state *bufq" "struct buf *bp"
 .Ft "struct buf *"
@@ -69,7 +72,7 @@
        void (*bq_put)(struct bufq_state *, struct buf *);
        struct buf *(*bq_get)(struct bufq_state *, int);
        void *bq_private;
-       int bq_flags;           /* Flags from bufq_init() */
+       int bq_flags;           /* Flags from bufq_alloc() */
 };
 .Ed
 .Pp
@@ -96,12 +99,16 @@
 .El
 .Sh FUNCTIONS
 .Bl -tag -width compact
-.It Fn bufq_init "bufq" "flags"
+.It Fn bufq_alloc "bufq" "flags"
 Initialize a
 .Em bufq_state
 descriptor.  The argument
 .Fa flags
 controls the strategy and sort order.
+.It Fn bufq_free "bufq"
+Destroy a
+.Em bufq_state
+descriptor.
 .It Fn BUFQ_PUT "bufq" "bp"
 Put the buf
 .Fa bp
diff -r 5c55b768bbdb -r 78c422303e07 sys/dev/ata/wd.c
--- a/sys/dev/ata/wd.c  Sun Jul 21 14:26:05 2002 +0000
+++ b/sys/dev/ata/wd.c  Sun Jul 21 15:32:17 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wd.c,v 1.223 2002/07/16 18:03:17 hannken Exp $ */
+/*     $NetBSD: wd.c,v 1.224 2002/07/21 15:32:17 hannken Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.223 2002/07/16 18:03:17 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.224 2002/07/21 15:32:17 hannken Exp $");
 
 #ifndef WDCDEBUG
 #define WDCDEBUG
@@ -267,7 +267,7 @@
        WDCDEBUG_PRINT(("wdattach\n"), DEBUG_FUNCS | DEBUG_PROBE);
 
        callout_init(&wd->sc_restart_ch);
-       bufq_init(&wd->sc_q, BUFQ_DISKSORT|BUFQ_SORT_RAWBLOCK);
+       bufq_alloc(&wd->sc_q, BUFQ_DISKSORT|BUFQ_SORT_RAWBLOCK);
 
        wd->atabus = adev->adev_bustype;
        wd->openings = adev->adev_openings;
@@ -418,6 +418,8 @@
                biodone(bp);
        }
 
+       bufq_free(&sc->sc_q);
+
        splx(s);
 
        /* Nuke the vnodes for any open instances. */
diff -r 5c55b768bbdb -r 78c422303e07 sys/dev/ld.c
--- a/sys/dev/ld.c      Sun Jul 21 14:26:05 2002 +0000
+++ b/sys/dev/ld.c      Sun Jul 21 15:32:17 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ld.c,v 1.14 2002/07/20 11:28:07 hannken Exp $  */
+/*     $NetBSD: ld.c,v 1.15 2002/07/21 15:32:18 hannken Exp $  */
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.14 2002/07/20 11:28:07 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.15 2002/07/21 15:32:18 hannken Exp $");
 
 #include "rnd.h"
 
@@ -130,7 +130,7 @@
        /* Set the `shutdownhook'. */
        if (ld_sdh == NULL)
                ld_sdh = shutdownhook_establish(ldshutdown, NULL);
-       bufq_init(&sc->sc_bufq, BUFQ_FCFS);
+       bufq_alloc(&sc->sc_bufq, BUFQ_FCFS);
 }
 
 int
@@ -200,6 +200,7 @@
                bp->b_resid = bp->b_bcount;
                biodone(bp);
        }
+       bufq_free(&sc->sc_bufq);
        splx(s);
 
        /* Nuke the vnodes for any open instances. */
diff -r 5c55b768bbdb -r 78c422303e07 sys/dev/mca/ed_mca.c
--- a/sys/dev/mca/ed_mca.c      Sun Jul 21 14:26:05 2002 +0000
+++ b/sys/dev/mca/ed_mca.c      Sun Jul 21 15:32:17 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ed_mca.c,v 1.12 2002/07/20 16:30:18 hannken Exp $      */
+/*     $NetBSD: ed_mca.c,v 1.13 2002/07/21 15:32:18 hannken Exp $      */
 
 /*
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ed_mca.c,v 1.12 2002/07/20 16:30:18 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ed_mca.c,v 1.13 2002/07/21 15:32:18 hannken Exp $");
 
 #include "rnd.h"
 #include "locators.h"
@@ -150,7 +150,7 @@
        ed->sc_devno  = eda->edc_drive;
        edc_add_disk(sc, ed);
 
-       bufq_init(&ed->sc_q, BUFQ_DISKSORT|BUFQ_SORT_RAWBLOCK);
+       bufq_alloc(&ed->sc_q, BUFQ_DISKSORT|BUFQ_SORT_RAWBLOCK);
        simple_lock_init(&ed->sc_q_lock);
        snprintf(lckname, sizeof(lckname), "%slck", ed->sc_dev.dv_xname);
        lockinit(&ed->sc_lock, PRIBIO | PCATCH, lckname, 0, 0);
diff -r 5c55b768bbdb -r 78c422303e07 sys/dev/md.c
--- a/sys/dev/md.c      Sun Jul 21 14:26:05 2002 +0000
+++ b/sys/dev/md.c      Sun Jul 21 15:32:17 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md.c,v 1.29 2002/07/20 11:28:08 hannken Exp $  */
+/*     $NetBSD: md.c,v 1.30 2002/07/21 15:32:18 hannken Exp $  */
 
 /*
  * Copyright (c) 1995 Gordon W. Ross, Leo Weppelman.
@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.29 2002/07/20 11:28:08 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.30 2002/07/21 15:32:18 hannken Exp $");
 
 #include "opt_md.h"
 
@@ -147,7 +147,7 @@
 {
        struct md_softc *sc = (struct md_softc *)self;
 
-       bufq_init(&sc->sc_buflist, BUFQ_FCFS);
+       bufq_alloc(&sc->sc_buflist, BUFQ_FCFS);
 
        /* XXX - Could accept aux info here to set the config. */
 #ifdef MEMORY_DISK_HOOKS
diff -r 5c55b768bbdb -r 78c422303e07 sys/dev/raidframe/rf_netbsdkintf.c
--- a/sys/dev/raidframe/rf_netbsdkintf.c        Sun Jul 21 14:26:05 2002 +0000
+++ b/sys/dev/raidframe/rf_netbsdkintf.c        Sun Jul 21 15:32:17 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_netbsdkintf.c,v 1.125 2002/07/20 16:34:15 hannken Exp $     */
+/*     $NetBSD: rf_netbsdkintf.c,v 1.126 2002/07/21 15:32:18 hannken Exp $     */
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -114,7 +114,7 @@
  ***********************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.125 2002/07/20 16:34:15 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.126 2002/07/21 15:32:18 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/errno.h>
@@ -366,7 +366,7 @@
        }
 
        for (raidID = 0; raidID < num; raidID++) {
-               bufq_init(&raid_softc[raidID].buf_queue, BUFQ_FCFS);
+               bufq_alloc(&raid_softc[raidID].buf_queue, BUFQ_FCFS);
 
                raidrootdev[raidID].dv_class  = DV_DISK;
                raidrootdev[raidID].dv_cfdata = NULL;
diff -r 5c55b768bbdb -r 78c422303e07 sys/dev/scsipi/sd.c
--- a/sys/dev/scsipi/sd.c       Sun Jul 21 14:26:05 2002 +0000
+++ b/sys/dev/scsipi/sd.c       Sun Jul 21 15:32:17 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sd.c,v 1.184 2002/07/16 18:03:18 hannken Exp $ */
+/*     $NetBSD: sd.c,v 1.185 2002/07/21 15:32:19 hannken Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.184 2002/07/16 18:03:18 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.185 2002/07/21 15:32:19 hannken Exp $");
 
 #include "opt_scsi.h"
 #include "rnd.h"
@@ -134,7 +134,7 @@
 
        SC_DEBUG(periph, SCSIPI_DB2, ("sdattach: "));
 
-       bufq_init(&sd->buf_queue, BUFQ_DISKSORT|BUFQ_SORT_RAWBLOCK);
+       bufq_alloc(&sd->buf_queue, BUFQ_DISKSORT|BUFQ_SORT_RAWBLOCK);
 
        /*
         * Store information needed to contact our base driver
@@ -276,6 +276,8 @@
                biodone(bp);
        }
 
+       bufq_free(&sd->buf_queue);
+
        /* Kill off any pending commands. */
        scsipi_kill_pending(sd->sc_periph);
 
diff -r 5c55b768bbdb -r 78c422303e07 sys/dev/vnd.c
--- a/sys/dev/vnd.c     Sun Jul 21 14:26:05 2002 +0000
+++ b/sys/dev/vnd.c     Sun Jul 21 15:32:17 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vnd.c,v 1.81 2002/07/20 11:28:08 hannken Exp $ */
+/*     $NetBSD: vnd.c,v 1.82 2002/07/21 15:32:18 hannken Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -98,7 +98,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.81 2002/07/20 11:28:08 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.82 2002/07/21 15:32:18 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "fs_nfs.h"
@@ -202,12 +202,17 @@
        numvnd = num;
 
        for (i = 0; i < numvnd; i++)
-               bufq_init(&vnd_softc[i].sc_tab, BUFQ_DISKSORT|BUFQ_SORT_RAWBLOCK);
+               bufq_alloc(&vnd_softc[i].sc_tab,
+                   BUFQ_DISKSORT|BUFQ_SORT_RAWBLOCK);
 }
 
 void
 vnddetach()
 {
+       int i;
+
+       for (i = 0; i < numvnd; i++)
+               bufq_free(&vnd_softc[i].sc_tab);
 
        free(vnd_softc, M_DEVBUF);
 }
diff -r 5c55b768bbdb -r 78c422303e07 sys/kern/subr_disk.c
--- a/sys/kern/subr_disk.c      Sun Jul 21 14:26:05 2002 +0000
+++ b/sys/kern/subr_disk.c      Sun Jul 21 15:32:17 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_disk.c,v 1.39 2002/07/16 18:03:19 hannken Exp $   */
+/*     $NetBSD: subr_disk.c,v 1.40 2002/07/21 15:32:19 hannken Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1999, 2000 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.39 2002/07/16 18:03:19 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.40 2002/07/21 15:32:19 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>



Home | Main Index | Thread Index | Old Index