summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorpk <pk@NetBSD.org>2003-02-05 21:38:38 +0000
committerpk <pk@NetBSD.org>2003-02-05 21:38:38 +0000
commit338f31f581b40d12e472e5c29223dfca09288dc1 (patch)
treec2b42af6bf7323dfe9bf15936a6b11f3e40af2be /sys/dev
parent09843e3b7e65392c6f7a1265fce8e27b17c75bb9 (diff)
Make the buffer cache code MP-safe.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ata/ata_raid.c3
-rw-r--r--sys/dev/ccd.c5
-rw-r--r--sys/dev/cgd.c5
-rw-r--r--sys/dev/isa/fd.c30
-rw-r--r--sys/dev/raidframe/rf_netbsdkintf.c10
-rw-r--r--sys/dev/scsipi/cd.c5
-rw-r--r--sys/dev/vnd.c5
7 files changed, 31 insertions, 32 deletions
diff --git a/sys/dev/ata/ata_raid.c b/sys/dev/ata/ata_raid.c
index 4a79deb58f9..d9ba4896f3b 100644
--- a/sys/dev/ata/ata_raid.c
+++ b/sys/dev/ata/ata_raid.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_raid.c,v 1.1 2003/01/27 18:21:27 thorpej Exp $ */
+/* $NetBSD: ata_raid.c,v 1.2 2003/02/05 21:38:40 pk Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -296,6 +296,7 @@ ata_raid_config_block_rw(struct vnode *vp, daddr_t blkno, void *buf,
int error;
bp = pool_get(&bufpool, PR_WAITOK);
+ simple_lock_init(&bp->b_interlock);
LIST_INIT(&bp->b_dep);
bp->b_vp = vp;
diff --git a/sys/dev/ccd.c b/sys/dev/ccd.c
index e4e44e1aa31..122fdc7ee1d 100644
--- a/sys/dev/ccd.c
+++ b/sys/dev/ccd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ccd.c,v 1.81 2003/01/25 23:09:58 kleink Exp $ */
+/* $NetBSD: ccd.c,v 1.82 2003/02/05 21:38:39 pk Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 1999 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.81 2003/01/25 23:09:58 kleink Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.82 2003/02/05 21:38:39 pk Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -802,6 +802,7 @@ ccdbuffer(cs, bp, bn, addr, bcount)
cbp = CCD_GETBUF();
if (cbp == NULL)
return (NULL);
+ simple_lock_init(&cbp->cb_buf.b_interlock);
cbp->cb_buf.b_flags = bp->b_flags | B_CALL;
cbp->cb_buf.b_iodone = ccdiodone;
cbp->cb_buf.b_proc = bp->b_proc;
diff --git a/sys/dev/cgd.c b/sys/dev/cgd.c
index e2d14972cbc..0761fe568b0 100644
--- a/sys/dev/cgd.c
+++ b/sys/dev/cgd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.6 2003/02/02 20:55:16 bouyer Exp $ */
+/* $NetBSD: cgd.c,v 1.7 2003/02/05 21:38:40 pk Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.6 2003/02/02 20:55:16 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.7 2003/02/05 21:38:40 pk Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -307,6 +307,7 @@ cgdstart(struct dk_softc *dksc, struct buf *bp)
disk_unbusy(&dksc->sc_dkdev, 0, (bp->b_flags & B_READ));
return;
}
+ simple_lock_init(&cbp->cb_buf.b_interlock);
cbp->cb_buf.b_data = newaddr;
cbp->cb_buf.b_flags = bp->b_flags | B_CALL;
cbp->cb_buf.b_iodone = cgdiodone;
diff --git a/sys/dev/isa/fd.c b/sys/dev/isa/fd.c
index 90eacbf1e10..9ec42d39f35 100644
--- a/sys/dev/isa/fd.c
+++ b/sys/dev/isa/fd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fd.c,v 1.36 2003/01/25 23:18:46 kleink Exp $ */
+/* $NetBSD: fd.c,v 1.37 2003/02/05 21:38:41 pk Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -92,7 +92,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.36 2003/01/25 23:18:46 kleink Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.37 2003/02/05 21:38:41 pk Exp $");
#include "rnd.h"
#include "opt_ddb.h"
@@ -1486,9 +1486,12 @@ fdformat(dev, finfo, p)
struct buf *bp;
/* set up a buffer header for fdstrategy() */
- bp = (struct buf *)malloc(sizeof(struct buf), M_TEMP, M_NOWAIT|M_ZERO);
- if(bp == 0)
+ bp = (struct buf *)pool_get(&bufpool, PR_NOWAIT);
+ if (bp == NULL)
return ENOBUFS;
+
+ memset((void *)bp, 0, sizeof(struct buf));
+ simple_lock_init(&bp->b_interlock);
bp->b_flags = B_BUSY | B_PHYS | B_FORMAT;
bp->b_proc = p;
bp->b_dev = dev;
@@ -1512,23 +1515,8 @@ fdformat(dev, finfo, p)
fdstrategy(bp);
/* ...and wait for it to complete */
- s = splbio();
- while (!(bp->b_flags & B_DONE)) {
- rv = tsleep((caddr_t)bp, PRIBIO, "fdform", 20 * hz);
- if (rv == EWOULDBLOCK)
- break;
- }
- splx(s);
-
- if (rv == EWOULDBLOCK) {
- /* timed out */
- rv = EIO;
- biodone(bp);
- }
- if(bp->b_flags & B_ERROR) {
- rv = bp->b_error;
- }
- free(bp, M_TEMP);
+ rv = biowait(bp);
+ pool_put(&bufpool, bp);
return rv;
}
diff --git a/sys/dev/raidframe/rf_netbsdkintf.c b/sys/dev/raidframe/rf_netbsdkintf.c
index a4ab55c2959..aeae2b9712f 100644
--- a/sys/dev/raidframe/rf_netbsdkintf.c
+++ b/sys/dev/raidframe/rf_netbsdkintf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_netbsdkintf.c,v 1.153 2003/02/01 06:23:40 thorpej Exp $ */
+/* $NetBSD: rf_netbsdkintf.c,v 1.154 2003/02/05 21:38:40 pk Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -111,7 +111,7 @@
***********************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.153 2003/02/01 06:23:40 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.154 2003/02/05 21:38:40 pk Exp $");
#include <sys/param.h>
#include <sys/errno.h>
@@ -1835,6 +1835,12 @@ rf_DispatchKernelIO(queue, req)
}
#endif
raidbp = pool_get(&raidframe_cbufpool, PR_NOWAIT);
+ if (raidbp == NULL) {
+ bp->b_flags |= B_ERROR;
+ bp->b_error = ENOMEM;
+ return (ENOMEM);
+ }
+ simple_lock_init(&raidbp->rf_buf.b_interlock);
/*
* context for raidiodone
diff --git a/sys/dev/scsipi/cd.c b/sys/dev/scsipi/cd.c
index bb120916ecb..deba12dc859 100644
--- a/sys/dev/scsipi/cd.c
+++ b/sys/dev/scsipi/cd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cd.c,v 1.177 2003/02/03 23:50:59 thorpej Exp $ */
+/* $NetBSD: cd.c,v 1.178 2003/02/05 21:38:41 pk Exp $ */
/*-
* Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.177 2003/02/03 23:50:59 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.178 2003/02/05 21:38:41 pk Exp $");
#include "rnd.h"
@@ -647,6 +647,7 @@ cdstrategy(bp)
}
/* Set up the IOP to the bounce buffer. */
+ simple_lock_init(&nbp->b_interlock);
nbp->b_error = 0;
nbp->b_proc = bp->b_proc;
nbp->b_vp = NULLVP;
diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c
index b7eea27cdc3..5c4577125bf 100644
--- a/sys/dev/vnd.c
+++ b/sys/dev/vnd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vnd.c,v 1.90 2003/01/25 23:09:59 kleink Exp $ */
+/* $NetBSD: vnd.c,v 1.91 2003/02/05 21:38:39 pk 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.90 2003/01/25 23:09:59 kleink Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.91 2003/02/05 21:38:39 pk Exp $");
#if defined(_KERNEL_OPT)
#include "fs_nfs.h"
@@ -490,6 +490,7 @@ vndstrategy(bp)
s = splbio();
nbp = VND_GETBUF(vnd);
splx(s);
+ simple_lock_init(&nbp->vb_buf.b_interlock);
nbp->vb_buf.b_flags = flags;
nbp->vb_buf.b_bcount = sz;
nbp->vb_buf.b_bufsize = round_page((ulong)addr + sz)