From patchwork Thu Jul 9 10:36:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 11654109 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9359014F6 for ; Thu, 9 Jul 2020 10:37:02 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3DF17206DF for ; Thu, 9 Jul 2020 10:37:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3DF17206DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-175-kg54YQ3cPf2xilq6hV4r_A-1; Thu, 09 Jul 2020 06:36:58 -0400 X-MC-Unique: kg54YQ3cPf2xilq6hV4r_A-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3DCE118FF66C; Thu, 9 Jul 2020 10:36:52 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 228BE5C1C3; Thu, 9 Jul 2020 10:36:52 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id ECA671809561; Thu, 9 Jul 2020 10:36:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 069AalCi031572 for ; Thu, 9 Jul 2020 06:36:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id B1C82100321C; Thu, 9 Jul 2020 10:36:47 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AB7E3114B2FE for ; Thu, 9 Jul 2020 10:36:44 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A76C28007CA for ; Thu, 9 Jul 2020 10:36:44 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-353-igGVIKoeNKm0BSTNy3MHCQ-1; Thu, 09 Jul 2020 06:36:42 -0400 X-MC-Unique: igGVIKoeNKm0BSTNy3MHCQ-1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 74C71AE44; Thu, 9 Jul 2020 10:36:40 +0000 (UTC) From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Thu, 9 Jul 2020 12:36:12 +0200 Message-Id: <20200709103623.8302-2-mwilck@suse.com> In-Reply-To: <20200709103623.8302-1-mwilck@suse.com> References: <20200709103623.8302-1-mwilck@suse.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 069AalCi031572 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH 43/54] libmultipath: adopt_paths(): use find_path_by_devt() X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck pp->dev_t is the primary identifying property for both dm and udev. Use it here, too. Signed-off-by: Martin Wilck --- libmultipath/structs_vec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c index c7dffb7..55fca9b 100644 --- a/libmultipath/structs_vec.c +++ b/libmultipath/structs_vec.c @@ -75,7 +75,7 @@ int adopt_paths(vector pathvec, struct multipath *mpp) if (!mpp->paths && !(mpp->paths = vector_alloc())) return 1; - if (!find_path_by_dev(mpp->paths, pp->dev) && + if (!find_path_by_devt(mpp->paths, pp->dev_t) && store_path(mpp->paths, pp)) return 1; conf = get_multipath_config(); From patchwork Thu Jul 9 10:36:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 11654103 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8EEED92A for ; Thu, 9 Jul 2020 10:36:57 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 45E3020772 for ; Thu, 9 Jul 2020 10:36:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 45E3020772 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-166-Wj9ywNDuOdO_bka6OaKImQ-1; Thu, 09 Jul 2020 06:36:53 -0400 X-MC-Unique: Wj9ywNDuOdO_bka6OaKImQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 92B3E1083; Thu, 9 Jul 2020 10:36:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 78AAF5D9C9; Thu, 9 Jul 2020 10:36:49 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 29ED193F85; Thu, 9 Jul 2020 10:36:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 069Aal2c031565 for ; Thu, 9 Jul 2020 06:36:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 28B112156A59; Thu, 9 Jul 2020 10:36:47 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1D8C52157F24 for ; Thu, 9 Jul 2020 10:36:45 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F016A8007C9 for ; Thu, 9 Jul 2020 10:36:44 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-84-E3wslXh4Obu9XBYySdkCww-1; Thu, 09 Jul 2020 06:36:42 -0400 X-MC-Unique: E3wslXh4Obu9XBYySdkCww-1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B0366AE65; Thu, 9 Jul 2020 10:36:40 +0000 (UTC) From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Thu, 9 Jul 2020 12:36:13 +0200 Message-Id: <20200709103623.8302-3-mwilck@suse.com> In-Reply-To: <20200709103623.8302-1-mwilck@suse.com> References: <20200709103623.8302-1-mwilck@suse.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 069Aal2c031565 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH 44/54] libmultipath: adopt_paths(): don't bail out on single path failure X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck If pathinfo fails for one path to be adopted, we currently fail the entire function. This may cause ev_add_path() for a valid path to fail because some other path is broken. Fix it by just skipping paths that don't look healthy. Signed-off-by: Martin Wilck --- libmultipath/structs_vec.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c index 55fca9b..bc47d1e 100644 --- a/libmultipath/structs_vec.c +++ b/libmultipath/structs_vec.c @@ -75,16 +75,20 @@ int adopt_paths(vector pathvec, struct multipath *mpp) if (!mpp->paths && !(mpp->paths = vector_alloc())) return 1; - if (!find_path_by_devt(mpp->paths, pp->dev_t) && - store_path(mpp->paths, pp)) - return 1; conf = get_multipath_config(); pthread_cleanup_push(put_multipath_config, conf); ret = pathinfo(pp, conf, DI_PRIO | DI_CHECKER); pthread_cleanup_pop(1); - if (ret) - return 1; + if (ret) { + condlog(3, "%s: pathinfo failed for %s", + __func__, pp->dev); + continue; + } + + if (!find_path_by_devt(mpp->paths, pp->dev_t) && + store_path(mpp->paths, pp)) + return 1; } } return 0; From patchwork Thu Jul 9 10:36:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 11654099 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4FD3B13B1 for ; Thu, 9 Jul 2020 10:36:57 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 01A27206DF for ; Thu, 9 Jul 2020 10:36:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 01A27206DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-381-vtIjpebuPOyP0Z-5ZAKXCg-1; Thu, 09 Jul 2020 06:36:54 -0400 X-MC-Unique: vtIjpebuPOyP0Z-5ZAKXCg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 81CE48015CE; Thu, 9 Jul 2020 10:36:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6238310013C2; Thu, 9 Jul 2020 10:36:49 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C63B71809547; Thu, 9 Jul 2020 10:36:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 069AalZL031571 for ; Thu, 9 Jul 2020 06:36:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id AC82C217B436; Thu, 9 Jul 2020 10:36:47 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A471B217B435 for ; Thu, 9 Jul 2020 10:36:47 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7D597856A59 for ; Thu, 9 Jul 2020 10:36:47 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-139-QHat-VeLMbamBFHxuMQP0Q-1; Thu, 09 Jul 2020 06:36:42 -0400 X-MC-Unique: QHat-VeLMbamBFHxuMQP0Q-1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id EF4C5AE6F; Thu, 9 Jul 2020 10:36:40 +0000 (UTC) From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Thu, 9 Jul 2020 12:36:14 +0200 Message-Id: <20200709103623.8302-4-mwilck@suse.com> In-Reply-To: <20200709103623.8302-1-mwilck@suse.com> References: <20200709103623.8302-1-mwilck@suse.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 069AalZL031571 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH 45/54] libmultipath: path_discover(): use find_path_by_devt() X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk 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-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck In path_discover(), it's actually expected that a the path to be discovered is not already in pathvec. So, do search by devt in the first place rather than searching twice. Signed-off-by: Martin Wilck --- libmultipath/discovery.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index e26aae2..5f4ebf0 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -125,27 +125,19 @@ static int path_discover (vector pathvec, struct config * conf, struct udev_device *udevice, int flag) { - struct path * pp; - const char * devname; - - devname = udev_device_get_sysname(udevice); - if (!devname) - return PATHINFO_FAILED; - - pp = find_path_by_dev(pathvec, devname); - if (!pp) { - char devt[BLK_DEV_SIZE]; - dev_t devnum = udev_device_get_devnum(udevice); + struct path *pp; + char devt[BLK_DEV_SIZE]; + dev_t devnum = udev_device_get_devnum(udevice); - snprintf(devt, BLK_DEV_SIZE, "%d:%d", - major(devnum), minor(devnum)); - pp = find_path_by_devt(pathvec, devt); - if (!pp) - return store_pathinfo(pathvec, conf, - udevice, flag | DI_BLACKLIST, - NULL); - } - return pathinfo(pp, conf, flag); + snprintf(devt, BLK_DEV_SIZE, "%d:%d", + major(devnum), minor(devnum)); + pp = find_path_by_devt(pathvec, devt); + if (!pp) + return store_pathinfo(pathvec, conf, + udevice, flag | DI_BLACKLIST, + NULL); + else + return pathinfo(pp, conf, flag); } static void cleanup_udev_enumerate_ptr(void *arg) From patchwork Thu Jul 9 10:36:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 11654105 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C24B713B1 for ; Thu, 9 Jul 2020 10:36:59 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7936B206DF for ; Thu, 9 Jul 2020 10:36:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7936B206DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-328-_N1ThRBZPZuOS9MWH0Af1Q-1; Thu, 09 Jul 2020 06:36:56 -0400 X-MC-Unique: _N1ThRBZPZuOS9MWH0Af1Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3937B88C7A1; Thu, 9 Jul 2020 10:36:52 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1A48C90E65; Thu, 9 Jul 2020 10:36:52 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E394E1809554; Thu, 9 Jul 2020 10:36:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 069Aalmi031578 for ; Thu, 9 Jul 2020 06:36:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id CA1782166BA4; Thu, 9 Jul 2020 10:36:47 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C642A2166B28 for ; Thu, 9 Jul 2020 10:36:47 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A3BC58007B3 for ; Thu, 9 Jul 2020 10:36:47 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-40-7mBgBSriP0SvlE76X4Awuw-1; Thu, 09 Jul 2020 06:36:43 -0400 X-MC-Unique: 7mBgBSriP0SvlE76X4Awuw-1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 36AA6AE78; Thu, 9 Jul 2020 10:36:41 +0000 (UTC) From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Thu, 9 Jul 2020 12:36:15 +0200 Message-Id: <20200709103623.8302-5-mwilck@suse.com> In-Reply-To: <20200709103623.8302-1-mwilck@suse.com> References: <20200709103623.8302-1-mwilck@suse.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 069Aalmi031578 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH 46/54] libmultipath: path_discover(): always set DI_BLACKLIST X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck Since 65e1845 ("multipath: call store_pathinfo with DI_BLACKLIST"), we use DI_BLACKLIST for new paths. There's no reason why we shouldn't do the same with paths which are (unexpectedly) already in pathvec. As argued for 65e1845, this might save some unnecessary work for paths which are blacklisted anyway. Signed-off-by: Martin Wilck --- libmultipath/discovery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index 5f4ebf0..caabfef 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -137,7 +137,7 @@ path_discover (vector pathvec, struct config * conf, udevice, flag | DI_BLACKLIST, NULL); else - return pathinfo(pp, conf, flag); + return pathinfo(pp, conf, flag | DI_BLACKLIST); } static void cleanup_udev_enumerate_ptr(void *arg) From patchwork Thu Jul 9 10:36:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 11654107 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3991E92A for ; Thu, 9 Jul 2020 10:37:02 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DF021206DF for ; Thu, 9 Jul 2020 10:37:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF021206DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-71-K_VEmIYxOzCDgEcPemBHcw-1; Thu, 09 Jul 2020 06:36:56 -0400 X-MC-Unique: K_VEmIYxOzCDgEcPemBHcw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3D1F618FF66B; Thu, 9 Jul 2020 10:36:52 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1D97590E66; Thu, 9 Jul 2020 10:36:52 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E81C193F90; Thu, 9 Jul 2020 10:36:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 069Aam0L031601 for ; Thu, 9 Jul 2020 06:36:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id D65752166BA4; Thu, 9 Jul 2020 10:36:48 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D28C62166B28 for ; Thu, 9 Jul 2020 10:36:48 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B16E68EF3A5 for ; Thu, 9 Jul 2020 10:36:48 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-231--qOh-7hPMDijc1HAzaq56A-1; Thu, 09 Jul 2020 06:36:44 -0400 X-MC-Unique: -qOh-7hPMDijc1HAzaq56A-1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 76B3DAE7A; Thu, 9 Jul 2020 10:36:41 +0000 (UTC) From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Thu, 9 Jul 2020 12:36:16 +0200 Message-Id: <20200709103623.8302-6-mwilck@suse.com> In-Reply-To: <20200709103623.8302-1-mwilck@suse.com> References: <20200709103623.8302-1-mwilck@suse.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 069Aam0L031601 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH 47/54] libmultipath: get_refwwid(): use find_path_by_devt() X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck If get_refwwid is called with a dev_t argument, there's no point in converting it into a devname first. If the device doesn't exist, get_udev_device() will fail. Signed-off-by: Martin Wilck --- libmultipath/configure.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index 75e11fd..e8d6db8 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -1414,17 +1414,15 @@ int get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, if (dev_type == DEV_DEVT) { strchop(dev); - if (devt2devname(buff, FILE_NAME_SIZE, dev)) { - condlog(0, "%s: cannot find block device\n", dev); - return 1; - } - pp = find_path_by_dev(pathvec, buff); + pp = find_path_by_devt(pathvec, dev); if (!pp) { struct udev_device *udevice = get_udev_device(dev, dev_type); - if (!udevice) + if (!udevice) { + condlog(0, "%s: cannot find block device", dev); return 1; + } conf = get_multipath_config(); pthread_cleanup_push(put_multipath_config, conf); From patchwork Thu Jul 9 10:36:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 11654117 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 377E192A for ; Thu, 9 Jul 2020 10:37:11 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E2324206DF for ; Thu, 9 Jul 2020 10:37:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E2324206DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-356-RzCcgP-QP8OdX1ZvY7qjzw-1; Thu, 09 Jul 2020 06:37:07 -0400 X-MC-Unique: RzCcgP-QP8OdX1ZvY7qjzw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C99CF18FF660; Thu, 9 Jul 2020 10:36:57 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A64BE610AF; Thu, 9 Jul 2020 10:36:57 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 795A31806B0D; Thu, 9 Jul 2020 10:36:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 069AaoTU031649 for ; Thu, 9 Jul 2020 06:36:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2F9AA208DD80; Thu, 9 Jul 2020 10:36:50 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2B58A2026D69 for ; Thu, 9 Jul 2020 10:36:47 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2FC19100E7C1 for ; Thu, 9 Jul 2020 10:36:47 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-32-9sv2N6R3MDKXq-iDH9GDQw-1; Thu, 09 Jul 2020 06:36:44 -0400 X-MC-Unique: 9sv2N6R3MDKXq-iDH9GDQw-1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B5206AE7F; Thu, 9 Jul 2020 10:36:41 +0000 (UTC) From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Thu, 9 Jul 2020 12:36:17 +0200 Message-Id: <20200709103623.8302-7-mwilck@suse.com> In-Reply-To: <20200709103623.8302-1-mwilck@suse.com> References: <20200709103623.8302-1-mwilck@suse.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 069AaoTU031649 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH 48/54] libmultipath: get_refwwid(): call get_multipath_config() only once X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck rather than 7 times in a single function. In get_refwwid(), the code that is not run under the RCU read lock is negligible, so we might as well keep the lock. The "invalid" variable becomes obsolete by this change. Signed-off-by: Martin Wilck --- libmultipath/configure.c | 60 ++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 39 deletions(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index e8d6db8..c4712d7 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -1344,22 +1344,14 @@ struct udev_device *get_udev_device(const char *dev, enum devtypes dev_type) return ud; } -/* - * returns: - * 0 - success - * 1 - failure - * 2 - blacklist - */ -int get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, - vector pathvec, char **wwid) +static int _get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, + vector pathvec, struct config *conf, char **wwid) { int ret = 1; struct path * pp; char buff[FILE_NAME_SIZE]; char * refwwid = NULL, tmpwwid[WWID_SIZE]; int flags = DI_SYSFS | DI_WWID; - struct config *conf; - int invalid = 0; if (!wwid) return 1; @@ -1386,11 +1378,8 @@ int get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, if (!udevice) return 1; - conf = get_multipath_config(); - pthread_cleanup_push(put_multipath_config, conf); ret = store_pathinfo(pathvec, conf, udevice, flags, &pp); - pthread_cleanup_pop(1); udev_device_unref(udevice); if (!pp) { if (ret == 1) @@ -1399,13 +1388,8 @@ int get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, return ret; } } - conf = get_multipath_config(); - pthread_cleanup_push(put_multipath_config, conf); if (pp->udev && pp->uid_attribute && filter_property(conf, pp->udev, 3, pp->uid_attribute) > 0) - invalid = 1; - pthread_cleanup_pop(1); - if (invalid) return 2; refwwid = pp->wwid; @@ -1424,11 +1408,8 @@ int get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, return 1; } - conf = get_multipath_config(); - pthread_cleanup_push(put_multipath_config, conf); ret = store_pathinfo(pathvec, conf, udevice, flags, &pp); - pthread_cleanup_pop(1); udev_device_unref(udevice); if (!pp) { if (ret == 1) @@ -1437,13 +1418,8 @@ int get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, return ret; } } - conf = get_multipath_config(); - pthread_cleanup_push(put_multipath_config, conf); if (pp->udev && pp->uid_attribute && filter_property(conf, pp->udev, 3, pp->uid_attribute) > 0) - invalid = 1; - pthread_cleanup_pop(1); - if (invalid) return 2; refwwid = pp->wwid; goto out; @@ -1455,24 +1431,16 @@ int get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, if (!udevice) return 1; - conf = get_multipath_config(); - pthread_cleanup_push(put_multipath_config, conf); ret = store_pathinfo(pathvec, conf, udevice, flags, &pp); - pthread_cleanup_pop(1); udev_device_unref(udevice); if (!pp) { if (ret == 1) condlog(0, "%s: can't store path info", dev); return ret; } - conf = get_multipath_config(); - pthread_cleanup_push(put_multipath_config, conf); if (pp->udev && pp->uid_attribute && filter_property(conf, pp->udev, 3, pp->uid_attribute) > 0) - invalid = 1; - pthread_cleanup_pop(1); - if (invalid) return 2; refwwid = pp->wwid; goto out; @@ -1480,8 +1448,6 @@ int get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, if (dev_type == DEV_DEVMAP) { - conf = get_multipath_config(); - pthread_cleanup_push(put_multipath_config, conf); if (((dm_get_uuid(dev, tmpwwid, WWID_SIZE)) == 0) && (strlen(tmpwwid))) { refwwid = tmpwwid; @@ -1512,9 +1478,6 @@ check: if (refwwid && strlen(refwwid) && filter_wwid(conf->blist_wwid, conf->elist_wwid, refwwid, NULL) > 0) - invalid = 1; - pthread_cleanup_pop(1); - if (invalid) return 2; } out: @@ -1526,6 +1489,25 @@ out: return 1; } +/* + * returns: + * 0 - success + * 1 - failure + * 2 - blacklist + */ +int get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, + vector pathvec, char **wwid) + +{ + int ret; + struct config *conf = get_multipath_config(); + + pthread_cleanup_push(put_multipath_config, conf); + ret = _get_refwwid(cmd, dev, dev_type, pathvec, conf, wwid); + pthread_cleanup_pop(1); + return ret; +} + int reload_map(struct vectors *vecs, struct multipath *mpp, int refresh, int is_daemon) { From patchwork Thu Jul 9 10:36:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 11654121 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B0D592A for ; Thu, 9 Jul 2020 10:37:14 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C66A2206DF for ; Thu, 9 Jul 2020 10:37:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C66A2206DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-456-kEYqt7j_PpWaMouEIRJi3Q-1; Thu, 09 Jul 2020 06:37:10 -0400 X-MC-Unique: kEYqt7j_PpWaMouEIRJi3Q-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D8EEB108BD17; Thu, 9 Jul 2020 10:36:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B9C29610F3; Thu, 9 Jul 2020 10:36:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8F5801809563; Thu, 9 Jul 2020 10:36:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 069AanaZ031620 for ; Thu, 9 Jul 2020 06:36:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6608F2157F25; Thu, 9 Jul 2020 10:36:49 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 621852166B28 for ; Thu, 9 Jul 2020 10:36:49 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3BAE218056A2 for ; Thu, 9 Jul 2020 10:36:49 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-283-jAj8ZvP3NoGT5a-hgYwFAA-1; Thu, 09 Jul 2020 06:36:44 -0400 X-MC-Unique: jAj8ZvP3NoGT5a-hgYwFAA-1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 3C0F7AE83; Thu, 9 Jul 2020 10:36:42 +0000 (UTC) From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Thu, 9 Jul 2020 12:36:19 +0200 Message-Id: <20200709103623.8302-9-mwilck@suse.com> In-Reply-To: <20200709103623.8302-1-mwilck@suse.com> References: <20200709103623.8302-1-mwilck@suse.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 069AanaZ031620 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH 50/54] libmultipath: get_refwwid(): use symbolic return values X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck The return values of get_refwwid() are the same as those of pathinfo(). So use them. Signed-off-by: Martin Wilck --- libmultipath/configure.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index defc54b..e68494b 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -1354,11 +1354,11 @@ static int _get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, int flags = DI_SYSFS | DI_WWID; if (!wwid) - return 1; + return PATHINFO_FAILED; *wwid = NULL; if (dev_type == DEV_NONE) - return 1; + return PATHINFO_FAILED; if (cmd != CMD_REMOVE_WWID) flags |= DI_BLACKLIST; @@ -1367,7 +1367,7 @@ static int _get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, if (basenamecpy(dev, buff, FILE_NAME_SIZE) == 0) { condlog(1, "basename failed for '%s' (%s)", dev, buff); - return 1; + return PATHINFO_FAILED; } pp = find_path_by_dev(pathvec, buff); @@ -1376,13 +1376,13 @@ static int _get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, get_udev_device(buff, dev_type); if (!udevice) - return 1; + return PATHINFO_FAILED; ret = store_pathinfo(pathvec, conf, udevice, flags, &pp); udev_device_unref(udevice); if (!pp) { - if (ret == 1) + if (ret == PATHINFO_FAILED) condlog(0, "%s: can't store path info", dev); return ret; @@ -1390,7 +1390,7 @@ static int _get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, } if (pp->udev && pp->uid_attribute && filter_property(conf, pp->udev, 3, pp->uid_attribute) > 0) - return 2; + return PATHINFO_SKIPPED; refwwid = pp->wwid; goto out; @@ -1405,14 +1405,14 @@ static int _get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, if (!udevice) { condlog(0, "%s: cannot find block device", dev); - return 1; + return PATHINFO_FAILED; } ret = store_pathinfo(pathvec, conf, udevice, flags, &pp); udev_device_unref(udevice); if (!pp) { - if (ret == 1) + if (ret == PATHINFO_FAILED) condlog(0, "%s can't store path info", buff); return ret; @@ -1420,7 +1420,7 @@ static int _get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, } if (pp->udev && pp->uid_attribute && filter_property(conf, pp->udev, 3, pp->uid_attribute) > 0) - return 2; + return PATHINFO_SKIPPED; refwwid = pp->wwid; goto out; } @@ -1429,19 +1429,19 @@ static int _get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, struct udev_device *udevice = get_udev_device(dev, dev_type); if (!udevice) - return 1; + return PATHINFO_FAILED; ret = store_pathinfo(pathvec, conf, udevice, flags, &pp); udev_device_unref(udevice); if (!pp) { - if (ret == 1) + if (ret == PATHINFO_FAILED) condlog(0, "%s: can't store path info", dev); return ret; } if (pp->udev && pp->uid_attribute && filter_property(conf, pp->udev, 3, pp->uid_attribute) > 0) - return 2; + return PATHINFO_SKIPPED; refwwid = pp->wwid; goto out; } @@ -1469,22 +1469,19 @@ static int _get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, if (refwwid && strlen(refwwid) && filter_wwid(conf->blist_wwid, conf->elist_wwid, refwwid, NULL) > 0) - return 2; + return PATHINFO_SKIPPED; } out: if (refwwid && strlen(refwwid)) { *wwid = STRDUP(refwwid); - return 0; + return PATHINFO_OK; } - return 1; + return PATHINFO_FAILED; } /* - * returns: - * 0 - success - * 1 - failure - * 2 - blacklist + * Returns: PATHINFO_OK, PATHINFO_FAILED, or PATHINFO_SKIPPED (see pathinfo()) */ int get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, vector pathvec, char **wwid) From patchwork Thu Jul 9 10:36:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 11654111 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A32B92A for ; Thu, 9 Jul 2020 10:37:05 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 117B4206DF for ; Thu, 9 Jul 2020 10:37:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 117B4206DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-346-Z4DFx8qZPQufId8W9P4CAA-1; Thu, 09 Jul 2020 06:37:02 -0400 X-MC-Unique: Z4DFx8qZPQufId8W9P4CAA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0D210108BD1D; Thu, 9 Jul 2020 10:36:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E351B6FED8; Thu, 9 Jul 2020 10:36:53 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BDEA293F90; Thu, 9 Jul 2020 10:36:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 069AanmO031612 for ; Thu, 9 Jul 2020 06:36:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 36F0C1000DAA; Thu, 9 Jul 2020 10:36:49 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 330EF100405E for ; Thu, 9 Jul 2020 10:36:49 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0EC5080CDDF for ; Thu, 9 Jul 2020 10:36:49 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-292-tk4P7jyMO7u_IwM1mzSB-g-1; Thu, 09 Jul 2020 06:36:44 -0400 X-MC-Unique: tk4P7jyMO7u_IwM1mzSB-g-1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 764DBAEBF; Thu, 9 Jul 2020 10:36:42 +0000 (UTC) From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Thu, 9 Jul 2020 12:36:20 +0200 Message-Id: <20200709103623.8302-10-mwilck@suse.com> In-Reply-To: <20200709103623.8302-1-mwilck@suse.com> References: <20200709103623.8302-1-mwilck@suse.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 069AanmO031612 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH 51/54] libmultipath: get_refwwid(): use switch statement X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck This code calls for a switch. Some additional compaction is possible by observing that the code for DEV_DEVNODE, DEV_DEVT, and DEV_UEVENT is almost the same, and factoring it out into a "common" section. Doing this with a goto inside the switch statement is a bit unusual, but shows the intention of the code more clearly than other variants I tried. Signed-off-by: Martin Wilck --- libmultipath/configure.c | 81 ++++++++++++---------------------------- 1 file changed, 24 insertions(+), 57 deletions(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index e68494b..db9a255 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -1351,6 +1351,7 @@ static int _get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, struct path * pp; char buff[FILE_NAME_SIZE]; char * refwwid = NULL, tmpwwid[WWID_SIZE]; + struct udev_device *udevice; int flags = DI_SYSFS | DI_WWID; if (!wwid) @@ -1363,45 +1364,31 @@ static int _get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, if (cmd != CMD_REMOVE_WWID) flags |= DI_BLACKLIST; - if (dev_type == DEV_DEVNODE) { + switch (dev_type) { + case DEV_DEVNODE: if (basenamecpy(dev, buff, FILE_NAME_SIZE) == 0) { condlog(1, "basename failed for '%s' (%s)", dev, buff); return PATHINFO_FAILED; } - pp = find_path_by_dev(pathvec, buff); - if (!pp) { - struct udev_device *udevice = - get_udev_device(buff, dev_type); + /* dev is used in common code below */ + dev = buff; + pp = find_path_by_dev(pathvec, dev); + goto common; - if (!udevice) - return PATHINFO_FAILED; - - ret = store_pathinfo(pathvec, conf, udevice, - flags, &pp); - udev_device_unref(udevice); - if (!pp) { - if (ret == PATHINFO_FAILED) - condlog(0, "%s: can't store path info", - dev); - return ret; - } - } - if (pp->udev && pp->uid_attribute && - filter_property(conf, pp->udev, 3, pp->uid_attribute) > 0) - return PATHINFO_SKIPPED; - - refwwid = pp->wwid; - goto out; - } - - if (dev_type == DEV_DEVT) { + case DEV_DEVT: strchop(dev); pp = find_path_by_devt(pathvec, dev); + goto common; + + case DEV_UEVENT: + pp = NULL; + /* For condlog below, dev is unused in get_udev_device() */ + dev = "environment"; + common: if (!pp) { - struct udev_device *udevice = - get_udev_device(dev, dev_type); + udevice = get_udev_device(dev, dev_type); if (!udevice) { condlog(0, "%s: cannot find block device", dev); @@ -1413,8 +1400,8 @@ static int _get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, udev_device_unref(udevice); if (!pp) { if (ret == PATHINFO_FAILED) - condlog(0, "%s can't store path info", - buff); + condlog(0, "%s: can't store path info", + dev); return ret; } } @@ -1422,32 +1409,9 @@ static int _get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, filter_property(conf, pp->udev, 3, pp->uid_attribute) > 0) return PATHINFO_SKIPPED; refwwid = pp->wwid; - goto out; - } - - if (dev_type == DEV_UEVENT) { - struct udev_device *udevice = get_udev_device(dev, dev_type); - - if (!udevice) - return PATHINFO_FAILED; - - ret = store_pathinfo(pathvec, conf, udevice, - flags, &pp); - udev_device_unref(udevice); - if (!pp) { - if (ret == PATHINFO_FAILED) - condlog(0, "%s: can't store path info", dev); - return ret; - } - if (pp->udev && pp->uid_attribute && - filter_property(conf, pp->udev, 3, pp->uid_attribute) > 0) - return PATHINFO_SKIPPED; - refwwid = pp->wwid; - goto out; - } - - if (dev_type == DEV_DEVMAP) { + break; + case DEV_DEVMAP: if (((dm_get_uuid(dev, tmpwwid, WWID_SIZE)) == 0) && (strlen(tmpwwid))) refwwid = tmpwwid; @@ -1470,8 +1434,11 @@ static int _get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, filter_wwid(conf->blist_wwid, conf->elist_wwid, refwwid, NULL) > 0) return PATHINFO_SKIPPED; + break; + default: + break; } -out: + if (refwwid && strlen(refwwid)) { *wwid = STRDUP(refwwid); return PATHINFO_OK; From patchwork Thu Jul 9 10:36:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 11654119 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B360A92A for ; Thu, 9 Jul 2020 10:37:12 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 69329206DF for ; Thu, 9 Jul 2020 10:37:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 69329206DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-93-v1Ms1AuQODeYyn8zmgbcbw-1; Thu, 09 Jul 2020 06:37:09 -0400 X-MC-Unique: v1Ms1AuQODeYyn8zmgbcbw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DE5C5800C64; Thu, 9 Jul 2020 10:36:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C20BA7F8C1; Thu, 9 Jul 2020 10:36:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9675893F93; Thu, 9 Jul 2020 10:36:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 069AanDn031611 for ; Thu, 9 Jul 2020 06:36:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 30FF85F253; Thu, 9 Jul 2020 10:36:49 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2CF235F248 for ; Thu, 9 Jul 2020 10:36:47 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 24D07185A797 for ; Thu, 9 Jul 2020 10:36:47 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-420-VnUMMMJkMe-2ERj_-qywMQ-1; Thu, 09 Jul 2020 06:36:44 -0400 X-MC-Unique: VnUMMMJkMe-2ERj_-qywMQ-1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B558DAE39; Thu, 9 Jul 2020 10:36:42 +0000 (UTC) From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Thu, 9 Jul 2020 12:36:21 +0200 Message-Id: <20200709103623.8302-11-mwilck@suse.com> In-Reply-To: <20200709103623.8302-1-mwilck@suse.com> References: <20200709103623.8302-1-mwilck@suse.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 069AanDn031611 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH 52/54] libmultipath: constify get_mpe_wwid() X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck As this returns a pointer to a struct member, the return value should also be a const char*. Signed-off-by: Martin Wilck --- libmultipath/config.c | 2 +- libmultipath/config.h | 2 +- libmultipath/configure.c | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libmultipath/config.c b/libmultipath/config.c index 658bec8..69a2723 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -157,7 +157,7 @@ struct mpentry *find_mpe(vector mptable, char *wwid) return NULL; } -char *get_mpe_wwid(vector mptable, char *alias) +const char *get_mpe_wwid(const struct _vector *mptable, const char *alias) { int i; struct mpentry * mpe; diff --git a/libmultipath/config.h b/libmultipath/config.h index 92c61a0..2bb7153 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -239,7 +239,7 @@ int find_hwe (const struct _vector *hwtable, const char * vendor, const char * product, const char *revision, vector result); struct mpentry * find_mpe (vector mptable, char * wwid); -char * get_mpe_wwid (vector mptable, char * alias); +const char *get_mpe_wwid (const struct _vector *mptable, const char *alias); struct hwentry * alloc_hwe (void); struct mpentry * alloc_mpe (void); diff --git a/libmultipath/configure.c b/libmultipath/configure.c index db9a255..7461e99 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -1350,7 +1350,8 @@ static int _get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, int ret = 1; struct path * pp; char buff[FILE_NAME_SIZE]; - char * refwwid = NULL, tmpwwid[WWID_SIZE]; + const char *refwwid = NULL; + char tmpwwid[WWID_SIZE]; struct udev_device *udevice; int flags = DI_SYSFS | DI_WWID; From patchwork Thu Jul 9 10:36:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 11654123 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 98E0313B1 for ; Thu, 9 Jul 2020 10:38:03 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4F90B206DF for ; Thu, 9 Jul 2020 10:38:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4F90B206DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-53-zJLATSJINbeveT9k8Rk67Q-1; Thu, 09 Jul 2020 06:37:07 -0400 X-MC-Unique: zJLATSJINbeveT9k8Rk67Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F05A8801E6A; Thu, 9 Jul 2020 10:36:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D254B90E60; Thu, 9 Jul 2020 10:36:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A6F1C1800433; Thu, 9 Jul 2020 10:36:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 069AaoAN031655 for ; Thu, 9 Jul 2020 06:36:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6FEA65F248; Thu, 9 Jul 2020 10:36:50 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6BBEA4C821 for ; Thu, 9 Jul 2020 10:36:50 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 50F3D856A54 for ; Thu, 9 Jul 2020 10:36:50 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-349-1A_o_2dbP5GvrZkkLy53Xg-1; Thu, 09 Jul 2020 06:36:45 -0400 X-MC-Unique: 1A_o_2dbP5GvrZkkLy53Xg-1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id F1970AE44; Thu, 9 Jul 2020 10:36:42 +0000 (UTC) From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Thu, 9 Jul 2020 12:36:22 +0200 Message-Id: <20200709103623.8302-12-mwilck@suse.com> In-Reply-To: <20200709103623.8302-1-mwilck@suse.com> References: <20200709103623.8302-1-mwilck@suse.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 069AaoAN031655 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH 53/54] multipath: call strchop() on command line argument X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck It's useful to sanitize these right away. We can't do this for DEV_DEVMAP, as aliases with trailing whitespace aren't strictly forbidden, but for the other types we can. Signed-off-by: Martin Wilck --- multipath/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/multipath/main.c b/multipath/main.c index 4c43314..cfb85dc 100644 --- a/multipath/main.c +++ b/multipath/main.c @@ -1028,6 +1028,8 @@ main (int argc, char *argv[]) condlog(0, "'%s' is not a valid argument\n", dev); goto out; } + if (dev_type == DEV_DEVNODE || dev_type == DEV_DEVT) + strchop(dev); } if (dev_type == DEV_UEVENT) { openlog("multipath", 0, LOG_DAEMON); From patchwork Thu Jul 9 10:36:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 11654113 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 291D713B1 for ; Thu, 9 Jul 2020 10:37:06 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CFC1B206DF for ; Thu, 9 Jul 2020 10:37:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFC1B206DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-425-KP3We-RFP-mrWAYThTmcQw-1; Thu, 09 Jul 2020 06:37:02 -0400 X-MC-Unique: KP3We-RFP-mrWAYThTmcQw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1971E80BCA7; Thu, 9 Jul 2020 10:36:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EC84A51C4F; Thu, 9 Jul 2020 10:36:53 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C2E8B1809563; Thu, 9 Jul 2020 10:36:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 069AanCf031628 for ; Thu, 9 Jul 2020 06:36:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9EBDB5F24D; Thu, 9 Jul 2020 10:36:49 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9AB0D4C821 for ; Thu, 9 Jul 2020 10:36:49 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 82759858EE9 for ; Thu, 9 Jul 2020 10:36:49 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-263-O_R8K0jINOu_rPfFe8QZiw-1; Thu, 09 Jul 2020 06:36:45 -0400 X-MC-Unique: O_R8K0jINOu_rPfFe8QZiw-1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 3CCC8AE65; Thu, 9 Jul 2020 10:36:43 +0000 (UTC) From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Thu, 9 Jul 2020 12:36:23 +0200 Message-Id: <20200709103623.8302-13-mwilck@suse.com> In-Reply-To: <20200709103623.8302-1-mwilck@suse.com> References: <20200709103623.8302-1-mwilck@suse.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 069AanCf031628 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH 54/54] libmultipath: get_refwwid(): skip strchop(), and constify dev parameter X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck With the previous change, we can safely assume that strchop() has been called already where appropriate (the only caller is multipath's configure()). We can now use const char* for the "dev" parameter. Signed-off-by: Martin Wilck --- libmultipath/configure.c | 6 +++--- libmultipath/configure.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index 7461e99..48426cd 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -1344,7 +1344,8 @@ struct udev_device *get_udev_device(const char *dev, enum devtypes dev_type) return ud; } -static int _get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, +static int _get_refwwid(enum mpath_cmds cmd, const char *dev, + enum devtypes dev_type, vector pathvec, struct config *conf, char **wwid) { int ret = 1; @@ -1379,7 +1380,6 @@ static int _get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, goto common; case DEV_DEVT: - strchop(dev); pp = find_path_by_devt(pathvec, dev); goto common; @@ -1451,7 +1451,7 @@ static int _get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, /* * Returns: PATHINFO_OK, PATHINFO_FAILED, or PATHINFO_SKIPPED (see pathinfo()) */ -int get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type, +int get_refwwid(enum mpath_cmds cmd, const char *dev, enum devtypes dev_type, vector pathvec, char **wwid) { diff --git a/libmultipath/configure.h b/libmultipath/configure.h index 0e33bf4..d9a7de6 100644 --- a/libmultipath/configure.h +++ b/libmultipath/configure.h @@ -52,7 +52,7 @@ int setup_map (struct multipath * mpp, char * params, int params_size, int domap (struct multipath * mpp, char * params, int is_daemon); int reinstate_paths (struct multipath *mpp); int coalesce_paths (struct vectors *vecs, vector curmp, char * refwwid, int force_reload, enum mpath_cmds cmd); -int get_refwwid (enum mpath_cmds cmd, char * dev, enum devtypes dev_type, +int get_refwwid (enum mpath_cmds cmd, const char *dev, enum devtypes dev_type, vector pathvec, char **wwid); int reload_map(struct vectors *vecs, struct multipath *mpp, int refresh, int is_daemon); struct udev_device *get_udev_device(const char *dev, enum devtypes dev_type);