Module Name: src
Committed By: pgoyette
Date: Thu Jul 21 00:02:13 UTC 2016
Modified Files:
src/sys/dev/mscp [pgoyette-localcount]: mscp_disk.c
Log Message:
Partial adaptation to the new {b,c}devsw locking. Still needs some work.
(See XXX comments in code)
To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.89.2.1 src/sys/dev/mscp/mscp_disk.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/mscp/mscp_disk.c
diff -u src/sys/dev/mscp/mscp_disk.c:1.89 src/sys/dev/mscp/mscp_disk.c:1.89.2.1
--- src/sys/dev/mscp/mscp_disk.c:1.89 Tue Mar 29 04:55:53 2016
+++ src/sys/dev/mscp/mscp_disk.c Thu Jul 21 00:02:13 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: mscp_disk.c,v 1.89 2016/03/29 04:55:53 mlelstv Exp $ */
+/* $NetBSD: mscp_disk.c,v 1.89.2.1 2016/07/21 00:02:13 pgoyette Exp $ */
/*
* Copyright (c) 1988 Regents of the University of California.
* All rights reserved.
@@ -82,7 +82,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mscp_disk.c,v 1.89 2016/03/29 04:55:53 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mscp_disk.c,v 1.89.2.1 2016/07/21 00:02:13 pgoyette Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -1129,6 +1129,9 @@ ra_putonline(dev_t dev, struct ra_softc
{
struct disklabel *dl;
const char *msg;
+#if NRACD
+ const struct cdevsw *cdev;
+#endif
if (rx_putonline(ra) != MSCP_DONE)
return MSCP_FAILED;
@@ -1144,10 +1147,15 @@ ra_putonline(dev_t dev, struct ra_softc
ra->ra_state = DK_OPEN;
}
#if NRACD
- else if (cdevsw_lookup(dev) == &racd_cdevsw) {
- dl->d_partitions[0].p_offset = 0;
- dl->d_partitions[0].p_size = dl->d_secperunit;
- dl->d_partitions[0].p_fstype = FS_ISO9660;
+ else {
+ cdev = cdevsw_lookup_acquire(dev);
+ if (cdev == &racd_cdevsw) {
+ dl->d_partitions[0].p_offset = 0;
+ dl->d_partitions[0].p_size = dl->d_secperunit;
+ dl->d_partitions[0].p_fstype = FS_ISO9660;
+ }
+ if (cdev != NULL)
+ cdevsw_release(cdev);
}
#endif /* NRACD */
else {
@@ -1159,7 +1167,14 @@ ra_putonline(dev_t dev, struct ra_softc
return MSCP_DONE;
}
-
+/* XXX
+ * This code needs to be restructured to deal with the localcount(9)
+ * referencing counting on {b,c}devsw. Since we're returning the
+ * softc address here, we need to use cdevsw_lookup_acquire() to
+ * keep a reference to the device. So all callers need to be able
+ * to determine which device's cdevsw needs to be released later on.
+ * XXX
+ */
static inline struct ra_softc *
mscp_device_lookup(dev_t dev)
{