From patchwork Wed Jul 1 09:04:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitaly Kuznetsov X-Patchwork-Id: 6701451 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1C530C05AC for ; Wed, 1 Jul 2015 09:04:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4E51E2065B for ; Wed, 1 Jul 2015 09:04:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5A12920658 for ; Wed, 1 Jul 2015 09:04:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752500AbbGAJEP (ORCPT ); Wed, 1 Jul 2015 05:04:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45292 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751832AbbGAJEM (ORCPT ); Wed, 1 Jul 2015 05:04:12 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 8550335C123; Wed, 1 Jul 2015 09:04:12 +0000 (UTC) Received: from vitty.brq.redhat.com (vitty.brq.redhat.com [10.34.26.3]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t6194AUK017703; Wed, 1 Jul 2015 05:04:10 -0400 From: Vitaly Kuznetsov To: linux-scsi@vger.kernel.org Cc: Long Li , "K. Y. Srinivasan" , Haiyang Zhang , "James E.J. Bottomley" , devel@linuxdriverproject.org, linux-kernel@vger.kernel.org Subject: [PATCH] scsi: storvsc: make INQUIRY response SPC-compliant Date: Wed, 1 Jul 2015 11:04:08 +0200 Message-Id: <1435741448-29070-1-git-send-email-vkuznets@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP SPC-2/3/4 specs state that "The standard INQUIRY data (see table ...) shall contain at least 36 bytes". Hyper-V host doesn't always honor this requirement, e.g. when there is no physical device present at a particular LUN host sets Peripheral qualifier to 011b and Additional length to 0 (thus making the reply 5-bytes long). Upper level SCSI stack complains with 'INQUIRY result too short (5), using 36'. Fix the issue by mangling Additional length field in host's reply at the driver level. Signed-off-by: Vitaly Kuznetsov --- This is a hack, the proper fix should probably be done in Hyper-V. --- drivers/scsi/storvsc_drv.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index 3c6584f..bca31af 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -1153,6 +1153,7 @@ static void storvsc_on_io_completion(struct hv_device *device, { struct storvsc_device *stor_device; struct vstor_packet *stor_pkt; + struct vmbus_packet_mpb_array *payload = request->payload; stor_device = hv_get_drvdata(device); stor_pkt = &request->vstor_packet; @@ -1174,6 +1175,24 @@ static void storvsc_on_io_completion(struct hv_device *device, vstor_packet->vm_srb.srb_status = SRB_STATUS_SUCCESS; } + /* + * When there is no physical device attached to a LUN Hyper-V host + * sets Peripheral qualifier to 011b and Additional length to 0. SPC + * spec, however, says that "The standard INQUIRY data ... shall + * contain at least 36 bytes". Upper level SCSI stack complains with + * 'INQUIRY result too short (5), using 36'. Mangle host's reply here. + */ + if (stor_pkt->vm_srb.cdb[0] == INQUIRY && payload) { + u8 *buf, per_qual, data_len; + int range_len = payload->range.len; + + buf = phys_to_virt(payload->range.pfn_array[0] << PAGE_SHIFT) + + payload->range.offset; + per_qual = (buf[0] >> 5) & 7; + data_len = buf[4] + 5; + if (per_qual == 3 && data_len < min(range_len, 36)) + buf[4] = min(range_len, 36) - 5; + } /* Copy over the status...etc */ stor_pkt->vm_srb.scsi_status = vstor_packet->vm_srb.scsi_status;