From patchwork Wed May 4 06:58:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Mackerras X-Patchwork-Id: 9011721 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 021E69F1D3 for ; Wed, 4 May 2016 09:21:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 41AC720392 for ; Wed, 4 May 2016 09:21:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 12E1C2038E for ; Wed, 4 May 2016 09:21:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757151AbcEDJVL (ORCPT ); Wed, 4 May 2016 05:21:11 -0400 Received: from ozlabs.org ([103.22.144.67]:38700 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757124AbcEDJVK (ORCPT ); Wed, 4 May 2016 05:21:10 -0400 Received: by ozlabs.org (Postfix, from userid 1003) id 3r0CFw2hQpz9t5w; Wed, 4 May 2016 19:21:08 +1000 (AEST) Date: Wed, 4 May 2016 16:58:30 +1000 From: Paul Mackerras To: Hannes Reinecke Cc: linux-scsi@vger.kernel.org Subject: [PATCH] scsi: Make scsi_vpd_lun_id() able to use T10 vendor ID based designators Message-ID: <20160504065830.GB19436@oak.ozlabs.ibm.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-9.0 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 This adds code to scsi_vpd_lun_id() to enable it to use T10 vendor ID based designators. This is needed to allow alua to work on disks that don't have any designators of type 2, 3 or 8. Commit 0047220c6c36 ("scsi_dh_alua: use unique device id", 2016-02-19) added a requirement that alua can only be used on disks for which scsi_vpd_lun_id() can produce an identifying string. Signed-off-by: Paul Mackerras --- drivers/scsi/scsi_lib.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 8106515..f4f69cc 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -3214,6 +3214,20 @@ int scsi_vpd_lun_id(struct scsi_device *sdev, char *id, size_t id_len) goto next_desig; switch (d[1] & 0xf) { + case 0x1: + /* T10 vendor ID */ + if (cur_id_size > d[3]) + break; + /* Prefer EUI-64 or NAA IEEE Registered Extended */ + if ((cur_id_type == 0x2 || cur_id_type == 0x3) && + cur_id_size == d[3]) + break; + cur_id_size = d[3]; + cur_id_str = d + 4; + cur_id_type = d[1] & 0xf; + id_size = snprintf(id, id_len, "%*phN", cur_id_size, + cur_id_str); + break; case 0x2: /* EUI-64 */ if (cur_id_size > d[3])