Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2383195ybg; Thu, 24 Oct 2019 08:55:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxelrEhgoY2L2wZQly5lJiDGYfCokSwgZv9f6E8KCg7lHBFyKglUtEjyA3/rQ44F0FgxCl5 X-Received: by 2002:a50:f744:: with SMTP id j4mr44065116edn.73.1571932546272; Thu, 24 Oct 2019 08:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571932546; cv=none; d=google.com; s=arc-20160816; b=Pe4uGf+W833msEMjGuZgQG4pbg8pl+Y8xCC5KmPmUXGPWSgGKnZgIoXoDtYMJrW4hS LFoV3i7Pem1XAEDfRlXw3SQGyfs4+LVplwK4EO/A4CSCZKQKJmOMGNoLV8c8PpArNIBR 5Scc4CxhmfpV+Q2o4A8ENMJrGbl/FC+GmJFJfvMgSY/z2MqAZzm0gXcXUh0eTKELSZSk sqEHfsmrUdrEb+ulRO1RbQPvuoO5RUvWZRhTubgovFemwHXlsGL4VO9zp7XU0iiaA9mf i4AWyxn52J97MrXC+CQaP9o3h2ElrHJxATi6o4wknVHv2Nhrvcjlk3zo0aJubnkBKlYv CoEA== 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:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature; bh=0D4EQ8thGQKRRU/Fz2c1O7VtA1gRTINZXqgRy6HfSuk=; b=mdkFX5Zp4jqi32NRdoqHhFZt7vOTpfp7cVj9KF7OGbrMr1T3u37B+7EARyiqTJBm5u 82bNkX/mRK89hum3Q7PIMNU4oDGRxFLIWyNfAu/KFwOZND7TPEJhyMo8nkQ/hCJbVDtl qoANQVTRw57l+vF/7w1pCbZd7+irIbKeT13DjGCOy142gW19Ls+oRhchWju1k08LrD5/ nIh/N8a4VE9eTUA1BPN6YbCd2gRJikKnabfbtXBX61Y4GU4p9z+rdzO/5Xxe72BdNw4K KwQZo7cg8/TQMmjVv7RK3ou1R1i/AhardvmG+KG5R7KcUBhk3/0qxPLU0XtQ7x9R/c+/ BeXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R0V7DxSa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s21si15925684ejm.122.2019.10.24.08.55.01; Thu, 24 Oct 2019 08:55: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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R0V7DxSa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407605AbfJWVpK (ORCPT + 99 others); Wed, 23 Oct 2019 17:45:10 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:39138 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2391240AbfJWVpK (ORCPT ); Wed, 23 Oct 2019 17:45:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571867109; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0D4EQ8thGQKRRU/Fz2c1O7VtA1gRTINZXqgRy6HfSuk=; b=R0V7DxSapSFPev4UGzimkxUEIrMclUZodFMOePwyBjdC3PkoEX9IHO8CiV/9e3ccXmQ+JC 4A7d90Cfe7WgzZmiok371uhmCno8Tx+Mt6X3tW1OKYEj5fCZSYkXuFHlMG9NatkMTXLOVE xRIUi6+z9xhMdPFbyJ284vd00qkuzMc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-240-m8GaqF_nOUal1pqA5AbW-g-1; Wed, 23 Oct 2019 17:45:05 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0FAFE100550E; Wed, 23 Oct 2019 21:45:03 +0000 (UTC) Received: from emilne (unknown [10.18.25.205]) by smtp.corp.redhat.com (Postfix) with ESMTP id 401405DA8D; Wed, 23 Oct 2019 21:44:55 +0000 (UTC) Message-ID: <6759dfc6c5c721b5060d75e6c5f5a0b1dbb9a80b.camel@redhat.com> Subject: Re: [PATCH v2 7/8] scsi: sr: workaround VMware ESXi cdrom emulation bug From: "Ewan D. Milne" To: Michal =?ISO-8859-1?Q?Such=E1nek?= , Hannes Reinecke 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 Date: Wed, 23 Oct 2019 17:44:54 -0400 In-Reply-To: <20191023162313.GE938@kitsune.suse.cz> References: <08f1e291-0196-2402-1947-c0cdaaf534da@suse.de> <20191023162313.GE938@kitsune.suse.cz> Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: m8GaqF_nOUal1pqA5AbW-g-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2019-10-23 at 18:23 +0200, Michal Such=C3=A1nek 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); > > >=20 > > > So the model looks like reliable identification while vendor does not= . > > >=20 > > > 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 i= s > > > dropped in the floor and the user must select a medium again before t= he > > > drive can be re-loaded. On the kernel side the tray_move call to clo= se > > > the tray succeeds but the drive state does not change as a result of = the > > > call. > > >=20 > > > The drive does not in fact emulate the tray state. There are two ways= to > > > get the medium state. One is the SCSI status: > > >=20 > > > Physical drive: > > >=20 > > > 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 > > >=20 > > > 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 > > >=20 > > > VMware ESXi: > > >=20 > > > Fixed format, current; Sense key: Not Ready > > > Additional sense: Medium not present > > > Info fld=3D0x0 [0] > > > Raw sense data (in hex): > > > f0 00 02 00 00 00 00 0a 00 00 00 00 3a 00 00 00 > > > 00 00 > > >=20 > > > So the tray state is not reported here. Other is medium status which = the > > > kernel prefers if available. Adding a print here gives: > > >=20 > > > cdrom: get_media_event success: code =3D 0, door_open =3D 1, medium_p= resent =3D 0 > > >=20 > > > door_open is interpreted as open tray. This is fine so long as tray_m= ove > > > would close the tray when requested or report an error which never > > > happens on VMware ESXi servers (5.5 and 6.5 tested). > > >=20 > > > This is a popular virtualization platform so a workaround is worthwhi= le. > > >=20 > > > Signed-off-by: Michal Suchanek > > > --- > > > drivers/scsi/sr.c | 6 ++++++ > > > 1 file changed, 6 insertions(+) > > >=20 > > > 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) > > > =09unsigned int ms_len =3D 128; > > > =09int rc, n; > > > =20 > > > +=09static const char *model_vmware =3D "VMware"; > > > =09static const char *loadmech[] =3D > > > =09{ > > > =09=09"caddy", > > > @@ -922,6 +923,11 @@ static void get_capabilities(struct scsi_cd *cd) > > > =09=09 buffer[n + 4] & 0x20 ? "xa/form2 " : "",=09/* can read xa/fr= om2 */ > > > =09=09 buffer[n + 5] & 0x01 ? "cdda " : "", /* can read audio data = */ > > > =09=09 loadmech[buffer[n + 6] >> 5]); > > > +=09if (!strncmp(cd->device->model, model_vmware, strlen(model_vmware= ))) { > > > +=09=09buffer[n + 6] &=3D ~(0xff << 5); > > > +=09=09sr_printk(KERN_INFO, cd, > > > +=09=09=09 "VMware ESXi bug workaround: tray -> caddy\n"); > > > +=09} > > > =09if ((buffer[n + 6] >> 5) =3D=3D 0) > > > =09=09/* caddy drives can't close tray... */ > > > =09=09cd->cdi.mask |=3D CDC_CLOSE_TRAY; > > >=20 > >=20 > > This looks something which should be handled via a blacklist flag, not > > some inline hack which everyone forgets about it... >=20 > 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. >=20 I agree with Hannes. We should have a blacklist flag for this. Putting inline code in the sr driver that special cases on a particular device model string is not clean. The "VMware ESXi bug workaround" message is not particularly descriptive either. -Ewan