From patchwork Wed Jul 17 18:10:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13735681 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BFB47470 for ; Wed, 17 Jul 2024 18:11:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239874; cv=none; b=p2rTKyPOueNrddKrK57I7rSqSJatRfS/dhZ4gDFKLgi9cESaHZ4uxJt+xLF1aSOlXN+yBM2WF+WM48ZUIP/7ayQgFJYaeIe0eR8bT4Bb9fyCoJT/frDRN9yPQr08tckW5U3bBmdh72lyAZp+/nxju8VdihU6YG31IUtH9ZBCLyk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239874; c=relaxed/simple; bh=hEQ2G+6ciD1ynuLJRz6N7W9UvqV7BhKvDgOR8I0XCyg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FrxDKUnj4p1jQDm0XqVo/8j0GJqxHRkNZ+b2bgbQoXzY+YhTo0vsYc/VbWGvfG2TUVsZJRX/sQzr1p9lKMOeOnrBMboZJa7BUqnSp+X1NS+CNVyM6Q4lEjIYH9DqfKEYTtGQDNocc6asRD8xS3M2jLMcCJ0WVISleZc/XOzWgdM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=BfU06IUF; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BfU06IUF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721239872; h=from:from: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; bh=lfyWsfYu1u/vV8zv8J5I7DL/1kM861ywCTQUO0RXkGk=; b=BfU06IUFQ0UWtMFbYL+sGO875loWSXJhfDA6CkbNjE3vFSM8e9/5jAVaav76euQgAculRR GofnjMboBRN5jTUd3Cd2BdPBeEdSJ9t8aim9/8zC7ahisl9awVo6yqprz8RJjerN7AoUb8 Agz5y4xOx11enByS3jd0IJQWPVGRUvM= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-459-vwFiPN4FNbOnDoakfFfzyg-1; Wed, 17 Jul 2024 14:11:10 -0400 X-MC-Unique: vwFiPN4FNbOnDoakfFfzyg-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 040721955D4F; Wed, 17 Jul 2024 18:11:09 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9D0911955F40; Wed, 17 Jul 2024 18:11:08 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 46HIB7X92173560 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Jul 2024 14:11:07 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46HIB7pE2173559; Wed, 17 Jul 2024 14:11:07 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 01/20] libmultipath: rename dm_map_present_by_wwid() and add outputs Date: Wed, 17 Jul 2024 14:10:47 -0400 Message-ID: <20240717181106.2173527-2-bmarzins@redhat.com> In-Reply-To: <20240717181106.2173527-1-bmarzins@redhat.com> References: <20240717181106.2173527-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com add arguments to dm_map_present_by_wwid() to allow optionally fetching the device name and dm info for the devices found by WWID. These will be used by a later patch. Since it can now also be used to get the name and dm info of a device from its WWID, rename it to dm_find_map_by_wwid() Signed-off-by: Benjamin Marzinski --- libmultipath/devmapper.c | 5 +++-- libmultipath/devmapper.h | 2 +- libmultipath/valid.c | 2 +- tests/valid.c | 13 +++++++------ 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index 3d256d38..9af0a80e 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -874,7 +874,8 @@ int dm_is_mpath(const char *name) } } -int dm_map_present_by_wwid(const char *wwid) +/* if name is non-NULL, it must point to an array of WWID_SIZE bytes */ +int dm_find_map_by_wwid(const char *wwid, char *name, struct dm_info *dmi) { char tmp[DM_UUID_LEN]; @@ -883,7 +884,7 @@ int dm_map_present_by_wwid(const char *wwid) return libmp_mapinfo(DM_MAP_BY_UUID, (mapid_t) { .str = tmp }, - (mapinfo_t) { .name = NULL }); + (mapinfo_t) { .name = name, .dmi = dmi }); } static int dm_dev_t (const char *mapname, char *dev_t, int len) diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h index f6d0017e..a26dc1e5 100644 --- a/libmultipath/devmapper.h +++ b/libmultipath/devmapper.h @@ -132,7 +132,7 @@ int dm_simplecmd_flush (int task, const char *name, uint16_t udev_flags); int dm_simplecmd_noflush (int task, const char *name, uint16_t udev_flags); int dm_addmap_create (struct multipath *mpp, char *params); int dm_addmap_reload (struct multipath *mpp, char *params, int flush); -int dm_map_present_by_wwid(const char *uuid); +int dm_find_map_by_wwid(const char *wwid, char *name, struct dm_info *dmi); enum { DM_IS_MPATH_NO, diff --git a/libmultipath/valid.c b/libmultipath/valid.c index 9267cef9..b7e0cc9b 100644 --- a/libmultipath/valid.c +++ b/libmultipath/valid.c @@ -360,7 +360,7 @@ is_path_valid(const char *name, struct config *conf, struct path *pp, if (check_wwids_file(pp->wwid, 0) == 0) return PATH_IS_VALID_NO_CHECK; - if (dm_map_present_by_wwid(pp->wwid) == DMP_OK) + if (dm_find_map_by_wwid(pp->wwid, NULL, NULL) == DMP_OK) return PATH_IS_VALID; /* all these act like FIND_MULTIPATHS_STRICT for finding if a diff --git a/tests/valid.c b/tests/valid.c index a93bbe50..ecaeb467 100644 --- a/tests/valid.c +++ b/tests/valid.c @@ -189,10 +189,11 @@ int __wrap_check_wwids_file(char *wwid, int write_wwid) return -1; } -int __wrap_dm_map_present_by_wwid(const char *uuid) +int __wrap_dm_find_map_by_wwid(const char *wwid, char *name, + struct dm_info *dmi) { int ret = mock_type(int); - assert_string_equal(uuid, mock_ptr_type(char *)); + assert_string_equal(wwid, mock_ptr_type(char *)); return ret; } @@ -271,8 +272,8 @@ static void setup_passing(char *name, char *wwid, unsigned int check_multipathd, will_return(__wrap_check_wwids_file, wwid); if (stage == STAGE_CHECK_WWIDS) return; - will_return(__wrap_dm_map_present_by_wwid, 0); - will_return(__wrap_dm_map_present_by_wwid, wwid); + will_return(__wrap_dm_find_map_by_wwid, 0); + will_return(__wrap_dm_find_map_by_wwid, wwid); } static void test_bad_arguments(void **state) @@ -516,8 +517,8 @@ static void test_check_uuid_present(void **state) memset(&pp, 0, sizeof(pp)); conf.find_multipaths = FIND_MULTIPATHS_STRICT; setup_passing(name, wwid, CHECK_MPATHD_RUNNING, STAGE_CHECK_WWIDS); - will_return(__wrap_dm_map_present_by_wwid, 1); - will_return(__wrap_dm_map_present_by_wwid, wwid); + will_return(__wrap_dm_find_map_by_wwid, 1); + will_return(__wrap_dm_find_map_by_wwid, wwid); assert_int_equal(is_path_valid(name, &conf, &pp, true), PATH_IS_VALID); assert_string_equal(pp.dev, name); From patchwork Wed Jul 17 18:10:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13735686 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CDFFC1822FB for ; Wed, 17 Jul 2024 18:11:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239876; cv=none; b=caf57HxQGAFb//yyReu8QH7cb+tPo9msofWDQs0W/DgwESIoAgBWOyaxjoa0IySd7XLkrRz0x2kSesc3nJgBag95Af+5CyBTUSF8bhphBmtLlbH0KlMu3b/tcSdtGzfxpPKXLqm/R0eIhO4zDHRJ3FvpvhPMuJPWTfa0tWTr1ms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239876; c=relaxed/simple; bh=fx7/wiQqFhNOWMu/KDzd2KbfocCTD66xj/vkXbmtAsY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ep+4V/jxKHxOvgReceL5zp2K96xODXXM6DarmKtx0bTiCI7O+yJwIET8zKjkhBjM+CPtrem6ba4i9ZqYCIXoagX5Orv6LBxDiaFe3uWuPc+S8hIlIAVq7bwEnPcJuaK7Re3ERLVihJzdhJoi2khNi3Rob74go0nXeS0M01SeH84= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=I1VjcKU8; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="I1VjcKU8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721239873; h=from:from: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; bh=R94oiu0lT9EzxNJSxBvPmT0GZScgl94iY0wBgdI0ZH0=; b=I1VjcKU8iv2Diju58YnfLUlacKu12PQnSf+yY64zacRV/H1hjF8aByOwPVxUBA4hLN/sIK LUXwAV+k3OJ+I24eUB0QqfohEd+t+cGO6mufx4iqL4Ei00xsBVF5vaq+2UnqzvyQ4KQOw1 JsrIa+1eJgrvUaO7R0xexf2EVM1KxwI= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-155-19FY-2xEOfWzclM-xSI4pQ-1; Wed, 17 Jul 2024 14:11:10 -0400 X-MC-Unique: 19FY-2xEOfWzclM-xSI4pQ-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7BBD21955D42; Wed, 17 Jul 2024 18:11:09 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D00FD1955F3B; Wed, 17 Jul 2024 18:11:08 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 46HIB7qT2173564 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Jul 2024 14:11:07 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46HIB78N2173563; Wed, 17 Jul 2024 14:11:07 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 02/20] multipathd: make cli_add_map() handle adding maps by WWID correctly Date: Wed, 17 Jul 2024 14:10:48 -0400 Message-ID: <20240717181106.2173527-3-bmarzins@redhat.com> In-Reply-To: <20240717181106.2173527-1-bmarzins@redhat.com> References: <20240717181106.2173527-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com cli_add_map() runs filter_wwid() on the input param as if it were a WWID, but dm_get_major_minor() will never find the multipath device if the user actually passes in a WWID. To handle this case, call get_refwwid() early in the function, and use dm_find_map_by_wwid() to check if the map exists, and find its alias and minor number. Also, the do/while loop is unnecessarily confusing and only avoids one repeated function call. Remove it to simplify cli_add_map(). Signed-off-by: Benjamin Marzinski --- libmultipath/libmultipath.version | 5 +++ multipathd/cli_handlers.c | 60 +++++++++++-------------------- 2 files changed, 25 insertions(+), 40 deletions(-) diff --git a/libmultipath/libmultipath.version b/libmultipath/libmultipath.version index 959f675e..d074032b 100644 --- a/libmultipath/libmultipath.version +++ b/libmultipath/libmultipath.version @@ -242,3 +242,8 @@ global: local: *; }; + +LIBMULTIPATH_25.1.0 { +global: + dm_find_map_by_wwid; +} LIBMULTIPATH_25.0.0; diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index 0106213e..772a45d0 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -697,57 +697,37 @@ cli_add_map (void * v, struct strbuf *reply, void * data) { struct vectors * vecs = (struct vectors *)data; char * param = get_keyparam(v, KEY_MAP); - int major = -1, minor = -1; char dev_path[FILE_NAME_SIZE]; - char *refwwid; - char *alias __attribute__((cleanup(cleanup_charp))) = NULL; - int rc, count = 0; - struct config *conf; - int invalid = 0; + char *refwwid __attribute__((cleanup(cleanup_charp))) = NULL; + char alias[WWID_SIZE]; + int rc; + struct dm_info dmi; param = convert_dev(param, 0); condlog(2, "%s: add map (operator)", param); - conf = get_multipath_config(); - pthread_cleanup_push(put_multipath_config, conf); - if (filter_wwid(conf->blist_wwid, conf->elist_wwid, param, NULL) > 0) - invalid = 1; - pthread_cleanup_pop(1); - if (invalid) { + if (get_refwwid(CMD_NONE, param, DEV_DEVMAP, vecs->pathvec, &refwwid) == + PATHINFO_SKIPPED) { append_strbuf_str(reply, "blacklisted\n"); condlog(2, "%s: map blacklisted", param); return 1; + } else if (!refwwid) { + condlog(2, "%s: unknown map.", param); + return -ENODEV; } - do { - if (dm_get_major_minor(param, &major, &minor) < 0) - condlog(count ? 2 : 3, - "%s: not a device mapper table", param); - else { - sprintf(dev_path, "dm-%d", minor); - alias = dm_mapname(major, minor); + if (dm_find_map_by_wwid(refwwid, alias, &dmi) != DMP_OK) { + condlog(3, "%s: map not present. creating", param); + if (coalesce_paths(vecs, NULL, refwwid, FORCE_RELOAD_NONE, + CMD_NONE) != CP_OK) { + condlog(2, "%s: coalesce_paths failed", param); + return 1; + } + if (dm_find_map_by_wwid(refwwid, alias, &dmi) != DMP_OK) { + condlog(2, "%s: failed getting map", param); + return 1; } - /*if there is no mapname found, we first create the device*/ - if (!alias && !count) { - condlog(3, "%s: mapname not found for %d:%d", - param, major, minor); - get_refwwid(CMD_NONE, param, DEV_DEVMAP, - vecs->pathvec, &refwwid); - if (refwwid) { - if (coalesce_paths(vecs, NULL, refwwid, - FORCE_RELOAD_NONE, CMD_NONE) - != CP_OK) - condlog(2, "%s: coalesce_paths failed", - param); - free(refwwid); - } - } /*we attempt to create device only once*/ - count++; - } while (!alias && (count < 2)); - - if (!alias) { - condlog(2, "%s: add map failed", param); - return 1; } + sprintf(dev_path, "dm-%u", dmi.minor); rc = ev_add_map(dev_path, alias, vecs); return rc; } From patchwork Wed Jul 17 18:10:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13735689 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1B78183070 for ; Wed, 17 Jul 2024 18:11:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239877; cv=none; b=pKebZgVNNDdQptD6QjHltGw+qyQzLl2SAW9EGM/GLvekaoqOdo7SUeJBp+x5b82gH1lYI7w10buSb4FEJBeMtwSZLMmAlpJOxxq7ZUy9UV+OIA7Ot/DSHgqN7ZYODh8SkVPvRwMCyvDAuqYriNHvTN8ozKJTXEH3V4aV0uzYbZY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239877; c=relaxed/simple; bh=jqNJ4U+mchHDIhAaQtCSgefWhJ0i1ENkDMQrnjdz1zk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=e6ZSOIJ37q5bd8QmuVI4/vC5V49x7ZABIzVvA2X+fydv5k8z96fxxO+FNr+cookRLG1a+0XZalf9DXzFIGRgtjL1W5RlUnZ/zoTQnemv+LNMLxHscEDs7ed49k7xEylsov3JGncd8Jwgmn26EyIoZktP2FsUOvuE3lR2wjEYm2k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=CTqv/JHt; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CTqv/JHt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721239874; h=from:from: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; bh=wva9wNybVY9ylz8cbfE+NTS4AF8mdPbI+wjhMqW0LzA=; b=CTqv/JHtTiGmBAVFKLVQ+6aQ9BCn5muD0+N7+f3IqpQn7ix2D1GVL1IAhht1iAzXhCLexq pkuVI8w5lCOp8/3F/G+2sY6wlUKNqoBNAXnWCCpe0Utrb/jY38pDdeEri341EBhCw2dtuJ iRsDJAb5scPe6fdLsPwYWHbJTR1qlQE= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-654-gcJRfNNJPHSn9dcBinx5oA-1; Wed, 17 Jul 2024 14:11:12 -0400 X-MC-Unique: gcJRfNNJPHSn9dcBinx5oA-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 923C31955F49; Wed, 17 Jul 2024 18:11:09 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 03E7B19560B2; Wed, 17 Jul 2024 18:11:08 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 46HIB7VJ2173568 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Jul 2024 14:11:07 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46HIB7182173567; Wed, 17 Jul 2024 14:11:07 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 03/20] multipathd: remove checker restart optimization Date: Wed, 17 Jul 2024 14:10:49 -0400 Message-ID: <20240717181106.2173527-4-bmarzins@redhat.com> In-Reply-To: <20240717181106.2173527-1-bmarzins@redhat.com> References: <20240717181106.2173527-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Future commits will make this optimization unusable. Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 13ed6d05..eaef505a 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2704,7 +2704,7 @@ checkerloop (void *ap) while (1) { struct timespec diff_time, start_time, end_time; - int num_paths = 0, strict_timing, rc = 0, i = 0; + int num_paths = 0, strict_timing, rc = 0; unsigned int ticks = 0; enum checker_state checker_state = CHECKER_STARTING; @@ -2723,7 +2723,7 @@ checkerloop (void *ap) sd_notify(0, "WATCHDOG=1"); #endif while (checker_state != CHECKER_FINISHED) { - unsigned int paths_checked = 0; + unsigned int paths_checked = 0, i; struct timespec chk_start_time; pthread_cleanup_push(cleanup_lock, &vecs->lock); @@ -2733,28 +2733,11 @@ checkerloop (void *ap) if (checker_state == CHECKER_STARTING) { vector_foreach_slot(vecs->pathvec, pp, i) pp->is_checked = false; - i = 0; checker_state = CHECKER_RUNNING; - } else { - /* - * Paths could have been removed since we - * dropped the lock. Find the path to continue - * checking at. Since paths can be removed from - * anywhere in the vector, but can only be added - * at the end, the last checked path must be - * between its old location, and the start or - * the vector. - */ - if (i >= VECTOR_SIZE(vecs->pathvec)) - i = VECTOR_SIZE(vecs->pathvec) - 1; - while ((pp = VECTOR_SLOT(vecs->pathvec, i))) { - if (pp->is_checked == true) - break; - i--; - } - i++; } - vector_foreach_slot_after (vecs->pathvec, pp, i) { + vector_foreach_slot(vecs->pathvec, pp, i) { + if (pp->is_checked) + continue; pp->is_checked = true; rc = check_path(vecs, pp, ticks); if (rc < 0) { From patchwork Wed Jul 17 18:10:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13735691 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CDFB21822E1 for ; Wed, 17 Jul 2024 18:11:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239877; cv=none; b=FUMCbI8g8RGuQiFd901rx57q9OJVepG5zdWEMoxSsGd6x/g/1q3zbuZ5TL6Dow7DZFv+7vSJRSJeWWIwO6pVgcmgOl6gwc0QLhse9UVQZCLesHIPAcpJVy9Qt+ptA2/Ap+T7xwxE8px3OcLi4Hgkl5bH1lzak+ZE+vSSFJcJ4QU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239877; c=relaxed/simple; bh=7/sKx7s1JrUyqU9PdccNe0yRxCgbCzT/VuMbe4sdiHQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sCY0rT+6zqtzGejiWO3BX+4BSXQU57aQNcz1qxXxOf1sTbgsyvD9o7W1wvMUn0RW7YiOGQS2ZNujxE6TWdV7vqEYvuGXkXhDibx651CSDEKcm0mnrAD5eoJTsqmj+D11TiYUY2zq+O5KWr+C44a8l1hbiskywiRAabNkid7RFUk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=cCZkZj3p; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="cCZkZj3p" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721239873; h=from:from: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; bh=ni238ux9tshvYi/hZiHKFQs+wdfve54sBELVGEW6cMY=; b=cCZkZj3pDemwZAV0Tcj6BTNd8Y3hw5ahdjhMKeWH6Kvj1+u4xDbvwSk6dZ42GOSoG8aviD Ff9kpPIpwsK3TqeCtMqEIncdKEIXxDcTA0/w5PndyiHUUXb+HWA6zylkjbDMIX90TkkbCK 2jvbDsAc8f6xE87ann4SujfP2gWTJzI= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-1-gS6k8BSxOvmzLCHxrdxl2Q-1; Wed, 17 Jul 2024 14:11:10 -0400 X-MC-Unique: gS6k8BSxOvmzLCHxrdxl2Q-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 78BF51955F3D; Wed, 17 Jul 2024 18:11:09 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 157293000187; Wed, 17 Jul 2024 18:11:08 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 46HIB72m2173572 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Jul 2024 14:11:07 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46HIB7372173571; Wed, 17 Jul 2024 14:11:07 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v2 04/20] multipathd: refactor path state getting code into a helper Date: Wed, 17 Jul 2024 14:10:50 -0400 Message-ID: <20240717181106.2173527-5-bmarzins@redhat.com> In-Reply-To: <20240717181106.2173527-1-bmarzins@redhat.com> References: <20240717181106.2173527-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Pull the code that gets the new path state out into a helper function named check_path_state(), in preparation for splittig check_path() into two functions. Reviewed-by: Martin Wilck Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 64 ++++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index eaef505a..37e6bd18 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2305,6 +2305,43 @@ should_skip_path(struct path *pp){ return 0; } +static int +check_path_state(struct path *pp) +{ + int newstate; + struct config *conf; + + newstate = path_offline(pp); + if (newstate == PATH_UP) { + conf = get_multipath_config(); + pthread_cleanup_push(put_multipath_config, conf); + newstate = get_state(pp, conf, 1, newstate); + pthread_cleanup_pop(1); + } else { + checker_clear_message(&pp->checker); + condlog(3, "%s: state %s, checker not called", + pp->dev, checker_state_name(newstate)); + } + /* + * Wait for uevent for removed paths; + * some LLDDs like zfcp keep paths unavailable + * without sending uevents. + */ + if (newstate == PATH_REMOVED) + newstate = PATH_DOWN; + + if (newstate == PATH_WILD || newstate == PATH_UNCHECKED) { + condlog(2, "%s: unusable path (%s) - checker failed", + pp->dev, checker_state_name(newstate)); + LOG_MSG(2, pp); + conf = get_multipath_config(); + pthread_cleanup_push(put_multipath_config, conf); + pathinfo(pp, conf, 0); + pthread_cleanup_pop(1); + } + return newstate; +} + /* * Returns '1' if the path has been checked, '-1' if it was blacklisted * and '0' otherwise @@ -2384,33 +2421,8 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) */ pp->tick = checkint; - newstate = path_offline(pp); - if (newstate == PATH_UP) { - conf = get_multipath_config(); - pthread_cleanup_push(put_multipath_config, conf); - newstate = get_state(pp, conf, 1, newstate); - pthread_cleanup_pop(1); - } else { - checker_clear_message(&pp->checker); - condlog(3, "%s: state %s, checker not called", - pp->dev, checker_state_name(newstate)); - } - /* - * Wait for uevent for removed paths; - * some LLDDs like zfcp keep paths unavailable - * without sending uevents. - */ - if (newstate == PATH_REMOVED) - newstate = PATH_DOWN; - + newstate = check_path_state(pp); if (newstate == PATH_WILD || newstate == PATH_UNCHECKED) { - condlog(2, "%s: unusable path (%s) - checker failed", - pp->dev, checker_state_name(newstate)); - LOG_MSG(2, pp); - conf = get_multipath_config(); - pthread_cleanup_push(put_multipath_config, conf); - pathinfo(pp, conf, 0); - pthread_cleanup_pop(1); return 1; } else if ((newstate != PATH_UP && newstate != PATH_GHOST && newstate != PATH_PENDING) && (pp->state == PATH_DELAYED)) { From patchwork Wed Jul 17 18:10:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13735696 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DDCB818411D for ; Wed, 17 Jul 2024 18:11:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239878; cv=none; b=m32LN3hKSkFMv9gf+ZLIMF5LK1wu9+IsgVLSu8i/e4U04NOwp4eZm7tfB0Zes5U3GnmD0HW4AhZMAf/qsgY2HVl7yk1VRLZ4yJc1+7bPQyI8VWMStGcyf15cJ5mR3H+WlsXXuhHLr5U9VFowscRyDB2oj/I5N6oY197wwifs/vo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239878; c=relaxed/simple; bh=NNOq3gcsc6zNjTSwEMTwjwhxo/Msu5+ynxkhtGB+Whk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=A1MnEdDVqH06XF9NG8QCrfEOp3ALPoLomRUhz1iK0UPgmxvKg/6UQuwYOhodO1FIR35LDCiTJqVfrLD+FHJo3m46SsP7Og/ZR/J+bpDjj2QvV51wcycz/0T8yOS7zX7FUAmQpahxvGMaFa3qT2cgtrxxx6VH8GjLDNw1uV3HG6Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=FaH6GeT6; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="FaH6GeT6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721239875; h=from:from: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; bh=M2lRXqADz2y9512f7J/tigDfMxzm8DUV3G9Ms/1NL4A=; b=FaH6GeT6C03iPeJ95QJfFkVRvYqw/w83jn14Ap65rTEIXQlzXf84pd6HOKawKaZHDbfF9x F6mT7tAquZ+o/AsoU2/eGWaicXL+Ayyhf/D/pkQfpENMVzsF4vfxwTXfRAjr3cXO+bsOec 5ZC253Oa5iwxxVtPJLTyYQ8p7KT+OYo= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-654-at7Kxsh1N3ePW7dmKViu5w-1; Wed, 17 Jul 2024 14:11:12 -0400 X-MC-Unique: at7Kxsh1N3ePW7dmKViu5w-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BEE101955D45; Wed, 17 Jul 2024 18:11:09 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 42ADA1956046; Wed, 17 Jul 2024 18:11:09 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 46HIB7g72173576 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Jul 2024 14:11:08 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46HIB7em2173575; Wed, 17 Jul 2024 14:11:07 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 05/20] multipathd: handle uninitialized paths in new function Date: Wed, 17 Jul 2024 14:10:51 -0400 Message-ID: <20240717181106.2173527-6-bmarzins@redhat.com> In-Reply-To: <20240717181106.2173527-1-bmarzins@redhat.com> References: <20240717181106.2173527-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Pull the code to handle uninitialized paths out of check_path() and into a new function called handle_uninitialized_paths(). This should cause no functional changes. Also make check_path() static. Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 168 ++++++++++++++++++++++++++++------------------ 1 file changed, 101 insertions(+), 67 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 37e6bd18..2331f18e 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2343,10 +2343,9 @@ check_path_state(struct path *pp) } /* - * Returns '1' if the path has been checked, '-1' if it was blacklisted - * and '0' otherwise + * Returns '1' if the path has been checked and '0' otherwise */ -int +static int check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) { int newstate; @@ -2354,16 +2353,13 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) int chkr_new_path_up = 0; int disable_reinstate = 0; int oldchkrstate = pp->chkrstate; - int retrigger_tries; unsigned int checkint, max_checkint; struct config *conf; int marginal_pathgroups, marginal_changed = 0; int ret; bool need_reload; - if (((pp->initialized == INIT_OK || pp->initialized == INIT_PARTIAL || - pp->initialized == INIT_REQUESTED_UDEV) && !pp->mpp) || - pp->initialized == INIT_REMOVED) + if (pp->initialized == INIT_REMOVED) return 0; if (pp->tick) @@ -2372,7 +2368,6 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) return 0; /* don't check this path yet */ conf = get_multipath_config(); - retrigger_tries = conf->retrigger_tries; checkint = conf->checkint; max_checkint = conf->max_checkint; marginal_pathgroups = conf->marginal_pathgroups; @@ -2383,38 +2378,6 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) pp->checkint = checkint; }; - if (!pp->mpp && pp->initialized == INIT_MISSING_UDEV) { - if (pp->retriggers < retrigger_tries) { - static const char change[] = "change"; - ssize_t ret; - - condlog(2, "%s: triggering change event to reinitialize", - pp->dev); - pp->initialized = INIT_REQUESTED_UDEV; - pp->retriggers++; - ret = sysfs_attr_set_value(pp->udev, "uevent", change, - sizeof(change) - 1); - if (ret != sizeof(change) - 1) - log_sysfs_attr_set_value(1, ret, - "%s: failed to trigger change event", - pp->dev); - return 0; - } else { - condlog(1, "%s: not initialized after %d udev retriggers", - pp->dev, retrigger_tries); - /* - * Make sure that the "add missing path" code path - * below may reinstate the path later, if it ever - * comes up again. - * The WWID needs not be cleared; if it was set, the - * state hadn't been INIT_MISSING_UDEV in the first - * place. - */ - pp->initialized = INIT_FAILED; - return 0; - } - } - /* * provision a next check soonest, * in case we exit abnormally from here @@ -2435,32 +2398,6 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) pp->checkint = checkint; return 1; } - if (!pp->mpp) { - if (!strlen(pp->wwid) && - (pp->initialized == INIT_FAILED || - pp->initialized == INIT_NEW) && - (newstate == PATH_UP || newstate == PATH_GHOST)) { - condlog(2, "%s: add missing path", pp->dev); - conf = get_multipath_config(); - pthread_cleanup_push(put_multipath_config, conf); - ret = pathinfo(pp, conf, DI_ALL | DI_BLACKLIST); - pthread_cleanup_pop(1); - /* INIT_OK implies ret == PATHINFO_OK */ - if (pp->initialized == INIT_OK) { - ev_add_path(pp, vecs, 1); - pp->tick = 1; - } else { - if (ret == PATHINFO_SKIPPED) - return -1; - /* - * We failed multiple times to initialize this - * path properly. Don't re-check too often. - */ - pp->checkint = max_checkint; - } - } - return 0; - } /* * Async IO in flight. Keep the previous path state * and reschedule as soon as possible @@ -2679,6 +2616,99 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) return 1; } +/* + * Returns -1 if the path was blacklisted, and 0 otherwise + */ +static int +handle_uninitialized_path(struct vectors * vecs, struct path * pp, + unsigned int ticks) +{ + int newstate; + int retrigger_tries; + unsigned int checkint, max_checkint; + struct config *conf; + int ret; + + if (pp->initialized != INIT_NEW && pp->initialized != INIT_FAILED && + pp->initialized != INIT_MISSING_UDEV) + return 0; + + if (pp->tick) + pp->tick -= (pp->tick > ticks) ? ticks : pp->tick; + if (pp->tick) + return 0; /* don't check this path yet */ + + conf = get_multipath_config(); + retrigger_tries = conf->retrigger_tries; + checkint = conf->checkint; + max_checkint = conf->max_checkint; + put_multipath_config(conf); + + if (pp->initialized == INIT_MISSING_UDEV) { + if (pp->retriggers < retrigger_tries) { + static const char change[] = "change"; + ssize_t ret; + + condlog(2, "%s: triggering change event to reinitialize", + pp->dev); + pp->initialized = INIT_REQUESTED_UDEV; + pp->retriggers++; + ret = sysfs_attr_set_value(pp->udev, "uevent", change, + sizeof(change) - 1); + if (ret != sizeof(change) - 1) + log_sysfs_attr_set_value(1, ret, + "%s: failed to trigger change event", + pp->dev); + return 0; + } else { + condlog(1, "%s: not initialized after %d udev retriggers", + pp->dev, retrigger_tries); + /* + * Make sure that the "add missing path" code path + * below may reinstate the path later, if it ever + * comes up again. + * The WWID needs not be cleared; if it was set, the + * state hadn't been INIT_MISSING_UDEV in the first + * place. + */ + pp->initialized = INIT_FAILED; + return 0; + } + } + + /* + * provision a next check soonest, + * in case we exit abnormally from here + */ + pp->tick = checkint; + + newstate = check_path_state(pp); + + if (!strlen(pp->wwid) && + (pp->initialized == INIT_FAILED || pp->initialized == INIT_NEW) && + (newstate == PATH_UP || newstate == PATH_GHOST)) { + condlog(2, "%s: add missing path", pp->dev); + conf = get_multipath_config(); + pthread_cleanup_push(put_multipath_config, conf); + ret = pathinfo(pp, conf, DI_ALL | DI_BLACKLIST); + pthread_cleanup_pop(1); + /* INIT_OK implies ret == PATHINFO_OK */ + if (pp->initialized == INIT_OK) { + ev_add_path(pp, vecs, 1); + pp->tick = 1; + } else { + if (ret == PATHINFO_SKIPPED) + return -1; + /* + * We failed multiple times to initialize this + * path properly. Don't re-check too often. + */ + pp->checkint = max_checkint; + } + } + return 0; +} + enum checker_state { CHECKER_STARTING, CHECKER_RUNNING, @@ -2751,7 +2781,11 @@ checkerloop (void *ap) if (pp->is_checked) continue; pp->is_checked = true; - rc = check_path(vecs, pp, ticks); + if (pp->mpp) + rc = check_path(vecs, pp, ticks); + else + rc = handle_uninitialized_path(vecs, pp, + ticks); if (rc < 0) { condlog(1, "%s: check_path() failed, removing", pp->dev); From patchwork Wed Jul 17 18:10:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13735687 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84CD518308B for ; Wed, 17 Jul 2024 18:11:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239877; cv=none; b=eD0t2hus1rJZaUroR/mM8sEc6fwWI57iNe/2ykQkkLC7zZBRttsY7dcRusbN7kIwk7NmvqUnQuLVM+lqKar+Rhp3t2Kq1hroHMI7ln2//cYzOChZVcwx7UjvLpGpOf84zlaA2IAXWlGHccfZSbuYFyEjtsW2etOPF4A0X1NyJ/M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239877; c=relaxed/simple; bh=1K/BJd5zOx6YokLzwcAgpDiqlwOIaij9tcQVHKZQy2Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qErdh0aYS2Q30uOGLHihbxkAt4FgMPxJNaSOlj3fBr3xwH3V0Ui0mDfEj89zNvyWd7hWrU3gWNFn02hE43XDDnn8qxA7NOJdDPZpWhg7M2yl4gGULqny1FLhbJUQ2jVSGEu0Z4DLuRsZ44oQ9Q3mTf/uTbVJXCOsl2sHg148F1M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=WFcQFf3G; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WFcQFf3G" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721239874; h=from:from: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; bh=SXLVoOzofO56mweeSPtXnxE8dHs3lOf6JjMR7tG5wSo=; b=WFcQFf3G5IfNrs2V5hhmJDoakEIcDTxxfYBisJILFGFi3RUx+bnEgHBIAZO+TumdmGtfbd gLz6gEUGo4V6a2kEoh3oZjaboXZ8mtIXS+nnm2zXfnywM2SAaxlLxY58KwussmIoDRpSuF g9/c60b8SYuPRSUAVHNuUwGkcFjzhjU= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-282-7wfyNUYxPyehKfQBvGaNuw-1; Wed, 17 Jul 2024 14:11:11 -0400 X-MC-Unique: 7wfyNUYxPyehKfQBvGaNuw-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CD4D71955D45; Wed, 17 Jul 2024 18:11:09 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 637C13000186; Wed, 17 Jul 2024 18:11:09 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 46HIB84N2173580 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Jul 2024 14:11:08 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46HIB8d62173579; Wed, 17 Jul 2024 14:11:08 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v2 06/20] multipathd: check paths immediately after failing udev initialization Date: Wed, 17 Jul 2024 14:10:52 -0400 Message-ID: <20240717181106.2173527-7-bmarzins@redhat.com> In-Reply-To: <20240717181106.2173527-1-bmarzins@redhat.com> References: <20240717181106.2173527-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com When handle_uninitialized_path() moves a path from INIT_MISSING_UDEV to INIT_FAILED, it has already waited for conf->retrigger_delay seconds. It might as well check the path state now, instead of waiting for the next iteration. Reviewed-by: Martin Wilck Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/multipathd/main.c b/multipathd/main.c index 2331f18e..f9451302 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2672,7 +2672,6 @@ handle_uninitialized_path(struct vectors * vecs, struct path * pp, * place. */ pp->initialized = INIT_FAILED; - return 0; } } From patchwork Wed Jul 17 18:10:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13735682 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA20E79D2 for ; Wed, 17 Jul 2024 18:11:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239875; cv=none; b=Pd+rrqaK+AGQT16F18nbDrZOlcxsJf2QdIzjHuksXX8NTVcDbgkF+xR4o0zsI66LtjyGHyFE4e9pBHP+kJbWVpJpwREPHemn7Y8yOJq72s8C0aj84ypmGkvdhg0z//39VOyPod/99nHVgIzAPjV6xC4CEGjumvKIeT8gLNYn+SQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239875; c=relaxed/simple; bh=bYLAVeLlrmFbhtSUm6wy9BdZ5PIMTucdwy8m1uLPoZc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ims01lQ13lvgECj+4kyTujySKHyPJQYWAY0xhYh78HqR5QKqs7Nj8Ttx5fsqQE6ZsNONfxfI8QhqjbB9zOKM/8/JV2JYyuC6QXkcKFFxji+DA71a5bPEx6bwU+hHRbFtcidOCp/eCIVkH0Lg2JG8xMxmTavUq/u5k2H8wJfIn8Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=bziEUOI/; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bziEUOI/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721239872; h=from:from: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; bh=ImgkSAUuZQrXYePA8TxJoVzfu24R3InlnmY9DHsssoM=; b=bziEUOI/OUFs38fP0NEXtrgILQrMFqnOndnwI0iwvbIA7kRPKDCKxW93Uut2D68a1gSYfC vTdZcLtDVm+XQat2OrSonUp5/tL9zsLnKeNqWWXOQQtvZPYGXHrMwPU29cBIcAu3+FSxYJ Ns57BLFir+NPBdHM68kAu0PMSxWKM/o= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-167-fST2gO-NMSy71JoHVtperA-1; Wed, 17 Jul 2024 14:11:11 -0400 X-MC-Unique: fST2gO-NMSy71JoHVtperA-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3C6151955D50; Wed, 17 Jul 2024 18:11:10 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A6FFD1955D47; Wed, 17 Jul 2024 18:11:09 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 46HIB8WQ2173584 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Jul 2024 14:11:08 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46HIB8Tk2173583; Wed, 17 Jul 2024 14:11:08 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v2 07/20] multipathd: set pp->tick = max_checkint in handle_uninitialized_path Date: Wed, 17 Jul 2024 14:10:53 -0400 Message-ID: <20240717181106.2173527-8-bmarzins@redhat.com> In-Reply-To: <20240717181106.2173527-1-bmarzins@redhat.com> References: <20240717181106.2173527-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com When handle_uninitialized_path() checks a path, it will either: 1. trigger a new uevent to initalize the path, in which case it won't check the path again until that uevent is processed and updates pp->tick 2. blacklist the path, in which case the path gets removed 3. intialize the path correctly, in which case it sets pp->tick = 1 4. fail to initialize the path, in which case it was supposed to set pp->tick to max_checkint, but instead it set pp->checkint to max_checkint, which never worked correctly. By setting pp->tick to max_checkint at the start, handle_uninitialized_path() will continue to work as it previously did, except in case 4, where in now works correctly. There's no point in messing with pp->checkint for paths that haven't been initialized yet. Reviewed-by: Martin Wilck Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index f9451302..7c4d3bf6 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2625,7 +2625,6 @@ handle_uninitialized_path(struct vectors * vecs, struct path * pp, { int newstate; int retrigger_tries; - unsigned int checkint, max_checkint; struct config *conf; int ret; @@ -2640,8 +2639,7 @@ handle_uninitialized_path(struct vectors * vecs, struct path * pp, conf = get_multipath_config(); retrigger_tries = conf->retrigger_tries; - checkint = conf->checkint; - max_checkint = conf->max_checkint; + pp->tick = conf->max_checkint; put_multipath_config(conf); if (pp->initialized == INIT_MISSING_UDEV) { @@ -2675,12 +2673,6 @@ handle_uninitialized_path(struct vectors * vecs, struct path * pp, } } - /* - * provision a next check soonest, - * in case we exit abnormally from here - */ - pp->tick = checkint; - newstate = check_path_state(pp); if (!strlen(pp->wwid) && @@ -2695,14 +2687,8 @@ handle_uninitialized_path(struct vectors * vecs, struct path * pp, if (pp->initialized == INIT_OK) { ev_add_path(pp, vecs, 1); pp->tick = 1; - } else { - if (ret == PATHINFO_SKIPPED) - return -1; - /* - * We failed multiple times to initialize this - * path properly. Don't re-check too often. - */ - pp->checkint = max_checkint; + } else if (ret == PATHINFO_SKIPPED) { + return -1; } } return 0; From patchwork Wed Jul 17 18:10:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13735685 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE04318306A for ; Wed, 17 Jul 2024 18:11:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239876; cv=none; b=M/ZKNfwqb+DS7XlMoVnRw8ZnqjKMKT/2z4PljJPQ0/EASKa1UtPKdU/CepbMvSLY5Z02ZosXoxHYCSPdsaP5fCrmPiFAldKlQO9htnXdka3kmxdKKDRd84dxozB4sSQaYiWsjMYPT43zfu2tW0+SQZoko1eG1DKBdTVkE3XHkMQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239876; c=relaxed/simple; bh=i8F+l7SS8O1bNGWj2PTt+ZCcTaF0lALBL7SV8KbWhag=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ChI0RbPZluq61oTID8kfH4BCiYqMcGgLvV6UNycZ7HKoInAU7Q6o/Xalds1TqUedGyjtaX80o5SAs7eeiL5agqji3sRCWQSpb35Z2ON6OfJW8xz6TyjVWkRfjVqvKmlZQDzg1r1MEGBWTghkybyMy339fXrlsiEbMQJ07AjCZjA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=G5GoAl1P; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="G5GoAl1P" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721239873; h=from:from: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; bh=1irfF3S8GR26MRA8ut3reXlF22uXF+hw10h7wB/frdo=; b=G5GoAl1PyjPuLJT7U/Uikc5QDEr6eA/52CaNfS63n/BU4rqYvZUh1vojvzEdePGE+RglwE mWpFgQw+jrfoh2+Y0FaYJiBgPcOWRUTzOOGeGEh+R4KFjTq6X0e8FcN8HVgNtgkOxCoy8p 2LDcDgY7843lFeDcs0Upu6oW/UnSIHU= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-193-KdIX43_KOjqoFn66QH27fw-1; Wed, 17 Jul 2024 14:11:12 -0400 X-MC-Unique: KdIX43_KOjqoFn66QH27fw-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 46A6D19560A1; Wed, 17 Jul 2024 18:11:10 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D71E03000185; Wed, 17 Jul 2024 18:11:09 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 46HIB8k42173588 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Jul 2024 14:11:08 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46HIB8xL2173587; Wed, 17 Jul 2024 14:11:08 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v2 08/20] multipathd: return 0 from check_path() if that path wasn't checked Date: Wed, 17 Jul 2024 14:10:54 -0400 Message-ID: <20240717181106.2173527-9-bmarzins@redhat.com> In-Reply-To: <20240717181106.2173527-1-bmarzins@redhat.com> References: <20240717181106.2173527-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com If check_path_state() returns PATH_WILD or PATH_UNCHECKED, then the path wasn't correctly checked, and check_path() should return 0. Reviewed-by: Martin Wilck Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multipathd/main.c b/multipathd/main.c index 7c4d3bf6..733952cf 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2386,7 +2386,7 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) newstate = check_path_state(pp); if (newstate == PATH_WILD || newstate == PATH_UNCHECKED) { - return 1; + return 0; } else if ((newstate != PATH_UP && newstate != PATH_GHOST && newstate != PATH_PENDING) && (pp->state == PATH_DELAYED)) { /* If path state become failed again cancel path delay state */ From patchwork Wed Jul 17 18:10:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13735694 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEA3C184120 for ; Wed, 17 Jul 2024 18:11:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239878; cv=none; b=gfc3PWEwG3h8WsULq1nPHdeygnUC6qM+xxULPn0P7szAgzEzxHqdWkXuwTqD2gRsox1/1O7H5Hniw0xOuJHY6V1N0XxN78dWVeN+03TOVors6OB2KD1tKl7snYAbFjTsefRHjG6NxglY9iKF9VT5O8ruCXg8tuYBXn0OKjjpg0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239878; c=relaxed/simple; bh=QHmuzgGtkePuUugHyyBeCbvWhC8AGk0byHyG6Vtx6mU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PWlgmgqkKXNDxjYCNYlYNDcosFUEDA7Z4Nh6xXFTXhVQDX6KHH32WoY2Wh0WmrhBDe0uZ73l6/b7KkUsJ7Ez+DWMxfW8gOcU3ybJh9IYs088uyfqeQ2dATmtgLuEKqiwzmbS1T14Mj7OKHXXqVZlCg/9HpFKKcZ9y+p9iCBjyU8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=RVgz5gSb; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RVgz5gSb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721239876; h=from:from: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; bh=K64AKtG8KeMB6LYvyPJyDGCUEcRShhSyxoMzu9mWZzo=; b=RVgz5gSb+wxbOKqpQgkEc3q+PQZ41/gJjU1z6/s2pK9NAkMWz59Bm3HdwS0ktHG90jwifC M+YHGPUhl25PSNjTTwAIfCPJ7hDz6TTzgAyufJUA0KVbPSHE6NmimqimKxXsio6McMy1Kx fQnDYYLNfPcjlf7qIF+Wy0OLZBecHkc= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-646-JQkvQZddPnSBt9bspp5BEw-1; Wed, 17 Jul 2024 14:11:11 -0400 X-MC-Unique: JQkvQZddPnSBt9bspp5BEw-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5942919560B1; Wed, 17 Jul 2024 18:11:10 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0962C1955D42; Wed, 17 Jul 2024 18:11:09 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 46HIB8Jw2173592 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Jul 2024 14:11:08 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46HIB87J2173591; Wed, 17 Jul 2024 14:11:08 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v2 09/20] multipathd: reorder path state checks Date: Wed, 17 Jul 2024 14:10:55 -0400 Message-ID: <20240717181106.2173527-10-bmarzins@redhat.com> In-Reply-To: <20240717181106.2173527-1-bmarzins@redhat.com> References: <20240717181106.2173527-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Reorder the path state checks in check_path(), so that it first does all the checks which can result in returning with the path unchecked or removed from the multipath device. Reviewed-by: Martin Wilck Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 733952cf..08b424d6 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2385,19 +2385,8 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) pp->tick = checkint; newstate = check_path_state(pp); - if (newstate == PATH_WILD || newstate == PATH_UNCHECKED) { + if (newstate == PATH_WILD || newstate == PATH_UNCHECKED) return 0; - } else if ((newstate != PATH_UP && newstate != PATH_GHOST && - newstate != PATH_PENDING) && (pp->state == PATH_DELAYED)) { - /* If path state become failed again cancel path delay state */ - pp->state = newstate; - /* - * path state bad again should change the check interval time - * to the shortest delay - */ - pp->checkint = checkint; - return 1; - } /* * Async IO in flight. Keep the previous path state * and reschedule as soon as possible @@ -2436,6 +2425,17 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) return 0; } + if ((newstate != PATH_UP && newstate != PATH_GHOST && + newstate != PATH_PENDING) && (pp->state == PATH_DELAYED)) { + /* If path state become failed again cancel path delay state */ + pp->state = newstate; + /* + * path state bad again should change the check interval time + * to the shortest delay + */ + pp->checkint = checkint; + return 1; + } if ((newstate == PATH_UP || newstate == PATH_GHOST) && (san_path_check_enabled(pp->mpp) || marginal_path_check_enabled(pp->mpp))) { From patchwork Wed Jul 17 18:10:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13735693 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC445183090 for ; Wed, 17 Jul 2024 18:11:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239877; cv=none; b=tTNhbPrrEBaqYosU5yIXPcVsYrVE82Q3JYSbNwU52uJO0zmFoUtjOEH4WW9HBUaRPxWDhs9Ok/4edFijiuvKErooW7bj4/kC2k4m3+x/a8N/SWVcezOdfIrOZSBz4BMia9u8iU57by6HHFDvsvywiiv/4xwxoisNpiTLCj6KtAE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239877; c=relaxed/simple; bh=jvkKHsQeNsRwgmF8KoDLEZYYiIxrcwyLc2RHsXfDSM8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OGeVf+jif/QaUDBGA6yiRQt+qreUl+zWGy07tvlKsvYmsLice0YPqTj0FsC/K5vrSwIntkRO8lafDNlDASZ3VpXIM4mWfJtpEHjWRTZUUH5u/vyeSeBjduqz2ls6lbFatL6ytXSKHrkiFq/TSIcxxhnhg0uzR4rF0iOUQGAQymk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=RVZnUq8y; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RVZnUq8y" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721239874; h=from:from: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; bh=tdUh1mIcHTtFmruWxFXBIhScsccsNQmCqr+wTZ8ze0M=; b=RVZnUq8yu/5bYrs/nyWYWxbAkS36RDqlbM7iVaovJtUzsyWjcNh0Oyk/9112OtMBsbVBkn gg5+/96rHgyIW0Iw0j7PmmeQY0N0RSikqDRsM8M15aLit/U2w5tLCxOZolT69lcImc29Il DzrLruFvwNXv3pMem9JaBc4quihgVg0= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-314-sGmmgWzbPdyj6ewRis06tQ-1; Wed, 17 Jul 2024 14:11:11 -0400 X-MC-Unique: sGmmgWzbPdyj6ewRis06tQ-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 57BAC1955D42; Wed, 17 Jul 2024 18:11:10 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EAF2A1955F3B; Wed, 17 Jul 2024 18:11:09 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 46HIB8nM2173596 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Jul 2024 14:11:08 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46HIB8922173595; Wed, 17 Jul 2024 14:11:08 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 10/20] multipathd: adjust when mpp is synced with the kernel Date: Wed, 17 Jul 2024 14:10:56 -0400 Message-ID: <20240717181106.2173527-11-bmarzins@redhat.com> In-Reply-To: <20240717181106.2173527-1-bmarzins@redhat.com> References: <20240717181106.2173527-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Move the code to sync the mpp device state into a helper function and add a counter to to make sure that the device is synced at least once every max_checkint secs. This makes sure that multipath devices with no paths will still get synced with the kernel. Also, if multiple paths are checked in the same loop, the multipath device will only be synced with the kernel once, since every time the mpp is synced in any code path, mpp->sync_tick is reset. The code still syncs the mpp before updating the path state for two main reasons. 1. Sometimes multipathd leaves the mpp with a garbage state. Future patches will fix most of these cases, but the code intentially does not remove the mpp is resyncing fails while checking paths. But this does leave the mpp with a garbage state. 2. The kernel chages the multipath state independently of multipathd. If the kernel fails a path, a uevent will arrive shortly. But the kernel doesn't provide any notification when it switches the active path group or if it ends up picking a different one than multipathd selected. Multipathd needs to know the actual current pathgroup to know when it should be switching them. Signed-off-by: Benjamin Marzinski --- libmultipath/configure.c | 1 + libmultipath/structs.h | 2 ++ libmultipath/structs_vec.c | 5 +++ multipathd/main.c | 64 +++++++++++++++++++++++++------------- 4 files changed, 50 insertions(+), 22 deletions(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index b4de863c..34158e31 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -358,6 +358,7 @@ int setup_map(struct multipath *mpp, char **params, struct vectors *vecs) sysfs_set_scsi_tmo(conf, mpp); marginal_pathgroups = conf->marginal_pathgroups; + mpp->sync_tick = conf->max_checkint; pthread_cleanup_pop(1); if (!mpp->features || !mpp->hwhandler || !mpp->selector) { diff --git a/libmultipath/structs.h b/libmultipath/structs.h index 3b91e39c..002eeae1 100644 --- a/libmultipath/structs.h +++ b/libmultipath/structs.h @@ -453,6 +453,8 @@ struct multipath { int ghost_delay; int ghost_delay_tick; int queue_mode; + unsigned int sync_tick; + bool is_checked; uid_t uid; gid_t gid; mode_t mode; diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c index 731b1bce..60360c76 100644 --- a/libmultipath/structs_vec.c +++ b/libmultipath/structs_vec.c @@ -505,10 +505,15 @@ update_multipath_table (struct multipath *mpp, vector pathvec, int flags) char __attribute__((cleanup(cleanup_charp))) *params = NULL; char __attribute__((cleanup(cleanup_charp))) *status = NULL; unsigned long long size = mpp->size; + struct config *conf; if (!mpp) return r; + conf = get_multipath_config(); + mpp->sync_tick = conf->max_checkint; + put_multipath_config(conf); + r = libmp_mapinfo(DM_MAP_BY_NAME | MAPINFO_MPATH_ONLY, (mapid_t) { .str = mpp->alias }, (mapinfo_t) { diff --git a/multipathd/main.c b/multipathd/main.c index 08b424d6..d7c87039 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2342,6 +2342,37 @@ check_path_state(struct path *pp) return newstate; } +static void +do_sync_mpp(struct vectors * vecs, struct multipath *mpp) +{ + int i, ret; + struct path *pp; + + mpp->is_checked = true; + ret = update_multipath_strings(mpp, vecs->pathvec); + if (ret != DMP_OK) { + condlog(1, "%s: %s", mpp->alias, ret == DMP_NOT_FOUND ? + "device not found" : + "couldn't synchronize with kernel state"); + vector_foreach_slot (mpp->paths, pp, i) + pp->dmstate = PSTATE_UNDEF; + return; + } + set_no_path_retry(mpp); +} + +static void +sync_mpp(struct vectors * vecs, struct multipath *mpp, unsigned int ticks) +{ + if (mpp->sync_tick) + mpp->sync_tick -= (mpp->sync_tick > ticks) ? ticks : + mpp->sync_tick; + if (mpp->sync_tick) + return; + + do_sync_mpp(vecs, mpp); +} + /* * Returns '1' if the path has been checked and '0' otherwise */ @@ -2356,7 +2387,6 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) unsigned int checkint, max_checkint; struct config *conf; int marginal_pathgroups, marginal_changed = 0; - int ret; bool need_reload; if (pp->initialized == INIT_REMOVED) @@ -2395,26 +2425,6 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) pp->tick = 1; return 0; } - /* - * Synchronize with kernel state - */ - ret = update_multipath_strings(pp->mpp, vecs->pathvec); - if (ret != DMP_OK) { - if (ret == DMP_NOT_FOUND) { - /* multipath device missing. Likely removed */ - condlog(1, "%s: multipath device '%s' not found", - pp->dev, pp->mpp ? pp->mpp->alias : ""); - return 0; - } else - condlog(1, "%s: Couldn't synchronize with kernel state", - pp->dev); - pp->dmstate = PSTATE_UNDEF; - } - /* if update_multipath_strings orphaned the path, quit early */ - if (!pp->mpp) - return 0; - set_no_path_retry(pp->mpp); - if (pp->recheck_wwid == RECHECK_WWID_ON && (newstate == PATH_UP || newstate == PATH_GHOST) && ((pp->state != PATH_UP && pp->state != PATH_GHOST) || @@ -2424,7 +2434,12 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) handle_path_wwid_change(pp, vecs); return 0; } - + if (!pp->mpp->is_checked) { + do_sync_mpp(vecs, pp->mpp); + /* if update_multipath_strings orphaned the path, quit early */ + if (!pp->mpp) + return 0; + } if ((newstate != PATH_UP && newstate != PATH_GHOST && newstate != PATH_PENDING) && (pp->state == PATH_DELAYED)) { /* If path state become failed again cancel path delay state */ @@ -2752,12 +2767,17 @@ checkerloop (void *ap) while (checker_state != CHECKER_FINISHED) { unsigned int paths_checked = 0, i; struct timespec chk_start_time; + struct multipath *mpp; pthread_cleanup_push(cleanup_lock, &vecs->lock); lock(&vecs->lock); pthread_testcancel(); + vector_foreach_slot(vecs->mpvec, mpp, i) + mpp->is_checked = false; get_monotonic_time(&chk_start_time); if (checker_state == CHECKER_STARTING) { + vector_foreach_slot(vecs->mpvec, mpp, i) + sync_mpp(vecs, mpp, ticks); vector_foreach_slot(vecs->pathvec, pp, i) pp->is_checked = false; checker_state = CHECKER_RUNNING; From patchwork Wed Jul 17 18:10:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13735684 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3293D17FAAE for ; Wed, 17 Jul 2024 18:11:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239875; cv=none; b=tH4LFdAfbNpRa+7pNhBWGNb7kQs8WAFG6ibLKPxU8su4Jb3ecsc3ELzFNzM5IUGWcBJL6Gw+LFY5AM5I2BNKSnq6JFR3bg6hOgmX0BsuFPrkL3QYWP8Hk3W9bX8qezeCAIkU9i6UzmP5jdfvfoLsjmEk61N32a6iJtkjI8oKGTE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239875; c=relaxed/simple; bh=k/MbXYdm9FqwQ+L6aVv0ZJ6SZI7lGvviOGjzDW2Ghjk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bpAsBr4ksLbyxZcsHzzr3WoSIkSzbs0V0xNaJrmfTr3bybzdMP2LmiH6auBjjP6718SMWT5MlEqdHaoY9O/ZfFjwlSMU31XZeRuSrxrUc8xSa5VMyMid5Qo+mBU3l0DDF6574Ho1ICrSleicPCZGYaDOJwSt9MIZywl/YiiikbI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=G53LEBhG; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="G53LEBhG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721239873; h=from:from: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; bh=YyifouYLDe74T7Vq8RIILmsU11BFW1JelfD8jG79xpg=; b=G53LEBhGzyPyHPwvVpyLJ0ONjmAH3ksv9kTXLCron55lnwiUTLmyzFI7nwrzwpKM2wcA8R ls6HqfFronmMk9rL95mNux3NQNVPwBOPrxHCj57uff1OK6c47JO7/A7+fr5n3XFD9GRZlF DjzM47lOdbMh09M6dA5P4IfcItJOYZM= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-678-l3clpyzkNXSKjDomCcwHBA-1; Wed, 17 Jul 2024 14:11:11 -0400 X-MC-Unique: l3clpyzkNXSKjDomCcwHBA-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A061519560B3; Wed, 17 Jul 2024 18:11:10 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5BC741955F40; Wed, 17 Jul 2024 18:11:10 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 46HIB8mv2173600 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Jul 2024 14:11:09 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46HIB8812173599; Wed, 17 Jul 2024 14:11:08 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 11/20] multipathd: resync map after setup_map in ev_remove_path Date: Wed, 17 Jul 2024 14:10:57 -0400 Message-ID: <20240717181106.2173527-12-bmarzins@redhat.com> In-Reply-To: <20240717181106.2173527-1-bmarzins@redhat.com> References: <20240717181106.2173527-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com In ev_remove_path() it was possible to exit after calling setup_map() without resyncing the mpp state with the kernel. This meant that the mpp state in multipathd might not match with the kernel state at all. It's safe to exit before calling setup_map() if either wait_for_udev or need_do_map is set. In both cases, setup_map() will later be called, either by a uevent or by the calling function. Once setup_map() has been called, setup_multipath() and sync_map_state() are now always called, to make sure the mpp matches the kernel state. Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index d7c87039..aa3c7eb6 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1395,6 +1395,8 @@ ev_remove_path (struct path *pp, struct vectors * vecs, int need_do_map) * avoid referring to the map of an orphaned path */ if ((mpp = pp->mpp)) { + char devt[BLK_DEV_SIZE]; + /* * Mark the path as removed. In case of success, we * will delete it for good. Otherwise, it will be deleted @@ -1428,12 +1430,6 @@ ev_remove_path (struct path *pp, struct vectors * vecs, int need_do_map) flush_map_nopaths(mpp, vecs)) goto out; - if (setup_map(mpp, ¶ms, vecs)) { - condlog(0, "%s: failed to setup map for" - " removal of path %s", mpp->alias, pp->dev); - goto fail; - } - if (mpp->wait_for_udev) { mpp->wait_for_udev = 2; retval = REMOVE_PATH_DELAY; @@ -1444,6 +1440,12 @@ ev_remove_path (struct path *pp, struct vectors * vecs, int need_do_map) retval = REMOVE_PATH_DELAY; goto out; } + + if (setup_map(mpp, ¶ms, vecs)) { + condlog(0, "%s: failed to setup map for" + " removal of path %s", mpp->alias, pp->dev); + goto fail; + } /* * reload the map */ @@ -1453,24 +1455,20 @@ ev_remove_path (struct path *pp, struct vectors * vecs, int need_do_map) "removal of path %s", mpp->alias, pp->dev); retval = REMOVE_PATH_FAILURE; - } else { - /* - * update our state from kernel - */ - char devt[BLK_DEV_SIZE]; - - strlcpy(devt, pp->dev_t, sizeof(devt)); - - /* setup_multipath will free the path - * regardless of whether it succeeds or - * fails */ - if (setup_multipath(vecs, mpp)) - return REMOVE_PATH_MAP_ERROR; - sync_map_state(mpp); + } + /* + * update mpp state from kernel even if domap failed. + * If the path was removed from the mpp, setup_multipath will + * free the path regardless of whether it succeeds or fails + */ + strlcpy(devt, pp->dev_t, sizeof(devt)); + if (setup_multipath(vecs, mpp)) + return REMOVE_PATH_MAP_ERROR; + sync_map_state(mpp); + if (retval == REMOVE_PATH_SUCCESS) condlog(2, "%s: path removed from map %s", devt, mpp->alias); - } } else { /* mpp == NULL */ if ((i = find_slot(vecs->pathvec, (void *)pp)) != -1) From patchwork Wed Jul 17 18:10:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13735697 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D44571836C4 for ; Wed, 17 Jul 2024 18:11:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239878; cv=none; b=JVPb5yMvkzIzX88cnWg9q6n2sMyhm/XdBt4hqwPgO9WalIDui/rtcNw2EbSAP760V1bObGFXdM65fSg2OAPWaZvAU1gnAE/HVEuAX8SWNlAb2Mt1/VfcvD5F2Sl26xZmOLI+AEHxuEdU95THvk+nP4jPr05SQCHFQIyaXo3kj2Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239878; c=relaxed/simple; bh=dz+fdtdNFECphCMYVy0NFwyKj631zd9ecp4rTO/Fyhw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oL9S5h+VzhvU55rnsU8IQ53zAshszaqjqEstxBnQWruIjc90LWdJzzX6v5lX+Plfqcn7hIvN5znVMwxqKlu6Gy+FZLMIZ+6AciRwS3RzCXxwI/RGfLxTrzGYbdMO+B1lDylx9FBjmmuKgZSCTgao5h7Gqhd2P8XFm4FTY+Sy8w0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=MN7dhu48; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MN7dhu48" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721239874; h=from:from: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; bh=DTVmmShzvdSOrCvehQ0TGYrWXMGz8j38e+bRFRa3Zjk=; b=MN7dhu48IecwcxFRjyTxr87FDMFB0TyB5VOaLR61us4vuCVwfoCSHEvS70zAn5K6iSlg0B 6D4eKrJSKEcJptt43+uuzWgbUuM3L3HvnfkbIiuPDnv0gFl6mBNwrkPPfvpQt/noApWzNd wT6SU6GXkYRHU0QwkLK30EHilm5ejAQ= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-678-dUQAttbmNPyWTSuRJgh1lA-1; Wed, 17 Jul 2024 14:11:11 -0400 X-MC-Unique: dUQAttbmNPyWTSuRJgh1lA-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B00531955D44; Wed, 17 Jul 2024 18:11:10 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 460781955E80; Wed, 17 Jul 2024 18:11:10 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 46HIB9vU2173604 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Jul 2024 14:11:09 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46HIB9VQ2173603; Wed, 17 Jul 2024 14:11:09 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 12/20] multipathd: resync map after setup_map in resize_map Date: Wed, 17 Jul 2024 14:10:58 -0400 Message-ID: <20240717181106.2173527-13-bmarzins@redhat.com> In-Reply-To: <20240717181106.2173527-1-bmarzins@redhat.com> References: <20240717181106.2173527-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com In resize_map() it was possible to exit after calling setup_map() without resyncing the mpp state with the kernel. This meant that the mpp state in multipathd might not match with the kernel state at all. Once setup_map() has been called, setup_multipath() and sync_map_state() are now always called, to make sure the mpp matches the kernel state. Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index aa3c7eb6..6d1a5382 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1534,6 +1534,7 @@ needs_ro_update(struct multipath *mpp, int ro) int resize_map(struct multipath *mpp, unsigned long long size, struct vectors * vecs) { + int ret = 0; char *params __attribute__((cleanup(cleanup_charp))) = NULL; unsigned long long orig_size = mpp->size; @@ -1543,7 +1544,8 @@ int resize_map(struct multipath *mpp, unsigned long long size, condlog(0, "%s: failed to setup map for resize : %s", mpp->alias, strerror(errno)); mpp->size = orig_size; - return 1; + ret = 1; + goto out; } mpp->action = ACT_RESIZE; mpp->force_udev_reload = 1; @@ -1551,13 +1553,14 @@ int resize_map(struct multipath *mpp, unsigned long long size, condlog(0, "%s: failed to resize map : %s", mpp->alias, strerror(errno)); mpp->size = orig_size; - return 1; + ret = 1; } +out: if (setup_multipath(vecs, mpp) != 0) return 2; sync_map_state(mpp); - return 0; + return ret; } static int From patchwork Wed Jul 17 18:10:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13735683 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53955180A9E for ; Wed, 17 Jul 2024 18:11:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239875; cv=none; b=FWRRIy+CMjieGXiY7y5pcW+w4nAOhAhnu2SfurTOq5W5yn1kjO+dT5I3LgaRVM1KuaBM7QkwO9efhBb4uwDe9+rW0lYDs6ysvIDhmq/BoZH85AI/3SEQTjZl5LqzpBD+9K/bW7VQKFiNj2mpjW06wLOvc+XbNRbrNkG9Q+KiXOE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239875; c=relaxed/simple; bh=10Lc3T9xDNIHk89BsJ6urvIogyQdCNAt6Tul9nmHLlI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pkQG6pxgSJkuqGL0MkHSfooBEuEiCUvHa9m3Vb/3sJ1zyWWi/cDyz7tG2KZa2xYGzAW+PNxqc7Bdps/zrsaZ7dgvdQWcE55u861P9Eq+A380+mCRxs6SPB+Ud4JTziI8qVVpQc5diXtaRqLEHAzoyhO9YKd5/A3A9AOhXc4Dmls= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=TMDOpiDB; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TMDOpiDB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721239873; h=from:from: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; bh=u5c7fVNR8onkmcmBl8P0wSYKM7bsAs+xAKx3SL3GDVE=; b=TMDOpiDBtFijPNLxGGnQANEltcD/zqcRyeRo/Vp5rdys4VZb25kpvFUu+0/BP8m3gH78VH AViqMx/k86W0catKT5L5EBq21EOen28ovNiFibWbQtYAKuSJt/N5Z1nyervwQcYuHwyVwr qwVtp0x7f9KMNjo+uw1d3V2d/WWgFf0= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-678-rB6eh1MAPF-gN63cvBslQg-1; Wed, 17 Jul 2024 14:11:12 -0400 X-MC-Unique: rB6eh1MAPF-gN63cvBslQg-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EF8771956095; Wed, 17 Jul 2024 18:11:10 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8FABA19560B2; Wed, 17 Jul 2024 18:11:10 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 46HIB9XV2173608 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Jul 2024 14:11:09 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46HIB9WX2173607; Wed, 17 Jul 2024 14:11:09 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v2 13/20] multipathd: always resync map in reload_and_sync_map Date: Wed, 17 Jul 2024 14:10:59 -0400 Message-ID: <20240717181106.2173527-14-bmarzins@redhat.com> In-Reply-To: <20240717181106.2173527-1-bmarzins@redhat.com> References: <20240717181106.2173527-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com reload_and_sync_map() needs to always resync the map after calling reload_map(), because the mpp state may no longer match the kernel state if reload_map() fails. Reviewed-by: Martin Wilck Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 6d1a5382..0d2a6780 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2188,13 +2188,15 @@ static int reload_map(struct vectors *vecs, struct multipath *mpp, int reload_and_sync_map(struct multipath *mpp, struct vectors *vecs) { + int ret = 0; + if (reload_map(vecs, mpp, 1)) - return 1; + ret = 1; if (setup_multipath(vecs, mpp) != 0) return 2; sync_map_state(mpp); - return 0; + return ret; } static int check_path_reinstate_state(struct path * pp) { From patchwork Wed Jul 17 18:11:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13735701 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1E2318411A for ; Wed, 17 Jul 2024 18:11:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239879; cv=none; b=ZR1mSUG0EbOFKElqPtGwzN6y4OZ1vqnPnKeo1gTVI1P7pwS47V7In+WY5oNNBfFpD/QlUSg5Tcx1CzEUk4+dgIFOmt3jjQHhSSWH7E1oWgdG1/VKUC/FR99OClqCfF3Oo7sjguz9tZVLuu2niJNTrzYT4WLJS5tsIa2heA45cqg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239879; c=relaxed/simple; bh=oIWlO7jA1YcbQ6FHKgkSkQBZs1MDTckZpCvHby+uNxs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PukAvxMH/YZUFnOhX1qrSCwG7hWyEiUvKR30sii3wBzPeTJEYBIpq2+/D8jQsEh2bYYIMG4b7TIg2SW4sqz6RqfoCE5AW2zi3gL0Zlbk4Jn6usz8Ktv48a1PIFbA88ScXLCh4fb6/xc4Hdil5U+3FCbBnTYtGQRcV9W+H5Fa4fw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=UgwDBjd3; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UgwDBjd3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721239875; h=from:from: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; bh=aTFUmfIoni0V2VjyDJay0u1FiqPdUYHcx5fRDwQvh5U=; b=UgwDBjd3poN2wRzs2u16G55j673sGmg3C6uvEjxVMZOP6VwrqxfO3KxQGizF1+GczXQndX Ao2y+YMNaNTVqMoGKDSZUivhFRhaFYT593P8ht/X+rre30foTeqZFXarhwXZRM0YPXN91a JdppgVS097B5ivIAChG/derdk/yZyeo= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-119-j8Pw3IGDMXisHePoEPrSyQ-1; Wed, 17 Jul 2024 14:11:12 -0400 X-MC-Unique: j8Pw3IGDMXisHePoEPrSyQ-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 033101955D4C; Wed, 17 Jul 2024 18:11:11 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B1A6F19560AA; Wed, 17 Jul 2024 18:11:10 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 46HIB9Xw2173612 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Jul 2024 14:11:09 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46HIB9p22173611; Wed, 17 Jul 2024 14:11:09 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 14/20] multipathd: correctly handle paths removed for a wwid change Date: Wed, 17 Jul 2024 14:11:00 -0400 Message-ID: <20240717181106.2173527-15-bmarzins@redhat.com> In-Reply-To: <20240717181106.2173527-1-bmarzins@redhat.com> References: <20240717181106.2173527-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com If check_path() exitted because the path's wwid changed and it was removed, checkerloop() wasn't decrementing the pathvec loop count. This caused the next path to be skipped by the checker loop. To solve this, switch check_path() and handle_uninitialized_path() to symbolic returns and make check_path() return CHECK_PATH_REMOVED when a path is removed, make handle_uninitialized_path() also remove the path if it was blacklisted, and make checkerloop() just decrement the loop count when a path handling function returns CHECK_PATH_REMOVED. Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 73 ++++++++++++++++++++++++++--------------------- multipathd/main.h | 2 +- 2 files changed, 41 insertions(+), 34 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 0d2a6780..92a0e424 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -974,20 +974,24 @@ rescan_path(struct udev_device *ud) } } -void +/* Returns true if the path was removed */ +bool handle_path_wwid_change(struct path *pp, struct vectors *vecs) { struct udev_device *udd; static const char add[] = "add"; ssize_t ret; char dev[FILE_NAME_SIZE]; + bool removed = false; if (!pp || !pp->udev) - return; + return removed; strlcpy(dev, pp->dev, sizeof(dev)); udd = udev_device_ref(pp->udev); - if (!(ev_remove_path(pp, vecs, 1) & REMOVE_PATH_SUCCESS) && pp->mpp) { + if (ev_remove_path(pp, vecs, 1) & REMOVE_PATH_SUCCESS) { + removed = true; + } else if (pp->mpp) { pp->dmstate = PSTATE_FAILED; dm_fail_path(pp->mpp->alias, pp->dev_t); } @@ -997,6 +1001,7 @@ handle_path_wwid_change(struct path *pp, struct vectors *vecs) if (ret != sizeof(add) - 1) log_sysfs_attr_set_value(1, ret, "%s: failed to trigger add event", dev); + return removed; } bool @@ -2376,9 +2381,12 @@ sync_mpp(struct vectors * vecs, struct multipath *mpp, unsigned int ticks) do_sync_mpp(vecs, mpp); } -/* - * Returns '1' if the path has been checked and '0' otherwise - */ +enum check_path_return { + CHECK_PATH_CHECKED, + CHECK_PATH_SKIPPED, + CHECK_PATH_REMOVED, +}; + static int check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) { @@ -2393,12 +2401,12 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) bool need_reload; if (pp->initialized == INIT_REMOVED) - return 0; + return CHECK_PATH_SKIPPED; if (pp->tick) pp->tick -= (pp->tick > ticks) ? ticks : pp->tick; if (pp->tick) - return 0; /* don't check this path yet */ + return CHECK_PATH_SKIPPED; conf = get_multipath_config(); checkint = conf->checkint; @@ -2419,14 +2427,14 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) newstate = check_path_state(pp); if (newstate == PATH_WILD || newstate == PATH_UNCHECKED) - return 0; + return CHECK_PATH_SKIPPED; /* * Async IO in flight. Keep the previous path state * and reschedule as soon as possible */ if (newstate == PATH_PENDING) { pp->tick = 1; - return 0; + return CHECK_PATH_SKIPPED; } if (pp->recheck_wwid == RECHECK_WWID_ON && (newstate == PATH_UP || newstate == PATH_GHOST) && @@ -2434,14 +2442,14 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) pp->dmstate == PSTATE_FAILED) && check_path_wwid_change(pp)) { condlog(0, "%s: path wwid change detected. Removing", pp->dev); - handle_path_wwid_change(pp, vecs); - return 0; + return handle_path_wwid_change(pp, vecs)? CHECK_PATH_REMOVED : + CHECK_PATH_SKIPPED; } if (!pp->mpp->is_checked) { do_sync_mpp(vecs, pp->mpp); /* if update_multipath_strings orphaned the path, quit early */ if (!pp->mpp) - return 0; + return CHECK_PATH_SKIPPED; } if ((newstate != PATH_UP && newstate != PATH_GHOST && newstate != PATH_PENDING) && (pp->state == PATH_DELAYED)) { @@ -2452,7 +2460,7 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) * to the shortest delay */ pp->checkint = checkint; - return 1; + return CHECK_PATH_CHECKED; } if ((newstate == PATH_UP || newstate == PATH_GHOST) && (san_path_check_enabled(pp->mpp) || @@ -2467,7 +2475,7 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) * in time */ pp->tick = 1; pp->state = PATH_DELAYED; - return 1; + return CHECK_PATH_CHECKED; } if (!pp->marginal) { pp->marginal = 1; @@ -2525,7 +2533,7 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) pp->mpp->failback_tick = 0; pp->mpp->stat_path_failures++; - return 1; + return CHECK_PATH_CHECKED; } if (newstate == PATH_UP || newstate == PATH_GHOST) { @@ -2604,7 +2612,7 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) pp->state = newstate; if (pp->mpp->wait_for_udev) - return 1; + return CHECK_PATH_CHECKED; /* * path prio refreshing */ @@ -2631,12 +2639,9 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) switch_pathgroup(pp->mpp); } } - return 1; + return CHECK_PATH_CHECKED; } -/* - * Returns -1 if the path was blacklisted, and 0 otherwise - */ static int handle_uninitialized_path(struct vectors * vecs, struct path * pp, unsigned int ticks) @@ -2648,12 +2653,12 @@ handle_uninitialized_path(struct vectors * vecs, struct path * pp, if (pp->initialized != INIT_NEW && pp->initialized != INIT_FAILED && pp->initialized != INIT_MISSING_UDEV) - return 0; + return CHECK_PATH_SKIPPED; if (pp->tick) pp->tick -= (pp->tick > ticks) ? ticks : pp->tick; if (pp->tick) - return 0; /* don't check this path yet */ + return CHECK_PATH_SKIPPED; conf = get_multipath_config(); retrigger_tries = conf->retrigger_tries; @@ -2675,7 +2680,7 @@ handle_uninitialized_path(struct vectors * vecs, struct path * pp, log_sysfs_attr_set_value(1, ret, "%s: failed to trigger change event", pp->dev); - return 0; + return CHECK_PATH_SKIPPED; } else { condlog(1, "%s: not initialized after %d udev retriggers", pp->dev, retrigger_tries); @@ -2706,10 +2711,16 @@ handle_uninitialized_path(struct vectors * vecs, struct path * pp, ev_add_path(pp, vecs, 1); pp->tick = 1; } else if (ret == PATHINFO_SKIPPED) { - return -1; + int i; + + condlog(1, "%s: path blacklisted. removing", pp->dev); + if ((i = find_slot(vecs->pathvec, (void *)pp)) != -1) + vector_del_slot(vecs->pathvec, i); + free_path(pp); + return CHECK_PATH_REMOVED; } } - return 0; + return CHECK_PATH_CHECKED; } enum checker_state { @@ -2794,14 +2805,10 @@ checkerloop (void *ap) else rc = handle_uninitialized_path(vecs, pp, ticks); - if (rc < 0) { - condlog(1, "%s: check_path() failed, removing", - pp->dev); - vector_del_slot(vecs->pathvec, i); - free_path(pp); + if (rc == CHECK_PATH_REMOVED) i--; - } else - num_paths += rc; + else if (rc == CHECK_PATH_CHECKED) + num_paths++; if (++paths_checked % 128 == 0 && (lock_has_waiters(&vecs->lock) || waiting_clients())) { diff --git a/multipathd/main.h b/multipathd/main.h index 4fcd6402..7aa93ca3 100644 --- a/multipathd/main.h +++ b/multipathd/main.h @@ -47,7 +47,7 @@ int setup_multipath(struct vectors * vecs, struct multipath * mpp); int update_multipath(struct vectors *vecs, char *mapname); int reload_and_sync_map(struct multipath *mpp, struct vectors *vecs); -void handle_path_wwid_change(struct path *pp, struct vectors *vecs); +bool handle_path_wwid_change(struct path *pp, struct vectors *vecs); bool check_path_wwid_change(struct path *pp); int finish_path_init(struct path *pp, struct vectors * vecs); int resize_map(struct multipath *mpp, unsigned long long size, From patchwork Wed Jul 17 18:11:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13735698 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 107401836D3 for ; Wed, 17 Jul 2024 18:11:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239879; cv=none; b=nvN6b2wuohfwLNSvNxScLhOVFit9jz3SrX15TIA9WAT5dGPe0nqgv6+1k6eGanF68a1NEgAYJIO9bomy8rzkwinQgrDo7Mx5BHOXh0e72I3XiXQ9/jlhYS43QBcEaLLr0GxJJ8Luz/Gu4O6b4PtQy6TaFKmcwpNcL60LEpCVmpM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239879; c=relaxed/simple; bh=9pWiKf+oKnYt7Vbi/hzsSxbhwGj2uAhn7N6LS+b9oRo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=om2GACRDSdxAro/FLXvzPuc0aMws3JUnOmkERXayudUDVjVJFN8ZGC6CFVMQ+SF7WQQIWEOJ6CJZcAhKwIrELmCYJu3ETnI8xeBOiYKrirA69xtp/IwF08O15G/qBcKrRbTHWcYGUM+ipID1L09Scg00N64kPb51DK8YYdbm7bc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=UYM5YgkJ; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UYM5YgkJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721239875; h=from:from: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; bh=6vFIM3kG2QKpnkC774EI1TH9fR40t7aTcjFSWgkImPo=; b=UYM5YgkJr/tC9uc2YcdebkhXhsfGAZJlqauCq6kP/z/eYX54x3ERA/cgloqKTpEkYy09+k +n8vfGjhR19DuTUHGL7nZqIesMpqgEAY0w9CAyS8QAhyl+8kAEY9AoGvpOR92ZdnbgP5E6 hxcci/f5uxAR64O9/l4zqVf5ltf71qE= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-410-JLbCJAXZMQqcvX28O9hfQw-1; Wed, 17 Jul 2024 14:11:12 -0400 X-MC-Unique: JLbCJAXZMQqcvX28O9hfQw-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 89104195608B; Wed, 17 Jul 2024 18:11:11 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DD705195605A; Wed, 17 Jul 2024 18:11:10 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 46HIB90q2173616 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Jul 2024 14:11:09 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46HIB9fu2173615; Wed, 17 Jul 2024 14:11:09 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 15/20] multipathd: handle changed wwid when adding partial path Date: Wed, 17 Jul 2024 14:11:01 -0400 Message-ID: <20240717181106.2173527-16-bmarzins@redhat.com> In-Reply-To: <20240717181106.2173527-1-bmarzins@redhat.com> References: <20240717181106.2173527-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com If multipathd noticed that the WWID didn't match the device when adding a partial path, but removing it failed, multipathd wasn't disabling the path. Instead of calling handle_path_wwid_change(), which doesn't make much sense when multipathd is expecting a uevent, just manually disable the path if ev_remove_path() fails. Since the path hasn't actually been removed, multipathd needs to make sure that it says failed when the path state is resynced with the kernel. Set the state to PATH_UNCHECKED in orphan_path(), and additionally skip all path in INIT_REMOVED in sync_map_state(). Signed-off-by: Benjamin Marzinski --- libmultipath/structs.c | 1 + libmultipath/structs_vec.c | 3 ++- multipathd/cli_handlers.c | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libmultipath/structs.c b/libmultipath/structs.c index 1583e001..0a26096a 100644 --- a/libmultipath/structs.c +++ b/libmultipath/structs.c @@ -146,6 +146,7 @@ uninitialize_path(struct path *pp) return; pp->dmstate = PSTATE_UNDEF; + pp->state = PATH_UNCHECKED; pp->uid_attribute = NULL; pp->checker_timeout = 0; diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c index 60360c76..345d3069 100644 --- a/libmultipath/structs_vec.c +++ b/libmultipath/structs_vec.c @@ -723,7 +723,8 @@ sync_map_state(struct multipath *mpp) vector_foreach_slot (mpp->pg, pgp, i){ vector_foreach_slot (pgp->paths, pp, j){ - if (pp->state == PATH_UNCHECKED || + if (pp->initialized == INIT_REMOVED || + pp->state == PATH_UNCHECKED || pp->state == PATH_WILD || pp->state == PATH_DELAYED) continue; diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index 772a45d0..3a935aa0 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -540,7 +540,11 @@ add_partial_path(struct path *pp, struct vectors *vecs) if (strlen(wwid) && strncmp(wwid, pp->wwid, WWID_SIZE) != 0) { condlog(0, "%s: path wwid changed from '%s' to '%s'. removing", pp->dev, wwid, pp->wwid); - ev_remove_path(pp, vecs, 1); + if (!(ev_remove_path(pp, vecs, 1) & REMOVE_PATH_SUCCESS) && + pp->mpp) { + pp->dmstate = PSTATE_FAILED; + dm_fail_path(pp->mpp->alias, pp->dev_t); + } udev_device_unref(udd); return -1; } From patchwork Wed Jul 17 18:11:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13735690 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D2F0E1836C2 for ; Wed, 17 Jul 2024 18:11:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239877; cv=none; b=MdsYGBPHvJw+m6roswQ8uvLBhMbP9kEBDnvR/Is2zXJ7vso48hb6VA1Y0AinhzY8fPRqniA67C80sOOpD6nro8GQha08AsiRyojgZ9WyNWMiyW30890dV0x4vZK7AyeQpzEQG9qQNAccvCW6cdS96AJLWK7H0ksI56GkQX6Ap2s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239877; c=relaxed/simple; bh=uQjjxFvBvwRjdkxor5lomLbaE6XLT6sEDxfRfZ+dBOw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=L39nFNoNScXsZ59oKpZrYks1YwZsRk8JNsMPcYmk4o31egym7RaZf0GYB5Y9PyunF50TkEEdVFX6eUbzAtiACL8FZGPrh1ZGVSgi/kl9MlijybeybM1WuzfGpUyMnq2+6GnarbYJMByJzy3j+6poTEvEYJ8eKeAUOmyl4O93JsI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=BAEAa+K0; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BAEAa+K0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721239874; h=from:from: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; bh=3QsjdWdcteki8vJH9EZyEFpdh6FiyuGrRVf/qGgBjr8=; b=BAEAa+K0Uai73ptdCHBB5HjGs3lPMom2T0LAPvH0ZU7JFl5Xe+yOdpcEQE9fmTa8PJMGQf GFNk7RbhzNPbvgSP4C0S3JCAp9bSui7c9HMVb8tfdeL+olST//lyCtBN7KXsjmzj9sd2e+ 0HAH0aU8ofriWE7b0HT2Scrn9ZaW4m4= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-133-KuXjLDisMsm-h_sEIbcc5Q-1; Wed, 17 Jul 2024 14:11:12 -0400 X-MC-Unique: KuXjLDisMsm-h_sEIbcc5Q-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 99F271956046; Wed, 17 Jul 2024 18:11:11 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 02D8F1955D42; Wed, 17 Jul 2024 18:11:10 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 46HIB9SS2173620 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Jul 2024 14:11:09 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46HIB9bT2173619; Wed, 17 Jul 2024 14:11:09 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v2 16/20] multipathd: don't read conf->checkint twice in check_path Date: Wed, 17 Jul 2024 14:11:02 -0400 Message-ID: <20240717181106.2173527-17-bmarzins@redhat.com> In-Reply-To: <20240717181106.2173527-1-bmarzins@redhat.com> References: <20240717181106.2173527-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com check_path() already has saved the value of conf->checkint in the local variable checkint, so there's no reason to read it again. Reviewed-by: Martin Wilck Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 92a0e424..84450906 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2513,9 +2513,7 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) * upon state change, reset the checkint * to the shortest delay */ - conf = get_multipath_config(); - pp->checkint = conf->checkint; - put_multipath_config(conf); + pp->checkint = checkint; if (newstate != PATH_UP && newstate != PATH_GHOST) { /* From patchwork Wed Jul 17 18:11:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13735699 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D68B18412D for ; Wed, 17 Jul 2024 18:11:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239879; cv=none; b=Bkd4CsaKONIAgmpByr+LZ8WdOxYcUil7U+C5r61VST99GTS3l54WsabV4hsfSmWC5PS/ylE+zaO5Woj2Pd/7LNUX7V2Lz3TGgOVWBV0VjAqmxaUSDG4wR+P2YEqHk3F9jQwYdrpr3VlPDcop+/i4o8MieoHJQ0TQaunl1mKQ3g4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239879; c=relaxed/simple; bh=XOvHVBoBjWWnkrIfp51P2htZaNdOt6JpD9ouwcqW0pY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VXKF6CZ+wt6d7yli4pCZ6nKCA+Nb60nIS50ts/gIUIzWMOm9l7YDwixsawVfMiimNUvIgdNPtym6Bjx1JaGd0l2k1c6ZXL5+oVTzh1h6ih0cNoYFhQQdTDzeW41bKcSh/iAVezulEFohLaCArbx8du0EwXRaok/ISFA/+/tEJ9A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=JXNLb+5L; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JXNLb+5L" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721239876; h=from:from: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; bh=gEZ/+DFbGtSfnb4e0UgGwWecsFQz9fx+N9xo2jHhBBU=; b=JXNLb+5LGXU3zcuefIpPtummO5PjJcBEcISAC/Q5+xwDDaqZ4z2Wc+5exi5wjrLbkAvNi3 oq58zjf1EoIsq22OOAA7hiA1DA3sEB6HyYYfJmZq8euZmZeIaPLTZO1vmmeSoIvycjKAue 73UUveeG9ruO0keLYIvdcJrLJtPzDcc= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-452-EpvePjYKNKevJp3dMZKWiw-1; Wed, 17 Jul 2024 14:11:12 -0400 X-MC-Unique: EpvePjYKNKevJp3dMZKWiw-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AD1C91955D42; Wed, 17 Jul 2024 18:11:11 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 47D6619560AA; Wed, 17 Jul 2024 18:11:11 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 46HIBA5m2173624 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Jul 2024 14:11:10 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46HIBAUE2173623; Wed, 17 Jul 2024 14:11:10 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 17/20] multipathd: make multipath devices manage their path check times Date: Wed, 17 Jul 2024 14:11:03 -0400 Message-ID: <20240717181106.2173527-18-bmarzins@redhat.com> In-Reply-To: <20240717181106.2173527-1-bmarzins@redhat.com> References: <20240717181106.2173527-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com multipathd's path checking can be very bursty, with all the paths running their path checkers at the same time, and then all doing nothing while waiting for the next check time. Alternatively, the paths in a multipath device might all run their path checkers at a different time, which can keep the multipath device from having a coherent view of the state of all of its paths. This patch makes all the paths of a multipath device converge to running their checkers at the same time, and spreads out when this time is for the different multipath devices. To do this, the checking time is divided into adjustment intervals (conf->adjust_int), so that the checkers run at some index within this interval. conf->adjust_int is chosen so that it is a multiple of all possible pp->checkint values. This means that regardless of pp->checkint, the path should always be checked on the same indexes, each adjustement interval. Each multipath device has a goal index. These are evenly spread out between 0 and conf->max_checkint. Every conf->adjust_int seconds, each multipath device should try to check all of its paths on its goal index. If the multipath device's check times are not aligned with the goal index, then pp->tick for the next check will be decremented by one, to align it over time. In order for the path checkers to run every pp->checkint seconds, multipathd needs to track how long a path check has been pending for, and subtract that time from the number of ticks till the checker is run again. If the checker has been pending for more that pp->checkint, the path will be rechecked on the next tick after the checker returns. Signed-off-by: Benjamin Marzinski --- libmultipath/config.c | 12 ++++++ libmultipath/config.h | 1 + libmultipath/structs.c | 1 + libmultipath/structs.h | 1 + multipathd/main.c | 91 ++++++++++++++++++++++++++++++++++-------- 5 files changed, 89 insertions(+), 17 deletions(-) diff --git a/libmultipath/config.c b/libmultipath/config.c index 83fa7369..a59533b5 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -982,6 +982,18 @@ int _init_config (const char *file, struct config *conf) conf->checkint = conf->max_checkint; condlog(3, "polling interval: %d, max: %d", conf->checkint, conf->max_checkint); + /* + * make sure that that adjust_int is a multiple of all possible values + * of pp->checkint. + */ + if (conf->max_checkint % conf->checkint == 0) { + conf->adjust_int = conf->max_checkint; + } else { + conf->adjust_int = conf->checkint; + while (2 * conf->adjust_int < conf->max_checkint) + conf->adjust_int *= 2; + conf->adjust_int *= conf->max_checkint; + } if (conf->blist_devnode == NULL) { conf->blist_devnode = vector_alloc(); diff --git a/libmultipath/config.h b/libmultipath/config.h index 384193ab..800c0ca9 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -147,6 +147,7 @@ struct config { int minio_rq; unsigned int checkint; unsigned int max_checkint; + unsigned int adjust_int; bool use_watchdog; int pgfailback; int rr_weight; diff --git a/libmultipath/structs.c b/libmultipath/structs.c index 0a26096a..232b4230 100644 --- a/libmultipath/structs.c +++ b/libmultipath/structs.c @@ -149,6 +149,7 @@ uninitialize_path(struct path *pp) pp->state = PATH_UNCHECKED; pp->uid_attribute = NULL; pp->checker_timeout = 0; + pp->pending_ticks = 0; if (checker_selected(&pp->checker)) checker_put(&pp->checker); diff --git a/libmultipath/structs.h b/libmultipath/structs.h index 002eeae1..457d7836 100644 --- a/libmultipath/structs.h +++ b/libmultipath/structs.h @@ -360,6 +360,7 @@ struct path { unsigned long long size; unsigned int checkint; unsigned int tick; + unsigned int pending_ticks; int bus; int offline; int state; diff --git a/multipathd/main.c b/multipathd/main.c index 84450906..87ddb101 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2388,7 +2388,7 @@ enum check_path_return { }; static int -check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) +do_check_path (struct vectors * vecs, struct path * pp) { int newstate; int new_path_up = 0; @@ -2400,14 +2400,6 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) int marginal_pathgroups, marginal_changed = 0; bool need_reload; - if (pp->initialized == INIT_REMOVED) - return CHECK_PATH_SKIPPED; - - if (pp->tick) - pp->tick -= (pp->tick > ticks) ? ticks : pp->tick; - if (pp->tick) - return CHECK_PATH_SKIPPED; - conf = get_multipath_config(); checkint = conf->checkint; max_checkint = conf->max_checkint; @@ -2419,12 +2411,6 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) pp->checkint = checkint; }; - /* - * provision a next check soonest, - * in case we exit abnormally from here - */ - pp->tick = checkint; - newstate = check_path_state(pp); if (newstate == PATH_WILD || newstate == PATH_UNCHECKED) return CHECK_PATH_SKIPPED; @@ -2587,7 +2573,6 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) condlog(4, "%s: delay next check %is", pp->dev_t, pp->checkint); } - pp->tick = pp->checkint; } } else if (newstate != PATH_UP && newstate != PATH_GHOST) { @@ -2640,6 +2625,77 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) return CHECK_PATH_CHECKED; } +static int +check_path (struct vectors * vecs, struct path * pp, unsigned int ticks, + time_t start_secs) +{ + int r; + unsigned int adjust_int, max_checkint; + struct config *conf; + time_t next_idx, goal_idx; + + if (pp->initialized == INIT_REMOVED) + return CHECK_PATH_SKIPPED; + + if (pp->tick) + pp->tick -= (pp->tick > ticks) ? ticks : pp->tick; + if (pp->tick) + return CHECK_PATH_SKIPPED; + + conf = get_multipath_config(); + max_checkint = conf->max_checkint; + adjust_int = conf->adjust_int; + put_multipath_config(conf); + + r = do_check_path(vecs, pp); + + /* + * do_check_path() removed or orphaned the path. + */ + if (r < 0 || !pp->mpp) + return r; + + if (pp->tick != 0) { + /* the path checker is pending */ + if (pp->state != PATH_DELAYED) + pp->pending_ticks++; + else + pp->pending_ticks = 0; + return r; + } + + /* schedule the next check */ + pp->tick = pp->checkint; + if (pp->pending_ticks >= pp->tick) + pp->tick = 1; + else + pp->tick -= pp->pending_ticks; + pp->pending_ticks = 0; + + if (pp->tick == 1) + return r; + + /* + * every mpp has a goal_idx in the range of + * 0 <= goal_idx < conf->max_checkint + * + * The next check has an index, next_idx, in the range of + * 0 <= next_idx < conf->adjust_int + * + * If the difference between the goal index and the next check index + * is not a multiple of pp->checkint, then the device is not checking + * the paths at its goal index, and pp->tick will be decremented by + * one, to align it over time. + */ + goal_idx = (find_slot(vecs->mpvec, pp->mpp)) * + max_checkint / VECTOR_SIZE(vecs->mpvec); + next_idx = (start_secs + pp->tick) % adjust_int; + if ((goal_idx - next_idx) % pp->checkint != 0) + pp->tick--; + + return r; +} + static int handle_uninitialized_path(struct vectors * vecs, struct path * pp, unsigned int ticks) @@ -2799,7 +2855,8 @@ checkerloop (void *ap) continue; pp->is_checked = true; if (pp->mpp) - rc = check_path(vecs, pp, ticks); + rc = check_path(vecs, pp, ticks, + chk_start_time.tv_sec); else rc = handle_uninitialized_path(vecs, pp, ticks); From patchwork Wed Jul 17 18:11:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13735692 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D184F183093 for ; Wed, 17 Jul 2024 18:11:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239877; cv=none; b=P6bXpYhl5djjDXOR/2mfS6M1jMcdh+EY4/b3emXuAvj6TYrm4mbmFbob9m6SEQ9yuuirzZD4SB4ip5shv/CUZ9Vr3oi5eQ8YjF1Q7Y97TzVPXQuXcfdT+YsD8EeVwl8ZTBdDIwi44ee2DbRTqEDAAwtBUL+JsxLK/yUKyh1lJ3g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239877; c=relaxed/simple; bh=+J8pYTLo7B8o4eM3NHbJNJDswb999Nv2Y/2v1g5F02Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HBNfQaA7TzgjpXfiSl64YtC/aS5QTdnVbitw/Z0mQXwzTcCc5EjjTp7T5gMqqFpkarOvNEqK3HsvEdlxYHexCzwta/s0yCr1r5pGzQ55MygNFXzsLqWyllMje7S/gB7vkLNi0XuAES/QUoMn1Z4lJnhs53xr5bN+NWn2AI+3I0I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=iXRbN39L; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iXRbN39L" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721239874; h=from:from: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; bh=z/2qsTjbgfeocsPNYcYsq/i+8uELS4LREOQ6bhk4UV8=; b=iXRbN39LTqR52Usxa4JcaqWw8ALLHIKWOVVlMTaBJC9UTOd22KvXO54a6hcLVGdz1w2Ta1 AkqX5UmDbzHydR3lcLApO0y5yljZhiH+XXsFHCX6DaRm3MScCg84zDHJAXwNziQFWcv5M7 VknfKS0YBPvLgQghzQfTUO/kqrvGvrA= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-357-xzT9bAkHNvujX-a9asxS6Q-1; Wed, 17 Jul 2024 14:11:12 -0400 X-MC-Unique: xzT9bAkHNvujX-a9asxS6Q-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D2B5B1955D4A; Wed, 17 Jul 2024 18:11:11 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8C5231955D47; Wed, 17 Jul 2024 18:11:11 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 46HIBAHp2173628 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Jul 2024 14:11:10 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46HIBABf2173627; Wed, 17 Jul 2024 14:11:10 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v2 18/20] multipathd: factor out actual path checking loop from checkerloop Date: Wed, 17 Jul 2024 14:11:04 -0400 Message-ID: <20240717181106.2173527-19-bmarzins@redhat.com> In-Reply-To: <20240717181106.2173527-1-bmarzins@redhat.com> References: <20240717181106.2173527-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Move the code that actually loops through the paths and checks them into a separate function, to stop it from being so heavily indented. This will be more imporant when a future patch makes paths checked by mpp. No functional changes. Reviewed-by: Martin Wilck Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 65 +++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 87ddb101..161c6962 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2783,6 +2783,38 @@ enum checker_state { CHECKER_FINISHED, }; +static enum checker_state +check_paths(struct vectors *vecs, unsigned int ticks, int *num_paths_p) +{ + unsigned int paths_checked = 0; + struct timespec diff_time, start_time, end_time; + struct path *pp; + int i, rc; + + get_monotonic_time(&start_time); + vector_foreach_slot(vecs->pathvec, pp, i) { + if (pp->is_checked) + continue; + pp->is_checked = true; + if (pp->mpp) + rc = check_path(vecs, pp, ticks, start_time.tv_sec); + else + rc = handle_uninitialized_path(vecs, pp, ticks); + if (rc == CHECK_PATH_REMOVED) + i--; + else if (rc == CHECK_PATH_CHECKED) + (*num_paths_p)++; + if (++paths_checked % 128 == 0 && + (lock_has_waiters(&vecs->lock) || waiting_clients())) { + get_monotonic_time(&end_time); + timespecsub(&end_time, &start_time, &diff_time); + if (diff_time.tv_sec > 0) + return CHECKER_RUNNING; + } + } + return CHECKER_FINISHED; +} + static void * checkerloop (void *ap) { @@ -2814,7 +2846,7 @@ checkerloop (void *ap) while (1) { struct timespec diff_time, start_time, end_time; - int num_paths = 0, strict_timing, rc = 0; + int num_paths = 0, strict_timing; unsigned int ticks = 0; enum checker_state checker_state = CHECKER_STARTING; @@ -2833,16 +2865,14 @@ checkerloop (void *ap) sd_notify(0, "WATCHDOG=1"); #endif while (checker_state != CHECKER_FINISHED) { - unsigned int paths_checked = 0, i; - struct timespec chk_start_time; struct multipath *mpp; + int i; pthread_cleanup_push(cleanup_lock, &vecs->lock); lock(&vecs->lock); pthread_testcancel(); vector_foreach_slot(vecs->mpvec, mpp, i) mpp->is_checked = false; - get_monotonic_time(&chk_start_time); if (checker_state == CHECKER_STARTING) { vector_foreach_slot(vecs->mpvec, mpp, i) sync_mpp(vecs, mpp, ticks); @@ -2850,32 +2880,7 @@ checkerloop (void *ap) pp->is_checked = false; checker_state = CHECKER_RUNNING; } - vector_foreach_slot(vecs->pathvec, pp, i) { - if (pp->is_checked) - continue; - pp->is_checked = true; - if (pp->mpp) - rc = check_path(vecs, pp, ticks, - chk_start_time.tv_sec); - else - rc = handle_uninitialized_path(vecs, pp, - ticks); - if (rc == CHECK_PATH_REMOVED) - i--; - else if (rc == CHECK_PATH_CHECKED) - num_paths++; - if (++paths_checked % 128 == 0 && - (lock_has_waiters(&vecs->lock) || - waiting_clients())) { - get_monotonic_time(&end_time); - timespecsub(&end_time, &chk_start_time, - &diff_time); - if (diff_time.tv_sec > 0) - goto unlock; - } - } - checker_state = CHECKER_FINISHED; -unlock: + checker_state = check_paths(vecs, ticks, &num_paths); lock_cleanup_pop(vecs->lock); if (checker_state != CHECKER_FINISHED) { /* Yield to waiters */ From patchwork Wed Jul 17 18:11:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13735700 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF1DC1849CC for ; Wed, 17 Jul 2024 18:11:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239879; cv=none; b=W1w4yw+AXoHzo7t7RY76N3iRqbA3pEuNKtCZQgZC6C3Bhj+QYlZ0AmM93e6liXffOaUj0mXHDwcplRjebEioQBQDxtvWEh4G9UTM5PLpqf+G3cHe2TUUna2rP+jf2+fONEQBp9xPUwoKKz9u18xNp/fePuRjPJ/BdmTVaN2drzo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239879; c=relaxed/simple; bh=BLI7pAwl7HC8ZV9FxUg5e2ks2h4/7d82adBO6lXMI4A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rfk+3uyOh2fauwSEFNKZLpariR13ajjqlP/SdZBmcKfUoS5j6Z2tk7ud7nzE/ljF/vZONHSsIDW81/d7PTB7mNarNlMH46YOLpfutww877uxV0i7GS+xI436pYHlkjaq/Om99Brc4781Ms5s3wVRKLauwgapIGIqh8h3DHE4zDc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=NX99btVT; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NX99btVT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721239876; h=from:from: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; bh=gRhJwNTuOrG9y1ymZlwHyFJeF8aV7WLvohClQnzaAOo=; b=NX99btVTYkt4aD4Njbabz+6sGe+22ZoNTcRMKMC51yXh7qKNlXlEPG8qvjVyGoXjeYNQF1 fFPmV5flQhaf50tVK6MaiRzzshpkCHiBV/fvfb43uxBSFnA64UfdCGX/mEW5gqImXk8ayy kdqIlzMxJaPgvr0/oqVISOe+fDm/xhY= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-500-hR0cXyOvPVixkSKJOBQjPA-1; Wed, 17 Jul 2024 14:11:13 -0400 X-MC-Unique: hR0cXyOvPVixkSKJOBQjPA-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 40B8C19560AD; Wed, 17 Jul 2024 18:11:12 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B9AF31955D4A; Wed, 17 Jul 2024 18:11:11 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 46HIBAcY2173632 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Jul 2024 14:11:10 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46HIBAGc2173631; Wed, 17 Jul 2024 14:11:10 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 19/20] multipathd: check paths in order by mpp Date: Wed, 17 Jul 2024 14:11:05 -0400 Message-ID: <20240717181106.2173527-20-bmarzins@redhat.com> In-Reply-To: <20240717181106.2173527-1-bmarzins@redhat.com> References: <20240717181106.2173527-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Instead of checking all of the paths in vecs->pathvec in order, first check all the paths in each multipath device. Then check the uninitialized paths. One issue with checking paths this way is that the multipath device can be resynced or even removed while a path is being checked. The path can also be removed. If there is any change to the multipath device, multipathd needs to loop through its paths again, because the current indexes may not longer be valid. To do this change mpp->is_checked to an int called mpp->synced_count, and increment it whenever the multipath device gets resynced. After each path is checked, make sure that the multipath device still exists, that mpp->synced_count hasn't changed. If either has happened, restart checking at the current index in mpvec (which will either be the same mpp if it was just resynced, or the next mpp if the last one was deleted). Since the multipath device is resynced when its first path is checked, this restart will happen to every multipath device at least once per loop. But the paths themselves aren't rechecked, so it's not much overhead. If resyncing a multipath device fails in do_check_mpp(), there may be path devices that have pp->mpp set, but are no longer in one of the multipath device's pathgroups, and thus will not get checked. This almost definitely means the multipath device was deleted. If do_check_mpp() failed to resync the device, but it wasn't deleted, it will get called again in max_checkint seconds even if it no longer has mpp->pg set, and the paths will get checked again after that. Signed-off-by: Benjamin Marzinski --- libmultipath/structs.h | 2 +- libmultipath/structs_vec.c | 1 + multipathd/main.c | 54 ++++++++++++++++++++++++++++++++------ 3 files changed, 48 insertions(+), 9 deletions(-) diff --git a/libmultipath/structs.h b/libmultipath/structs.h index 457d7836..91509881 100644 --- a/libmultipath/structs.h +++ b/libmultipath/structs.h @@ -455,7 +455,7 @@ struct multipath { int ghost_delay_tick; int queue_mode; unsigned int sync_tick; - bool is_checked; + int synced_count; uid_t uid; gid_t gid; mode_t mode; diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c index 345d3069..cf9c6fe8 100644 --- a/libmultipath/structs_vec.c +++ b/libmultipath/structs_vec.c @@ -513,6 +513,7 @@ update_multipath_table (struct multipath *mpp, vector pathvec, int flags) conf = get_multipath_config(); mpp->sync_tick = conf->max_checkint; put_multipath_config(conf); + mpp->synced_count++; r = libmp_mapinfo(DM_MAP_BY_NAME | MAPINFO_MPATH_ONLY, (mapid_t) { .str = mpp->alias }, diff --git a/multipathd/main.c b/multipathd/main.c index 161c6962..5eefa475 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2356,7 +2356,6 @@ do_sync_mpp(struct vectors * vecs, struct multipath *mpp) int i, ret; struct path *pp; - mpp->is_checked = true; ret = update_multipath_strings(mpp, vecs->pathvec); if (ret != DMP_OK) { condlog(1, "%s: %s", mpp->alias, ret == DMP_NOT_FOUND ? @@ -2431,7 +2430,7 @@ do_check_path (struct vectors * vecs, struct path * pp) return handle_path_wwid_change(pp, vecs)? CHECK_PATH_REMOVED : CHECK_PATH_SKIPPED; } - if (!pp->mpp->is_checked) { + if (pp->mpp->synced_count == 0) { do_sync_mpp(vecs, pp->mpp); /* if update_multipath_strings orphaned the path, quit early */ if (!pp->mpp) @@ -2788,18 +2787,57 @@ check_paths(struct vectors *vecs, unsigned int ticks, int *num_paths_p) { unsigned int paths_checked = 0; struct timespec diff_time, start_time, end_time; + struct multipath *mpp; struct path *pp; int i, rc; get_monotonic_time(&start_time); + + vector_foreach_slot(vecs->mpvec, mpp, i) { + struct pathgroup *pgp; + struct path *pp; + int j, k; + bool check_for_waiters = false; + /* maps can be rechecked, so this is not always 0 */ + int synced_count = mpp->synced_count; + + vector_foreach_slot (mpp->pg, pgp, j) { + vector_foreach_slot (pgp->paths, pp, k) { + if (!pp->mpp || pp->is_checked) + continue; + pp->is_checked = true; + rc = check_path(vecs, pp, ticks, + start_time.tv_sec); + if (rc == CHECK_PATH_CHECKED) + (*num_paths_p)++; + if (++paths_checked % 128 == 0) + check_for_waiters = true; + /* + * mpp has been removed or resynced. Path may + * have been removed. + */ + if (VECTOR_SLOT(vecs->mpvec, i) != mpp || + synced_count != mpp->synced_count) { + i--; + goto next_mpp; + } + } + } +next_mpp: + if (check_for_waiters && + (lock_has_waiters(&vecs->lock) || waiting_clients())) { + get_monotonic_time(&end_time); + timespecsub(&end_time, &start_time, &diff_time); + if (diff_time.tv_sec > 0) + return CHECKER_RUNNING; + } + } vector_foreach_slot(vecs->pathvec, pp, i) { - if (pp->is_checked) + if (pp->mpp || pp->is_checked) continue; pp->is_checked = true; - if (pp->mpp) - rc = check_path(vecs, pp, ticks, start_time.tv_sec); - else - rc = handle_uninitialized_path(vecs, pp, ticks); + + rc = handle_uninitialized_path(vecs, pp, ticks); if (rc == CHECK_PATH_REMOVED) i--; else if (rc == CHECK_PATH_CHECKED) @@ -2872,7 +2910,7 @@ checkerloop (void *ap) lock(&vecs->lock); pthread_testcancel(); vector_foreach_slot(vecs->mpvec, mpp, i) - mpp->is_checked = false; + mpp->synced_count = 0; if (checker_state == CHECKER_STARTING) { vector_foreach_slot(vecs->mpvec, mpp, i) sync_mpp(vecs, mpp, ticks); From patchwork Wed Jul 17 18:11:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13735695 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C97918412B for ; Wed, 17 Jul 2024 18:11:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239878; cv=none; b=qP1zvBx5GoeKim4gaz0+VWGkJ8gYI+qSefBvuczrq46wzQtd2mhhy4QA+MwBhhO0vi1Aba7YwnSReflbeVvqQCAFkWzAvKTHKSVmdIPxhkiy+9qrQdX+A1j+Bj+ZDwFYzUIVAyk2KO9rY3W4d9u+rJRcfNl5lc9wGDahPJJjQS0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721239878; c=relaxed/simple; bh=Juo2tXG7PwhKMaTSbhyONSWxsjrjlNE0bw9TJBXWoJE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Y0WwdoxqmhbEkKXSFr+oLfk/CTYQzeY8ofG9gA/40jiUdeCak7QtkbkMBCfO3NlaZVaDsuqCdeSn+4PXStDuiDzT0tfPlYNHaOEA+LD9v08sAK94EJ690/8mn/UQCCxGNlhXZOaTWIrHY7DjjVd62W/D3yNCS29g8ZbSRnB5QiE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=T4fYDg41; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="T4fYDg41" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721239876; h=from:from: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; bh=GPYBb2zrqT4NJhhXaGCHvO8WxAEN9QgTUlG258g8pmg=; b=T4fYDg41vnD5/wIdVL8xLEyWUao7QQj5ybuGdzFvcPAOEWM3L551wx9wbXvXB6zoNmhIQT iOKR57GbllWGPirxrINR1kW5bLFXx2uTKTNUuhQ3iEBMmY69QjTGnpXUPRl8JDz1vyRsgK KD42QvfwoPMezwoOJVnKn6/32+EWYe4= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-145-kStssKaDN_SSNbhuSwgYKQ-1; Wed, 17 Jul 2024 14:11:13 -0400 X-MC-Unique: kStssKaDN_SSNbhuSwgYKQ-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1772819560A2; Wed, 17 Jul 2024 18:11:12 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C49F019560AA; Wed, 17 Jul 2024 18:11:11 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 46HIBAs42173636 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Jul 2024 14:11:10 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46HIBAZt2173635; Wed, 17 Jul 2024 14:11:10 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v2 20/20] multipathd: clean up the correct wwid in check_path_wwid_change Date: Wed, 17 Jul 2024 14:11:06 -0400 Message-ID: <20240717181106.2173527-21-bmarzins@redhat.com> In-Reply-To: <20240717181106.2173527-1-bmarzins@redhat.com> References: <20240717181106.2173527-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com After check_path_wwid_change() grabbed a new copy of the wwid, it was stripping trailing whitespace off of pp->wwid, instead of the copy it just got. Fixes: 4660cff ("multipathd: add recheck_wwid option to verify the path wwid") Reviewed-by: Martin Wilck Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 5eefa475..f4910403 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1025,9 +1025,9 @@ check_path_wwid_change(struct path *pp) } /*Strip any trailing blanks */ - for (i = strlen(pp->wwid); i > 0 && pp->wwid[i-1] == ' '; i--); + for (i = strlen(wwid); i > 0 && wwid[i-1] == ' '; i--); /* no-op */ - pp->wwid[i] = '\0'; + wwid[i] = '\0'; condlog(4, "%s: Got wwid %s by sgio", pp->dev, wwid); if (strncmp(wwid, pp->wwid, WWID_SIZE)) {