From owner-freebsd-bugs@FreeBSD.ORG Wed Jan 21 08:00:32 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 227E216A4D1 for ; Wed, 21 Jan 2004 08:00:32 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id CF1FB43D53 for ; Wed, 21 Jan 2004 08:00:23 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i0LG0NFR004577 for ; Wed, 21 Jan 2004 08:00:23 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id i0LG0NjT004576; Wed, 21 Jan 2004 08:00:23 -0800 (PST) (envelope-from gnats) Resent-Date: Wed, 21 Jan 2004 08:00:23 -0800 (PST) Resent-Message-Id: <200401211600.i0LG0NjT004576@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Jim Bauer Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3BEA716A4CE for ; Wed, 21 Jan 2004 07:53:29 -0800 (PST) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id CB43643D1D for ; Wed, 21 Jan 2004 07:53:27 -0800 (PST) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.12.10/8.12.10) with ESMTP id i0LFrPdL094974 for ; Wed, 21 Jan 2004 07:53:25 -0800 (PST) (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.12.10/8.12.10/Submit) id i0LFrPGi094973; Wed, 21 Jan 2004 07:53:25 -0800 (PST) (envelope-from nobody) Message-Id: <200401211553.i0LFrPGi094973@www.freebsd.org> Date: Wed, 21 Jan 2004 07:53:25 -0800 (PST) From: Jim Bauer To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.0 Subject: kern/61677: Unable to open CDROM tray if boot_cdrom is in loader.conf X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jan 2004 16:00:32 -0000 >Number: 61677 >Category: kern >Synopsis: Unable to open CDROM tray if boot_cdrom is in loader.conf >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Jan 21 08:00:23 PST 2004 >Closed-Date: >Last-Modified: >Originator: Jim Bauer >Release: 4.8-RELEASE >Organization: NFR Security Inc >Environment: FreeBSD gyro.nidlab.nfr.net 4.8-RELEASE FreeBSD 4.8-RELEASE #4: Mon Jan 5 12:47:40 EST 2004 jfbauer@gyro.nidlab.nfr.net:/home/jfbauer/freebsd_48_src/sys/compile/JFB i386 >Description: If loader.conf contains: boot_cdrom="YES" (the value is unimportant, just the existence seems to matter) but you don't actually boot from the CDROM drive (because it does not contain a CD) then the cdrom tray will remain locked. As the system boots, the kernel will try to mount the CDROM trying 3 different CD devices. All will fail as there is no CD in any cdrom drive. The kernel will then fallback and mount the root FS from the hard disk. Once the system is up and running you can login and see that nothing is mounted from the (empty) cdrom drive, but the eject command (CDIOCEJECT ioctl) will return EBUSY. Also, pressing the eject button on the drive will fail to open the tray. It looks like the mount attempt is not fully cleaning up and leaving the device in a busy state. >How-To-Repeat: 1) Place this in your loader.conf file: boot_cdrom="YES" 2) Make sure there is no CD in the drive 3) Reboot (the kernel will attempt to mount the CD, fail and mount hard disk as usual) 4) Try to open the CD tray via either the eject command or the pressing the eject button on the cd drive. Both will fail to open the tray. >Fix: This patch seem to fix the problem. diff -u -r1.1.1.1 cd9660_vfsops.c --- isofs/cd9660/cd9660_vfsops.c 11 Apr 2003 00:34:55 -0000 1.1.1.1 +++ isofs/cd9660/cd9660_vfsops.c 20 Jan 2004 20:46:31 -0000 @@ -163,7 +163,7 @@ error = VOP_OPEN(rootvp, FREAD, FSCRED, p); VOP_UNLOCK(rootvp, 0, p); if (error) - return (error); + goto err; args.ssector = iso_get_ssector(rootdev, p); @@ -173,10 +173,15 @@ printf("iso_mountroot(): using session at block %d\n", args.ssector); if ((error = iso_mountfs(rootvp, mp, p, &args)) != 0) - return (error); + goto err; (void)cd9660_statfs(mp, &mp->mnt_stat, p); return (0); + + err: + /* Undo the addalias() called from bdevvp() */ + delalias(rootvp, rootdev); + return error; } /* Index: kern/vfs_subr.c =================================================================== diff -u -r1.1.1.1 vfs_subr.c --- kern/vfs_subr.c 11 Apr 2003 00:34:56 -0000 1.1.1.1 +++ kern/vfs_subr.c 20 Jan 2004 20:46:31 -0000 @@ -1481,6 +1481,22 @@ } /* + * Remove an alias created by addalias() + */ +void +delalias(nvp, dev) + struct vnode *nvp; + dev_t dev; +{ + if (nvp->v_type != VBLK && nvp->v_type != VCHR) + panic("delalias on non-special vnode"); + + simple_lock(&spechash_slock); + SLIST_REMOVE(&dev->si_hlist, nvp, vnode, v_specnext); + simple_unlock(&spechash_slock); +} + +/* * Grab a particular vnode from the free list, increment its * reference count and lock it. The vnode lock bit is set if the * vnode is being eliminated in vgone. The process is awakened >Release-Note: >Audit-Trail: >Unformatted: