Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758354Ab2BMXbD (ORCPT ); Mon, 13 Feb 2012 18:31:03 -0500 Received: from mail-tul01m020-f174.google.com ([209.85.214.174]:54768 "EHLO mail-tul01m020-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758307Ab2BMXbB convert rfc822-to-8bit (ORCPT ); Mon, 13 Feb 2012 18:31:01 -0500 MIME-Version: 1.0 In-Reply-To: <20120213225623.GA2988@redhat.com> References: <4F38B657.7060405@de.ibm.com> <4F38C27E.7030300@redhat.com> <1329136806.9333.383.camel@haakon2.linux-iscsi.org> <4F3907EB.4030402@redhat.com> <20120213130005.GB26773@redhat.com> <20120213131848.GD26773@redhat.com> <4F39287A.9030808@suse.de> <20120213225623.GA2988@redhat.com> Date: Tue, 14 Feb 2012 10:30:59 +1100 Message-ID: Subject: Re: Pe: [PATCH v5 1/3] virtio-scsi: first version From: ronnie sahlberg To: "Michael S. Tsirkin" Cc: Hannes Reinecke , Dor Laor , "Nicholas A. Bellinger" , Christian Borntraeger , James Bottomley , Paolo Bonzini , Christian Hoff , borntrae@linux.vnet.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, rusty@rustcorp.com.au, Stefan Hajnoczi , target-devel Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4337 Lines: 114 On Tue, Feb 14, 2012 at 9:59 AM, Michael S. Tsirkin wrote: > On Tue, Feb 14, 2012 at 07:53:26AM +1100, ronnie sahlberg wrote: >> On Tue, Feb 14, 2012 at 7:42 AM, ronnie sahlberg >> wrote: >> > On Tue, Feb 14, 2012 at 2:12 AM, Hannes Reinecke wrote: >> >> On 02/13/2012 02:18 PM, Michael S. Tsirkin wrote: >> >>> On Tue, Feb 14, 2012 at 12:13:36AM +1100, ronnie sahlberg wrote: >> >>>> On Tue, Feb 14, 2012 at 12:00 AM, Michael S. Tsirkin wrote: >> >>>>> On Mon, Feb 13, 2012 at 02:54:03PM +0200, Dor Laor wrote: >> >>>>>> Only if you use the pci multi-function option but that kills >> >>>>>> standard hot unplug >> >>>>> >> >>>>> It doesn't kill it as such, rather you can't unplug luns individually. >> >>>> >> >>>> Isnt that just a consequence of the current implementation rather than >> >>>> a SCSI limitation? >> >>> >> >>> Yes. >> >>> >> >>>> A different way to do hoplug could be to flag all devices as removable >> >>>> in the standard inq page then >> >>>> leave the LUN there persistently and what you remove/add is not the >> >>>> LUN device itself but just the media in the device. >> >>>> >> >>>> Instead of hot-plug remove the LUN, ?hot-plug becomes "media eject" or >> >>>> "media insert". >> >>>> The device remains present all time, you never remove it, but instead >> >>>> hot-plug controls if the media is present or not. >> >>>> >> >>>> >> >>>> This would require implementing at least START_STOP_UNIT and >> >>>> PREVENT_ALLOW_MEDIUM_REMOVAL opcode emulation from SBC. >> >>>> >> >>>> >> >>>> regards >> >>>> ronnie sahlberg >> >>> >> >>> That would work. >> >>> >> >> Or we simply use the Peripheral Qualifier that the device is gone; >> >> eg we could simply set PQ = 1, return sense code 0x25/00 and be done >> >> with ... >> >> >> > >> > That is still similar to "rip a device out from the guest without notice" >> > and can cause the guest to be "surprised". >> > >> > >> > Removable media is standard feature in SCSI SBC (and other commandsets). >> > The nice part of removable media is that it activates a contract >> > between the device and the guest >> > to prevent removal of the media when the guest depends on the media >> > not being removed. >> > >> > I.e. ?If you have a SBC device with the removable-media bit set, >> > this is used to tell the initiator "this media can be removed, be >> > prepared that this might happen". >> > So when you mount such a SBC device in the guest, the guest will issue >> > a "PREVENT_ALLOW_MEDIUM_REMOVAL" >> > to tell the device "this medium is in use and may not be removed". >> > >> >> What I mean is that if /dev/sdb is removable, >> if you mount this as ? "mount /dev/sdb1 /mnt" >> this will automatically cause the guest kernel to send a >> PREVENT_ALLOW_MEDIUM_REMOVAL to /dev/sdb to prevent removal. >> >> When you "umount /dev/sdb1" ? the kernel/guest will automagically send >> PREVENT_ALLOW_MEDIUM_REMOVEAL to /dev/sdb and allow removal of the >> media again. >> >> >> If you capture this command and track the "prevent/allow removal >> status" ?you automatically get a channel where qemu will >> know when it is safe to unplug the device ?and when it is not safe to >> unplug the device. >> This is a nice feature. > > Presumably there's a way for device to notify the OS > that user requested removal, as well? I think that is done by responding with sense to one of the commands, like the every few second TEST_UNIT_READY that the initiator/guest-kernel will send. 5Ah 01h DT WROM BK OPERATOR MEDIUM REMOVAL REQUEST This sense code should be the one to use. I dont know if linux scsi initiator honors this or what it will do. I guess something like this could work ? IF device is marked as prevent-removal THEN send OPERATOR SEND MEDIUM REMOVAL REQUEST to the initiator wait xyz seconds IF device is still marked as prevent-removal THEN ask operator "guest refused to release the LUN, do you want to forcefully remove it?" ELSE unmount the media FI ELSE unmount the media FI -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/