Replace some uses of lockmgr() / simplelocks.
This commit is contained in:
parent
4cdc2ed889
commit
9abeea588a
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: gdt.c,v 1.36 2005/12/24 20:07:10 perry Exp $ */
|
||||
/* $NetBSD: gdt.c,v 1.37 2007/02/15 15:40:50 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
|
||||
|
@ -37,14 +37,14 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.36 2005/12/24 20:07:10 perry Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.37 2007/02/15 15:40:50 ad Exp $");
|
||||
|
||||
#include "opt_multiprocessor.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/user.h>
|
||||
|
||||
#include <uvm/uvm.h>
|
||||
|
@ -56,7 +56,7 @@ int gdt_count; /* number of GDT entries in use */
|
|||
int gdt_next; /* next available slot for sweeping */
|
||||
int gdt_free; /* next free slot; terminated with GNULL_SEL */
|
||||
|
||||
struct lock gdt_lock_store;
|
||||
static kmutex_t gdt_lock_store;
|
||||
|
||||
static inline void gdt_lock(void);
|
||||
static inline void gdt_unlock(void);
|
||||
|
@ -78,14 +78,14 @@ static inline void
|
|||
gdt_lock()
|
||||
{
|
||||
|
||||
(void) lockmgr(&gdt_lock_store, LK_EXCLUSIVE, NULL);
|
||||
mutex_enter(&gdt_lock_store);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gdt_unlock()
|
||||
{
|
||||
|
||||
(void) lockmgr(&gdt_lock_store, LK_RELEASE, NULL);
|
||||
mutex_exit(&gdt_lock_store);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -115,7 +115,7 @@ gdt_init()
|
|||
vaddr_t va;
|
||||
struct cpu_info *ci = &cpu_info_primary;
|
||||
|
||||
lockinit(&gdt_lock_store, PZERO, "gdtlck", 0, 0);
|
||||
mutex_init(&gdt_lock_store, MUTEX_DEFAULT, IPL_NONE);
|
||||
|
||||
max_len = MAXGDTSIZ * sizeof(gdt[0]);
|
||||
min_len = MINGDTSIZ * sizeof(gdt[0]);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kvm86.c,v 1.11 2007/01/07 20:16:14 christos Exp $ */
|
||||
/* $NetBSD: kvm86.c,v 1.12 2007/02/15 15:40:50 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002
|
||||
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kvm86.c,v 1.11 2007/01/07 20:16:14 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kvm86.c,v 1.12 2007/02/15 15:40:50 ad Exp $");
|
||||
|
||||
#include "opt_multiprocessor.h"
|
||||
|
||||
|
@ -36,8 +36,10 @@ __KERNEL_RCSID(0, "$NetBSD: kvm86.c,v 1.11 2007/01/07 20:16:14 christos Exp $");
|
|||
#include <sys/proc.h>
|
||||
#include <sys/user.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
|
||||
#include <uvm/uvm.h>
|
||||
|
||||
#include <machine/pcb.h>
|
||||
#include <machine/pte.h>
|
||||
#include <machine/pmap.h>
|
||||
|
@ -71,7 +73,7 @@ void *bioscallscratchpage;
|
|||
/* a virtual page to map in vm86 memory temporarily */
|
||||
vaddr_t bioscalltmpva;
|
||||
|
||||
struct lock kvm86_mp_lock;
|
||||
kmutex_t kvm86_mp_lock;
|
||||
|
||||
#define KVM86_IOPL3 /* not strictly necessary, saves a lot of traps */
|
||||
|
||||
|
@ -122,7 +124,7 @@ kvm86_init()
|
|||
BIOSCALLSCRATCHPAGE_VMVA);
|
||||
bioscallvmd = vmd;
|
||||
bioscalltmpva = uvm_km_alloc(kernel_map, PAGE_SIZE, 0, UVM_KMF_VAONLY);
|
||||
lockinit(&kvm86_mp_lock, 0, "KVM86 MP", 0, LK_RECURSEFAIL);
|
||||
mutex_init(&kvm86_mp_lock, MUTEX_DEFAULT, IPL_NONE);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -276,9 +278,9 @@ kvm86_bioscall_simple(intno, r)
|
|||
tf.tf_edi = r->EDI;
|
||||
tf.tf_vm86_es = r->ES;
|
||||
|
||||
lockmgr(&kvm86_mp_lock, LK_EXCLUSIVE, NULL);
|
||||
mutex_enter(&kvm86_mp_lock);
|
||||
res = kvm86_bioscall(intno, &tf);
|
||||
lockmgr(&kvm86_mp_lock, LK_RELEASE, NULL);
|
||||
mutex_exit(&kvm86_mp_lock);
|
||||
|
||||
r->EAX = tf.tf_eax;
|
||||
r->EBX = tf.tf_ebx;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ipmivar.h,v 1.1 2006/10/01 18:37:55 bouyer Exp $ */
|
||||
/* $NetBSD: ipmivar.h,v 1.2 2007/02/15 15:40:50 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005 Jordan Hargrave
|
||||
|
@ -27,6 +27,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <sys/mutex.h>
|
||||
|
||||
#include <dev/sysmon/sysmonvar.h>
|
||||
|
||||
#ifndef _IPMIVAR_H_
|
||||
|
@ -94,7 +96,7 @@ struct ipmi_softc {
|
|||
int sc_retries;
|
||||
int sc_wakeup;
|
||||
|
||||
struct lock sc_lock;
|
||||
kmutex_t sc_lock;
|
||||
|
||||
struct ipmi_bmc_args *sc_iowait_args;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ipmi.c,v 1.4 2006/11/16 01:32:39 christos Exp $ */
|
||||
/* $NetBSD: ipmi.c,v 1.5 2007/02/15 15:40:50 ad Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2006 Manuel Bouyer.
|
||||
*
|
||||
|
@ -56,7 +56,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.4 2006/11/16 01:32:39 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.5 2007/02/15 15:40:50 ad Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
|
@ -1409,11 +1409,8 @@ read_sensor(struct ipmi_softc *sc, struct ipmi_sensor *psensor)
|
|||
int rxlen, rv = -1;
|
||||
struct envsys_tre_data *sdata = &sc->sc_sensor_data[psensor->i_envnum];
|
||||
|
||||
if (!cold) {
|
||||
rv = lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL);
|
||||
if (rv)
|
||||
return rv;
|
||||
}
|
||||
if (!cold)
|
||||
mutex_enter(&sc->sc_lock);
|
||||
|
||||
memset(data, 0, sizeof(data));
|
||||
data[0] = psensor->i_num;
|
||||
|
@ -1436,7 +1433,7 @@ read_sensor(struct ipmi_softc *sc, struct ipmi_sensor *psensor)
|
|||
rv = 0;
|
||||
done:
|
||||
if (!cold)
|
||||
(void) lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
|
||||
mutex_exit(&sc->sc_lock);
|
||||
return (rv);
|
||||
}
|
||||
|
||||
|
@ -1444,13 +1441,10 @@ int
|
|||
ipmi_gtredata(struct sysmon_envsys *sme, struct envsys_tre_data *tred)
|
||||
{
|
||||
struct ipmi_softc *sc = sme->sme_cookie;
|
||||
int rv;
|
||||
|
||||
rv = lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL);
|
||||
if (rv)
|
||||
return rv;
|
||||
mutex_enter(&sc->sc_lock);
|
||||
*tred = sc->sc_sensor_data[tred->sensor];
|
||||
(void) lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
|
||||
mutex_exit(&sc->sc_lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1848,7 +1842,7 @@ ipmi_attach(struct device *parent, struct device *self, void *aux)
|
|||
sysmon_wdog_register(&sc->sc_wdog);
|
||||
|
||||
/* lock around read_sensor so that no one messes with the bmc regs */
|
||||
lockinit(&sc->sc_lock, PRIBIO, "ipmilk", 0, 0);
|
||||
mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
|
||||
|
||||
/* setup ticker */
|
||||
sc->sc_retries = 0;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: ccd.c,v 1.116 2006/11/16 01:32:44 christos Exp $ */
|
||||
/* $NetBSD: ccd.c,v 1.117 2007/02/15 15:40:51 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1997, 1998, 1999 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 1996, 1997, 1998, 1999, 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
|
@ -125,7 +125,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.116 2006/11/16 01:32:44 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.117 2007/02/15 15:40:51 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -145,7 +145,7 @@ __KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.116 2006/11/16 01:32:44 christos Exp $");
|
|||
#include <sys/fcntl.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/kauth.h>
|
||||
|
||||
|
@ -262,7 +262,7 @@ ccdattach(int num)
|
|||
cs = &ccd_softc[i];
|
||||
snprintf(cs->sc_xname, sizeof(cs->sc_xname), "ccd%d", i);
|
||||
cs->sc_dkdev.dk_name = cs->sc_xname; /* XXX */
|
||||
lockinit(&cs->sc_lock, PRIBIO, "ccdlk", 0, 0);
|
||||
mutex_init(&cs->sc_lock, MUTEX_DRIVER, IPL_NONE);
|
||||
pseudo_disk_init(&cs->sc_dkdev);
|
||||
}
|
||||
}
|
||||
|
@ -563,8 +563,7 @@ ccdopen(dev_t dev, int flags, int fmt, struct lwp *l)
|
|||
return (ENXIO);
|
||||
cs = &ccd_softc[unit];
|
||||
|
||||
if ((error = lockmgr(&cs->sc_lock, LK_EXCLUSIVE, NULL)) != 0)
|
||||
return (error);
|
||||
mutex_enter(&cs->sc_lock);
|
||||
|
||||
lp = cs->sc_dkdev.dk_label;
|
||||
|
||||
|
@ -605,7 +604,7 @@ ccdopen(dev_t dev, int flags, int fmt, struct lwp *l)
|
|||
cs->sc_dkdev.dk_copenmask | cs->sc_dkdev.dk_bopenmask;
|
||||
|
||||
done:
|
||||
(void) lockmgr(&cs->sc_lock, LK_RELEASE, NULL);
|
||||
mutex_exit(&cs->sc_lock);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
@ -615,7 +614,7 @@ ccdclose(dev_t dev, int flags, int fmt, struct lwp *l)
|
|||
{
|
||||
int unit = ccdunit(dev);
|
||||
struct ccd_softc *cs;
|
||||
int error = 0, part;
|
||||
int part;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ccddebug & CCDB_FOLLOW)
|
||||
|
@ -626,8 +625,7 @@ ccdclose(dev_t dev, int flags, int fmt, struct lwp *l)
|
|||
return (ENXIO);
|
||||
cs = &ccd_softc[unit];
|
||||
|
||||
if ((error = lockmgr(&cs->sc_lock, LK_EXCLUSIVE, NULL)) != 0)
|
||||
return (error);
|
||||
mutex_enter(&cs->sc_lock);
|
||||
|
||||
part = DISKPART(dev);
|
||||
|
||||
|
@ -649,7 +647,7 @@ ccdclose(dev_t dev, int flags, int fmt, struct lwp *l)
|
|||
cs->sc_flags &= ~CCDF_VLABEL;
|
||||
}
|
||||
|
||||
(void) lockmgr(&cs->sc_lock, LK_RELEASE, NULL);
|
||||
mutex_exit(&cs->sc_lock);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -990,7 +988,7 @@ static int
|
|||
ccdioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l)
|
||||
{
|
||||
int unit = ccdunit(dev);
|
||||
int s, i, j, lookedup = 0, error;
|
||||
int s, i, j, lookedup = 0, error = 0;
|
||||
int part, pmask;
|
||||
struct ccd_softc *cs;
|
||||
struct ccd_ioctl *ccio = (struct ccd_ioctl *)data;
|
||||
|
@ -1023,8 +1021,7 @@ ccdioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l)
|
|||
return (EBADF);
|
||||
}
|
||||
|
||||
if ((error = lockmgr(&cs->sc_lock, LK_EXCLUSIVE, NULL)) != 0)
|
||||
return (error);
|
||||
mutex_enter(&cs->sc_lock);
|
||||
|
||||
/* Must be initialized for these... */
|
||||
switch (cmd) {
|
||||
|
@ -1309,7 +1306,7 @@ ccdioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l)
|
|||
}
|
||||
|
||||
out:
|
||||
(void) lockmgr(&cs->sc_lock, LK_RELEASE, NULL);
|
||||
mutex_exit(&cs->sc_lock);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: ccdvar.h,v 1.28 2005/12/11 12:20:53 christos Exp $ */
|
||||
/* $NetBSD: ccdvar.h,v 1.29 2007/02/15 15:40:51 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1997, 1998, 1999 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 1996, 1997, 1998, 1999, 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
|
@ -117,7 +117,7 @@
|
|||
#define _DEV_CCDVAR_H_
|
||||
|
||||
#include <sys/buf.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
/*
|
||||
|
@ -212,7 +212,7 @@ struct ccd_softc {
|
|||
struct ccdgeom sc_geom; /* pseudo geometry info */
|
||||
char sc_xname[8]; /* XXX external name */
|
||||
struct disk sc_dkdev; /* generic disk device info */
|
||||
struct lock sc_lock; /* lock on this structure */
|
||||
kmutex_t sc_lock; /* lock on this structure */
|
||||
#if defined(_KERNEL) /* XXX ccdconfig(8) refers softc directly using kvm */
|
||||
struct bufq_state *sc_bufq; /* buffer queue */
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: fss.c,v 1.30 2007/01/19 14:49:09 hannken Exp $ */
|
||||
/* $NetBSD: fss.c,v 1.31 2007/02/15 15:40:51 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
|
@ -43,7 +43,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.30 2007/01/19 14:49:09 hannken Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.31 2007/02/15 15:40:51 ad Exp $");
|
||||
|
||||
#include "fss.h"
|
||||
|
||||
|
@ -163,7 +163,7 @@ fssattach(int num)
|
|||
sc->sc_unit = i;
|
||||
sc->sc_bdev = NODEV;
|
||||
simple_lock_init(&sc->sc_slock);
|
||||
lockinit(&sc->sc_lock, PRIBIO, "fsslock", 0, 0);
|
||||
mutex_init(&sc->sc_lock, MUTEX_DRIVER, IPL_NONE);
|
||||
bufq_alloc(&sc->sc_bufq, "fcfs", 0);
|
||||
}
|
||||
}
|
||||
|
@ -274,29 +274,29 @@ fss_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l)
|
|||
|
||||
switch (cmd) {
|
||||
case FSSIOCSET:
|
||||
lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL);
|
||||
mutex_enter(&sc->sc_lock);
|
||||
if ((flag & FWRITE) == 0)
|
||||
error = EPERM;
|
||||
else if ((sc->sc_flags & FSS_ACTIVE) != 0)
|
||||
error = EBUSY;
|
||||
else
|
||||
error = fss_create_snapshot(sc, fss, l);
|
||||
lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
|
||||
mutex_exit(&sc->sc_lock);
|
||||
break;
|
||||
|
||||
case FSSIOCCLR:
|
||||
lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL);
|
||||
mutex_enter(&sc->sc_lock);
|
||||
if ((flag & FWRITE) == 0)
|
||||
error = EPERM;
|
||||
else if ((sc->sc_flags & FSS_ACTIVE) == 0)
|
||||
error = ENXIO;
|
||||
else
|
||||
error = fss_delete_snapshot(sc, l);
|
||||
lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
|
||||
mutex_exit(&sc->sc_lock);
|
||||
break;
|
||||
|
||||
case FSSIOCGET:
|
||||
lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL);
|
||||
mutex_enter(&sc->sc_lock);
|
||||
switch (sc->sc_flags & (FSS_PERSISTENT | FSS_ACTIVE)) {
|
||||
case FSS_ACTIVE:
|
||||
memcpy(fsg->fsg_mount, sc->sc_mntname, MNAMELEN);
|
||||
|
@ -318,7 +318,7 @@ fss_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l)
|
|||
error = ENXIO;
|
||||
break;
|
||||
}
|
||||
lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
|
||||
mutex_exit(&sc->sc_lock);
|
||||
break;
|
||||
|
||||
case FSSIOFSET:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: fssvar.h,v 1.13 2006/03/14 15:07:29 chs Exp $ */
|
||||
/* $NetBSD: fssvar.h,v 1.14 2007/02/15 15:40:51 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
|
@ -144,7 +144,7 @@ struct fss_cache {
|
|||
struct fss_softc {
|
||||
int sc_unit; /* Logical unit number */
|
||||
struct simplelock sc_slock; /* Protect this softc */
|
||||
struct lock sc_lock; /* Sleep lock for fss_ioctl */
|
||||
kmutex_t sc_lock; /* Sleep lock for fss_ioctl */
|
||||
volatile int sc_flags; /* Flags */
|
||||
#define FSS_ACTIVE 0x01 /* Snapshot is active */
|
||||
#define FSS_ERROR 0x02 /* I/O error occurred */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: dpti.c,v 1.31 2006/12/02 03:10:42 elad Exp $ */
|
||||
/* $NetBSD: dpti.c,v 1.32 2007/02/15 15:40:51 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 2001, 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
|
@ -64,7 +64,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: dpti.c,v 1.31 2006/12/02 03:10:42 elad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: dpti.c,v 1.32 2007/02/15 15:40:51 ad Exp $");
|
||||
|
||||
#include "opt_i2o.h"
|
||||
|
||||
|
@ -301,10 +301,9 @@ dptiioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l)
|
|||
break;
|
||||
|
||||
case DPT_I2ORESCANCMD:
|
||||
if ((rv = lockmgr(&iop->sc_conflock, LK_EXCLUSIVE, NULL)) != 0)
|
||||
break;
|
||||
mutex_enter(&iop->sc_conflock);
|
||||
rv = iop_reconfigure(iop, 0);
|
||||
lockmgr(&iop->sc_conflock, LK_RELEASE, NULL);
|
||||
mutex_exit(&iop->sc_conflock);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: iop.c,v 1.62 2006/12/02 03:10:42 elad Exp $ */
|
||||
/* $NetBSD: iop.c,v 1.63 2007/02/15 15:40:51 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000, 2001, 2002 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 2000, 2001, 2002, 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
|
@ -41,7 +41,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: iop.c,v 1.62 2006/12/02 03:10:42 elad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: iop.c,v 1.63 2007/02/15 15:40:51 ad Exp $");
|
||||
|
||||
#include "opt_i2o.h"
|
||||
#include "iop.h"
|
||||
|
@ -455,7 +455,8 @@ iop_init(struct iop_softc *sc, const char *intrstr)
|
|||
sc->sc_maxob, le32toh(sc->sc_status.maxoutboundmframes));
|
||||
#endif
|
||||
|
||||
lockinit(&sc->sc_conflock, PRIBIO, "iopconf", hz * 30, 0);
|
||||
mutex_init(&sc->sc_conflock, MUTEX_DRIVER, IPL_NONE);
|
||||
cv_init(&sc->sc_confcv, "iopzzz");
|
||||
return;
|
||||
|
||||
bail_out3:
|
||||
|
@ -596,14 +597,13 @@ iop_config_interrupts(struct device *self)
|
|||
/*
|
||||
* Start device configuration.
|
||||
*/
|
||||
lockmgr(&sc->sc_conflock, LK_EXCLUSIVE, NULL);
|
||||
if ((rv = iop_reconfigure(sc, 0)) == -1) {
|
||||
mutex_enter(&sc->sc_conflock);
|
||||
if ((rv = iop_reconfigure(sc, 0)) == -1)
|
||||
printf("%s: configure failed (%d)\n", sc->sc_dv.dv_xname, rv);
|
||||
return;
|
||||
}
|
||||
lockmgr(&sc->sc_conflock, LK_RELEASE, NULL);
|
||||
mutex_exit(&sc->sc_conflock);
|
||||
|
||||
kthread_create(iop_create_reconf_thread, sc);
|
||||
if (rv == 0)
|
||||
kthread_create(iop_create_reconf_thread, sc);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -645,6 +645,8 @@ iop_reconf_thread(void *cookie)
|
|||
chgind = sc->sc_chgind + 1;
|
||||
l = curlwp;
|
||||
|
||||
mutex_enter(&sc->sc_conflock);
|
||||
|
||||
for (;;) {
|
||||
DPRINTF(("%s: async reconfig: requested 0x%08x\n",
|
||||
sc->sc_dv.dv_xname, chgind));
|
||||
|
@ -656,14 +658,12 @@ iop_reconf_thread(void *cookie)
|
|||
DPRINTF(("%s: async reconfig: notified (0x%08x, %d)\n",
|
||||
sc->sc_dv.dv_xname, le32toh(lct.changeindicator), rv));
|
||||
|
||||
if (rv == 0 &&
|
||||
lockmgr(&sc->sc_conflock, LK_EXCLUSIVE, NULL) == 0) {
|
||||
if (rv == 0) {
|
||||
iop_reconfigure(sc, le32toh(lct.changeindicator));
|
||||
chgind = sc->sc_chgind + 1;
|
||||
lockmgr(&sc->sc_conflock, LK_RELEASE, NULL);
|
||||
}
|
||||
|
||||
tsleep(iop_reconf_thread, PWAIT, "iopzzz", hz * 5);
|
||||
cv_timedwait(&sc->sc_confcv, &sc->sc_conflock, hz * 10);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2523,6 +2523,7 @@ iopioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l)
|
|||
int rv, i;
|
||||
|
||||
sc = device_lookup(&iop_cd, minor(dev));
|
||||
rv = 0;
|
||||
|
||||
switch (cmd) {
|
||||
case IOPIOCPT:
|
||||
|
@ -2556,8 +2557,7 @@ iopioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l)
|
|||
return (ENOTTY);
|
||||
}
|
||||
|
||||
if ((rv = lockmgr(&sc->sc_conflock, LK_SHARED, NULL)) != 0)
|
||||
return (rv);
|
||||
mutex_enter(&sc->sc_conflock);
|
||||
|
||||
switch (cmd) {
|
||||
case IOPIOCGLCT:
|
||||
|
@ -2571,8 +2571,7 @@ iopioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l)
|
|||
break;
|
||||
|
||||
case IOPIOCRECONFIG:
|
||||
if ((rv = lockmgr(&sc->sc_conflock, LK_UPGRADE, NULL)) == 0)
|
||||
rv = iop_reconfigure(sc, 0);
|
||||
rv = iop_reconfigure(sc, 0);
|
||||
break;
|
||||
|
||||
case IOPIOCGTIDMAP:
|
||||
|
@ -2586,7 +2585,7 @@ iopioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l)
|
|||
break;
|
||||
}
|
||||
|
||||
lockmgr(&sc->sc_conflock, LK_RELEASE, NULL);
|
||||
mutex_exit(&sc->sc_conflock);
|
||||
return (rv);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: iopsp.c,v 1.25 2006/11/16 01:32:50 christos Exp $ */
|
||||
/* $NetBSD: iopsp.c,v 1.26 2007/02/15 15:40:51 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: iopsp.c,v 1.25 2006/11/16 01:32:50 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: iopsp.c,v 1.26 2007/02/15 15:40:51 ad Exp $");
|
||||
|
||||
#include "opt_i2o.h"
|
||||
|
||||
|
@ -56,7 +56,6 @@ __KERNEL_RCSID(0, "$NetBSD: iopsp.c,v 1.25 2006/11/16 01:32:50 christos Exp $");
|
|||
#include <sys/endian.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/scsiio.h>
|
||||
#include <sys/lock.h>
|
||||
|
||||
#include <sys/bswap.h>
|
||||
#include <machine/bus.h>
|
||||
|
@ -371,14 +370,7 @@ iopsp_rescan(struct iopsp_softc *sc)
|
|||
|
||||
iop = (struct iop_softc *)device_parent(&sc->sc_dv);
|
||||
|
||||
rv = lockmgr(&iop->sc_conflock, LK_EXCLUSIVE, NULL);
|
||||
if (rv != 0) {
|
||||
#ifdef I2ODEBUG
|
||||
printf("iopsp_rescan: unable to acquire lock\n");
|
||||
#endif
|
||||
return (rv);
|
||||
}
|
||||
|
||||
mutex_enter(&iop->sc_conflock);
|
||||
im = iop_msg_alloc(iop, IM_WAIT);
|
||||
|
||||
mf.msgflags = I2O_MSGFLAGS(i2o_hba_bus_scan);
|
||||
|
@ -395,7 +387,7 @@ iopsp_rescan(struct iopsp_softc *sc)
|
|||
if ((rv = iop_lct_get(iop)) == 0)
|
||||
rv = iopsp_reconfig(&sc->sc_dv);
|
||||
|
||||
lockmgr(&iop->sc_conflock, LK_RELEASE, NULL);
|
||||
mutex_exit(&iop->sc_conflock);
|
||||
return (rv);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: iopvar.h,v 1.16 2005/12/11 12:21:23 christos Exp $ */
|
||||
/* $NetBSD: iopvar.h,v 1.17 2007/02/15 15:40:52 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000, 2001, 2002 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 2000, 2001, 2002, 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
|
@ -39,6 +39,9 @@
|
|||
#ifndef _I2O_IOPVAR_H_
|
||||
#define _I2O_IOPVAR_H_
|
||||
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/condvar.h>
|
||||
|
||||
/*
|
||||
* Transfer descriptor.
|
||||
*/
|
||||
|
@ -134,7 +137,8 @@ struct iop_softc {
|
|||
int sc_nlctent; /* Number of LCT entries */
|
||||
int sc_flags; /* IOP-wide flags */
|
||||
u_int32_t sc_chgind; /* Configuration change indicator */
|
||||
struct lock sc_conflock; /* Configuration lock */
|
||||
kmutex_t sc_conflock; /* Configuration lock */
|
||||
kcondvar_t sc_confcv; /* Configuration CV */
|
||||
struct proc *sc_reconf_proc;/* Auto reconfiguration process */
|
||||
LIST_HEAD(, iop_initiator) sc_iilist;/* Initiator list */
|
||||
int sc_nii; /* Total number of initiators */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ntfs_ihash.c,v 1.3 2005/12/11 12:24:29 christos Exp $ */
|
||||
/* $NetBSD: ntfs_ihash.c,v 1.4 2007/02/15 15:40:52 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1991, 1993, 1995
|
||||
|
@ -33,7 +33,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ntfs_ihash.c,v 1.3 2005/12/11 12:24:29 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ntfs_ihash.c,v 1.4 2007/02/15 15:40:52 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -56,10 +56,8 @@ MALLOC_DEFINE(M_NTFSNTHASH, "NTFS nthash", "NTFS ntnode hash tables");
|
|||
static LIST_HEAD(nthashhead, ntnode) *ntfs_nthashtbl;
|
||||
static u_long ntfs_nthash; /* size of hash table - 1 */
|
||||
#define NTNOHASH(device, inum) ((minor(device) + (inum)) & ntfs_nthash)
|
||||
#ifndef NULL_SIMPLELOCKS
|
||||
static struct simplelock ntfs_nthash_slock;
|
||||
#endif
|
||||
struct lock ntfs_hashlock;
|
||||
static kmutex_t ntfs_nthash_lock;
|
||||
kmutex_t ntfs_hashlock;
|
||||
|
||||
/*
|
||||
* Initialize inode hash table.
|
||||
|
@ -67,13 +65,12 @@ struct lock ntfs_hashlock;
|
|||
void
|
||||
ntfs_nthashinit()
|
||||
{
|
||||
lockinit(&ntfs_hashlock, PINOD, "ntfs_nthashlock", 0, 0);
|
||||
mutex_init(&ntfs_hashlock, MUTEX_DEFAULT, IPL_NONE);
|
||||
mutex_init(&ntfs_nthash_lock, MUTEX_DEFAULT, IPL_NONE);
|
||||
ntfs_nthashtbl = HASHINIT(desiredvnodes, M_NTFSNTHASH, M_WAITOK,
|
||||
&ntfs_nthash);
|
||||
simple_lock_init(&ntfs_nthash_slock);
|
||||
}
|
||||
|
||||
#ifdef __NetBSD__
|
||||
/*
|
||||
* Reinitialize inode hash table.
|
||||
*/
|
||||
|
@ -88,7 +85,7 @@ ntfs_nthashreinit()
|
|||
|
||||
hash = HASHINIT(desiredvnodes, M_NTFSNTHASH, M_WAITOK, &mask);
|
||||
|
||||
simple_lock(&ntfs_nthash_slock);
|
||||
mutex_enter(&ntfs_nthash_lock);
|
||||
oldhash = ntfs_nthashtbl;
|
||||
oldmask = ntfs_nthash;
|
||||
ntfs_nthashtbl = hash;
|
||||
|
@ -100,7 +97,7 @@ ntfs_nthashreinit()
|
|||
LIST_INSERT_HEAD(&hash[val], ip, i_hash);
|
||||
}
|
||||
}
|
||||
simple_unlock(&ntfs_nthash_slock);
|
||||
mutex_exit(&ntfs_nthash_lock);
|
||||
hashdone(oldhash, M_NTFSNTHASH);
|
||||
}
|
||||
|
||||
|
@ -113,7 +110,6 @@ ntfs_nthashdone()
|
|||
{
|
||||
hashdone(ntfs_nthashtbl, M_NTFSNTHASH);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Use the device/inum pair to find the incore inode, and return a pointer
|
||||
|
@ -127,13 +123,13 @@ ntfs_nthashlookup(dev, inum)
|
|||
struct ntnode *ip;
|
||||
struct nthashhead *ipp;
|
||||
|
||||
simple_lock(&ntfs_nthash_slock);
|
||||
mutex_enter(&ntfs_nthash_lock);
|
||||
ipp = &ntfs_nthashtbl[NTNOHASH(dev, inum)];
|
||||
LIST_FOREACH(ip, ipp, i_hash) {
|
||||
if (inum == ip->i_number && dev == ip->i_dev)
|
||||
break;
|
||||
}
|
||||
simple_unlock(&ntfs_nthash_slock);
|
||||
mutex_exit(&ntfs_nthash_lock);
|
||||
|
||||
return (ip);
|
||||
}
|
||||
|
@ -147,11 +143,11 @@ ntfs_nthashins(ip)
|
|||
{
|
||||
struct nthashhead *ipp;
|
||||
|
||||
simple_lock(&ntfs_nthash_slock);
|
||||
mutex_enter(&ntfs_nthash_lock);
|
||||
ipp = &ntfs_nthashtbl[NTNOHASH(ip->i_dev, ip->i_number)];
|
||||
LIST_INSERT_HEAD(ipp, ip, i_hash);
|
||||
ip->i_flag |= IN_HASHED;
|
||||
simple_unlock(&ntfs_nthash_slock);
|
||||
mutex_exit(&ntfs_nthash_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -161,10 +157,10 @@ void
|
|||
ntfs_nthashrem(ip)
|
||||
struct ntnode *ip;
|
||||
{
|
||||
simple_lock(&ntfs_nthash_slock);
|
||||
mutex_enter(&ntfs_nthash_lock);
|
||||
if (ip->i_flag & IN_HASHED) {
|
||||
ip->i_flag &= ~IN_HASHED;
|
||||
LIST_REMOVE(ip, i_hash);
|
||||
}
|
||||
simple_unlock(&ntfs_nthash_slock);
|
||||
mutex_exit(&ntfs_nthash_lock);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ntfs_ihash.h,v 1.3 2005/12/03 17:34:43 christos Exp $ */
|
||||
/* $NetBSD: ntfs_ihash.h,v 1.4 2007/02/15 15:40:52 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 1999 Semen Ustimenko
|
||||
|
@ -27,11 +27,14 @@
|
|||
*
|
||||
* Id: ntfs_ihash.h,v 1.3 1999/05/12 09:42:59 semenu Exp
|
||||
*/
|
||||
|
||||
#if !defined(_KERNEL)
|
||||
#error not supposed to be exposed to userland.
|
||||
#endif
|
||||
|
||||
extern struct lock ntfs_hashlock;
|
||||
#include <sys/mutex.h>
|
||||
|
||||
extern kmutex_t ntfs_hashlock;
|
||||
void ntfs_nthashinit(void);
|
||||
void ntfs_nthashreinit(void);
|
||||
void ntfs_nthashdone(void);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ntfs_subr.c,v 1.27 2006/11/16 01:33:35 christos Exp $ */
|
||||
/* $NetBSD: ntfs_subr.c,v 1.28 2007/02/15 15:40:52 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 1999 Semen Ustimenko (semenu@FreeBSD.org)
|
||||
|
@ -29,7 +29,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ntfs_subr.c,v 1.27 2006/11/16 01:33:35 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ntfs_subr.c,v 1.28 2007/02/15 15:40:52 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -89,7 +89,7 @@ static int ntfs_uastrcmp(struct ntfsmount *, const wchar *, size_t,
|
|||
static wchar *ntfs_toupper_tab;
|
||||
#define NTFS_U28(ch) ((((ch) & 0xE0) == 0) ? '_' : (ch) & 0xFF)
|
||||
#define NTFS_TOUPPER(ch) (ntfs_toupper_tab[(unsigned char)(ch)])
|
||||
static struct lock ntfs_toupper_lock;
|
||||
static kmutex_t ntfs_toupper_lock;
|
||||
static signed int ntfs_toupper_usecount;
|
||||
|
||||
/* support macro for ntfs_ntvattrget() */
|
||||
|
@ -409,16 +409,14 @@ ntfs_ntlookup(
|
|||
dprintf(("ntfs_ntlookup: looking for ntnode %llu\n",
|
||||
(unsigned long long)ino));
|
||||
|
||||
do {
|
||||
if ((ip = ntfs_nthashlookup(ntmp->ntm_dev, ino)) != NULL) {
|
||||
ntfs_ntget(ip);
|
||||
dprintf(("ntfs_ntlookup: ntnode %llu: %p,"
|
||||
" usecount: %d\n",
|
||||
(unsigned long long)ino, ip, ip->i_usecount));
|
||||
*ipp = ip;
|
||||
return (0);
|
||||
}
|
||||
} while (lockmgr(&ntfs_hashlock, LK_EXCLUSIVE | LK_SLEEPFAIL, NULL));
|
||||
if ((ip = ntfs_nthashlookup(ntmp->ntm_dev, ino)) != NULL) {
|
||||
ntfs_ntget(ip);
|
||||
dprintf(("ntfs_ntlookup: ntnode %llu: %p,"
|
||||
" usecount: %d\n",
|
||||
(unsigned long long)ino, ip, ip->i_usecount));
|
||||
*ipp = ip;
|
||||
return (0);
|
||||
}
|
||||
|
||||
MALLOC(ip, struct ntnode *, sizeof(struct ntnode),
|
||||
M_NTFSNTNODE, M_WAITOK);
|
||||
|
@ -426,6 +424,18 @@ ntfs_ntlookup(
|
|||
(unsigned long long)ino, ip));
|
||||
bzero(ip, sizeof(struct ntnode));
|
||||
|
||||
mutex_enter(&ntfs_hashlock);
|
||||
if ((ip = ntfs_nthashlookup(ntmp->ntm_dev, ino)) != NULL) {
|
||||
mutex_exit(&ntfs_hashlock);
|
||||
ntfs_ntget(ip);
|
||||
FREE(ip, M_NTFSNTNODE);
|
||||
dprintf(("ntfs_ntlookup: ntnode %llu: %p,"
|
||||
" usecount: %d\n",
|
||||
(unsigned long long)ino, ip, ip->i_usecount));
|
||||
*ipp = ip;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Generic initialization */
|
||||
ip->i_devvp = ntmp->ntm_devvp;
|
||||
ip->i_dev = ntmp->ntm_dev;
|
||||
|
@ -441,7 +451,7 @@ ntfs_ntlookup(
|
|||
|
||||
ntfs_nthashins(ip);
|
||||
|
||||
lockmgr(&ntfs_hashlock, LK_RELEASE, NULL);
|
||||
mutex_exit(&ntfs_hashlock);
|
||||
|
||||
*ipp = ip;
|
||||
|
||||
|
@ -2026,7 +2036,7 @@ void
|
|||
ntfs_toupper_init()
|
||||
{
|
||||
ntfs_toupper_tab = (wchar *) NULL;
|
||||
lockinit(&ntfs_toupper_lock, PVFS, "ntfs_toupper", 0, 0);
|
||||
mutex_init(&ntfs_toupper_lock, MUTEX_DEFAULT, IPL_NONE);
|
||||
ntfs_toupper_usecount = 0;
|
||||
}
|
||||
|
||||
|
@ -2043,7 +2053,7 @@ ntfs_toupper_use(mp, ntmp)
|
|||
struct vnode *vp;
|
||||
|
||||
/* get exclusive access */
|
||||
lockmgr(&ntfs_toupper_lock, LK_EXCLUSIVE, NULL);
|
||||
mutex_enter(&ntfs_toupper_lock);
|
||||
|
||||
/* only read the translation data from a file if it hasn't been
|
||||
* read already */
|
||||
|
@ -2067,7 +2077,7 @@ ntfs_toupper_use(mp, ntmp)
|
|||
|
||||
out:
|
||||
ntfs_toupper_usecount++;
|
||||
lockmgr(&ntfs_toupper_lock, LK_RELEASE, NULL);
|
||||
mutex_exit(&ntfs_toupper_lock);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
@ -2079,7 +2089,7 @@ void
|
|||
ntfs_toupper_unuse()
|
||||
{
|
||||
/* get exclusive access */
|
||||
lockmgr(&ntfs_toupper_lock, LK_EXCLUSIVE, NULL);
|
||||
mutex_enter(&ntfs_toupper_lock);
|
||||
|
||||
ntfs_toupper_usecount--;
|
||||
if (ntfs_toupper_usecount == 0) {
|
||||
|
@ -2094,5 +2104,5 @@ ntfs_toupper_unuse()
|
|||
#endif
|
||||
|
||||
/* release the lock */
|
||||
lockmgr(&ntfs_toupper_lock, LK_RELEASE, NULL);
|
||||
mutex_exit(&ntfs_toupper_lock);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: subr_specificdata.c,v 1.8 2007/01/25 13:58:40 elad Exp $ */
|
||||
/* $NetBSD: subr_specificdata.c,v 1.9 2007/02/15 15:40:52 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
|
@ -63,13 +63,14 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_specificdata.c,v 1.8 2007/01/25 13:58:40 elad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_specificdata.c,v 1.9 2007/02/15 15:40:52 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kmem.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/specificdata.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/mutex.h>
|
||||
|
||||
/*
|
||||
* Locking notes:
|
||||
|
@ -96,7 +97,7 @@ struct specificdata_container {
|
|||
(sizeof(struct specificdata_container) + ((n) * sizeof(void *)))
|
||||
|
||||
struct specificdata_domain {
|
||||
struct lock sd_lock;
|
||||
kmutex_t sd_lock;
|
||||
unsigned int sd_nkey;
|
||||
LIST_HEAD(, specificdata_container) sd_list;
|
||||
specificdata_key_impl *sd_keys;
|
||||
|
@ -107,21 +108,6 @@ struct specificdata_domain {
|
|||
#define specdataref_lock(ref) simple_lock(&(ref)->specdataref_slock)
|
||||
#define specdataref_unlock(ref) simple_unlock(&(ref)->specdataref_slock)
|
||||
|
||||
static void
|
||||
specificdata_domain_lock(specificdata_domain_t sd)
|
||||
{
|
||||
|
||||
ASSERT_SLEEPABLE(NULL, __func__);
|
||||
lockmgr(&sd->sd_lock, LK_EXCLUSIVE, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
specificdata_domain_unlock(specificdata_domain_t sd)
|
||||
{
|
||||
|
||||
lockmgr(&sd->sd_lock, LK_RELEASE, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
specificdata_container_link(specificdata_domain_t sd,
|
||||
specificdata_container_t sc)
|
||||
|
@ -181,7 +167,7 @@ specificdata_domain_create(void)
|
|||
|
||||
sd = kmem_zalloc(sizeof(*sd), KM_SLEEP);
|
||||
KASSERT(sd != NULL);
|
||||
lockinit(&sd->sd_lock, PLOCK, "specdata", 0, 0);
|
||||
mutex_init(&sd->sd_lock, MUTEX_DEFAULT, IPL_NONE);
|
||||
LIST_INIT(&sd->sd_list);
|
||||
|
||||
return (sd);
|
||||
|
@ -217,7 +203,7 @@ specificdata_key_create(specificdata_domain_t sd, specificdata_key_t *keyp,
|
|||
if (dtor == NULL)
|
||||
dtor = specificdata_noop_dtor;
|
||||
|
||||
specificdata_domain_lock(sd);
|
||||
mutex_enter(&sd->sd_lock);
|
||||
|
||||
if (sd->sd_keys == NULL)
|
||||
goto needalloc;
|
||||
|
@ -229,6 +215,7 @@ specificdata_key_create(specificdata_domain_t sd, specificdata_key_t *keyp,
|
|||
|
||||
needalloc:
|
||||
nsz = (sd->sd_nkey + 1) * sizeof(*newkeys);
|
||||
/* XXXSMP allocating memory while holding a lock. */
|
||||
newkeys = kmem_zalloc(nsz, KM_SLEEP);
|
||||
KASSERT(newkeys != NULL);
|
||||
if (sd->sd_keys != NULL) {
|
||||
|
@ -241,7 +228,7 @@ specificdata_key_create(specificdata_domain_t sd, specificdata_key_t *keyp,
|
|||
gotit:
|
||||
sd->sd_keys[key].ski_dtor = dtor;
|
||||
|
||||
specificdata_domain_unlock(sd);
|
||||
mutex_exit(&sd->sd_lock);
|
||||
|
||||
*keyp = key;
|
||||
return (0);
|
||||
|
@ -258,7 +245,7 @@ specificdata_key_delete(specificdata_domain_t sd, specificdata_key_t key)
|
|||
{
|
||||
specificdata_container_t sc;
|
||||
|
||||
specificdata_domain_lock(sd);
|
||||
mutex_enter(&sd->sd_lock);
|
||||
|
||||
if (key >= sd->sd_nkey)
|
||||
goto out;
|
||||
|
@ -274,7 +261,7 @@ specificdata_key_delete(specificdata_domain_t sd, specificdata_key_t key)
|
|||
sd->sd_keys[key].ski_dtor = NULL;
|
||||
|
||||
out:
|
||||
specificdata_domain_unlock(sd);
|
||||
mutex_exit(&sd->sd_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -314,14 +301,14 @@ specificdata_fini(specificdata_domain_t sd, specificdata_reference *ref)
|
|||
return;
|
||||
ref->specdataref_container = NULL;
|
||||
|
||||
specificdata_domain_lock(sd);
|
||||
mutex_enter(&sd->sd_lock);
|
||||
|
||||
specificdata_container_unlink(sd, sc);
|
||||
for (key = 0; key < sc->sc_nkey; key++) {
|
||||
specificdata_destroy_datum(sd, sc, key);
|
||||
}
|
||||
|
||||
specificdata_domain_unlock(sd);
|
||||
mutex_exit(&sd->sd_lock);
|
||||
|
||||
kmem_free(sc, SPECIFICDATA_CONTAINER_BYTESIZE(sc->sc_nkey));
|
||||
}
|
||||
|
@ -404,10 +391,10 @@ specificdata_setspecific(specificdata_domain_t sd,
|
|||
* Slow path: need to resize.
|
||||
*/
|
||||
|
||||
specificdata_domain_lock(sd);
|
||||
mutex_enter(&sd->sd_lock);
|
||||
newnkey = sd->sd_nkey;
|
||||
if (key >= newnkey) {
|
||||
specificdata_domain_unlock(sd);
|
||||
mutex_exit(&sd->sd_lock);
|
||||
panic("specificdata_setspecific");
|
||||
}
|
||||
sz = SPECIFICDATA_CONTAINER_BYTESIZE(newnkey);
|
||||
|
@ -426,7 +413,7 @@ specificdata_setspecific(specificdata_domain_t sd,
|
|||
*/
|
||||
sc->sc_data[key] = data;
|
||||
specdataref_unlock(ref);
|
||||
specificdata_domain_unlock(sd);
|
||||
mutex_exit(&sd->sd_lock);
|
||||
kmem_free(newsc, sz);
|
||||
return;
|
||||
}
|
||||
|
@ -439,7 +426,7 @@ specificdata_setspecific(specificdata_domain_t sd,
|
|||
ref->specdataref_container = newsc;
|
||||
|
||||
specdataref_unlock(ref);
|
||||
specificdata_domain_unlock(sd);
|
||||
mutex_exit(&sd->sd_lock);
|
||||
|
||||
if (sc != NULL)
|
||||
kmem_free(sc, SPECIFICDATA_CONTAINER_BYTESIZE(sc->sc_nkey));
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: sysv_shm.c,v 1.95 2007/02/09 21:55:31 ad Exp $ */
|
||||
/* $NetBSD: sysv_shm.c,v 1.96 2007/02/15 15:40:52 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 1999, 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
|
@ -68,14 +68,14 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: sysv_shm.c,v 1.95 2007/02/09 21:55:31 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: sysv_shm.c,v 1.96 2007/02/15 15:40:52 ad Exp $");
|
||||
|
||||
#define SYSVSHM
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -112,7 +112,7 @@ struct shmmap_entry {
|
|||
int shmid;
|
||||
};
|
||||
|
||||
struct lock shm_lock;
|
||||
static kmutex_t shm_lock;
|
||||
static int shm_last_free, shm_committed, shm_use_phys;
|
||||
|
||||
static POOL_INIT(shmmap_entry_pool, sizeof(struct shmmap_entry), 0, 0, 0,
|
||||
|
@ -764,7 +764,7 @@ shminit(void)
|
|||
int i, sz;
|
||||
vaddr_t v;
|
||||
|
||||
lockinit(&shm_lock, PWAIT, "shmlk", 0, 0);
|
||||
mutex_init(&shm_lock, MUTEX_DEFAULT, IPL_NONE);
|
||||
|
||||
/* Allocate pageable memory for our structures */
|
||||
sz = shminfo.shmmni * sizeof(struct shmid_ds);
|
||||
|
@ -797,11 +797,11 @@ sysctl_ipc_shmmni(SYSCTLFN_ARGS)
|
|||
if (error || newp == NULL)
|
||||
return error;
|
||||
|
||||
lockmgr(&shm_lock, LK_EXCLUSIVE, NULL);
|
||||
mutex_enter(&shm_lock);
|
||||
error = shmrealloc(newsize);
|
||||
if (error == 0)
|
||||
shminfo.shmmni = newsize;
|
||||
lockmgr(&shm_lock, LK_RELEASE, NULL);
|
||||
mutex_exit(&shm_lock);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: vfs_trans.c,v 1.3 2007/02/10 15:51:02 hannken Exp $ */
|
||||
/* $NetBSD: vfs_trans.c,v 1.4 2007/02/15 15:40:53 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.3 2007/02/10 15:51:02 hannken Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.4 2007/02/15 15:40:53 ad Exp $");
|
||||
|
||||
/*
|
||||
* File system transaction operations.
|
||||
|
@ -73,8 +73,7 @@ struct fstrans_mount_info {
|
|||
|
||||
static specificdata_key_t lwp_data_key;
|
||||
static specificdata_key_t mount_data_key;
|
||||
static struct lock vfs_suspend_lock = /* Serialize suspensions. */
|
||||
LOCK_INITIALIZER(PUSER, "suspwt1", 0, 0);
|
||||
static kmutex_t vfs_suspend_lock; /* Serialize suspensions. */
|
||||
|
||||
POOL_INIT(fstrans_pl, sizeof(struct fstrans_lwp_info), 0, 0, 0,
|
||||
"fstrans", NULL);
|
||||
|
@ -95,6 +94,7 @@ fstrans_init(void)
|
|||
KASSERT(error == 0);
|
||||
error = mount_specific_key_create(&mount_data_key, fstrans_mount_dtor);
|
||||
KASSERT(error == 0);
|
||||
mutex_init(&vfs_suspend_lock, MUTEX_DEFAULT, IPL_NONE);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -354,20 +354,20 @@ vfs_suspend(struct mount *mp, int nowait)
|
|||
#ifndef NEWVNGATE
|
||||
struct lwp *l = curlwp; /* XXX */
|
||||
#endif /* NEWVNGATE */
|
||||
int error, flags;
|
||||
int error;
|
||||
|
||||
flags = LK_EXCLUSIVE;
|
||||
if (nowait)
|
||||
flags |= LK_NOWAIT;
|
||||
if (lockmgr(&vfs_suspend_lock, flags, NULL) != 0)
|
||||
return EWOULDBLOCK;
|
||||
if (nowait) {
|
||||
if (!mutex_tryenter(&vfs_suspend_lock))
|
||||
return EWOULDBLOCK;
|
||||
} else
|
||||
mutex_enter(&vfs_suspend_lock);
|
||||
|
||||
#ifdef NEWVNGATE
|
||||
mutex_enter(&syncer_mutex);
|
||||
|
||||
if ((error = VFS_SUSPENDCTL(mp, SUSPEND_SUSPEND)) != 0) {
|
||||
mutex_exit(&syncer_mutex);
|
||||
lockmgr(&vfs_suspend_lock, LK_RELEASE, NULL);
|
||||
mutex_exit(&vfs_suspend_lock);
|
||||
}
|
||||
|
||||
return error;
|
||||
|
@ -411,14 +411,14 @@ vfs_resume(struct mount *mp)
|
|||
#ifdef NEWVNGATE
|
||||
VFS_SUSPENDCTL(mp, SUSPEND_RESUME);
|
||||
mutex_exit(&syncer_mutex);
|
||||
lockmgr(&vfs_suspend_lock, LK_RELEASE, NULL);
|
||||
mutex_exit(&vfs_suspend_lock);
|
||||
#else /* NEWVNGATE */
|
||||
if ((mp->mnt_iflag & IMNT_SUSPEND) == 0)
|
||||
return;
|
||||
mp->mnt_iflag &= ~(IMNT_SUSPEND | IMNT_SUSPENDLOW | IMNT_SUSPENDED);
|
||||
wakeup(&mp->mnt_flag);
|
||||
|
||||
lockmgr(&vfs_suspend_lock, LK_RELEASE, NULL);
|
||||
mutex_exit(&vfs_suspend_lock);
|
||||
#endif /* NEWVNGATE */
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: genfs_node.h,v 1.14 2006/10/14 09:16:28 yamt Exp $ */
|
||||
/* $NetBSD: genfs_node.h,v 1.15 2007/02/15 15:40:53 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Chuck Silvers.
|
||||
|
@ -33,6 +33,8 @@
|
|||
#ifndef _MISCFS_GENFS_GENFS_NODE_H_
|
||||
#define _MISCFS_GENFS_GENFS_NODE_H_
|
||||
|
||||
#include <sys/rwlock.h>
|
||||
|
||||
struct vm_page;
|
||||
struct kauth_cred;
|
||||
struct uio;
|
||||
|
@ -73,7 +75,7 @@ struct genfs_ops {
|
|||
|
||||
struct genfs_node {
|
||||
const struct genfs_ops *g_op; /* ops vector */
|
||||
struct lock g_glock; /* getpages lock */
|
||||
krwlock_t g_glock; /* getpages lock */
|
||||
int g_dirtygen;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: genfs_vnops.c,v 1.145 2007/02/09 21:55:36 ad Exp $ */
|
||||
/* $NetBSD: genfs_vnops.c,v 1.146 2007/02/15 15:40:53 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1993
|
||||
|
@ -31,7 +31,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.145 2007/02/09 21:55:36 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.146 2007/02/15 15:40:53 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -538,7 +538,7 @@ startover:
|
|||
error = EBUSY;
|
||||
goto out_err;
|
||||
}
|
||||
if (lockmgr(&gp->g_glock, LK_SHARED | LK_NOWAIT, NULL)) {
|
||||
if (!rw_tryenter(&gp->g_glock, RW_READER)) {
|
||||
genfs_rel_pages(ap->a_m, npages);
|
||||
|
||||
/*
|
||||
|
@ -553,7 +553,7 @@ startover:
|
|||
}
|
||||
}
|
||||
} else {
|
||||
lockmgr(&gp->g_glock, LK_RELEASE, NULL);
|
||||
rw_exit(&gp->g_glock);
|
||||
}
|
||||
error = (ap->a_m[ap->a_centeridx] == NULL ? EBUSY : 0);
|
||||
goto out_err;
|
||||
|
@ -612,13 +612,13 @@ startover:
|
|||
*/
|
||||
|
||||
if (blockalloc) {
|
||||
lockmgr(&gp->g_glock, LK_EXCLUSIVE, NULL);
|
||||
rw_enter(&gp->g_glock, RW_WRITER);
|
||||
} else {
|
||||
lockmgr(&gp->g_glock, LK_SHARED, NULL);
|
||||
rw_enter(&gp->g_glock, RW_READER);
|
||||
}
|
||||
simple_lock(&uobj->vmobjlock);
|
||||
if (vp->v_size < origvsize) {
|
||||
lockmgr(&gp->g_glock, LK_RELEASE, NULL);
|
||||
rw_exit(&gp->g_glock);
|
||||
if (pgs != pgs_onstack)
|
||||
kmem_free(pgs, pgs_size);
|
||||
goto startover;
|
||||
|
@ -626,7 +626,7 @@ startover:
|
|||
|
||||
if (uvn_findpages(uobj, origoffset, &npages, &pgs[ridx],
|
||||
async ? UFP_NOWAIT : UFP_ALL) != orignpages) {
|
||||
lockmgr(&gp->g_glock, LK_RELEASE, NULL);
|
||||
rw_exit(&gp->g_glock);
|
||||
KASSERT(async != 0);
|
||||
genfs_rel_pages(&pgs[ridx], orignpages);
|
||||
simple_unlock(&uobj->vmobjlock);
|
||||
|
@ -647,7 +647,7 @@ startover:
|
|||
}
|
||||
}
|
||||
if (i == npages) {
|
||||
lockmgr(&gp->g_glock, LK_RELEASE, NULL);
|
||||
rw_exit(&gp->g_glock);
|
||||
UVMHIST_LOG(ubchist, "returning cached pages", 0,0,0,0);
|
||||
npages += ridx;
|
||||
goto out;
|
||||
|
@ -658,7 +658,7 @@ startover:
|
|||
*/
|
||||
|
||||
if (overwrite) {
|
||||
lockmgr(&gp->g_glock, LK_RELEASE, NULL);
|
||||
rw_exit(&gp->g_glock);
|
||||
UVMHIST_LOG(ubchist, "PGO_OVERWRITE",0,0,0,0);
|
||||
|
||||
for (i = 0; i < npages; i++) {
|
||||
|
@ -693,7 +693,7 @@ startover:
|
|||
npgs = npages;
|
||||
if (uvn_findpages(uobj, startoffset, &npgs, pgs,
|
||||
async ? UFP_NOWAIT : UFP_ALL) != npages) {
|
||||
lockmgr(&gp->g_glock, LK_RELEASE, NULL);
|
||||
rw_exit(&gp->g_glock);
|
||||
KASSERT(async != 0);
|
||||
genfs_rel_pages(pgs, npages);
|
||||
simple_unlock(&uobj->vmobjlock);
|
||||
|
@ -867,7 +867,7 @@ loopdone:
|
|||
nestiobuf_done(mbp, skipbytes, error);
|
||||
if (async) {
|
||||
UVMHIST_LOG(ubchist, "returning 0 (async)",0,0,0,0);
|
||||
lockmgr(&gp->g_glock, LK_RELEASE, NULL);
|
||||
rw_exit(&gp->g_glock);
|
||||
error = 0;
|
||||
goto out_err;
|
||||
}
|
||||
|
@ -901,7 +901,7 @@ loopdone:
|
|||
}
|
||||
}
|
||||
}
|
||||
lockmgr(&gp->g_glock, LK_RELEASE, NULL);
|
||||
rw_exit(&gp->g_glock);
|
||||
simple_lock(&uobj->vmobjlock);
|
||||
|
||||
/*
|
||||
|
@ -1631,7 +1631,7 @@ genfs_node_init(struct vnode *vp, const struct genfs_ops *ops)
|
|||
{
|
||||
struct genfs_node *gp = VTOG(vp);
|
||||
|
||||
lockinit(&gp->g_glock, PINOD, "glock", 0, 0);
|
||||
rw_init(&gp->g_glock);
|
||||
gp->g_op = ops;
|
||||
}
|
||||
|
||||
|
@ -2076,7 +2076,7 @@ genfs_node_wrlock(struct vnode *vp)
|
|||
{
|
||||
struct genfs_node *gp = VTOG(vp);
|
||||
|
||||
lockmgr(&gp->g_glock, LK_EXCLUSIVE, NULL);
|
||||
rw_enter(&gp->g_glock, RW_WRITER);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2084,7 +2084,7 @@ genfs_node_rdlock(struct vnode *vp)
|
|||
{
|
||||
struct genfs_node *gp = VTOG(vp);
|
||||
|
||||
lockmgr(&gp->g_glock, LK_SHARED, NULL);
|
||||
rw_enter(&gp->g_glock, RW_READER);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2092,5 +2092,5 @@ genfs_node_unlock(struct vnode *vp)
|
|||
{
|
||||
struct genfs_node *gp = VTOG(vp);
|
||||
|
||||
lockmgr(&gp->g_glock, LK_RELEASE, NULL);
|
||||
rw_exit(&gp->g_glock);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kernfs_subr.c,v 1.9 2005/12/11 12:24:51 christos Exp $ */
|
||||
/* $NetBSD: kernfs_subr.c,v 1.10 2007/02/15 15:40:53 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993
|
||||
|
@ -73,7 +73,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kernfs_subr.c,v 1.9 2005/12/11 12:24:51 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kernfs_subr.c,v 1.10 2007/02/15 15:40:53 ad Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_ipsec.h"
|
||||
|
@ -111,8 +111,8 @@ static LIST_HEAD(kfs_hashhead, kernfs_node) *kfs_hashtbl;
|
|||
static u_long kfs_ihash; /* size of hash table - 1 */
|
||||
#define KFSVALUEHASH(v) ((v) & kfs_ihash)
|
||||
|
||||
static struct lock kfs_hashlock;
|
||||
static struct simplelock kfs_hash_slock;
|
||||
static kmutex_t kfs_hashlock;
|
||||
static kmutex_t kfs_ihash_lock;
|
||||
|
||||
#define ISSET(t, f) ((t) & (f))
|
||||
|
||||
|
@ -155,10 +155,14 @@ kernfs_allocvp(mp, vpp, kfs_type, kt, value)
|
|||
int error;
|
||||
long *cookie;
|
||||
|
||||
do {
|
||||
if ((*vpp = kernfs_hashget(kfs_type, mp, kt, value)) != NULL)
|
||||
return (0);
|
||||
} while (lockmgr(&kfs_hashlock, LK_EXCLUSIVE|LK_SLEEPFAIL, 0));
|
||||
if ((*vpp = kernfs_hashget(kfs_type, mp, kt, value)) != NULL)
|
||||
return (0);
|
||||
|
||||
mutex_enter(&kfs_hashlock);
|
||||
if ((*vpp = kernfs_hashget(kfs_type, mp, kt, value)) != NULL) {
|
||||
mutex_exit(&kfs_hashlock);
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (kfs_type == KFSdevice) {
|
||||
/* /kern/rootdev = look for device and obey */
|
||||
|
@ -173,20 +177,20 @@ kernfs_allocvp(mp, vpp, kfs_type, kt, value)
|
|||
dp = kt->kt_data;
|
||||
loop:
|
||||
if (*dp == NODEV || !vfinddev(*dp, kt->kt_vtype, &fvp)) {
|
||||
lockmgr(&kfs_hashlock, LK_RELEASE, NULL);
|
||||
mutex_exit(&kfs_hashlock);
|
||||
return (ENOENT);
|
||||
}
|
||||
vp = fvp;
|
||||
if (vget(fvp, LK_EXCLUSIVE))
|
||||
goto loop;
|
||||
*vpp = vp;
|
||||
lockmgr(&kfs_hashlock, LK_RELEASE, NULL);
|
||||
mutex_exit(&kfs_hashlock);
|
||||
return (0);
|
||||
}
|
||||
|
||||
if ((error = getnewvnode(VT_KERNFS, mp, kernfs_vnodeop_p, &vp)) != 0) {
|
||||
*vpp = NULL;
|
||||
lockmgr(&kfs_hashlock, LK_RELEASE, NULL);
|
||||
mutex_exit(&kfs_hashlock);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
@ -233,7 +237,7 @@ again:
|
|||
|
||||
kernfs_hashins(kfs);
|
||||
uvm_vnp_setsize(vp, 0);
|
||||
lockmgr(&kfs_hashlock, LK_RELEASE, NULL);
|
||||
mutex_exit(&kfs_hashlock);
|
||||
|
||||
*vpp = vp;
|
||||
return (0);
|
||||
|
@ -260,10 +264,10 @@ void
|
|||
kernfs_hashinit()
|
||||
{
|
||||
|
||||
lockinit(&kfs_hashlock, PINOD, "kfs_hashlock", 0, 0);
|
||||
mutex_init(&kfs_hashlock, MUTEX_DEFAULT, IPL_NONE);
|
||||
mutex_init(&kfs_ihash_lock, MUTEX_DEFAULT, IPL_NONE);
|
||||
kfs_hashtbl = hashinit(desiredvnodes / 4, HASH_LIST, M_UFSMNT,
|
||||
M_WAITOK, &kfs_ihash);
|
||||
simple_lock_init(&kfs_hash_slock);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -276,7 +280,7 @@ kernfs_hashreinit()
|
|||
hash = hashinit(desiredvnodes / 4, HASH_LIST, M_UFSMNT, M_WAITOK,
|
||||
&mask);
|
||||
|
||||
simple_lock(&kfs_hash_slock);
|
||||
mutex_enter(&kfs_ihash_lock);
|
||||
oldhash = kfs_hashtbl;
|
||||
oldmask = kfs_ihash;
|
||||
kfs_hashtbl = hash;
|
||||
|
@ -288,7 +292,7 @@ kernfs_hashreinit()
|
|||
LIST_INSERT_HEAD(&hash[val], pp, kfs_hash);
|
||||
}
|
||||
}
|
||||
simple_unlock(&kfs_hash_slock);
|
||||
mutex_exit(&kfs_ihash_lock);
|
||||
hashdone(oldhash, M_UFSMNT);
|
||||
}
|
||||
|
||||
|
@ -313,21 +317,21 @@ kernfs_hashget(type, mp, kt, value)
|
|||
struct kernfs_node *pp;
|
||||
struct vnode *vp;
|
||||
|
||||
loop:
|
||||
simple_lock(&kfs_hash_slock);
|
||||
loop:
|
||||
mutex_enter(&kfs_ihash_lock);
|
||||
ppp = &kfs_hashtbl[KFSVALUEHASH(value)];
|
||||
LIST_FOREACH(pp, ppp, kfs_hash) {
|
||||
vp = KERNFSTOV(pp);
|
||||
if (pp->kfs_type == type && vp->v_mount == mp &&
|
||||
pp->kfs_kt == kt && pp->kfs_value == value) {
|
||||
simple_lock(&vp->v_interlock);
|
||||
simple_unlock(&kfs_hash_slock);
|
||||
mutex_exit(&kfs_ihash_lock);
|
||||
if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK))
|
||||
goto loop;
|
||||
return (vp);
|
||||
}
|
||||
}
|
||||
simple_unlock(&kfs_hash_slock);
|
||||
mutex_exit(&kfs_ihash_lock);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
@ -343,10 +347,10 @@ kernfs_hashins(pp)
|
|||
/* lock the kfsnode, then put it on the appropriate hash list */
|
||||
lockmgr(&pp->kfs_vnode->v_lock, LK_EXCLUSIVE, (struct simplelock *)0);
|
||||
|
||||
simple_lock(&kfs_hash_slock);
|
||||
mutex_enter(&kfs_ihash_lock);
|
||||
ppp = &kfs_hashtbl[KFSVALUEHASH(pp->kfs_value)];
|
||||
LIST_INSERT_HEAD(ppp, pp, kfs_hash);
|
||||
simple_unlock(&kfs_hash_slock);
|
||||
mutex_exit(&kfs_ihash_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -356,9 +360,9 @@ void
|
|||
kernfs_hashrem(pp)
|
||||
struct kernfs_node *pp;
|
||||
{
|
||||
simple_lock(&kfs_hash_slock);
|
||||
mutex_enter(&kfs_ihash_lock);
|
||||
LIST_REMOVE(pp, kfs_hash);
|
||||
simple_unlock(&kfs_hash_slock);
|
||||
mutex_exit(&kfs_ihash_lock);
|
||||
}
|
||||
|
||||
#ifdef IPSEC
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: procfs_subr.c,v 1.75 2007/02/09 21:55:36 ad Exp $ */
|
||||
/* $NetBSD: procfs_subr.c,v 1.76 2007/02/15 15:40:53 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
|
@ -109,7 +109,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.75 2007/02/09 21:55:36 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.76 2007/02/15 15:40:53 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -133,8 +133,8 @@ LIST_HEAD(pfs_hashhead, pfsnode) *pfs_hashtbl;
|
|||
u_long pfs_ihash; /* size of hash table - 1 */
|
||||
#define PFSPIDHASH(pid) ((pid) & pfs_ihash)
|
||||
|
||||
kmutex_t pfs_hashmutex;
|
||||
struct simplelock pfs_hash_slock;
|
||||
kmutex_t pfs_hashlock;
|
||||
kmutex_t pfs_ihash_lock;
|
||||
|
||||
#define ISSET(t, f) ((t) & (f))
|
||||
|
||||
|
@ -177,18 +177,23 @@ procfs_allocvp(mp, vpp, pid, pfs_type, fd, p)
|
|||
struct vnode *vp;
|
||||
int error;
|
||||
|
||||
do {
|
||||
if ((*vpp = procfs_hashget(pid, pfs_type, fd, mp)) != NULL)
|
||||
return (0);
|
||||
} while (!mutex_tryenter(&pfs_hashmutex));
|
||||
if ((*vpp = procfs_hashget(pid, pfs_type, fd, mp)) != NULL)
|
||||
return (0);
|
||||
|
||||
if ((error = getnewvnode(VT_PROCFS, mp, procfs_vnodeop_p, &vp)) != 0) {
|
||||
*vpp = NULL;
|
||||
mutex_exit(&pfs_hashmutex);
|
||||
return (error);
|
||||
}
|
||||
|
||||
MALLOC(pfs, void *, sizeof(struct pfsnode), M_TEMP, M_WAITOK);
|
||||
|
||||
mutex_enter(&pfs_hashlock);
|
||||
if ((*vpp = procfs_hashget(pid, pfs_type, fd, mp)) != NULL) {
|
||||
mutex_exit(&pfs_hashlock);
|
||||
ungetnewvnode(vp);
|
||||
FREE(pfs, M_TEMP);
|
||||
return (0);
|
||||
}
|
||||
|
||||
vp->v_data = pfs;
|
||||
|
||||
pfs->pfs_pid = pid;
|
||||
|
@ -310,13 +315,13 @@ procfs_allocvp(mp, vpp, pid, pfs_type, fd, p)
|
|||
|
||||
procfs_hashins(pfs);
|
||||
uvm_vnp_setsize(vp, 0);
|
||||
mutex_exit(&pfs_hashmutex);
|
||||
mutex_exit(&pfs_hashlock);
|
||||
|
||||
*vpp = vp;
|
||||
return (0);
|
||||
|
||||
bad:
|
||||
mutex_exit(&pfs_hashmutex);
|
||||
mutex_exit(&pfs_hashlock);
|
||||
FREE(pfs, M_TEMP);
|
||||
ungetnewvnode(vp);
|
||||
return (error);
|
||||
|
@ -534,10 +539,10 @@ vfs_findname(nm, bf, buflen)
|
|||
void
|
||||
procfs_hashinit()
|
||||
{
|
||||
mutex_init(&pfs_hashmutex, MUTEX_DEFAULT, IPL_NONE);
|
||||
mutex_init(&pfs_hashlock, MUTEX_DEFAULT, IPL_NONE);
|
||||
mutex_init(&pfs_ihash_lock, MUTEX_DEFAULT, IPL_NONE);
|
||||
pfs_hashtbl = hashinit(desiredvnodes / 4, HASH_LIST, M_UFSMNT,
|
||||
M_WAITOK, &pfs_ihash);
|
||||
simple_lock_init(&pfs_hash_slock);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -550,7 +555,7 @@ procfs_hashreinit()
|
|||
hash = hashinit(desiredvnodes / 4, HASH_LIST, M_UFSMNT, M_WAITOK,
|
||||
&mask);
|
||||
|
||||
simple_lock(&pfs_hash_slock);
|
||||
mutex_enter(&pfs_ihash_lock);
|
||||
oldhash = pfs_hashtbl;
|
||||
oldmask = pfs_ihash;
|
||||
pfs_hashtbl = hash;
|
||||
|
@ -562,7 +567,7 @@ procfs_hashreinit()
|
|||
LIST_INSERT_HEAD(&hash[val], pp, pfs_hash);
|
||||
}
|
||||
}
|
||||
simple_unlock(&pfs_hash_slock);
|
||||
mutex_exit(&pfs_ihash_lock);
|
||||
hashdone(oldhash, M_UFSMNT);
|
||||
}
|
||||
|
||||
|
@ -587,20 +592,20 @@ procfs_hashget(pid, type, fd, mp)
|
|||
struct vnode *vp;
|
||||
|
||||
loop:
|
||||
simple_lock(&pfs_hash_slock);
|
||||
mutex_enter(&pfs_ihash_lock);
|
||||
ppp = &pfs_hashtbl[PFSPIDHASH(pid)];
|
||||
LIST_FOREACH(pp, ppp, pfs_hash) {
|
||||
vp = PFSTOV(pp);
|
||||
if (pid == pp->pfs_pid && pp->pfs_type == type &&
|
||||
pp->pfs_fd == fd && vp->v_mount == mp) {
|
||||
simple_lock(&vp->v_interlock);
|
||||
simple_unlock(&pfs_hash_slock);
|
||||
mutex_exit(&pfs_ihash_lock);
|
||||
if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK))
|
||||
goto loop;
|
||||
return (vp);
|
||||
}
|
||||
}
|
||||
simple_unlock(&pfs_hash_slock);
|
||||
mutex_exit(&pfs_ihash_lock);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
@ -616,10 +621,10 @@ procfs_hashins(pp)
|
|||
/* lock the pfsnode, then put it on the appropriate hash list */
|
||||
lockmgr(&pp->pfs_vnode->v_lock, LK_EXCLUSIVE, (struct simplelock *)0);
|
||||
|
||||
simple_lock(&pfs_hash_slock);
|
||||
mutex_enter(&pfs_ihash_lock);
|
||||
ppp = &pfs_hashtbl[PFSPIDHASH(pp->pfs_pid)];
|
||||
LIST_INSERT_HEAD(ppp, pp, pfs_hash);
|
||||
simple_unlock(&pfs_hash_slock);
|
||||
mutex_exit(&pfs_ihash_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -629,9 +634,9 @@ void
|
|||
procfs_hashrem(pp)
|
||||
struct pfsnode *pp;
|
||||
{
|
||||
simple_lock(&pfs_hash_slock);
|
||||
mutex_enter(&pfs_ihash_lock);
|
||||
LIST_REMOVE(pp, pfs_hash);
|
||||
simple_unlock(&pfs_hash_slock);
|
||||
mutex_exit(&pfs_ihash_lock);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ext2fs_vfsops.c,v 1.107 2007/01/19 14:49:12 hannken Exp $ */
|
||||
/* $NetBSD: ext2fs_vfsops.c,v 1.108 2007/02/15 15:40:53 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1991, 1993, 1994
|
||||
|
@ -65,7 +65,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.107 2007/01/19 14:49:12 hannken Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.108 2007/02/15 15:40:53 ad Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_compat_netbsd.h"
|
||||
|
@ -105,7 +105,7 @@ __KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.107 2007/01/19 14:49:12 hannken
|
|||
#include <ufs/ext2fs/ext2fs_dir.h>
|
||||
#include <ufs/ext2fs/ext2fs_extern.h>
|
||||
|
||||
extern struct lock ufs_hashlock;
|
||||
extern kmutex_t ufs_hashlock;
|
||||
|
||||
int ext2fs_sbupdate(struct ufsmount *, int);
|
||||
static int ext2fs_checksb(struct ext2fs *, int);
|
||||
|
@ -945,17 +945,18 @@ ext2fs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
|
|||
*vpp = NULL;
|
||||
return (error);
|
||||
}
|
||||
ip = pool_get(&ext2fs_inode_pool, PR_WAITOK);
|
||||
|
||||
do {
|
||||
if ((*vpp = ufs_ihashget(dev, ino, LK_EXCLUSIVE)) != NULL) {
|
||||
ungetnewvnode(vp);
|
||||
return (0);
|
||||
}
|
||||
} while (lockmgr(&ufs_hashlock, LK_EXCLUSIVE|LK_SLEEPFAIL, 0));
|
||||
mutex_enter(&ufs_hashlock);
|
||||
if ((*vpp = ufs_ihashget(dev, ino, LK_EXCLUSIVE)) != NULL) {
|
||||
mutex_exit(&ufs_hashlock);
|
||||
ungetnewvnode(vp);
|
||||
pool_put(&ext2fs_inode_pool, ip);
|
||||
return (0);
|
||||
}
|
||||
|
||||
vp->v_flag |= VLOCKSWORK;
|
||||
|
||||
ip = pool_get(&ext2fs_inode_pool, PR_WAITOK);
|
||||
memset(ip, 0, sizeof(struct inode));
|
||||
vp->v_data = ip;
|
||||
ip->i_vnode = vp;
|
||||
|
@ -974,7 +975,7 @@ ext2fs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
|
|||
*/
|
||||
|
||||
ufs_ihashins(ip);
|
||||
lockmgr(&ufs_hashlock, LK_RELEASE, 0);
|
||||
mutex_exit(&ufs_hashlock);
|
||||
|
||||
/* Read in the disk contents for the inode, copy into the inode. */
|
||||
error = bread(ump->um_devvp, fsbtodb(fs, ino_to_fsba(fs, ino)),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ffs_vfsops.c,v 1.194 2007/01/29 15:42:50 hannken Exp $ */
|
||||
/* $NetBSD: ffs_vfsops.c,v 1.195 2007/02/15 15:40:54 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1991, 1993, 1994
|
||||
|
@ -32,7 +32,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.194 2007/01/29 15:42:50 hannken Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.195 2007/02/15 15:40:54 ad Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_ffs.h"
|
||||
|
@ -78,7 +78,7 @@ __KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.194 2007/01/29 15:42:50 hannken Exp
|
|||
/* how many times ffs_init() was called */
|
||||
int ffs_initcount = 0;
|
||||
|
||||
extern struct lock ufs_hashlock;
|
||||
extern kmutex_t ufs_hashlock;
|
||||
|
||||
extern const struct vnodeopv_desc ffs_vnodeop_opv_desc;
|
||||
extern const struct vnodeopv_desc ffs_specop_opv_desc;
|
||||
|
@ -1442,18 +1442,19 @@ ffs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
|
|||
*vpp = NULL;
|
||||
return (error);
|
||||
}
|
||||
ip = pool_get(&ffs_inode_pool, PR_WAITOK);
|
||||
|
||||
/*
|
||||
* If someone beat us to it while sleeping in getnewvnode(),
|
||||
* push back the freshly allocated vnode we don't need, and return.
|
||||
*/
|
||||
|
||||
do {
|
||||
if ((*vpp = ufs_ihashget(dev, ino, LK_EXCLUSIVE)) != NULL) {
|
||||
ungetnewvnode(vp);
|
||||
return (0);
|
||||
}
|
||||
} while (lockmgr(&ufs_hashlock, LK_EXCLUSIVE|LK_SLEEPFAIL, 0));
|
||||
mutex_enter(&ufs_hashlock);
|
||||
if ((*vpp = ufs_ihashget(dev, ino, LK_EXCLUSIVE)) != NULL) {
|
||||
mutex_exit(&ufs_hashlock);
|
||||
ungetnewvnode(vp);
|
||||
pool_put(&ffs_inode_pool, ip);
|
||||
return (0);
|
||||
}
|
||||
|
||||
vp->v_flag |= VLOCKSWORK;
|
||||
|
||||
|
@ -1462,7 +1463,6 @@ ffs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
|
|||
* XXX create another pool for MFS inodes?
|
||||
*/
|
||||
|
||||
ip = pool_get(&ffs_inode_pool, PR_WAITOK);
|
||||
memset(ip, 0, sizeof(struct inode));
|
||||
vp->v_data = ip;
|
||||
ip->i_vnode = vp;
|
||||
|
@ -1488,7 +1488,7 @@ ffs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
|
|||
*/
|
||||
|
||||
ufs_ihashins(ip);
|
||||
lockmgr(&ufs_hashlock, LK_RELEASE, 0);
|
||||
mutex_exit(&ufs_hashlock);
|
||||
|
||||
/* Read in the disk contents for the inode, copy into the inode. */
|
||||
error = bread(ump->um_devvp, fsbtodb(fs, ino_to_fsba(fs, ino)),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lfs.h,v 1.117 2006/09/28 23:08:23 perseant Exp $ */
|
||||
/* $NetBSD: lfs.h,v 1.118 2007/02/15 15:40:54 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
|
||||
|
@ -69,6 +69,8 @@
|
|||
#ifndef _UFS_LFS_LFS_H_
|
||||
#define _UFS_LFS_LFS_H_
|
||||
|
||||
#include <sys/rwlock.h>
|
||||
|
||||
/*
|
||||
* Compile-time options for LFS.
|
||||
*/
|
||||
|
@ -822,7 +824,7 @@ struct lfs {
|
|||
u_int32_t lfs_diropwait; /* # procs waiting on dirop flush */
|
||||
size_t lfs_devbsize; /* Device block size */
|
||||
size_t lfs_devbshift; /* Device block shift */
|
||||
struct lock lfs_fraglock;
|
||||
krwlock_t lfs_fraglock;
|
||||
struct lock lfs_iflock; /* Ifile lock */
|
||||
struct lock lfs_stoplock; /* Wrap lock */
|
||||
pid_t lfs_rfpid; /* Process ID of roll-forward agent */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: lfs_alloc.c,v 1.99 2006/11/16 01:33:53 christos Exp $ */
|
||||
/* $NetBSD: lfs_alloc.c,v 1.100 2007/02/15 15:40:54 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
|
@ -67,7 +67,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.99 2006/11/16 01:33:53 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.100 2007/02/15 15:40:54 ad Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_quota.h"
|
||||
|
@ -95,7 +95,7 @@ __KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.99 2006/11/16 01:33:53 christos Exp
|
|||
#include <ufs/lfs/lfs.h>
|
||||
#include <ufs/lfs/lfs_extern.h>
|
||||
|
||||
extern struct lock ufs_hashlock;
|
||||
extern kmutex_t ufs_hashlock;
|
||||
|
||||
/* Constants for inode free bitmap */
|
||||
#define BMSHIFT 5 /* 2 ** 5 = 32 */
|
||||
|
@ -280,7 +280,7 @@ lfs_ialloc(struct lfs *fs, struct vnode *pvp, ino_t new_ino, int new_gen,
|
|||
ASSERT_NO_SEGLOCK(fs);
|
||||
|
||||
vp = *vpp;
|
||||
lockmgr(&ufs_hashlock, LK_EXCLUSIVE, 0);
|
||||
mutex_enter(&ufs_hashlock);
|
||||
/* Create an inode to associate with the vnode. */
|
||||
lfs_vcreate(pvp->v_mount, new_ino, vp);
|
||||
|
||||
|
@ -300,7 +300,7 @@ lfs_ialloc(struct lfs *fs, struct vnode *pvp, ino_t new_ino, int new_gen,
|
|||
|
||||
/* Insert into the inode hash table. */
|
||||
ufs_ihashins(ip);
|
||||
lockmgr(&ufs_hashlock, LK_RELEASE, 0);
|
||||
mutex_exit(&ufs_hashlock);
|
||||
|
||||
ufs_vinit(vp->v_mount, lfs_specop_p, lfs_fifoop_p, vpp);
|
||||
vp = *vpp;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lfs_balloc.c,v 1.61 2006/05/14 21:32:45 elad Exp $ */
|
||||
/* $NetBSD: lfs_balloc.c,v 1.62 2007/02/15 15:40:54 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_balloc.c,v 1.61 2006/05/14 21:32:45 elad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: lfs_balloc.c,v 1.62 2007/02/15 15:40:54 ad Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_quota.h"
|
||||
|
@ -401,7 +401,7 @@ lfs_fragextend(struct vnode *vp, int osize, int nsize, daddr_t lbn, struct buf *
|
|||
*/
|
||||
top:
|
||||
if (bpp) {
|
||||
lockmgr(&fs->lfs_fraglock, LK_SHARED, 0);
|
||||
rw_enter(&fs->lfs_fraglock, RW_READER);
|
||||
LFS_DEBUG_COUNTLOCKED("frag");
|
||||
}
|
||||
|
||||
|
@ -441,7 +441,7 @@ lfs_fragextend(struct vnode *vp, int osize, int nsize, daddr_t lbn, struct buf *
|
|||
#ifdef QUOTA
|
||||
chkdq(ip, -bb, cred, 0);
|
||||
#endif
|
||||
lockmgr(&fs->lfs_fraglock, LK_RELEASE, 0);
|
||||
rw_exit(&fs->lfs_fraglock);
|
||||
lfs_availwait(fs, bb);
|
||||
goto top;
|
||||
}
|
||||
|
@ -470,7 +470,7 @@ lfs_fragextend(struct vnode *vp, int osize, int nsize, daddr_t lbn, struct buf *
|
|||
|
||||
out:
|
||||
if (bpp) {
|
||||
lockmgr(&fs->lfs_fraglock, LK_RELEASE, 0);
|
||||
rw_exit(&fs->lfs_fraglock);
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lfs_subr.c,v 1.65 2006/11/16 01:33:53 christos Exp $ */
|
||||
/* $NetBSD: lfs_subr.c,v 1.66 2007/02/15 15:40:54 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_subr.c,v 1.65 2006/11/16 01:33:53 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.66 2007/02/15 15:40:54 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -325,7 +325,7 @@ lfs_seglock(struct lfs *fs, unsigned long flags)
|
|||
LFS_ENTER_LOG("seglock", __FILE__, __LINE__, 0, flags, curproc->p_pid);
|
||||
#endif
|
||||
/* Drain fragment size changes out */
|
||||
lockmgr(&fs->lfs_fraglock, LK_EXCLUSIVE, 0);
|
||||
rw_enter(&fs->lfs_fraglock, RW_WRITER);
|
||||
|
||||
sp = fs->lfs_sp = pool_get(&fs->lfs_segpool, PR_WAITOK);
|
||||
sp->bpp = pool_get(&fs->lfs_bpppool, PR_WAITOK);
|
||||
|
@ -562,7 +562,7 @@ lfs_segunlock(struct lfs *fs)
|
|||
wakeup(&fs->lfs_seglock);
|
||||
}
|
||||
/* Reenable fragment size changes */
|
||||
lockmgr(&fs->lfs_fraglock, LK_RELEASE, 0);
|
||||
rw_exit(&fs->lfs_fraglock);
|
||||
if (do_unmark_dirop)
|
||||
lfs_unmark_dirop(fs);
|
||||
} else if (fs->lfs_seglock == 0) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: lfs_syscalls.c,v 1.120 2007/02/09 21:55:39 ad Exp $ */
|
||||
/* $NetBSD: lfs_syscalls.c,v 1.121 2007/02/15 15:40:54 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
|
@ -67,7 +67,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.120 2007/02/09 21:55:39 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.121 2007/02/15 15:40:54 ad Exp $");
|
||||
|
||||
#ifndef LFS
|
||||
# define LFS /* for prototypes in syscallargs.h */
|
||||
|
@ -1003,7 +1003,7 @@ sys_lfs_segwait(struct lwp *l, void *v, register_t *retval)
|
|||
* we lfs_vref, and it is the caller's responsibility to lfs_vunref
|
||||
* when finished.
|
||||
*/
|
||||
extern struct lock ufs_hashlock;
|
||||
extern kmutex_t ufs_hashlock;
|
||||
|
||||
int
|
||||
lfs_fasthashget(dev_t dev, ino_t ino, struct vnode **vpp)
|
||||
|
@ -1028,7 +1028,8 @@ lfs_fasthashget(dev_t dev, ino_t ino, struct vnode **vpp)
|
|||
}
|
||||
|
||||
int
|
||||
lfs_fastvget(struct mount *mp, ino_t ino, daddr_t daddr, struct vnode **vpp, struct ufs1_dinode *dinp)
|
||||
lfs_fastvget(struct mount *mp, ino_t ino, daddr_t daddr, struct vnode **vpp,
|
||||
struct ufs1_dinode *dinp)
|
||||
{
|
||||
struct inode *ip;
|
||||
struct ufs1_dinode *dip;
|
||||
|
@ -1079,13 +1080,13 @@ lfs_fastvget(struct mount *mp, ino_t ino, daddr_t daddr, struct vnode **vpp, str
|
|||
return (error);
|
||||
}
|
||||
|
||||
do {
|
||||
error = lfs_fasthashget(dev, ino, vpp);
|
||||
if (error != 0 || *vpp != NULL) {
|
||||
ungetnewvnode(vp);
|
||||
return (error);
|
||||
}
|
||||
} while (lockmgr(&ufs_hashlock, LK_EXCLUSIVE|LK_SLEEPFAIL, 0));
|
||||
mutex_enter(&ufs_hashlock);
|
||||
error = lfs_fasthashget(dev, ino, vpp);
|
||||
if (error != 0 || *vpp != NULL) {
|
||||
mutex_exit(&ufs_hashlock);
|
||||
ungetnewvnode(vp);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/* Allocate new vnode/inode. */
|
||||
lfs_vcreate(mp, ino, vp);
|
||||
|
@ -1098,7 +1099,7 @@ lfs_fastvget(struct mount *mp, ino_t ino, daddr_t daddr, struct vnode **vpp, str
|
|||
*/
|
||||
ip = VTOI(vp);
|
||||
ufs_ihashins(ip);
|
||||
lockmgr(&ufs_hashlock, LK_RELEASE, 0);
|
||||
mutex_exit(&ufs_hashlock);
|
||||
|
||||
/*
|
||||
* XXX
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: lfs_vfsops.c,v 1.226 2007/01/19 14:49:12 hannken Exp $ */
|
||||
/* $NetBSD: lfs_vfsops.c,v 1.227 2007/02/15 15:40:54 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
|
@ -67,7 +67,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.226 2007/01/19 14:49:12 hannken Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.227 2007/02/15 15:40:54 ad Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_quota.h"
|
||||
|
@ -729,7 +729,7 @@ lfs_mountfs(struct vnode *devvp, struct mount *mp, struct lwp *l)
|
|||
fs->lfs_sleepers = 0;
|
||||
fs->lfs_pages = 0;
|
||||
simple_lock_init(&fs->lfs_interlock);
|
||||
lockinit(&fs->lfs_fraglock, PINOD, "lfs_fraglock", 0, 0);
|
||||
rw_init(&fs->lfs_fraglock);
|
||||
lockinit(&fs->lfs_iflock, PINOD, "lfs_iflock", 0, 0);
|
||||
lockinit(&fs->lfs_stoplock, PINOD, "lfs_stoplock", 0, 0);
|
||||
|
||||
|
@ -1069,7 +1069,7 @@ lfs_sync(struct mount *mp, int waitfor, kauth_cred_t cred,
|
|||
return (error);
|
||||
}
|
||||
|
||||
extern struct lock ufs_hashlock;
|
||||
extern kmutex_t ufs_hashlock;
|
||||
|
||||
/*
|
||||
* Look up an LFS dinode number to find its incore vnode. If not already
|
||||
|
@ -1115,12 +1115,12 @@ lfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
|
|||
return (error);
|
||||
}
|
||||
|
||||
do {
|
||||
if ((*vpp = ufs_ihashget(dev, ino, LK_EXCLUSIVE)) != NULL) {
|
||||
ungetnewvnode(vp);
|
||||
return (0);
|
||||
}
|
||||
} while (lockmgr(&ufs_hashlock, LK_EXCLUSIVE|LK_SLEEPFAIL, 0));
|
||||
mutex_enter(&ufs_hashlock);
|
||||
if ((*vpp = ufs_ihashget(dev, ino, LK_EXCLUSIVE)) != NULL) {
|
||||
mutex_exit(&ufs_hashlock);
|
||||
ungetnewvnode(vp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Translate the inode number to a disk address. */
|
||||
if (ino == LFS_IFILE_INUM)
|
||||
|
@ -1138,7 +1138,7 @@ lfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
|
|||
if (daddr == LFS_UNUSED_DADDR) {
|
||||
*vpp = NULLVP;
|
||||
ungetnewvnode(vp);
|
||||
lockmgr(&ufs_hashlock, LK_RELEASE, 0);
|
||||
mutex_exit(&ufs_hashlock);
|
||||
return (ENOENT);
|
||||
}
|
||||
}
|
||||
|
@ -1154,7 +1154,7 @@ lfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
|
|||
*/
|
||||
ip = VTOI(vp);
|
||||
ufs_ihashins(ip);
|
||||
lockmgr(&ufs_hashlock, LK_RELEASE, 0);
|
||||
mutex_exit(&ufs_hashlock);
|
||||
|
||||
/*
|
||||
* XXX
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ufs_ihash.c,v 1.20 2005/12/11 12:25:28 christos Exp $ */
|
||||
/* $NetBSD: ufs_ihash.c,v 1.21 2007/02/15 15:40:55 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1991, 1993
|
||||
|
@ -32,14 +32,14 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ufs_ihash.c,v 1.20 2005/12/11 12:25:28 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ufs_ihash.c,v 1.21 2007/02/15 15:40:55 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
|
||||
#include <ufs/ufs/inode.h>
|
||||
#include <ufs/ufs/ufs_extern.h>
|
||||
|
@ -51,8 +51,8 @@ static LIST_HEAD(ihashhead, inode) *ihashtbl;
|
|||
static u_long ihash; /* size of hash table - 1 */
|
||||
#define INOHASH(device, inum) (((device) + (inum)) & ihash)
|
||||
|
||||
struct lock ufs_hashlock;
|
||||
struct simplelock ufs_ihash_slock;
|
||||
kmutex_t ufs_ihash_lock;
|
||||
kmutex_t ufs_hashlock;
|
||||
|
||||
/*
|
||||
* Initialize inode hash table.
|
||||
|
@ -60,10 +60,10 @@ struct simplelock ufs_ihash_slock;
|
|||
void
|
||||
ufs_ihashinit(void)
|
||||
{
|
||||
lockinit(&ufs_hashlock, PINOD, "ufs_hashlock", 0, 0);
|
||||
mutex_init(&ufs_hashlock, MUTEX_DEFAULT, IPL_NONE);
|
||||
mutex_init(&ufs_ihash_lock, MUTEX_DEFAULT, IPL_NONE);
|
||||
ihashtbl =
|
||||
hashinit(desiredvnodes, HASH_LIST, M_UFSMNT, M_WAITOK, &ihash);
|
||||
simple_lock_init(&ufs_ihash_slock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -79,7 +79,7 @@ ufs_ihashreinit(void)
|
|||
int i;
|
||||
|
||||
hash = hashinit(desiredvnodes, HASH_LIST, M_UFSMNT, M_WAITOK, &mask);
|
||||
simple_lock(&ufs_ihash_slock);
|
||||
mutex_enter(&ufs_ihash_lock);
|
||||
oldhash = ihashtbl;
|
||||
oldmask = ihash;
|
||||
ihashtbl = hash;
|
||||
|
@ -91,7 +91,7 @@ ufs_ihashreinit(void)
|
|||
LIST_INSERT_HEAD(&hash[val], ip, i_hash);
|
||||
}
|
||||
}
|
||||
simple_unlock(&ufs_ihash_slock);
|
||||
mutex_exit(&ufs_ihash_lock);
|
||||
hashdone(oldhash, M_UFSMNT);
|
||||
}
|
||||
|
||||
|
@ -114,13 +114,13 @@ ufs_ihashlookup(dev_t dev, ino_t inum)
|
|||
struct inode *ip;
|
||||
struct ihashhead *ipp;
|
||||
|
||||
simple_lock(&ufs_ihash_slock);
|
||||
mutex_enter(&ufs_ihash_lock);
|
||||
ipp = &ihashtbl[INOHASH(dev, inum)];
|
||||
LIST_FOREACH(ip, ipp, i_hash) {
|
||||
if (inum == ip->i_number && dev == ip->i_dev)
|
||||
break;
|
||||
}
|
||||
simple_unlock(&ufs_ihash_slock);
|
||||
mutex_exit(&ufs_ihash_lock);
|
||||
if (ip)
|
||||
return (ITOV(ip));
|
||||
return (NULLVP);
|
||||
|
@ -137,38 +137,40 @@ ufs_ihashget(dev_t dev, ino_t inum, int flags)
|
|||
struct inode *ip;
|
||||
struct vnode *vp;
|
||||
|
||||
loop:
|
||||
simple_lock(&ufs_ihash_slock);
|
||||
loop:
|
||||
mutex_enter(&ufs_ihash_lock);
|
||||
ipp = &ihashtbl[INOHASH(dev, inum)];
|
||||
LIST_FOREACH(ip, ipp, i_hash) {
|
||||
if (inum == ip->i_number && dev == ip->i_dev) {
|
||||
vp = ITOV(ip);
|
||||
simple_lock(&vp->v_interlock);
|
||||
simple_unlock(&ufs_ihash_slock);
|
||||
mutex_exit(&ufs_ihash_lock);
|
||||
if (vget(vp, flags | LK_INTERLOCK))
|
||||
goto loop;
|
||||
return (vp);
|
||||
}
|
||||
}
|
||||
simple_unlock(&ufs_ihash_slock);
|
||||
mutex_exit(&ufs_ihash_lock);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert the inode into the hash table, and return it locked.
|
||||
* Insert the inode into the hash table, and return it locked.
|
||||
*/
|
||||
void
|
||||
ufs_ihashins(struct inode *ip)
|
||||
{
|
||||
struct ihashhead *ipp;
|
||||
|
||||
KASSERT(mutex_owned(&ufs_hashlock));
|
||||
|
||||
/* lock the inode, then put it on the appropriate hash list */
|
||||
lockmgr(&ip->i_vnode->v_lock, LK_EXCLUSIVE, NULL);
|
||||
|
||||
simple_lock(&ufs_ihash_slock);
|
||||
mutex_enter(&ufs_ihash_lock);
|
||||
ipp = &ihashtbl[INOHASH(ip->i_dev, ip->i_number)];
|
||||
LIST_INSERT_HEAD(ipp, ip, i_hash);
|
||||
simple_unlock(&ufs_ihash_slock);
|
||||
mutex_exit(&ufs_ihash_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -177,7 +179,7 @@ ufs_ihashins(struct inode *ip)
|
|||
void
|
||||
ufs_ihashrem(struct inode *ip)
|
||||
{
|
||||
simple_lock(&ufs_ihash_slock);
|
||||
mutex_enter(&ufs_ihash_lock);
|
||||
LIST_REMOVE(ip, i_hash);
|
||||
simple_unlock(&ufs_ihash_slock);
|
||||
mutex_exit(&ufs_ihash_lock);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue