Module Name: src
Committed By: tsutsui
Date: Sat Jun 30 10:52:32 UTC 2012
Modified Files:
src/sys/dev: md.c
Log Message:
Make sure that disklabel of md(4) device is initialized
in the case where it's configured in MD md_open_hook().
Without this, msdosfs_mountfs() (which is called from msdosfs_mountroot())
will be called with uninitialized disklabel (d_secsize == 0) and
it gets "panic: buf mem pool index 23" later on atari.
This is because getdisksize() doesn't check returned d_secsize value
and msdosfs_mountfs() blindly calls bread(9) with size==0 in that case.
Should be pulled up to netbsd-6 (at least for atari).
To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/dev/md.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/md.c
diff -u src/sys/dev/md.c:1.66 src/sys/dev/md.c:1.67
--- src/sys/dev/md.c:1.66 Thu Nov 25 08:53:30 2010
+++ src/sys/dev/md.c Sat Jun 30 10:52:31 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: md.c,v 1.66 2010/11/25 08:53:30 hannken Exp $ */
+/* $NetBSD: md.c,v 1.67 2012/06/30 10:52:31 tsutsui Exp $ */
/*
* Copyright (c) 1995 Gordon W. Ross, Leo Weppelman.
@@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.66 2010/11/25 08:53:30 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.67 2012/06/30 10:52:31 tsutsui Exp $");
#ifdef _KERNEL_OPT
#include "opt_md.h"
@@ -243,6 +243,9 @@ mdopen(dev_t dev, int flag, int fmt, str
cfdata_t cf;
struct md_softc *sc;
struct disk *dk;
+#ifdef MEMORY_DISK_HOOKS
+ bool configured;
+#endif
mutex_enter(&md_device_lock);
unit = MD_UNIT(dev);
@@ -274,7 +277,11 @@ mdopen(dev_t dev, int flag, int fmt, str
#ifdef MEMORY_DISK_HOOKS
/* Call the open hook to allow loading the device. */
+ configured = (sc->sc_type != MD_UNCONFIGURED);
md_open_hook(unit, &sc->sc_md);
+ /* initialize disklabel if the device is configured in open hook */
+ if (!configured && sc->sc_type != MD_UNCONFIGURED)
+ md_set_disklabel(sc);
#endif
/*