From owner-freebsd-hackers@FreeBSD.ORG Mon May 12 16:32:03 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 65612106564A for ; Mon, 12 May 2008 16:32:03 +0000 (UTC) (envelope-from ale@FreeBSD.org) Received: from lab.alexdupre.com (cl-506.trn-01.it.sixxs.net [IPv6:2001:1418:100:1f9::2]) by mx1.freebsd.org (Postfix) with ESMTP id 982928FC1C for ; Mon, 12 May 2008 16:32:02 +0000 (UTC) (envelope-from ale@FreeBSD.org) Received: (qmail 79493 invoked from network); 12 May 2008 16:31:56 -0000 Received: from unknown (HELO athlon.alexdupre.com) (192.168.178.2) by lab.alexdupre.com with SMTP; 12 May 2008 16:31:56 -0000 Message-ID: <482870FC.5050806@FreeBSD.org> Date: Mon, 12 May 2008 18:31:56 +0200 From: Alex Dupre User-Agent: Thunderbird 2.0.0.14 (X11/20080504) MIME-Version: 1.0 To: Andriy Gapon References: <48285372.9060103@icyb.net.ua> In-Reply-To: <48285372.9060103@icyb.net.ua> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org Subject: Re: openbsd solution to mounted umass removal X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 May 2008 16:32:03 -0000 Andriy Gapon wrote: > Filesystems on USB devices are automatically dismounted if the device is > disconnected. > > Does anybody have more [technical] details on this? Modified files: sys/dev/usb : umass.c sys/scsi : sdvar.h sd.c sys/kern : vfs_default.c vfs_subr.c Log message: Allow to pull out an usb stick with ffs filesystem while mounted and a file is written onto the stick. Without these fixes the machine panics or hangs. The usb fix calls the callback when the stick is pulled out to free the associated buffers. Otherwise we have busy buffers for ever and the automatic unmount will panic. The change in the scsi layer prevents passing down further dirty buffers to usb after the stick has been deactivated. In vfs the automatic unmount has moved from the function vgonel() to vop_generic_revoke(). Both are called when the sd device's vnode is removed. In vgonel() the VXLOCK is already held which can cause a deadlock. So call dounmount() earlier. -- Alex Dupre