From patchwork Wed Jun 18 00:17:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Merla, ShivaKrishna" X-Patchwork-Id: 4373521 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E8E549F36A for ; Wed, 18 Jun 2014 06:46:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E478320218 for ; Wed, 18 Jun 2014 06:46:22 +0000 (UTC) Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mail.kernel.org (Postfix) with ESMTP id 965E520148 for ; Wed, 18 Jun 2014 06:46:21 +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 s5I6fgET021396; Wed, 18 Jun 2014 02:41:43 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s5I0HUmG003235 for ; Tue, 17 Jun 2014 20:17:31 -0400 Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.16]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5I0HTwv027458 for ; Tue, 17 Jun 2014 20:17:29 -0400 Received: from mx11.netapp.com (mx11.netapp.com [216.240.18.76]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5I0HQXC001771 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Tue, 17 Jun 2014 20:17:27 -0400 X-IronPort-AV: E=Sophos;i="5.01,498,1400050800"; d="scan'208";a="129298072" Received: from vmwexceht03-prd.hq.netapp.com ([10.106.76.241]) by mx11-out.netapp.com with ESMTP; 17 Jun 2014 17:17:25 -0700 Received: from HIOEXCMBX03-PRD.hq.netapp.com (10.122.105.36) by vmwexceht03-prd.hq.netapp.com (10.106.76.241) with Microsoft SMTP Server (TLS) id 14.3.123.3; Tue, 17 Jun 2014 17:17:24 -0700 Received: from HIOEXCMBX01-PRD.hq.netapp.com (10.122.105.34) by hioexcmbx03-prd.hq.netapp.com (10.122.105.36) with Microsoft SMTP Server (TLS) id 15.0.847.32; Tue, 17 Jun 2014 17:17:12 -0700 Received: from HIOEXCMBX01-PRD.hq.netapp.com ([10.122.105.34]) by hioexcmbx01-prd.hq.netapp.com ([10.122.105.34]) with mapi id 15.00.0847.030; Tue, 17 Jun 2014 17:17:12 -0700 From: "Merla, ShivaKrishna" To: "christophe.varoqui@opensvc.com" Thread-Topic: [PATCH ] multipath: Fall back to getuid_callout if ID_SERIAL attribute is missing. Thread-Index: Ac+KiXNl46S21uIoT/etG0+rwud9KQ== Date: Wed, 18 Jun 2014 00:17:11 +0000 Message-ID: <229730203dc540ef9cae7b665577519c@hioexcmbx01-prd.hq.netapp.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.122.56.79] MIME-Version: 1.0 X-RedHat-Spam-Score: -3.312 (BAYES_00, DCC_REPUT_00_12, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.16 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id s5I0HUmG003235 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Wed, 18 Jun 2014 02:41:41 -0400 Cc: "dm-devel@redhat.com" Subject: [dm-devel] [PATCH ] multipath: Fall back to getuid_callout if ID_SERIAL attribute is missing. 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: , 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 Sometimes whenever a path is added, scsi_id call during udev rule processing can fail and ID_SERIAL attribute will not be set. This causes multipathd to add the path as orphan. We have seen several instances of this happening during testing. Jun 17 10:14:43 ictm-vader multipathd[474]: sda: uid_attribute = ID_SERIAL (config file default) Jun 17 10:14:43 ictm-vader multipathd[474]: sda: no ID_SERIAL attribute Jun 17 10:14:43 ictm-vader multipathd[474]: sda: uid = (udev) Jun 17 10:14:43 ictm-vader multipathd[474]: sda: no ID_SERIAL attribute Jun 17 10:14:43 ictm-vader multipathd[474]: sda: uid = (udev) Jun 17 10:14:43 ictm-vader multipathd[474]: sda: failed to get path uid Jun 17 10:14:43 ictm-vader multipathd[474]: sda: orphan path, failed to add path This patch handles this case by allowing to fall back to explict getuid_callout incase if ID_SERIAL attribute is not set. This way support for deprecated getuid_callout is not lost for older versions where ID_SERIAL attribute is not present but also serves good purpose in the scenario mentioned above. Signed-off-by: Shiva Krishna Merla --- libmultipath/defaults.h | 1 + libmultipath/discovery.c | 59 +++++++++++++++++++++------------------------ libmultipath/propsel.c | 29 ++++++++++++---------- 3 files changed, 45 insertions(+), 44 deletions(-) --- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel diff --git a/libmultipath/defaults.h b/libmultipath/defaults.h index b83d9fb..47bd7ba 100644 --- a/libmultipath/defaults.h +++ b/libmultipath/defaults.h @@ -1,4 +1,5 @@ #define DEFAULT_UID_ATTRIBUTE "ID_SERIAL" +#define DEFAULT_GETUID "/lib/udev/scsi_id --whitelisted --device=/dev/%n" #define DEFAULT_UDEVDIR "/dev" #define DEFAULT_MULTIPATHDIR "/" LIB_STRING "/multipath" #define DEFAULT_SELECTOR "service-time 0" diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index 786e1de..7cf674d 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -1098,7 +1098,8 @@ static int get_uid (struct path * pp) { char *c; - const char *origin; + const char *origin = "udev"; + const char *value; if (!pp->uid_attribute && !pp->getuid) select_getuid(pp); @@ -1109,40 +1110,36 @@ get_uid (struct path * pp) } memset(pp->wwid, 0, WWID_SIZE); - if (pp->getuid) { - char buff[CALLOUT_MAX_SIZE]; - - /* Use 'getuid' callout, deprecated */ - condlog(1, "%s: using deprecated getuid callout", pp->dev); - if (apply_format(pp->getuid, &buff[0], pp)) { - condlog(0, "error formatting uid callout command"); - memset(pp->wwid, 0, WWID_SIZE); - } else if (execute_program(buff, pp->wwid, WWID_SIZE)) { - condlog(3, "error calling out %s", buff); - memset(pp->wwid, 0, WWID_SIZE); + + value = udev_device_get_property_value(pp->udev, + pp->uid_attribute); + if ((!value || strlen(value) == 0) && conf->dry_run == 2) + value = getenv(pp->uid_attribute); + if (value && strlen(value)) { + size_t len = WWID_SIZE; + + if (strlen(value) + 1 > WWID_SIZE) { + condlog(0, "%s: wwid overflow", pp->dev); + } else { + len = strlen(value); } - origin = "callout"; + strncpy(pp->wwid, value, len); } else { - const char *value; - - value = udev_device_get_property_value(pp->udev, - pp->uid_attribute); - if ((!value || strlen(value) == 0) && conf->dry_run == 2) - value = getenv(pp->uid_attribute); - if (value && strlen(value)) { - size_t len = WWID_SIZE; - - if (strlen(value) + 1 > WWID_SIZE) { - condlog(0, "%s: wwid overflow", pp->dev); - } else { - len = strlen(value); + condlog(3, "%s: no %s attribute", pp->dev, + pp->uid_attribute); + if (pp->getuid) { + char buff[CALLOUT_MAX_SIZE]; + /* Use 'getuid' callout, deprecated */ + condlog(1, "%s: using deprecated getuid callout", pp->dev); + if (apply_format(pp->getuid, &buff[0], pp)) { + condlog(0, "error formatting uid callout command"); + memset(pp->wwid, 0, WWID_SIZE); + } else if (execute_program(buff, pp->wwid, WWID_SIZE)) { + condlog(3, "error calling out %s", buff); + memset(pp->wwid, 0, WWID_SIZE); } - strncpy(pp->wwid, value, len); - } else { - condlog(3, "%s: no %s attribute", pp->dev, - pp->uid_attribute); + origin = "callout"; } - origin = "udev"; } /* Strip any trailing blanks */ c = strchr(pp->wwid, '\0'); diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c index ee6cea6..b8a155c 100644 --- a/libmultipath/propsel.c +++ b/libmultipath/propsel.c @@ -379,29 +379,32 @@ select_getuid (struct path * pp) pp->uid_attribute = pp->hwe->uid_attribute; condlog(3, "%s: uid_attribute = %s (controller setting)", pp->dev, pp->uid_attribute); - return 0; + } + else if (conf->uid_attribute) { + pp->uid_attribute = conf->uid_attribute; + condlog(3, "%s: uid_attribute = %s (config file default)", + pp->dev, pp->uid_attribute); + } + else { + pp->uid_attribute = STRDUP(DEFAULT_UID_ATTRIBUTE); + condlog(3, "%s: uid_attribute = %s (internal default)", + pp->dev, pp->uid_attribute); } if (pp->hwe && pp->hwe->getuid) { pp->getuid = pp->hwe->getuid; condlog(3, "%s: getuid = %s (deprecated) (controller setting)", pp->dev, pp->getuid); - return 0; } - if (conf->uid_attribute) { - pp->uid_attribute = conf->uid_attribute; - condlog(3, "%s: uid_attribute = %s (config file default)", - pp->dev, pp->uid_attribute); - return 0; - } - if (conf->getuid) { + else if (conf->getuid) { pp->getuid = conf->getuid; condlog(3, "%s: getuid = %s (deprecated) (config file default)", pp->dev, pp->getuid); - return 0; } - pp->uid_attribute = STRDUP(DEFAULT_UID_ATTRIBUTE); - condlog(3, "%s: uid_attribute = %s (internal default)", - pp->dev, pp->uid_attribute); + else { + pp->getuid = STRDUP(DEFAULT_GETUID); + condlog(3, "%s: getuid = %s (deprecated) (internal default)", + pp->dev, pp->getuid); + } return 0; } --