Give bbusy() an interlock argument. If the we need to wait for the buffer,
the interlock is dropped and reacquired when awoken. This allows for busying buffers attached to a list that is not locked by bufcache_lock.
This commit is contained in:
parent
b2fa822a33
commit
fb00b83874
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ts.c,v 1.35 2008/01/02 11:48:31 ad Exp $ */
|
||||
/* $NetBSD: ts.c,v 1.36 2008/02/15 13:46:04 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991 The Regents of the University of California.
|
||||
@ -66,7 +66,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ts.c,v 1.35 2008/01/02 11:48:31 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ts.c,v 1.36 2008/02/15 13:46:04 ad Exp $");
|
||||
|
||||
#define TS11_COMPAT /* don't use extended features provided by TS05 */
|
||||
|
||||
@ -376,7 +376,7 @@ tscommand (dev, cmd, count)
|
||||
|
||||
bp = &ts_cbuf[TS_UNIT(dev)];
|
||||
mutex_enter(&bufcache_lock);
|
||||
while (bbusy(bp) != 0)
|
||||
while (bbusy(bp, false, 0, NULL) != 0)
|
||||
;
|
||||
mutex_exit(&bufcache_lock);
|
||||
bp->b_flags |= B_READ;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ts.c,v 1.22 2008/01/02 11:48:38 ad Exp $ */
|
||||
/* $NetBSD: ts.c,v 1.23 2008/02/15 13:46:04 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991 The Regents of the University of California.
|
||||
@ -66,7 +66,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ts.c,v 1.22 2008/01/02 11:48:38 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ts.c,v 1.23 2008/02/15 13:46:04 ad Exp $");
|
||||
|
||||
#undef TSDEBUG
|
||||
|
||||
@ -336,7 +336,8 @@ tscommand(struct ts_softc *sc, dev_t dev, int cmd, int count)
|
||||
*/
|
||||
if (bp->b_bcount == 0 && (bp->b_oflags & BO_DONE))
|
||||
break;
|
||||
(void )bbusy(bp, false, 0);
|
||||
if (bbusy(bp, false, 0, NULL) == 0)
|
||||
break;
|
||||
/* check MOT-flag !!! */
|
||||
}
|
||||
bp->b_flags = B_READ;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kern_physio.c,v 1.86 2008/01/02 11:48:51 ad Exp $ */
|
||||
/* $NetBSD: kern_physio.c,v 1.87 2008/02/15 13:46:04 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1990, 1993
|
||||
@ -71,7 +71,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_physio.c,v 1.86 2008/01/02 11:48:51 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_physio.c,v 1.87 2008/02/15 13:46:04 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -285,7 +285,7 @@ physio(void (*strategy)(struct buf *), struct buf *obp, dev_t dev, int flags,
|
||||
if (obp != NULL) {
|
||||
/* [raise the processor priority level to splbio;] */
|
||||
mutex_enter(&bufcache_lock);
|
||||
while (bbusy(obp, false, 0) == EPASSTHROUGH)
|
||||
while (bbusy(obp, false, 0, NULL) == EPASSTHROUGH)
|
||||
;
|
||||
/* Mark it busy, so nobody else will use it. */
|
||||
obp->b_cflags |= BC_DONTFREE;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: vfs_bio.c,v 1.187 2008/02/15 13:30:56 ad Exp $ */
|
||||
/* $NetBSD: vfs_bio.c,v 1.188 2008/02/15 13:46:04 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
@ -114,7 +114,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.187 2008/02/15 13:30:56 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.188 2008/02/15 13:46:04 ad Exp $");
|
||||
|
||||
#include "fs_ffs.h"
|
||||
#include "opt_bufcache.h"
|
||||
@ -1141,7 +1141,7 @@ getblk(struct vnode *vp, daddr_t blkno, int size, int slpflag, int slptimeo)
|
||||
loop:
|
||||
bp = incore(vp, blkno);
|
||||
if (bp != NULL) {
|
||||
err = bbusy(bp, ((slpflag & PCATCH) != 0), slptimeo);
|
||||
err = bbusy(bp, ((slpflag & PCATCH) != 0), slptimeo, NULL);
|
||||
if (err != 0) {
|
||||
if (err == EPASSTHROUGH)
|
||||
goto loop;
|
||||
@ -2031,7 +2031,7 @@ buf_destroy(buf_t *bp)
|
||||
}
|
||||
|
||||
int
|
||||
bbusy(buf_t *bp, bool intr, int timo)
|
||||
bbusy(buf_t *bp, bool intr, int timo, kmutex_t *interlock)
|
||||
{
|
||||
int error;
|
||||
|
||||
@ -2042,6 +2042,8 @@ bbusy(buf_t *bp, bool intr, int timo)
|
||||
return EDEADLK;
|
||||
bp->b_cflags |= BC_WANTED;
|
||||
bref(bp);
|
||||
if (interlock != NULL)
|
||||
mutex_exit(interlock);
|
||||
if (intr) {
|
||||
error = cv_timedwait_sig(&bp->b_busy, &bufcache_lock,
|
||||
timo);
|
||||
@ -2050,6 +2052,8 @@ bbusy(buf_t *bp, bool intr, int timo)
|
||||
timo);
|
||||
}
|
||||
brele(bp);
|
||||
if (interlock != NULL)
|
||||
mutex_enter(interlock);
|
||||
if (error != 0)
|
||||
return error;
|
||||
return EPASSTHROUGH;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: vfs_subr2.c,v 1.18 2008/02/05 13:32:09 ad Exp $ */
|
||||
/* $NetBSD: vfs_subr2.c,v 1.19 2008/02/15 13:46:04 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
@ -82,7 +82,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_subr2.c,v 1.18 2008/02/05 13:32:09 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_subr2.c,v 1.19 2008/02/15 13:46:04 ad Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
|
||||
@ -319,7 +319,7 @@ vinvalbuf(struct vnode *vp, int flags, kauth_cred_t cred, struct lwp *l,
|
||||
restart:
|
||||
for (bp = LIST_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
|
||||
nbp = LIST_NEXT(bp, b_vnbufs);
|
||||
error = bbusy(bp, catch, slptimeo);
|
||||
error = bbusy(bp, catch, slptimeo, NULL);
|
||||
if (error != 0) {
|
||||
if (error == EPASSTHROUGH)
|
||||
goto restart;
|
||||
@ -331,7 +331,7 @@ restart:
|
||||
|
||||
for (bp = LIST_FIRST(&vp->v_cleanblkhd); bp; bp = nbp) {
|
||||
nbp = LIST_NEXT(bp, b_vnbufs);
|
||||
error = bbusy(bp, catch, slptimeo);
|
||||
error = bbusy(bp, catch, slptimeo, NULL);
|
||||
if (error != 0) {
|
||||
if (error == EPASSTHROUGH)
|
||||
goto restart;
|
||||
@ -391,7 +391,7 @@ restart:
|
||||
nbp = LIST_NEXT(bp, b_vnbufs);
|
||||
if (bp->b_lblkno < lbn)
|
||||
continue;
|
||||
error = bbusy(bp, catch, slptimeo);
|
||||
error = bbusy(bp, catch, slptimeo, NULL);
|
||||
if (error != 0) {
|
||||
if (error == EPASSTHROUGH)
|
||||
goto restart;
|
||||
@ -405,7 +405,7 @@ restart:
|
||||
nbp = LIST_NEXT(bp, b_vnbufs);
|
||||
if (bp->b_lblkno < lbn)
|
||||
continue;
|
||||
error = bbusy(bp, catch, slptimeo);
|
||||
error = bbusy(bp, catch, slptimeo, NULL);
|
||||
if (error != 0) {
|
||||
if (error == EPASSTHROUGH)
|
||||
goto restart;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: buf.h,v 1.104 2008/02/15 13:30:56 ad Exp $ */
|
||||
/* $NetBSD: buf.h,v 1.105 2008/02/15 13:46:04 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2007 The NetBSD Foundation, Inc.
|
||||
@ -306,7 +306,7 @@ buf_t *getiobuf(struct vnode *, bool);
|
||||
void putiobuf(buf_t *);
|
||||
void buf_init(buf_t *);
|
||||
void buf_destroy(buf_t *);
|
||||
int bbusy(buf_t *, bool, int);
|
||||
int bbusy(buf_t *, bool, int, kmutex_t *);
|
||||
|
||||
void nestiobuf_iodone(buf_t *);
|
||||
void nestiobuf_setup(buf_t *, buf_t *, int, size_t);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ffs_softdep.c,v 1.106 2008/01/12 00:34:10 ad Exp $ */
|
||||
/* $NetBSD: ffs_softdep.c,v 1.107 2008/02/15 13:46:04 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1998 Marshall Kirk McKusick. All Rights Reserved.
|
||||
@ -33,7 +33,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ffs_softdep.c,v 1.106 2008/01/12 00:34:10 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ffs_softdep.c,v 1.107 2008/02/15 13:46:04 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/buf.h>
|
||||
@ -5575,7 +5575,7 @@ getdirtybuf(bpp, waitfor)
|
||||
break;
|
||||
if (waitfor != MNT_WAIT)
|
||||
return (0);
|
||||
(void)bbusy(bp, false, 0);
|
||||
(void)bbusy(bp, false, 0, NULL);
|
||||
}
|
||||
mutex_enter(bp->b_objlock);
|
||||
if ((bp->b_oflags & BO_DELWRI) == 0) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: lfs_inode.c,v 1.117 2008/02/15 13:30:56 ad Exp $ */
|
||||
/* $NetBSD: lfs_inode.c,v 1.118 2008/02/15 13:46:05 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
|
||||
@ -67,7 +67,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.117 2008/02/15 13:30:56 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.118 2008/02/15 13:46:05 ad Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_quota.h"
|
||||
@ -855,7 +855,7 @@ restart:
|
||||
nbp = LIST_NEXT(bp, b_vnbufs);
|
||||
if (bp->b_lblkno < lbn)
|
||||
continue;
|
||||
error = bbusy(bp, catch, slptimeo);
|
||||
error = bbusy(bp, catch, slptimeo, NULL);
|
||||
if (error == EPASSTHROUGH)
|
||||
goto restart;
|
||||
if (error != 0) {
|
||||
@ -877,7 +877,7 @@ restart:
|
||||
nbp = LIST_NEXT(bp, b_vnbufs);
|
||||
if (bp->b_lblkno < lbn)
|
||||
continue;
|
||||
error = bbusy(bp, catch, slptimeo);
|
||||
error = bbusy(bp, catch, slptimeo, NULL);
|
||||
if (error == EPASSTHROUGH)
|
||||
goto restart;
|
||||
if (error != 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user