Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev Make sure that disklabel of md(4) device is initialized



details:   https://anonhg.NetBSD.org/src/rev/a0dfe5825ce1
branches:  trunk
changeset: 779942:a0dfe5825ce1
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sat Jun 30 10:52:31 2012 +0000

description:
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).

diffstat:

 sys/dev/md.c |  11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diffs (40 lines):

diff -r 81d9c9979245 -r a0dfe5825ce1 sys/dev/md.c
--- a/sys/dev/md.c      Sat Jun 30 10:37:00 2012 +0000
+++ b/sys/dev/md.c      Sat Jun 30 10:52:31 2012 +0000
@@ -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 @@
        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 @@
 
 #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
 
        /*



Home | Main Index | Thread Index | Old Index