From patchwork Thu Jul 26 13:28:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1242751 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 2286C3FC5A for ; Thu, 26 Jul 2012 13:29:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752310Ab2GZN2l (ORCPT ); Thu, 26 Jul 2012 09:28:41 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:49739 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751500Ab2GZN2a (ORCPT ); Thu, 26 Jul 2012 09:28:30 -0400 Received: by mail-pb0-f46.google.com with SMTP id rp8so3232997pbb.19 for ; Thu, 26 Jul 2012 06:28:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=+gI42BOroyFKioh0FZS2tVMMNSJXosIwq/QUoRu6hHI=; b=VzSjq8AF/d3+HuqJTUjhB+qd9/CCY84qIFHCYZnFBlQedfGj5Qbg/qfmlfNJjT3sX4 3J67ZKBWxCKFNwkvPwWngWld/jd6cjfW7sXW99H6CfOZrAqTG0nhie0Br7SvE5jGOJE2 h55dq+LQ6RGAVGNXz3uDO9/RsoiR3LaSGRXVgrC9+bgNkjEouTyBfbrCO4U370CncWke dsAHA0PTubFVmfnk1noNvIv/EOGv3SrMuI4rYOVwn3NLSwhd9trkLB16s/gpEEzSew3k vyh0wmRGluzKgE4oMkn8nu/ptBRVjf10paWWd/jeL5ZNRn0jVJ5YIs51AQCVTwRnljXZ ww+Q== Received: by 10.68.195.167 with SMTP id if7mr5458950pbc.16.1343309310392; Thu, 26 Jul 2012 06:28:30 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-189-113.ip51.fastwebnet.it. [93.34.189.113]) by mx.google.com with ESMTPS id tl6sm14291567pbc.3.2012.07.26.06.28.26 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 26 Jul 2012 06:28:29 -0700 (PDT) From: Paolo Bonzini To: linux-kernel@vger.kernel.org Cc: linux-scsi@vger.kernel.org, kvm@vger.kernel.org, JBottomley@parallels.com, virtualization@lists.linux-foundation.org, Subject: [PATCH 1/2] virtio-scsi: fix LUNs greater than 255 Date: Thu, 26 Jul 2012 15:28:07 +0200 Message-Id: <1343309288-32615-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1343309288-32615-1-git-send-email-pbonzini@redhat.com> References: <1343309288-32615-1-git-send-email-pbonzini@redhat.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org virtio-scsi needs to report LUNs greater than 256 using the "flat" format. Because the Linux SCSI layer just maps the SCSI LUN to an u32, without any parsing, these end up in the range from 16640 to 32767. Fix max_lun to account for the possibility that logical unit numbers are encoded with the "flat" format. Cc: Signed-off-by: Paolo Bonzini --- drivers/scsi/virtio_scsi.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index c7030fb..8b6b927 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -677,7 +677,11 @@ static int __devinit virtscsi_probe(struct virtio_device *vdev) cmd_per_lun = virtscsi_config_get(vdev, cmd_per_lun) ?: 1; shost->cmd_per_lun = min_t(u32, cmd_per_lun, shost->can_queue); shost->max_sectors = virtscsi_config_get(vdev, max_sectors) ?: 0xFFFF; - shost->max_lun = virtscsi_config_get(vdev, max_lun) + 1; + + /* LUNs > 256 are reported with format 1, so they go in the range + * 16640-32767. + */ + shost->max_lun = virtscsi_config_get(vdev, max_lun) + 1 + 0x4000; shost->max_id = num_targets; shost->max_channel = 0; shost->max_cmd_len = VIRTIO_SCSI_CDB_SIZE;