From patchwork Fri Oct 23 21:15:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 11854567 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 020F6C388F9 for ; Fri, 23 Oct 2020 21:15:57 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5841D21D6C for ; Fri, 23 Oct 2020 21:15:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RnXqRLj7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5841D21D6C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603487755; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=RpU1e5zlllv2z0tnFMHA0v57nO5ox1vhPPsIRRIpQdQ=; b=RnXqRLj7nUOmboO+i3j+cxjq0uQykBZQyMy1gfrHbOe6nHAOeWWKFaSJSXuuSAfUrv+bWC nkIErvErxlMk3jnNjKWB5F/UExB77Lc5IMLd4cZ/DNb8D9y5lSZVyllFqPFIclhKLPn5IT CYcposlwFS3qAYAp0KtPhMZOQFltf6k= 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-333-4l33oNl6PAiA39Xy3Rcfww-1; Fri, 23 Oct 2020 17:15:52 -0400 X-MC-Unique: 4l33oNl6PAiA39Xy3Rcfww-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C4235804B74; Fri, 23 Oct 2020 21:15:45 +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 1CC5C19C66; Fri, 23 Oct 2020 21:15:44 +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 8AADA180B657; Fri, 23 Oct 2020 21:15:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09NLFDeA027774 for ; Fri, 23 Oct 2020 17:15:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id C3C6E60CCC; Fri, 23 Oct 2020 21:15:13 +0000 (UTC) Received: from octiron.msp.redhat.com (octiron.msp.redhat.com [10.15.80.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C3D7360C84; Fri, 23 Oct 2020 21:15:11 +0000 (UTC) Received: from octiron.msp.redhat.com (localhost.localdomain [127.0.0.1]) by octiron.msp.redhat.com (8.14.9/8.14.9) with ESMTP id 09NLFAYw012589; Fri, 23 Oct 2020 16:15:10 -0500 Received: (from bmarzins@localhost) by octiron.msp.redhat.com (8.14.9/8.14.9/Submit) id 09NLF93H012588; Fri, 23 Oct 2020 16:15:09 -0500 From: Benjamin Marzinski To: Christophe Varoqui Date: Fri, 23 Oct 2020 16:15:04 -0500 Message-Id: <1603487708-12547-2-git-send-email-bmarzins@redhat.com> In-Reply-To: <1603487708-12547-1-git-send-email-bmarzins@redhat.com> References: <1603487708-12547-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: dm-devel@redhat.com Cc: device-mapper development , Martin Wilck Subject: [dm-devel] [PATCH 1/5] libmultipath: move fast_io_fail defines to structs.h 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: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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 Since fast_io_fail is part of the multipath struct, its symbolic values belong in structs.h. Also, make it an instance of a general enum, which will be used again in future patches, and change the set/print functions which use it to use the general enum instead. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- libmultipath/config.h | 8 -------- libmultipath/dict.c | 30 +++++++++++++++--------------- libmultipath/dict.h | 2 +- libmultipath/propsel.c | 2 +- libmultipath/structs.h | 17 +++++++++++++++++ 5 files changed, 34 insertions(+), 25 deletions(-) diff --git a/libmultipath/config.h b/libmultipath/config.h index 5d460359..661dd586 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -10,14 +10,6 @@ #define ORIGIN_DEFAULT 0 #define ORIGIN_CONFIG 1 -/* - * In kernel, fast_io_fail == 0 means immediate failure on rport delete. - * OTOH '0' means not-configured in various places in multipath-tools. - */ -#define MP_FAST_IO_FAIL_UNSET (0) -#define MP_FAST_IO_FAIL_OFF (-1) -#define MP_FAST_IO_FAIL_ZERO (-2) - enum devtypes { DEV_NONE, DEV_DEVT, diff --git a/libmultipath/dict.c b/libmultipath/dict.c index f12c2e5c..f4357da1 100644 --- a/libmultipath/dict.c +++ b/libmultipath/dict.c @@ -822,7 +822,7 @@ declare_mp_attr_handler(gid, set_gid) declare_mp_attr_snprint(gid, print_gid) static int -set_fast_io_fail(vector strvec, void *ptr) +set_undef_off_zero(vector strvec, void *ptr) { char * buff; int *int_ptr = (int *)ptr; @@ -832,36 +832,36 @@ set_fast_io_fail(vector strvec, void *ptr) return 1; if (strcmp(buff, "off") == 0) - *int_ptr = MP_FAST_IO_FAIL_OFF; + *int_ptr = UOZ_OFF; else if (sscanf(buff, "%d", int_ptr) != 1 || - *int_ptr < MP_FAST_IO_FAIL_ZERO) - *int_ptr = MP_FAST_IO_FAIL_UNSET; + *int_ptr < UOZ_ZERO) + *int_ptr = UOZ_UNDEF; else if (*int_ptr == 0) - *int_ptr = MP_FAST_IO_FAIL_ZERO; + *int_ptr = UOZ_ZERO; FREE(buff); return 0; } int -print_fast_io_fail(char * buff, int len, long v) +print_undef_off_zero(char * buff, int len, long v) { - if (v == MP_FAST_IO_FAIL_UNSET) + if (v == UOZ_UNDEF) return 0; - if (v == MP_FAST_IO_FAIL_OFF) + if (v == UOZ_OFF) return snprintf(buff, len, "\"off\""); - if (v == MP_FAST_IO_FAIL_ZERO) + if (v == UOZ_ZERO) return snprintf(buff, len, "0"); return snprintf(buff, len, "%ld", v); } -declare_def_handler(fast_io_fail, set_fast_io_fail) -declare_def_snprint_defint(fast_io_fail, print_fast_io_fail, +declare_def_handler(fast_io_fail, set_undef_off_zero) +declare_def_snprint_defint(fast_io_fail, print_undef_off_zero, DEFAULT_FAST_IO_FAIL) -declare_ovr_handler(fast_io_fail, set_fast_io_fail) -declare_ovr_snprint(fast_io_fail, print_fast_io_fail) -declare_hw_handler(fast_io_fail, set_fast_io_fail) -declare_hw_snprint(fast_io_fail, print_fast_io_fail) +declare_ovr_handler(fast_io_fail, set_undef_off_zero) +declare_ovr_snprint(fast_io_fail, print_undef_off_zero) +declare_hw_handler(fast_io_fail, set_undef_off_zero) +declare_hw_snprint(fast_io_fail, print_undef_off_zero) static int set_dev_loss(vector strvec, void *ptr) diff --git a/libmultipath/dict.h b/libmultipath/dict.h index a40ac66f..a917e1ca 100644 --- a/libmultipath/dict.h +++ b/libmultipath/dict.h @@ -13,7 +13,7 @@ int print_rr_weight(char *buff, int len, long v); int print_pgfailback(char *buff, int len, long v); int print_pgpolicy(char *buff, int len, long v); int print_no_path_retry(char *buff, int len, long v); -int print_fast_io_fail(char *buff, int len, long v); +int print_undef_off_zero(char *buff, int len, long v); int print_dev_loss(char *buff, int len, unsigned long v); int print_reservation_key(char * buff, int len, struct be64 key, uint8_t flags, int source); diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c index 3f2c2cfa..67d025cf 100644 --- a/libmultipath/propsel.c +++ b/libmultipath/propsel.c @@ -754,7 +754,7 @@ int select_fast_io_fail(struct config *conf, struct multipath *mp) mp_set_conf(fast_io_fail); mp_set_default(fast_io_fail, DEFAULT_FAST_IO_FAIL); out: - print_fast_io_fail(buff, 12, mp->fast_io_fail); + print_undef_off_zero(buff, 12, mp->fast_io_fail); condlog(3, "%s: fast_io_fail_tmo = %s %s", mp->alias, buff, origin); return 0; } diff --git a/libmultipath/structs.h b/libmultipath/structs.h index 4ce30551..cfa7b649 100644 --- a/libmultipath/structs.h +++ b/libmultipath/structs.h @@ -219,6 +219,23 @@ enum vpd_vendor_ids { VPD_VP_ARRAY_SIZE, /* This must remain the last entry */ }; +/* + * Multipath treats 0 as undefined for optional config parameters. + * Use this for cases where 0 is a valid option for systems multipath + * is communicating with + */ +enum undefined_off_zero { + UOZ_UNDEF = 0, + UOZ_OFF = -1, + UOZ_ZERO = -2, +}; + +enum fast_io_fail_states { + MP_FAST_IO_FAIL_UNSET = UOZ_UNDEF, + MP_FAST_IO_FAIL_OFF = UOZ_OFF, + MP_FAST_IO_FAIL_ZERO = UOZ_ZERO, +}; + struct vpd_vendor_page { int pg; const char *name; From patchwork Fri Oct 23 21:15:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 11854575 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36694C55178 for ; Fri, 23 Oct 2020 21:23:00 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 633DB20754 for ; Fri, 23 Oct 2020 21:22:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UQE6jXES" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 633DB20754 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603488177; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=qY4WiXQDr+zv11m52B9gw/yM+a8XSuWwzhxeErCGEq8=; b=UQE6jXESaY6YLcq9W9ZdULtEWTNWoMo3oPo8v+78n5JxHgKiKSNNqcgY2jqxfBWN1uQJBi 6j/Or9DpoJwZPl8kxipjR8mU2j6J0gOpT0jgfKWq0Q74WdqmtdaNC8hu3IBzFZzOJldedw uu0kj3N6JkP1Ul+Hkw+L5A03n8Z6SiU= 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-391-74Vb3i9IOWy-fKgPpsfRsQ-1; Fri, 23 Oct 2020 17:22:55 -0400 X-MC-Unique: 74Vb3i9IOWy-fKgPpsfRsQ-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 B8D5F107AFC7; Fri, 23 Oct 2020 21:22:50 +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 991CF9CBA1; Fri, 23 Oct 2020 21:22:50 +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 6A42F9230B; Fri, 23 Oct 2020 21:22:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09NLFGKY027795 for ; Fri, 23 Oct 2020 17:15:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1B9F910013D7; Fri, 23 Oct 2020 21:15:16 +0000 (UTC) Received: from octiron.msp.redhat.com (octiron.msp.redhat.com [10.15.80.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 095B010013BD; Fri, 23 Oct 2020 21:15:12 +0000 (UTC) Received: from octiron.msp.redhat.com (localhost.localdomain [127.0.0.1]) by octiron.msp.redhat.com (8.14.9/8.14.9) with ESMTP id 09NLFBOK012593; Fri, 23 Oct 2020 16:15:11 -0500 Received: (from bmarzins@localhost) by octiron.msp.redhat.com (8.14.9/8.14.9/Submit) id 09NLFB2p012592; Fri, 23 Oct 2020 16:15:11 -0500 From: Benjamin Marzinski To: Christophe Varoqui Date: Fri, 23 Oct 2020 16:15:05 -0500 Message-Id: <1603487708-12547-3-git-send-email-bmarzins@redhat.com> In-Reply-To: <1603487708-12547-1-git-send-email-bmarzins@redhat.com> References: <1603487708-12547-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: dm-devel@redhat.com Cc: device-mapper development , Martin Wilck Subject: [dm-devel] [PATCH 2/5] libmultipath: add eh_deadline multipath.conf 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: , MIME-Version: 1.0 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 There are times a fc rport is never lost, meaning that fast_io_fail_tmo and dev_loss_tmo never trigger, but scsi commands still hang. This can cause problems in cases where users have string timing requirements, and the easiest way to solve these issues is to set eh_deadline. Since it's already possible to set fast_io_fail_tmo and dev_loss_tmo from multipath.conf, and have multipath take care of setting it correctly for the scsi devices in sysfs, it makes sense to allow users to set eh_deadline here as well. Signed-off-by: Benjamin Marzinski --- libmultipath/config.c | 2 ++ libmultipath/config.h | 2 ++ libmultipath/configure.c | 1 + libmultipath/dict.c | 10 ++++++ libmultipath/discovery.c | 70 ++++++++++++++++++++++++++++++-------- libmultipath/propsel.c | 17 +++++++++ libmultipath/propsel.h | 1 + libmultipath/structs.h | 7 ++++ multipath/multipath.conf.5 | 16 +++++++++ 9 files changed, 111 insertions(+), 15 deletions(-) diff --git a/libmultipath/config.c b/libmultipath/config.c index 49e7fb81..9f3cb38d 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -424,6 +424,7 @@ merge_hwe (struct hwentry * dst, struct hwentry * src) merge_num(flush_on_last_del); merge_num(fast_io_fail); merge_num(dev_loss); + merge_num(eh_deadline); merge_num(user_friendly_names); merge_num(retain_hwhandler); merge_num(detect_prio); @@ -579,6 +580,7 @@ store_hwe (vector hwtable, struct hwentry * dhwe) hwe->flush_on_last_del = dhwe->flush_on_last_del; hwe->fast_io_fail = dhwe->fast_io_fail; hwe->dev_loss = dhwe->dev_loss; + hwe->eh_deadline = dhwe->eh_deadline; hwe->user_friendly_names = dhwe->user_friendly_names; hwe->retain_hwhandler = dhwe->retain_hwhandler; hwe->detect_prio = dhwe->detect_prio; diff --git a/libmultipath/config.h b/libmultipath/config.h index 661dd586..9ce37f16 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -63,6 +63,7 @@ struct hwentry { int flush_on_last_del; int fast_io_fail; unsigned int dev_loss; + int eh_deadline; int user_friendly_names; int retain_hwhandler; int detect_prio; @@ -148,6 +149,7 @@ struct config { int attribute_flags; int fast_io_fail; unsigned int dev_loss; + int eh_deadline; int log_checker_err; int allow_queueing; int allow_usb_devices; diff --git a/libmultipath/configure.c b/libmultipath/configure.c index 1c8aac08..a878d870 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -368,6 +368,7 @@ int setup_map(struct multipath *mpp, char *params, int params_size, select_gid(conf, mpp); select_fast_io_fail(conf, mpp); select_dev_loss(conf, mpp); + select_eh_deadline(conf, mpp); select_reservation_key(conf, mpp); select_deferred_remove(conf, mpp); select_marginal_path_err_sample_time(conf, mpp); diff --git a/libmultipath/dict.c b/libmultipath/dict.c index f4357da1..bab96146 100644 --- a/libmultipath/dict.c +++ b/libmultipath/dict.c @@ -899,6 +899,13 @@ declare_ovr_snprint(dev_loss, print_dev_loss) declare_hw_handler(dev_loss, set_dev_loss) declare_hw_snprint(dev_loss, print_dev_loss) +declare_def_handler(eh_deadline, set_undef_off_zero) +declare_def_snprint(eh_deadline, print_undef_off_zero) +declare_ovr_handler(eh_deadline, set_undef_off_zero) +declare_ovr_snprint(eh_deadline, print_undef_off_zero) +declare_hw_handler(eh_deadline, set_undef_off_zero) +declare_hw_snprint(eh_deadline, print_undef_off_zero) + static int set_pgpolicy(vector strvec, void *ptr) { @@ -1771,6 +1778,7 @@ init_keywords(vector keywords) install_keyword("gid", &def_gid_handler, &snprint_def_gid); install_keyword("fast_io_fail_tmo", &def_fast_io_fail_handler, &snprint_def_fast_io_fail); install_keyword("dev_loss_tmo", &def_dev_loss_handler, &snprint_def_dev_loss); + install_keyword("eh_deadline", &def_eh_deadline_handler, &snprint_def_eh_deadline); install_keyword("bindings_file", &def_bindings_file_handler, &snprint_def_bindings_file); install_keyword("wwids_file", &def_wwids_file_handler, &snprint_def_wwids_file); install_keyword("prkeys_file", &def_prkeys_file_handler, &snprint_def_prkeys_file); @@ -1880,6 +1888,7 @@ init_keywords(vector keywords) install_keyword("flush_on_last_del", &hw_flush_on_last_del_handler, &snprint_hw_flush_on_last_del); install_keyword("fast_io_fail_tmo", &hw_fast_io_fail_handler, &snprint_hw_fast_io_fail); install_keyword("dev_loss_tmo", &hw_dev_loss_handler, &snprint_hw_dev_loss); + install_keyword("eh_deadline", &hw_eh_deadline_handler, &snprint_hw_eh_deadline); install_keyword("user_friendly_names", &hw_user_friendly_names_handler, &snprint_hw_user_friendly_names); install_keyword("retain_attached_hw_handler", &hw_retain_hwhandler_handler, &snprint_hw_retain_hwhandler); install_keyword("detect_prio", &hw_detect_prio_handler, &snprint_hw_detect_prio); @@ -1920,6 +1929,7 @@ init_keywords(vector keywords) install_keyword("flush_on_last_del", &ovr_flush_on_last_del_handler, &snprint_ovr_flush_on_last_del); install_keyword("fast_io_fail_tmo", &ovr_fast_io_fail_handler, &snprint_ovr_fast_io_fail); install_keyword("dev_loss_tmo", &ovr_dev_loss_handler, &snprint_ovr_dev_loss); + install_keyword("eh_deadline", &ovr_eh_deadline_handler, &snprint_ovr_eh_deadline); install_keyword("user_friendly_names", &ovr_user_friendly_names_handler, &snprint_ovr_user_friendly_names); install_keyword("retain_attached_hw_handler", &ovr_retain_hwhandler_handler, &snprint_ovr_retain_hwhandler); install_keyword("detect_prio", &ovr_detect_prio_handler, &snprint_ovr_detect_prio); diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index 950b1586..ef9a9a23 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -585,6 +585,42 @@ sysfs_get_asymmetric_access_state(struct path *pp, char *buff, int buflen) return !!preferred; } +static int +sysfs_set_eh_deadline(struct multipath *mpp, struct path *pp) +{ + struct udev_device *hostdev; + char host_name[HOST_NAME_LEN], value[16]; + int ret; + + if (mpp->eh_deadline == EH_DEADLINE_UNSET) + return 0; + + sprintf(host_name, "host%d", pp->sg_id.host_no); + hostdev = udev_device_new_from_subsystem_sysname(udev, + "scsi_host", host_name); + if (!hostdev) + return 1; + + if (mpp->eh_deadline == EH_DEADLINE_OFF) + sprintf(value, "off"); + else if (mpp->eh_deadline == EH_DEADLINE_ZERO) + sprintf(value, "0"); + else + snprintf(value, 16, "%u", mpp->eh_deadline); + + ret = sysfs_attr_set_value(hostdev, "eh_deadline", + value, strlen(value)); + /* + * not all scsi drivers support setting eh_deadline, so failing + * is totally reasonable + */ + if (ret <= 0) + condlog(4, "%s: failed to set eh_deadline to %s, error %d", udev_device_get_sysname(hostdev), value, -ret); + + udev_device_unref(hostdev); + return (ret <= 0); +} + static void sysfs_set_rport_tmo(struct multipath *mpp, struct path *pp) { @@ -799,7 +835,8 @@ sysfs_set_scsi_tmo (struct multipath *mpp, unsigned int checkint) mpp->fast_io_fail = MP_FAST_IO_FAIL_OFF; } if (mpp->dev_loss == DEV_LOSS_TMO_UNSET && - mpp->fast_io_fail == MP_FAST_IO_FAIL_UNSET) + mpp->fast_io_fail == MP_FAST_IO_FAIL_UNSET && + mpp->eh_deadline == EH_DEADLINE_UNSET) return 0; vector_foreach_slot(mpp->paths, pp, i) { @@ -808,21 +845,24 @@ sysfs_set_scsi_tmo (struct multipath *mpp, unsigned int checkint) err_path = pp; continue; } - - switch (pp->sg_id.proto_id) { - case SCSI_PROTOCOL_FCP: - sysfs_set_rport_tmo(mpp, pp); - continue; - case SCSI_PROTOCOL_ISCSI: - sysfs_set_session_tmo(mpp, pp); - continue; - case SCSI_PROTOCOL_SAS: - sysfs_set_nexus_loss_tmo(mpp, pp); - continue; - default: - if (!err_path) - err_path = pp; + if (mpp->dev_loss != DEV_LOSS_TMO_UNSET || + mpp->fast_io_fail != MP_FAST_IO_FAIL_UNSET) { + switch (pp->sg_id.proto_id) { + case SCSI_PROTOCOL_FCP: + sysfs_set_rport_tmo(mpp, pp); + break; + case SCSI_PROTOCOL_ISCSI: + sysfs_set_session_tmo(mpp, pp); + break; + case SCSI_PROTOCOL_SAS: + sysfs_set_nexus_loss_tmo(mpp, pp); + break; + default: + if (!err_path) + err_path = pp; + } } + sysfs_set_eh_deadline(mpp, pp); } if (err_path) { diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c index 67d025cf..fa4ac5d9 100644 --- a/libmultipath/propsel.c +++ b/libmultipath/propsel.c @@ -775,6 +775,23 @@ out: return 0; } +int select_eh_deadline(struct config *conf, struct multipath *mp) +{ + const char *origin; + char buff[12]; + + mp_set_ovr(eh_deadline); + mp_set_hwe(eh_deadline); + mp_set_conf(eh_deadline); + mp->eh_deadline = EH_DEADLINE_UNSET; + /* not changing sysfs in default cause, so don't print anything */ + return 0; +out: + print_undef_off_zero(buff, 12, mp->eh_deadline); + condlog(3, "%s: eh_deadline = %s %s", mp->alias, buff, origin); + return 0; +} + int select_flush_on_last_del(struct config *conf, struct multipath *mp) { const char *origin; diff --git a/libmultipath/propsel.h b/libmultipath/propsel.h index 3d6edd8a..a68bacf0 100644 --- a/libmultipath/propsel.h +++ b/libmultipath/propsel.h @@ -17,6 +17,7 @@ int select_uid(struct config *conf, struct multipath *mp); int select_gid(struct config *conf, struct multipath *mp); int select_fast_io_fail(struct config *conf, struct multipath *mp); int select_dev_loss(struct config *conf, struct multipath *mp); +int select_eh_deadline(struct config *conf, struct multipath *mp); int select_reservation_key(struct config *conf, struct multipath *mp); int select_retain_hwhandler (struct config *conf, struct multipath * mp); int select_detect_prio(struct config *conf, struct path * pp); diff --git a/libmultipath/structs.h b/libmultipath/structs.h index cfa7b649..d6ff6762 100644 --- a/libmultipath/structs.h +++ b/libmultipath/structs.h @@ -236,6 +236,12 @@ enum fast_io_fail_states { MP_FAST_IO_FAIL_ZERO = UOZ_ZERO, }; +enum eh_deadline_states { + EH_DEADLINE_UNSET = UOZ_UNDEF, + EH_DEADLINE_OFF = UOZ_OFF, + EH_DEADLINE_ZERO = UOZ_ZERO, +}; + struct vpd_vendor_page { int pg; const char *name; @@ -356,6 +362,7 @@ struct multipath { int ghost_delay; int ghost_delay_tick; unsigned int dev_loss; + int eh_deadline; uid_t uid; gid_t gid; mode_t mode; diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5 index d2101ed6..cf05c1ab 100644 --- a/multipath/multipath.conf.5 +++ b/multipath/multipath.conf.5 @@ -717,6 +717,22 @@ The default is: \fB600\fR . . .TP +.B eh_deadline +Specify the maximum number of seconds the SCSI layer will spend doing error +handling when scsi devices fail. After this timeout the scsi layer will perform +a full HBA reset. Setting this may be necessary in cases where the rport is +never lost, so \fIfast_io_fail_tmo\fR and \fIdev_loss_tmo\fR will never +trigger, but (frequently do to load) scsi commands still hang. \fBNote:\fR when +the scsi error handler performs the HBA reset, all target paths on that HBA +will be affected. eh_deadline should only be set in cases where all targets on +the affected HBAs are multipathed. +.RS +.TP +The default is: \fB\fR +.RE +. +. +.TP .B bindings_file The full pathname of the binding file to be used when the user_friendly_names option is set. From patchwork Fri Oct 23 21:15:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 11854573 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4641C388F9 for ; Fri, 23 Oct 2020 21:22:56 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E1E6020754 for ; Fri, 23 Oct 2020 21:22:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bGF9PSyi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E1E6020754 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603488174; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=i0K/f3Q0k9xyt10KVoN99lgFfQ9r4vU4VLs5lrcH+Dw=; b=bGF9PSyiwyXWUWECRDqQsgZp6djWBKiVbIoXqDEVdGv8ep4LG1ECjsaWCBKmrUi9jtZMF3 z2y0S0sIv4B4ztRDt+zHnm/UY1WFCE7rWUIuS1EoglRq+z3yhg4RIeqS1YPWtG5vB5/scN qhiEj6FRNtlXcwHscjyDwXm3QHGrVAk= 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-35-e8Z9GfS1OQSZGIh8sRHYqg-1; Fri, 23 Oct 2020 17:22:51 -0400 X-MC-Unique: e8Z9GfS1OQSZGIh8sRHYqg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9EBCD107AFAE; Fri, 23 Oct 2020 21:22:46 +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 7B54219C66; Fri, 23 Oct 2020 21:22:46 +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 4DABD180B657; Fri, 23 Oct 2020 21:22:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09NLFEkd027779 for ; Fri, 23 Oct 2020 17:15:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 57D9860C84; Fri, 23 Oct 2020 21:15:14 +0000 (UTC) Received: from octiron.msp.redhat.com (octiron.msp.redhat.com [10.15.80.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4287660CCC; Fri, 23 Oct 2020 21:15:14 +0000 (UTC) Received: from octiron.msp.redhat.com (localhost.localdomain [127.0.0.1]) by octiron.msp.redhat.com (8.14.9/8.14.9) with ESMTP id 09NLFCYZ012597; Fri, 23 Oct 2020 16:15:12 -0500 Received: (from bmarzins@localhost) by octiron.msp.redhat.com (8.14.9/8.14.9/Submit) id 09NLFCXO012596; Fri, 23 Oct 2020 16:15:12 -0500 From: Benjamin Marzinski To: Christophe Varoqui Date: Fri, 23 Oct 2020 16:15:06 -0500 Message-Id: <1603487708-12547-4-git-send-email-bmarzins@redhat.com> In-Reply-To: <1603487708-12547-1-git-send-email-bmarzins@redhat.com> References: <1603487708-12547-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: dm-devel@redhat.com Cc: device-mapper development , Martin Wilck Subject: [dm-devel] [PATCH 3/5] multipathd: remove redundant vector_free() int configure 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: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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 remove_maps(vecs) already calls vector_free(vecs->mpvec) Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- multipathd/main.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 0cf8a264..e114bab7 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2634,14 +2634,10 @@ configure (struct vectors * vecs) } /* - * purge dm of old maps + * purge dm of old maps and save new set of maps formed by + * considering current path state */ remove_maps(vecs); - - /* - * save new set of maps formed by considering current path state - */ - vector_free(vecs->mpvec); vecs->mpvec = mpvec; /* From patchwork Fri Oct 23 21:15:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 11854577 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2B20C5517A for ; Fri, 23 Oct 2020 21:23:01 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D332620754 for ; Fri, 23 Oct 2020 21:23:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="FXEqRCX5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D332620754 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603488179; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=jR7ilaCKsICD8c+UrrAEmtizmCbqceDeqW55C/Fjx/Q=; b=FXEqRCX5lmVbmhqwRDTDA7Z93nJ5q5DlNDjJfXAeWS7mgCyV1aXVJsB8JAyyV9Nq7XySVQ /VkqHJw2omsqlqO9Kghh2AjhxapWbpfQjpOAiyX+YxTD6oPy59trONPyfsLmsuXzQZ6H8F nlN7opOgvzlNzCCoORZa1+1kBcctaDY= 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-123-S-FFnE4FNFqORUy7GZwQUQ-1; Fri, 23 Oct 2020 17:22:57 -0400 X-MC-Unique: S-FFnE4FNFqORUy7GZwQUQ-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 93965804B80; Fri, 23 Oct 2020 21:22: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 7745E55795; Fri, 23 Oct 2020 21:22: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 4F68A180B658; Fri, 23 Oct 2020 21:22:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09NLFIIW027810 for ; Fri, 23 Oct 2020 17:15:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id C5FEE1992D; Fri, 23 Oct 2020 21:15:18 +0000 (UTC) Received: from octiron.msp.redhat.com (octiron.msp.redhat.com [10.15.80.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AC09519C66; Fri, 23 Oct 2020 21:15:15 +0000 (UTC) Received: from octiron.msp.redhat.com (localhost.localdomain [127.0.0.1]) by octiron.msp.redhat.com (8.14.9/8.14.9) with ESMTP id 09NLFEHx012601; Fri, 23 Oct 2020 16:15:14 -0500 Received: (from bmarzins@localhost) by octiron.msp.redhat.com (8.14.9/8.14.9/Submit) id 09NLFDxf012600; Fri, 23 Oct 2020 16:15:13 -0500 From: Benjamin Marzinski To: Christophe Varoqui Date: Fri, 23 Oct 2020 16:15:07 -0500 Message-Id: <1603487708-12547-5-git-send-email-bmarzins@redhat.com> In-Reply-To: <1603487708-12547-1-git-send-email-bmarzins@redhat.com> References: <1603487708-12547-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: dm-devel@redhat.com Cc: NetApp RDAC team , device-mapper development , Steve Schremmer , Martin Wilck Subject: [dm-devel] [PATCH 4/5] libmultipath: only read 0xc9 vpd page for devices with rdac checker 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: , MIME-Version: 1.0 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 Only rdac arrays support 0xC9 vpd page inquiries. All other arrays will return a failure. Since all rdac arrays in the the built-in device configuration explicitly set the RDAC path checker, and almost all other scsi arrays do not set a path checker, it makes sense to only do the rdac inquiry when detecting array capabilities if the array's path checker is explicitly set to rdac. Multipath was doing the check if either the path checker was set to rdac, or no path checker was set. This means that for almost all non-rdac arrays, multipath was issuing a bad inquiry. This was annoying users. Cc: Steve Schremmer Cc: NetApp RDAC team Signed-off-by: Benjamin Marzinski Reviewed-by: Steve Schremmer --- libmultipath/propsel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c index fa4ac5d9..90a77d77 100644 --- a/libmultipath/propsel.c +++ b/libmultipath/propsel.c @@ -501,7 +501,7 @@ check_rdac(struct path * pp) if (pp->bus != SYSFS_BUS_SCSI) return 0; /* Avoid ioctl if this is likely not an RDAC array */ - if (__do_set_from_hwe(checker_name, pp, checker_name) && + if (!__do_set_from_hwe(checker_name, pp, checker_name) || strcmp(checker_name, RDAC)) return 0; len = get_vpd_sgio(pp->fd, 0xC9, 0, buff, 44); From patchwork Fri Oct 23 21:15:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 11854571 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D000C388F9 for ; Fri, 23 Oct 2020 21:21:19 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 88A35208E4 for ; Fri, 23 Oct 2020 21:21:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Zr+NymEK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 88A35208E4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603488076; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=uHHIhzeFidDNdJlxJ05btU03mRI+iLk8FaHrkzHIq8Y=; b=Zr+NymEKd4t82L+Cqisx5TaZ7/McOzqvni7Fld0P5fm4u8SD8yr0LrvjZ0EcyQ/WKiVz78 xWHNbJcQqLC1IpRtIJcHnnRkwbYwuLy+ZirwofOMubhuBMs6MD07BO1yLFyAyHiVR5cYS3 7j8X5g7qs23OTrk3w7bR5/7pWOv/D8I= 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-270-wZOcGW0hMgGritsaaM0WHQ-1; Fri, 23 Oct 2020 17:21:14 -0400 X-MC-Unique: wZOcGW0hMgGritsaaM0WHQ-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 2BEBB805EF2; Fri, 23 Oct 2020 21:21:10 +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 D7BE473661; Fri, 23 Oct 2020 21:21:09 +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 76FBB180B657; Fri, 23 Oct 2020 21:21:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09NLFJlb027815 for ; Fri, 23 Oct 2020 17:15:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id C7EA855793; Fri, 23 Oct 2020 21:15:19 +0000 (UTC) Received: from octiron.msp.redhat.com (octiron.msp.redhat.com [10.15.80.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 04BE755785; Fri, 23 Oct 2020 21:15:16 +0000 (UTC) Received: from octiron.msp.redhat.com (localhost.localdomain [127.0.0.1]) by octiron.msp.redhat.com (8.14.9/8.14.9) with ESMTP id 09NLFFPT012605; Fri, 23 Oct 2020 16:15:15 -0500 Received: (from bmarzins@localhost) by octiron.msp.redhat.com (8.14.9/8.14.9/Submit) id 09NLFF6n012604; Fri, 23 Oct 2020 16:15:15 -0500 From: Benjamin Marzinski To: Christophe Varoqui Date: Fri, 23 Oct 2020 16:15:08 -0500 Message-Id: <1603487708-12547-6-git-send-email-bmarzins@redhat.com> In-Reply-To: <1603487708-12547-1-git-send-email-bmarzins@redhat.com> References: <1603487708-12547-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: dm-devel@redhat.com Cc: device-mapper development , Martin Wilck Subject: [dm-devel] [PATCH 5/5] libmultipath: don't dlclose tur checker DSO 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: , MIME-Version: 1.0 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 The multipathd tur checker thread is designed to be able to finish at any time, even after the tur checker itself has been freed. The multipathd shutdown code makes sure all the checkers have been freed before freeing the checker_class and calling dlclose() to unload the DSO, but this doesn't guarantee that the checker threads have finished. If one hasn't, the DSO will get unloaded while the thread still running code from it, causing a segfault. Unfortunately, it's not possible to be sure that all tur checker threads have ended during shutdown, without making them joinable. However, since libmultipath will never be reinitialized after it has been uninitialzed, not dlclosing the tur checker DSO once a thread is started has minimal cost (keeping the DSO code around until the program exits, which usually happens right after freeing the checkers). Signed-off-by: Benjamin Marzinski --- libmultipath/checkers.c | 10 +++++++++- libmultipath/checkers.h | 1 + libmultipath/checkers/tur.c | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libmultipath/checkers.c b/libmultipath/checkers.c index 18b1f5eb..35a17f8c 100644 --- a/libmultipath/checkers.c +++ b/libmultipath/checkers.c @@ -22,6 +22,7 @@ struct checker_class { void (*reset)(void); /* to reset the global variables */ const char **msgtable; short msgtable_size; + int keep_dso; }; static const char *checker_state_names[PATH_MAX_STATE] = { @@ -74,7 +75,7 @@ void free_checker_class(struct checker_class *c) list_del(&c->node); if (c->reset) c->reset(); - if (c->handle) { + if (c->handle && !c->keep_dso) { if (dlclose(c->handle) != 0) { condlog(0, "Cannot unload checker %s: %s", c->name, dlerror()); @@ -197,6 +198,13 @@ out: return NULL; } +void checker_keep_dso(struct checker * c) +{ + if (!c || !c->cls) + return; + c->cls->keep_dso = 1; +} + void checker_set_fd (struct checker * c, int fd) { if (!c) diff --git a/libmultipath/checkers.h b/libmultipath/checkers.h index 9d5f90b9..af5a4006 100644 --- a/libmultipath/checkers.h +++ b/libmultipath/checkers.h @@ -146,6 +146,7 @@ void checker_reset (struct checker *); void checker_set_sync (struct checker *); void checker_set_async (struct checker *); void checker_set_fd (struct checker *, int); +void checker_keep_dso(struct checker *c); void checker_enable (struct checker *); void checker_disable (struct checker *); int checker_check (struct checker *, int); diff --git a/libmultipath/checkers/tur.c b/libmultipath/checkers/tur.c index e886fcf8..fd58d62a 100644 --- a/libmultipath/checkers/tur.c +++ b/libmultipath/checkers/tur.c @@ -394,6 +394,7 @@ int libcheck_check(struct checker * c) uatomic_set(&ct->running, 1); tur_set_async_timeout(c); setup_thread_attr(&attr, 32 * 1024, 1); + checker_keep_dso(c); r = pthread_create(&ct->thread, &attr, tur_thread, ct); pthread_attr_destroy(&attr); if (r) {