Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/pgoyette-localcount]: src/sys/kern Defer initialization of the pserializ...
details: https://anonhg.NetBSD.org/src/rev/b7044e1a5d0c
branches: pgoyette-localcount
changeset: 852801:b7044e1a5d0c
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Sun Jul 17 05:02:19 2016 +0000
description:
Defer initialization of the pserialize_t device_psz" until just before
we need it. We can't initialize within devsw_init() because init_main()
has not yet initialized the pserialize stuff.
Restore a "return bdev" in bdevsw_lookup_acquire() - accidental deletion
Update cdevsw_lookup_acquire() to match bdev_lookup_acquire()
diffstat:
sys/kern/subr_devsw.c | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)
diffs (77 lines):
diff -r 734a8f084f72 -r b7044e1a5d0c sys/kern/subr_devsw.c
--- a/sys/kern/subr_devsw.c Sun Jul 17 02:44:41 2016 +0000
+++ b/sys/kern/subr_devsw.c Sun Jul 17 05:02:19 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_devsw.c,v 1.34.2.3 2016/07/17 02:37:54 pgoyette Exp $ */
+/* $NetBSD: subr_devsw.c,v 1.34.2.4 2016/07/17 05:02:19 pgoyette Exp $ */
/*-
* Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.3 2016/07/17 02:37:54 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.4 2016/07/17 05:02:19 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_dtrace.h"
@@ -113,7 +113,7 @@
kmutex_t device_lock;
kcondvar_t device_cv;
-pserialize_t device_psz;
+pserialize_t device_psz = NULL;
void (*biodone_vfs)(buf_t *) = (void *)nullop;
@@ -125,7 +125,6 @@
KASSERT(sys_cdevsws < MAXDEVSW - 1);
mutex_init(&device_lock, MUTEX_DEFAULT, IPL_NONE);
cv_init(&device_cv, "devsw");
- device_psz = pserialize_init();
}
int
@@ -392,7 +391,12 @@
if (j < max_cdevsws )
cdevsw[j] = NULL;
- /* We need to wait for all current readers to finish. */
+ /*
+ * If we haven't already done so, create the serialization
+ * stucture. Then wait for all current readers to finish.
+ */
+ if(__predict_false(device_psz == NULL))
+ device_psz = pserialize_create();
pserialize_perform(device_psz);
/*
@@ -469,6 +473,8 @@
localcount_acquire(bdevsw[bmajor]->d_localcount);
out: pserialize_read_exit(s);
+
+ return bdev;
}
void
@@ -512,9 +518,6 @@
if (cmajor < 0 || cmajor >= max_cdevsws)
return (NULL);
- /* Prevent any concurrent attempts to detach the device */
- mutex_enter(&device_lock);
-
/* Start a read transaction to block localcount_drain() */
s = pserialize_read_enter();
@@ -523,7 +526,7 @@
if (cdev == NULL)
goto out;
- /* Wait for the content of the struct bdevsw to become visible */
+ /* Wait for the content of the struct cdevsw to become visible */
membar_datadep_consumer();
/* If the devsw is not statically linked, acquire a reference */
Home |
Main Index |
Thread Index |
Old Index