Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Nov 2001 21:38:02 -0700
From:      "Kenneth D. Merry" <ken@kdm.org>
To:        Dirk Froemberg <dirk@FreeBSD.ORG>
Cc:        Poul-Henning Kamp <phk@critter.freebsd.dk>, stable@FreeBSD.ORG
Subject:   Re: kernel panic if using SCSI CDROM as root device
Message-ID:  <20011116213802.A44758@panzer.kdm.org>
In-Reply-To: <20011116075743.A96224@physik.TU-Berlin.DE>; from dirk@FreeBSD.ORG on Fri, Nov 16, 2001 at 07:57:43AM %2B0100
References:  <20011115152226.A35113@panzer.kdm.org> <5832.1005863617@critter.freebsd.dk> <20011115154058.A35230@panzer.kdm.org> <20011116075743.A96224@physik.TU-Berlin.DE>

next in thread | previous in thread | raw e-mail | index | archive | help

--LZvS9be/3tNcYl/X
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Fri, Nov 16, 2001 at 07:57:43 +0100, Dirk Froemberg wrote:
> Hi!
> 
> On Thu, Nov 15, 2001 at 03:40:58PM -0700, Kenneth D. Merry wrote:
> > On Thu, Nov 15, 2001 at 23:33:37 +0100, Poul-Henning Kamp wrote:
> > > In message <20011115152226.A35113@panzer.kdm.org>, "Kenneth D. Merry" writes:
> > > >On Thu, Nov 15, 2001 at 23:11:16 +0100, Dirk Froemberg wrote:
> > > >> On Thu, Nov 15, 2001 at 02:56:15PM -0700, Kenneth D. Merry wrote:
> > > >> > [...]
> > > > [...]
> > > >Poul-Henning, any idea why this might be blowing up?  It looks like the
> > > >slice pointer isn't initialized for some reason.
> > > 
> > > Has the disk actually been opened ?
> > 
> > Good question, I dunno.
> > 
> > You'd figure this stuff would work, since the CD installation process boots
> > off of a CD.
> > 
> > But of course Dirk may be using the new El Torito boot code that enables
> > non-emulation booting.  (i.e. you're not booting off of a floppy image
> > anymore)  Is that what you're using Dirk?
> 
> No... The CD image is created with
> 
> 	mkisofs -U -R -b cdboot/boot.flp -c cdboot/boot.catalog -o /var/tmp/bootable.iso /usr/CDROM
> 
> boot.flp is a copy of 4.4-RELEASE's floppy with a GENERIC kernel on
> it.

Ahh.

> The iso image can be fetched from
> 
> ftp://ftp.todo.de/pub/FreeBSD/CD-ROM-images/bootable.iso.bz2
> 
> if someone likes to look at it.
> 
> (it's about 45 MB)

I might, but I have an idea of what may be going on here.

> > That would change things around somewhat, since the ISO9660 code would now
> > be running the root device where before it was probably the msdos
> > filesystem code.
> > 
> > > I have fixed some instances where some of the boot-glue would issue
> > > ioctl' calls to disks which were not yet opened, that used to work,
> > > despite being a gross error.
> > 
> > Yeah, I can certainly see how that could cause problems.

Even though you're booting off a floppy, the root filesystem in this case
is ISO9660.

After looking through the stack trace from your previous mail:

db> trace
dsioctl(c0900b80,40046304,c03e1e28,1,c090e844) at dsioctl+0x42
diskioctl(c0900b80,40046304,c03e1e28,1,c0355b60) at diskioctl+0x6f
iso_get_ssector(c0900b80,c0355b60,0,c0909e00,c0355b60) at iso_get_ssector+0x2e
iso_mountroot(c0909e00,c0355b60,c03e1fb0,c0900e80,c090df30) at iso_mountroot+0x47
cd9660_mount(c0909e00,0,0,0,c0355b60) at cd9660_mount+0x2c
vfs_mountroot_try(c02dc78a) at vfs_mountroot_try+0x13d
vfs_mountroot(0,3dec00,3e6000,0,c0120670) at vfs_mountroot+0x3c
mi_startup(0,0,0,0,0) at mi_startup+0x68
begin() at begin+0x47

It looks like Poul-Henning is probably right about the cause.
iso_mountroot() calls iso_get_ssector(), which issues
CDIOREADTOCHEADER and CDIOREADTOCENTRY ioctls.  The thing is, the
device hasn't been opened yet -- it gets opened in iso_mountfs(),
which is called later in iso_mountroot().

So what needs to happen is we need to make sure the device is open
before iso_get_ssector() is called.  That means we either need to do
the open in iso_mountroot(), or we need to move the call to
iso_get_ssector() into iso_mountfs().

I've attached a patch that does an open/close inside iso_mountroot().
I'm open to opinions on whether the open/close should go there or
whether the iso_get_ssector() call should be moved into iso_mountfs().

I have only checked to see that this compiles on -stable.  I don't
know whether this works.

If you can test this out, we'll know whether this works.

The reason the ATAPI cd driver doesn't blow up in this instance is
because it doesn't use the slice code, and evidently doesn't care if
its ioctl routine is called without it first having been opened.

Ken
-- 
Kenneth Merry
ken@kdm.org

--LZvS9be/3tNcYl/X
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="cd9660_mountroot.20011116"

==== //depot/FreeBSD-ken-RELENG_4/src/sys/isofs/cd9660/cd9660_vfsops.c#3 - /usr/home/ken/perforce/FreeBSD-ken-RELENG_4/src/sys/isofs/cd9660/cd9660_vfsops.c ====
*** /tmp/tmp.75089.0	Fri Nov 16 21:30:58 2001
--- /usr/home/ken/perforce/FreeBSD-ken-RELENG_4/src/sys/isofs/cd9660/cd9660_vfsops.c	Fri Nov 16 21:29:37 2001
***************
*** 158,164 ****
--- 158,174 ----
  		return (error);
  	}
  	args.flags = ISOFSMNT_ROOT;
+ 
+ 	vn_lock(rootvp, LK_EXCLUSIVE | LK_RETRY, p);
+ 	error = VOP_OPEN(rootvp, FREAD, FSCRED, p);
+ 	VOP_UNLOCK(rootvp, 0, p);
+ 	if (error)
+ 		return (error);
+ 
  	args.ssector = iso_get_ssector(rootdev, p);
+ 
+ 	(void)VOP_CLOSE(rootvp, FREAD, NOCRED, p);
+ 
  	if (bootverbose)
  		printf("iso_mountroot(): using session at block %d\n",
  		       args.ssector);

--LZvS9be/3tNcYl/X--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011116213802.A44758>