Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-3]: src/sys/dev Pull up following revision(s) (requested by chs i...
details: https://anonhg.NetBSD.org/src/rev/f54640f0f390
branches: netbsd-3
changeset: 577882:f54640f0f390
user: tron <tron%NetBSD.org@localhost>
date: Fri Mar 17 15:18:50 2006 +0000
description:
Pull up following revision(s) (requested by chs in ticket #1202):
sys/dev/fssvar.h: revision 1.13 via patch
sys/dev/fss.c: revision 1.23 via patch
use lockmgr() instead of bespoke code for mutual exclusion in fss_ioctl().
only take the lock when we actually need it (and particularly not for
unknown cmds that are just going to fail immediately). fixes PR 33060.
diffstat:
sys/dev/fss.c | 29 ++++++++++-------------------
sys/dev/fssvar.h | 4 ++--
2 files changed, 12 insertions(+), 21 deletions(-)
diffs (120 lines):
diff -r ac96da161411 -r f54640f0f390 sys/dev/fss.c
--- a/sys/dev/fss.c Fri Mar 10 13:29:41 2006 +0000
+++ b/sys/dev/fss.c Fri Mar 17 15:18:50 2006 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fss.c,v 1.13.2.2 2005/04/21 19:01:40 tron Exp $ */
+/* $NetBSD: fss.c,v 1.13.2.3 2006/03/17 15:18:50 tron Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.13.2.2 2005/04/21 19:01:40 tron Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.13.2.3 2006/03/17 15:18:50 tron Exp $");
#include "fss.h"
@@ -165,6 +165,7 @@
sc->sc_unit = i;
sc->sc_bdev = NODEV;
simple_lock_init(&sc->sc_slock);
+ lockinit(&sc->sc_lock, PRIBIO, "fsslock", 0, 0);
bufq_alloc(&sc->sc_bufq, BUFQ_FCFS|BUFQ_SORT_RAWBLOCK);
}
}
@@ -265,7 +266,7 @@
int
fss_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
{
- int s, error;
+ int error;
struct fss_softc *sc;
struct fss_set *fss = (struct fss_set *)data;
struct fss_get *fsg = (struct fss_get *)data;
@@ -273,37 +274,31 @@
if ((sc = FSS_DEV_TO_SOFTC(dev)) == NULL)
return ENODEV;
- FSS_LOCK(sc, s);
- while ((sc->sc_flags & FSS_EXCL) == FSS_EXCL) {
- error = ltsleep(sc, PRIBIO|PCATCH, "fsslock", 0, &sc->sc_slock);
- if (error) {
- FSS_UNLOCK(sc, s);
- return error;
- }
- }
- sc->sc_flags |= FSS_EXCL;
- FSS_UNLOCK(sc, s);
-
switch (cmd) {
case FSSIOCSET:
+ lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL);
if ((flag & FWRITE) == 0)
error = EPERM;
else if ((sc->sc_flags & FSS_ACTIVE) != 0)
error = EBUSY;
else
error = fss_create_snapshot(sc, fss, p);
+ lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
break;
case FSSIOCCLR:
+ lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL);
if ((flag & FWRITE) == 0)
error = EPERM;
else if ((sc->sc_flags & FSS_ACTIVE) == 0)
error = ENXIO;
else
error = fss_delete_snapshot(sc, p);
+ lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
break;
case FSSIOCGET:
+ lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL);
switch (sc->sc_flags & (FSS_PERSISTENT | FSS_ACTIVE)) {
case FSS_ACTIVE:
memcpy(fsg->fsg_mount, sc->sc_mntname, MNAMELEN);
@@ -325,6 +320,7 @@
error = ENXIO;
break;
}
+ lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
break;
case FSSIOFSET:
@@ -342,11 +338,6 @@
break;
}
- FSS_LOCK(sc, s);
- sc->sc_flags &= ~FSS_EXCL;
- FSS_UNLOCK(sc, s);
- wakeup(sc);
-
return error;
}
diff -r ac96da161411 -r f54640f0f390 sys/dev/fssvar.h
--- a/sys/dev/fssvar.h Fri Mar 10 13:29:41 2006 +0000
+++ b/sys/dev/fssvar.h Fri Mar 17 15:18:50 2006 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fssvar.h,v 1.8.2.1 2005/04/21 19:01:59 tron Exp $ */
+/* $NetBSD: fssvar.h,v 1.8.2.2 2006/03/17 15:18:50 tron Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -144,11 +144,11 @@
struct fss_softc {
int sc_unit; /* Logical unit number */
struct simplelock sc_slock; /* Protect this softc */
+ struct lock sc_lock; /* Protect this softc */
volatile int sc_flags; /* Flags */
#define FSS_ACTIVE 0x01 /* Snapshot is active */
#define FSS_ERROR 0x02 /* I/O error occurred */
#define FSS_BS_THREAD 0x04 /* Kernel thread is running */
-#define FSS_EXCL 0x08 /* Exclusive access granted */
#define FSS_BS_ALLOC 0x10 /* Allocate backing store */
#define FSS_PERSISTENT 0x20 /* File system internal snapshot */
#define FSS_CDEV_OPEN 0x40 /* character device open */
Home |
Main Index |
Thread Index |
Old Index