Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2685668ybg; Thu, 24 Oct 2019 13:32:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOH5D4EEzLO44yUIa1DilrbGSegScymBMRZhVhm23nwq2WSB08QNylwe+Ff6+F9rp6GLA1 X-Received: by 2002:a50:984b:: with SMTP id h11mr90786edb.248.1571949166725; Thu, 24 Oct 2019 13:32:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571949166; cv=none; d=google.com; s=arc-20160816; b=q3Q5aLYA/8gbZKD8EIJc4Rlu1R5bLwDI4Ul4bFrZ0y7Pq6JAGOwxhSZSeWsTNPYecW 6q+O0XD6zZOmfdpiWBv3ve7hG7pwzX6n6P7RJIJh9yVgOYmNhLEIHmBqqM4Kg9YYRNzU 7wxYxmtv2zrjAa1C9J0UxUEpdMf1uwHJXIOdh/fn06Sn8Mtm8K+7juwOozbg50R+vtvG CC/owXY+7a8EcPqqQhEumaXWs8ULhLqW3QTUmSEGH+9PvXPsTXm38t9ElxzKdcOZOCYy kkHu7kFQwuydxNwaAIDo5Es2evjY3YLfJUvhUHUzmNHugwz3egEMJjCrGIsGmrt9wJCo jSYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject; bh=k8AIosXtz00G4jlQIG4BI/+FRaJ+7UlwHkq62flHBOs=; b=xExepIcBZCyOGfVsuGspEboh/OthTMwdx6LGNhigtEMVNWooxOQzGJIUNymdYc2n9p dVqRKK8JYpNQphNIOhKNU68+IfgPfCJK/vxX1Ur4o+AGSdJJ+OM8PDciINbnjP7wEBnk 8yW3XgY01nQgVWM0mB0O/eRnr9dKw59GdniQ0YpkKfH/fcDO+SzfwpIKur6xRAXlr08H LJ/rVpdUAjuas/rkCMITLBYzFwyysY7PYtT/WCDnbBB5ofQJKFyUpoGnQxqBNPN7LqRA 9f0OYILXUKccG4hoBC4UA/3di4tH9K7MaDVEfQxUqpnSzl2eU1dirJOGTP5rQ18A+9ng ln0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c13si1487803edk.4.2019.10.24.13.32.16; Thu, 24 Oct 2019 13:32:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2408462AbfJXFrC (ORCPT + 99 others); Thu, 24 Oct 2019 01:47:02 -0400 Received: from mx2.suse.de ([195.135.220.15]:36860 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2406898AbfJXFrC (ORCPT ); Thu, 24 Oct 2019 01:47:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 991ACB208; Thu, 24 Oct 2019 05:46:58 +0000 (UTC) Subject: Re: [PATCH v2 7/8] scsi: sr: workaround VMware ESXi cdrom emulation bug To: =?UTF-8?Q?Michal_Such=c3=a1nek?= Cc: linux-scsi@vger.kernel.org, Jonathan Corbet , Jens Axboe , "James E.J. Bottomley" , "Martin K. Petersen" , Alexander Viro , Mauro Carvalho Chehab , Eric Biggers , "J. Bruce Fields" , Benjamin Coddington , Hannes Reinecke , Omar Sandoval , Ming Lei , Damien Le Moal , Bart Van Assche , Tejun Heo , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org References: <08f1e291-0196-2402-1947-c0cdaaf534da@suse.de> <20191023162313.GE938@kitsune.suse.cz> From: Hannes Reinecke Openpgp: preference=signencrypt Autocrypt: addr=hare@suse.de; prefer-encrypt=mutual; keydata= mQINBE6KyREBEACwRN6XKClPtxPiABx5GW+Yr1snfhjzExxkTYaINHsWHlsLg13kiemsS6o7 qrc+XP8FmhcnCOts9e2jxZxtmpB652lxRB9jZE40mcSLvYLM7S6aH0WXKn8bOqpqOGJiY2bc 6qz6rJuqkOx3YNuUgiAxjuoYauEl8dg4bzex3KGkGRuxzRlC8APjHlwmsr+ETxOLBfUoRNuE b4nUtaseMPkNDwM4L9+n9cxpGbdwX0XwKFhlQMbG3rWA3YqQYWj1erKIPpgpfM64hwsdk9zZ QO1krgfULH4poPQFpl2+yVeEMXtsSou915jn/51rBelXeLq+cjuK5+B/JZUXPnNDoxOG3j3V VSZxkxLJ8RO1YamqZZbVP6jhDQ/bLcAI3EfjVbxhw9KWrh8MxTcmyJPn3QMMEp3wpVX9nSOQ tzG72Up/Py67VQe0x8fqmu7R4MmddSbyqgHrab/Nu+ak6g2RRn3QHXAQ7PQUq55BDtj85hd9 W2iBiROhkZ/R+Q14cJkWhzaThN1sZ1zsfBNW0Im8OVn/J8bQUaS0a/NhpXJWv6J1ttkX3S0c QUratRfX4D1viAwNgoS0Joq7xIQD+CfJTax7pPn9rT////hSqJYUoMXkEz5IcO+hptCH1HF3 qz77aA5njEBQrDRlslUBkCZ5P+QvZgJDy0C3xRGdg6ZVXEXJOQARAQABtCpIYW5uZXMgUmVp bmVja2UgKFN1U0UgTGFicykgPGhhcmVAc3VzZS5kZT6JAkEEEwECACsCGwMFCRLMAwAGCwkI BwMCBhUIAgkKCwQWAgMBAh4BAheABQJOisquAhkBAAoJEGz4yi9OyKjPOHoQAJLeLvr6JNHx GPcHXaJLHQiinz2QP0/wtsT8+hE26dLzxb7hgxLafj9XlAX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; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20191023162313.GE938@kitsune.suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/23/19 6:23 PM, Michal Suchánek wrote: > On Wed, Oct 23, 2019 at 04:13:15PM +0200, Hannes Reinecke wrote: >> On 10/23/19 2:52 PM, Michal Suchanek wrote: >>> The WMware ESXi cdrom identifies itself as: >>> sr 0:0:0:0: [sr0] scsi3-mmc drive: vendor: "NECVMWarVMware SATA CD001.00" >>> model: "VMware SATA CD001.00" >>> with the following get_capabilities print in sr.c: >>> sr_printk(KERN_INFO, cd, >>> "scsi3-mmc drive: vendor: \"%s\" model: \"%s\"\n", >>> cd->device->vendor, cd->device->model); >>> >>> So the model looks like reliable identification while vendor does not. >>> >>> The drive claims to have a tray and claims to be able to close it. >>> However, the UI has no notion of a tray - when medium is ejected it is >>> dropped in the floor and the user must select a medium again before the >>> drive can be re-loaded. On the kernel side the tray_move call to close >>> the tray succeeds but the drive state does not change as a result of the >>> call. >>> >>> The drive does not in fact emulate the tray state. There are two ways to >>> get the medium state. One is the SCSI status: >>> >>> Physical drive: >>> >>> Fixed format, current; Sense key: Not Ready >>> Additional sense: Medium not present - tray open >>> Raw sense data (in hex): >>> 70 00 02 00 00 00 00 0a 00 00 00 00 3a 02 00 00 >>> 00 00 >>> >>> Fixed format, current; Sense key: Not Ready >>> Additional sense: Medium not present - tray closed >>> Raw sense data (in hex): >>> 70 00 02 00 00 00 00 0a 00 00 00 00 3a 01 00 00 >>> 00 00 >>> >>> VMware ESXi: >>> >>> Fixed format, current; Sense key: Not Ready >>> Additional sense: Medium not present >>> Info fld=0x0 [0] >>> Raw sense data (in hex): >>> f0 00 02 00 00 00 00 0a 00 00 00 00 3a 00 00 00 >>> 00 00 >>> >>> So the tray state is not reported here. Other is medium status which the >>> kernel prefers if available. Adding a print here gives: >>> >>> cdrom: get_media_event success: code = 0, door_open = 1, medium_present = 0 >>> >>> door_open is interpreted as open tray. This is fine so long as tray_move >>> would close the tray when requested or report an error which never >>> happens on VMware ESXi servers (5.5 and 6.5 tested). >>> >>> This is a popular virtualization platform so a workaround is worthwhile. >>> >>> Signed-off-by: Michal Suchanek >>> --- >>> drivers/scsi/sr.c | 6 ++++++ >>> 1 file changed, 6 insertions(+) >>> >>> diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c >>> index 4664fdf75c0f..8090c5bdec09 100644 >>> --- a/drivers/scsi/sr.c >>> +++ b/drivers/scsi/sr.c >>> @@ -867,6 +867,7 @@ static void get_capabilities(struct scsi_cd *cd) >>> unsigned int ms_len = 128; >>> int rc, n; >>> >>> + static const char *model_vmware = "VMware"; >>> static const char *loadmech[] = >>> { >>> "caddy", >>> @@ -922,6 +923,11 @@ static void get_capabilities(struct scsi_cd *cd) >>> buffer[n + 4] & 0x20 ? "xa/form2 " : "", /* can read xa/from2 */ >>> buffer[n + 5] & 0x01 ? "cdda " : "", /* can read audio data */ >>> loadmech[buffer[n + 6] >> 5]); >>> + if (!strncmp(cd->device->model, model_vmware, strlen(model_vmware))) { >>> + buffer[n + 6] &= ~(0xff << 5); >>> + sr_printk(KERN_INFO, cd, >>> + "VMware ESXi bug workaround: tray -> caddy\n"); >>> + } >>> if ((buffer[n + 6] >> 5) == 0) >>> /* caddy drives can't close tray... */ >>> cd->cdi.mask |= CDC_CLOSE_TRAY; >>> >> This looks something which should be handled via a blacklist flag, not >> some inline hack which everyone forgets about it... > > AFAIK we used to have a blacklist but don't have anymore. So either it > has to be resurrected for this one flag or an inline hack should be good > enough. > But we do have one for generic scsi; cf drivers/scsi/scsi_devinfo.c. And this pretty much falls into the category of SCSI quirks, so I'd prefer have it hooked into that. Cheers, Hannes -- Dr. Hannes Reinecke Teamlead Storage & Networking hare@suse.de +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 247165 (AG München), GF: Felix Imendörffer