Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys introduce a variant of disk_attach/detach, for pseudo disks
details: https://anonhg.NetBSD.org/src/rev/f5ed23d05b03
branches: trunk
changeset: 583721:f5ed23d05b03
user: yamt <yamt%NetBSD.org@localhost>
date: Sat Aug 20 12:00:01 2005 +0000
description:
introduce a variant of disk_attach/detach, for pseudo disks
which is opened by user before being attached.
diffstat:
sys/kern/subr_disk.c | 94 +++++++++++++++++++++++++++++++++++++++------------
sys/sys/disk.h | 5 ++-
2 files changed, 76 insertions(+), 23 deletions(-)
diffs (157 lines):
diff -r b378ba3cf8bc -r f5ed23d05b03 sys/kern/subr_disk.c
--- a/sys/kern/subr_disk.c Sat Aug 20 09:03:29 2005 +0000
+++ b/sys/kern/subr_disk.c Sat Aug 20 12:00:01 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_disk.c,v 1.69 2005/05/29 22:24:15 christos Exp $ */
+/* $NetBSD: subr_disk.c,v 1.70 2005/08/20 12:00:01 yamt Exp $ */
/*-
* Copyright (c) 1996, 1997, 1999, 2000 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.69 2005/05/29 22:24:15 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.70 2005/08/20 12:00:01 yamt Exp $");
#include "opt_compat_netbsd.h"
@@ -200,11 +200,21 @@
return (NULL);
}
-/*
- * Attach a disk.
- */
-void
-disk_attach(struct disk *diskp)
+static void
+disk_init0(struct disk *diskp)
+{
+
+ /*
+ * Initialize the wedge-related locks and other fields.
+ */
+ lockinit(&diskp->dk_rawlock, PRIBIO, "dkrawlk", 0, 0);
+ lockinit(&diskp->dk_openlock, PRIBIO, "dkoplk", 0, 0);
+ LIST_INIT(&diskp->dk_wedges);
+ diskp->dk_nwedges = 0;
+}
+
+static void
+disk_attach0(struct disk *diskp)
{
int s;
@@ -223,14 +233,6 @@
memset(diskp->dk_cpulabel, 0, sizeof(struct cpu_disklabel));
/*
- * Initialize the wedge-related locks and other fields.
- */
- lockinit(&diskp->dk_rawlock, PRIBIO, "dkrawlk", 0, 0);
- lockinit(&diskp->dk_openlock, PRIBIO, "dkoplk", 0, 0);
- LIST_INIT(&diskp->dk_wedges);
- diskp->dk_nwedges = 0;
-
- /*
* Set the attached timestamp.
*/
s = splclock();
@@ -246,15 +248,10 @@
simple_unlock(&disklist_slock);
}
-/*
- * Detach a disk.
- */
-void
-disk_detach(struct disk *diskp)
+static void
+disk_detach0(struct disk *diskp)
{
- (void) lockmgr(&diskp->dk_openlock, LK_DRAIN, NULL);
-
/*
* Remove from the disklist.
*/
@@ -273,6 +270,59 @@
}
/*
+ * Attach a disk.
+ */
+void
+disk_attach(struct disk *diskp)
+{
+
+ disk_init0(diskp);
+ disk_attach0(diskp);
+}
+
+/*
+ * Detach a disk.
+ */
+void
+disk_detach(struct disk *diskp)
+{
+
+ (void) lockmgr(&diskp->dk_openlock, LK_DRAIN, NULL);
+ disk_detach0(diskp);
+}
+
+/*
+ * Initialize a pseudo disk.
+ */
+void
+pseudo_disk_init(struct disk *diskp)
+{
+
+ disk_init0(diskp);
+}
+
+/*
+ * Attach a pseudo disk.
+ */
+void
+pseudo_disk_attach(struct disk *diskp)
+{
+
+ disk_attach0(diskp);
+}
+
+/*
+ * Detach a pseudo disk.
+ */
+void
+pseudo_disk_detach(struct disk *diskp)
+{
+
+ disk_detach0(diskp);
+}
+
+
+/*
* Increment a disk's busy counter. If the counter is going from
* 0 to 1, set the timestamp.
*/
diff -r b378ba3cf8bc -r f5ed23d05b03 sys/sys/disk.h
--- a/sys/sys/disk.h Sat Aug 20 09:03:29 2005 +0000
+++ b/sys/sys/disk.h Sat Aug 20 12:00:01 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: disk.h,v 1.29 2005/02/03 19:20:01 perry Exp $ */
+/* $NetBSD: disk.h,v 1.30 2005/08/20 12:00:01 yamt Exp $ */
/*-
* Copyright (c) 1996, 1997, 2004 The NetBSD Foundation, Inc.
@@ -318,6 +318,9 @@
void disk_attach(struct disk *);
void disk_detach(struct disk *);
+void pseudo_disk_init(struct disk *);
+void pseudo_disk_attach(struct disk *);
+void pseudo_disk_detach(struct disk *);
void disk_busy(struct disk *);
void disk_unbusy(struct disk *, long, int);
void disk_resetstat(struct disk *);
Home |
Main Index |
Thread Index |
Old Index