From patchwork Mon Mar 16 12:36:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 6017981 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Original-To: patchwork-dm-devel@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 9FC049F691 for ; Mon, 16 Mar 2015 12:43:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D6A22204C9 for ; Mon, 16 Mar 2015 12:43:36 +0000 (UTC) Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ED36C204D5 for ; Mon, 16 Mar 2015 12:43:35 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id t2GCcVG2028018; Mon, 16 Mar 2015 08:38:31 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id t2GCbKRI028951 for ; Mon, 16 Mar 2015 08:37:20 -0400 Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2GCbKxn004232 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 16 Mar 2015 08:37:20 -0400 Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by mx1.redhat.com (Postfix) with ESMTPS id A45F931CEA1; Mon, 16 Mar 2015 12:37:19 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 51005ADFB; Mon, 16 Mar 2015 12:37:11 +0000 (UTC) From: Hannes Reinecke To: Christophe Varoqui Date: Mon, 16 Mar 2015 13:36:58 +0100 Message-Id: <1426509425-15978-72-git-send-email-hare@suse.de> In-Reply-To: <1426509425-15978-1-git-send-email-hare@suse.de> References: <1426509425-15978-1-git-send-email-hare@suse.de> X-RedHat-Spam-Score: -7.309 (BAYES_00, DCC_REPUT_00_12, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, URIBL_BLOCKED) 195.135.220.15 cantor2.suse.de 195.135.220.15 cantor2.suse.de X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Scanned-By: MIMEDefang 2.75 on 10.5.110.27 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com Subject: [dm-devel] [PATCH 71/78] Do not automatically fall back to vpd uid generation X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 When a wwid via uid_attribute cannot be generated we should not fall back to using sysfs vpd attributes automatically. The uid_attribute can be set to virtually anything and an automatic fallback will then generated a different wwid, leading to an incorrect setup. A fallback is only valid if the uid_attribute value is the default setting of 'ID_SERIAL', for which the format is fixed. Signed-off-by: Hannes Reinecke --- libmultipath/discovery.c | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index 009ef0c..d1a16e6 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -1509,7 +1509,7 @@ static int get_uid (struct path * pp) { char *c; - const char *origin = "none"; + const char *origin = "unknown"; ssize_t len = 0; if (!pp->uid_attribute && !pp->getuid) @@ -1542,35 +1542,28 @@ get_uid (struct path * pp) len = get_udev_uid(pp, pp->uid_attribute); origin = "udev"; if (len <= 0) - condlog(2, - "%s: failed to get UID attribute '%s'", - pp->dev, pp->uid_attribute); + condlog(1, + "%s: failed to get udev uid: %s", + pp->dev, strerror(-len)); + } - if (len <= 0) { + if (len <= 0 && + !strcmp(pp->uid_attribute, DEFAULT_UID_ATTRIBUTE)) { len = get_vpd_uid(pp); - if (len > 0) { - origin = "sysfs"; - pp->uid_attribute = NULL; - } else { - condlog(2, "%s: failed to get sysfs vpd pg83", - pp->dev); - } - } - if (len <= 0) { - len = get_vpd_sgio(pp->fd, 0x83, pp->wwid, - WWID_SIZE); - if (len > 0) { + origin = "sysfs"; + pp->uid_attribute = NULL; + if (len < 0) { + condlog(1, "%s: failed to get sysfs uid: %s", + pp->dev, strerror(-len)); + len = get_vpd_sgio(pp->fd, 0x83, pp->wwid, + WWID_SIZE); origin = "sgio"; - pp->uid_attribute = NULL; - } else { - condlog(2, "%s: failed to get sgio vpd pg83", - pp->dev); } } } if ( len < 0 ) { - condlog(1, "%s: failed to get uid: %s", - pp->dev, strerror(-len)); + condlog(1, "%s: failed to get %s uid: %s", + pp->dev, origin, strerror(-len)); memset(pp->wwid, 0x0, WWID_SIZE); } else { /* Strip any trailing blanks */