From patchwork Sat Jul 13 06:04:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13732322 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 6D00F18C05 for ; Sat, 13 Jul 2024 06:05: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=1720850716; cv=none; b=mSg5Fk3MY1XvmRKcBo05+DN2XfeyAcnfuf/gGy+7UKGnLsjsXpTCjTUgtcPvSr8bm3Osz9oYmyYxY2I5OfVr63pRZqedByCrAyzycSOYcLSiYWO6O1PO1iC3waLIdPBSn/dEOeYogITCGt93b0jXk+fOPI5zIXX2pqwCZMBGlYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720850716; c=relaxed/simple; bh=D85aTLVA4iVcaBJBVSq3Lqr2gfaZpWsFSd3gAVs5E1c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WYtOCsuNzyims2QNNqoa+LR+lV9dXbnApSQLcU6T1KVSpF2hml3+tsZ72BSoB8vIEKdT9kRwcSuhI5D5AKnY3L7sFRHNzNzlnkFWg8BQUCKvFfKUQX70QaNILChe5A1UsDTVLiLK9g6vnvuEF/ASzVto4rvNPgd+J1ZCD+vEX2c= 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=b1BA2UN4; 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="b1BA2UN4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720850712; 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=6BqUH7BeXziyi7bmuSpx/iosOsKz2cyeKRHJu015htM=; b=b1BA2UN4ZMjhvkCgrQ/H/xm3giMJzbZbBQb785JcPj5xvztspCfMx4NvbN1lQbDSlYK9Pq NAR6pZXS0UQWCnhNwSR0Y6UukMcNc68BWiRF4viLoPETwdjX730DqWgZAlHHlu5AQzxeEh BmjABNj50TTwYJnmFD7cyF7iwGN+gJY= 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-390-DGAgHC52NtuEM_wluilHjg-1; Sat, 13 Jul 2024 02:05:10 -0400 X-MC-Unique: DGAgHC52NtuEM_wluilHjg-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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5897519560B0; Sat, 13 Jul 2024 06:05: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 CFFCF3000181; Sat, 13 Jul 2024 06:05: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 46D657GY2015498 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 13 Jul 2024 02:05:07 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46D657S32015497; Sat, 13 Jul 2024 02:05:07 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 01/22] libmultipath: rename dm_map_present_by_wwid() and add outputs Date: Sat, 13 Jul 2024 02:04:45 -0400 Message-ID: <20240713060506.2015463-2-bmarzins@redhat.com> In-Reply-To: <20240713060506.2015463-1-bmarzins@redhat.com> References: <20240713060506.2015463-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 add arguments to dm_map_present_by_wwid() to allow optionally fetching the device name and minor number 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 minor number of a device from its WWID, rename it to dm_find_map_by_wwid() Signed-off-by: Benjamin Marzinski --- libmultipath/devmapper.c | 16 ++++++++++++---- libmultipath/devmapper.h | 2 +- libmultipath/valid.c | 2 +- tests/valid.c | 12 ++++++------ 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index bbbadeee..60d786c6 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -872,16 +872,24 @@ 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, int *minor) { char tmp[DM_UUID_LEN]; + struct dm_info dmi; + int rc; if (safe_sprintf(tmp, UUID_PREFIX "%s", wwid)) return DMP_ERR; - return libmp_mapinfo(DM_MAP_BY_UUID, - (mapid_t) { .str = tmp }, - (mapinfo_t) { .name = NULL }); + rc = libmp_mapinfo(DM_MAP_BY_UUID, + (mapid_t) { .str = tmp }, + (mapinfo_t) { .name = name, + .dmi = minor ? &dmi : NULL }); + if (rc == DMP_OK && minor) + *minor = dmi.minor; + + return rc; } static int dm_dev_t (const char *mapname, char *dev_t, int len) diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h index c28991fb..1de694c9 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, int *minor); 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..d9325f8b 100644 --- a/tests/valid.c +++ b/tests/valid.c @@ -189,10 +189,10 @@ 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, int *minor) { 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 +271,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 +516,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 Sat Jul 13 06:04:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13732323 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 7B8C21BC4E for ; Sat, 13 Jul 2024 06:05: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=1720850717; cv=none; b=qvq3ZqsncI48hrm5Osr93Lqkc2wy1xr1/EK0ut0OmPq7qXjATp8DgGgDFEop9DhwVcOlFPEBPUlxMmy1VAHWOxc2+HzRPJm7EvkMn7pHkBVuYdTvOtS9TlXojZqzPJk2rdVKcXfO+cgNDFku4QGikb+RvN5vZ62uhzbz7GiJNcs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720850717; c=relaxed/simple; bh=kJLKLYaTYHR9c74F2iKzEb/74Bwwf25KkAkeIVLxK9I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UlZco+4uxL8CTugqH9XxoZ9uo/iXKtw6qaTb82AuQC1DuKZJY/R1x9nWC0piaNJZ++D68egTZN2XmzSWOVooSGXFbI0l4c+cncQdx2PX6Jp/qZoZwSnx+0Y3F/tAm+sBxmWfhk3+8cFJXxtgL43lrgl2mLHx+ID62CUhCKXf29U= 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=I2PXpDLh; 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="I2PXpDLh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720850714; 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=GwXyao30OVKmn+oeVbiL8f737Gd9oboWzjhSkkLHAN4=; b=I2PXpDLhtA3/2sBGOwnWQtpXL8WC7ZQikiXsv0XE1aAObm57yhIVBMi8DsnxRhiqdHQOVD mXnzDx/FVywgo6fCrEuydOXiDRhxqkfCC03sWCJkA7HR4IX7TzdkZNWDjbD3aUYEz5AAH2 P8/w0LDojRyNjbhCa5ae2VylNbQXTac= 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-683-PzWB8HrSNTy8yLEMxg7eVg-1; Sat, 13 Jul 2024 02:05:10 -0400 X-MC-Unique: PzWB8HrSNTy8yLEMxg7eVg-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 E2495195608A; Sat, 13 Jul 2024 06:05: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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 435D3195606C; Sat, 13 Jul 2024 06:05: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 46D6579x2015502 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 13 Jul 2024 02:05:07 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46D6579k2015501; Sat, 13 Jul 2024 02:05:07 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 02/22] multipathd: make cli_add_map() handle adding maps by WWID correctly Date: Sat, 13 Jul 2024 02:04:46 -0400 Message-ID: <20240713060506.2015463-3-bmarzins@redhat.com> In-Reply-To: <20240713060506.2015463-1-bmarzins@redhat.com> References: <20240713060506.2015463-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 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 | 59 ++++++++++--------------------- 2 files changed, 24 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..0643be15 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -697,57 +697,36 @@ 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, minor = -1; 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, &minor) != 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, &minor) != 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-%d", minor); rc = ev_add_map(dev_path, alias, vecs); return rc; } From patchwork Sat Jul 13 06:04: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: 13732340 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 0037945945 for ; Sat, 13 Jul 2024 06:05:19 +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=1720850721; cv=none; b=hRjj5b7E0QZnXnTR+lrfcJMK0ar5g053j1XIktLNOFihfHl4FxmjMCXee2y/46keMmYNEAoyplFsnWo4rRtnKQDbg8sRkKf8dcQsb0uWiYw45Tsmiaok0Nff3U4ejFnKNUpSlMdzDHJarmCS2+4ef0ergv99CfAt/a3unub9Flo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720850721; c=relaxed/simple; bh=7epjJtBUShVaffUzRsDkazIF9K+mFPwcq2Wr4b1uVXU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fgzlOCyQDRYwgX3+busxozN+IqHSy1ozsnOOmAvPcAeE4f3lVnAfTEy0skNwNGcXHGbyFOqG1imZQJL5KRWuABlSoZ64zt9YNpWUXZjS1KHwrs7kJhf8UVut3oyzR+/y0GICWH6g/i1ZFtffgJiba9wz+0rDdsRpkQOhT/ysoos= 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=KlDrHebD; 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="KlDrHebD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720850718; 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=E0fKWvczRjCAgmWvZLc2pqQL4H2plMr0QhKZd8PUPjc=; b=KlDrHebD1UecTSwbV1ljzsZU6HpZEJe+ty1tLGvT1zLkMNVkrcbPPE0uLm2j9bg9Kbi+xG nak7yDENWBH+7/IIU0sURSXL7x/U2JRzs2z1qsmF/vHpJV8ylZLzShatrqnbszwHMMVXeE X5OdqudRRAoJ8L8EXb5yIehgiOryi7w= 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-683-sLa-s2UWNCufTHu4fADtPw-1; Sat, 13 Jul 2024 02:05:10 -0400 X-MC-Unique: sLa-s2UWNCufTHu4fADtPw-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 DAAE8196CDEF; Sat, 13 Jul 2024 06:05: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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 32C8C1956066; Sat, 13 Jul 2024 06:05: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 46D6574q2015506 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 13 Jul 2024 02:05:07 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46D657Vd2015505; Sat, 13 Jul 2024 02:05:07 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 03/22] multipathd: remove checker restart optimization Date: Sat, 13 Jul 2024 02:04:47 -0400 Message-ID: <20240713060506.2015463-4-bmarzins@redhat.com> In-Reply-To: <20240713060506.2015463-1-bmarzins@redhat.com> References: <20240713060506.2015463-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 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 386cd076..0b0ebc8a 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 Sat Jul 13 06:04: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: 13732334 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 0E5451CAB5 for ; Sat, 13 Jul 2024 06:05: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=1720850719; cv=none; b=IhSwLP0sZS6RVFL1DtJuuHLukh77cTtO9X4qoETuJW9STCskyz5UK9UeYWS+TR5u/YRFyp0Ut3edxsE6s4uuu+dDhgALkDn6fTR8CDH4dWyFL+cmnLaC3yu72ae7jdVx4zvkSiolVpn4llifEA1Mwo8PdezBrXHw1KlhVdesSmE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720850719; c=relaxed/simple; bh=fbI6sjpGkTM11rk+zUuSzJzQ+Q3hSa93apw7IUIy7Ws=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CFOcf3WOreeLxrmH3frVMTtpUkJG7YB1PfGEdpZZo6rxFTOmooa01nKjEsan7d6KThKwkv2aRewO5JsQc8f7PsTAR+Ho+XYkj5c3v9wCWNcy/l/JLdt0ag1lqwnJkcIervNNcZndUK0BBeZVLxc14lxrVu3/EfBXiL9kvXN+MSI= 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=YoXe3WGw; 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="YoXe3WGw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720850717; 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=IYS8ABrPVJcB9kFJ6ULZ6jDfUjeLtLp9B6n4NNk3LKQ=; b=YoXe3WGwRMQcKsDWVCxvQ5+0vQBlXIQQSoNz67T6mAE6oH0Csg3oKziT2PLe3DeYn0WxWK 96yX94tjGMtGN8D0bbCfvUAnkuQHCT14LEgTInAzxyLS6imdomlpsRJd50mnnaLxQhqb8N mHps1okuqsy9VtnebdNzXspsVnxpbf0= 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-625-cz1_bALHMEmIJ4aTtzLx9A-1; Sat, 13 Jul 2024 02:05:11 -0400 X-MC-Unique: cz1_bALHMEmIJ4aTtzLx9A-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 F029E196CDF1; Sat, 13 Jul 2024 06:05: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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 525F71955F3B; Sat, 13 Jul 2024 06:05: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 46D657H62015510 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 13 Jul 2024 02:05:08 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46D657TI2015509; Sat, 13 Jul 2024 02:05:07 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 04/22] multipathd: refactor path state getting code into a helper Date: Sat, 13 Jul 2024 02:04:48 -0400 Message-ID: <20240713060506.2015463-5-bmarzins@redhat.com> In-Reply-To: <20240713060506.2015463-1-bmarzins@redhat.com> References: <20240713060506.2015463-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 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. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- multipathd/main.c | 64 ++++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 0b0ebc8a..9b1b5226 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 Sat Jul 13 06:04: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: 13732333 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 5964B29428 for ; Sat, 13 Jul 2024 06:05: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=1720850719; cv=none; b=jznvW+0T2pRpgWMvR3f2/l/CPXaDj5pY8Kf63FcXYL3kDHDvqAIk2gnB5nGgNGBj8Gym0xbP+Vbo2Pkc474HiwNIDFmmY9Gk7yKuq6I5pJmlVZUXK4apIpK3MNXvfJC1Mts4bqEqzQXSmh+X1xyQlhhqL1BHTq7UlWDJwfOglcA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720850719; c=relaxed/simple; bh=We17LeLYHTE0WHG7s9Ywy6NHIWeIQBuq9SkxdAUUfe0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KCW7kVodwJedQaGC9FDCaMC9Efmr0g5Y9c63GbhYGQg24NkfR2wQjp2bDqb2w4ZkrzTrcUc6X6cf0bjG0sYIccTi9kaiRH0ZrKIZrOlR0qZhe31JPdi/3krF3AweTfU64Pd2KPSiuWmfXPZrxlsC0RvOd4m7qGqGL/SAdGoYfbE= 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=MCdgGGTs; 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="MCdgGGTs" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720850716; 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=kP0kY/RuEaJUhM7ZjBDUaLXgmLQ467ttPzobG3bF5W4=; b=MCdgGGTsyAqsRrAfLtcpxFlqZR9Qc5lF5K8ICNqbHlt0sDOFzS0wJpFwclrAkETJ2e91Rc f877rS+oCICUKTbbBsC1/V0zPNnxW2QB6AY/nJDLn35DFKz76HwRDCSkoi5o28FXqpEi7w 0HP0EE+U7nQSCnuJ+wtj7UIq4pmufNU= 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-687-9O0rKalcPPicntG6y1KYLQ-1; Sat, 13 Jul 2024 02:05:11 -0400 X-MC-Unique: 9O0rKalcPPicntG6y1KYLQ-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 1DDEF195609D; Sat, 13 Jul 2024 06:05: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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 92C2D1955F3B; Sat, 13 Jul 2024 06:05: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 46D658TR2015514 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 13 Jul 2024 02:05:08 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46D6587Q2015513; Sat, 13 Jul 2024 02:05:08 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 05/22] multipathd: handle uninitialized paths in new function Date: Sat, 13 Jul 2024 02:04:49 -0400 Message-ID: <20240713060506.2015463-6-bmarzins@redhat.com> In-Reply-To: <20240713060506.2015463-1-bmarzins@redhat.com> References: <20240713060506.2015463-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 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. Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 171 ++++++++++++++++++++++++++++------------------ 1 file changed, 105 insertions(+), 66 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 9b1b5226..9e329e89 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2343,8 +2343,7 @@ 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 check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) @@ -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,104 @@ 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_OK || pp->initialized == INIT_PARTIAL || + pp->initialized == INIT_REQUESTED_UDEV) && !pp->mpp) || + pp->initialized == INIT_REMOVED) + 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->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 + */ + pp->tick = checkint; + + newstate = check_path_state(pp); + + 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; + } + return 0; +} + enum checker_state { CHECKER_STARTING, CHECKER_RUNNING, @@ -2751,7 +2786,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 Sat Jul 13 06:04: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: 13732335 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 11D963BB23 for ; Sat, 13 Jul 2024 06:05: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=1720850719; cv=none; b=bdyTK9LQIMYgdcoOyWcEfvP1knRMHQEsjbTttAd0X+KyNdfjC8Vba0ROUa/Cp43BSBYV4ED4JtzkIezaGr/ZXO6kf/6/j4xCqkynu7Bum4X2RLbu/hK+y8jiEcis0dMZ4nislsnamtFwW/rs4OmBMnHdYK53SuqYwdLiI1WJv7M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720850719; c=relaxed/simple; bh=/DyHTbQ6L3EHEV6ZBavUusss1G2bDuJld2bKfBq6puw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Nhj1a5+BK44IRfGAIGHagM3U7OMC+8LkOPrSJgb4eJM2jXuwqeuvNA8IQ0JULqVzExOzeBXp1tj8/MRIq6zsfhCq9ygWsKFw+Eb50YE//YQ5Ts16qwnDflZteSDVLchxhIglAfNlSalxsO5J7o9IUaffpqIx6gqTWKOKznrxkd8= 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=YwNz5phi; 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="YwNz5phi" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720850717; 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=CONAXBnMF1NhV2i/YpjMc29iCaaoWFzzqjxQkvQxbmA=; b=YwNz5phiCfFzAoyj7EYWj27CreD3TXQYx+oAB1gpXcB8IF7VYvfInDUcWcXUyOwwBP1LNp YogtFwG8CImtBk9I5nnjrIqcQgQoHJ9DPFhyQ1+pbYdPi0ICyPNiJhGIZWrvBJKb8gn8AN HgToYEfgXwGDYKlLLEiNdOyKuVclaSY= 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-216-lUK-UdzhMmy2AiZD2U2kIQ-1; Sat, 13 Jul 2024 02:05:11 -0400 X-MC-Unique: lUK-UdzhMmy2AiZD2U2kIQ-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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 264F21956080; Sat, 13 Jul 2024 06:05: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 BC9361955F40; Sat, 13 Jul 2024 06:05: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 46D658sS2015518 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 13 Jul 2024 02:05:08 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46D658X12015517; Sat, 13 Jul 2024 02:05:08 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 06/22] multipathd: make check_path() static Date: Sat, 13 Jul 2024 02:04:50 -0400 Message-ID: <20240713060506.2015463-7-bmarzins@redhat.com> In-Reply-To: <20240713060506.2015463-1-bmarzins@redhat.com> References: <20240713060506.2015463-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 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 9e329e89..276329c4 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2345,7 +2345,7 @@ check_path_state(struct path *pp) /* * 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; From patchwork Sat Jul 13 06:04: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: 13732328 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 4FA651BC3F for ; Sat, 13 Jul 2024 06:05: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=1720850718; cv=none; b=nzPd6YnbiJT9XS/6V4f9C8UXToksdJiX+UO+IcvS3VeUR4KCKnQ2cAWUajtJEVoJX4BpsrmHzSjigi834aMgQFz4tbXyUK4clJwZhsvo2Artri6+lkdNuLj/4itIvLiEBTGfgbxfM3hiEWFIQcUj+h3dfkPQCTc7/sU2E+Na1ws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720850718; c=relaxed/simple; bh=3OtWutwTjBngfK6RCZeX4Qj6ULzOX8wjywwIdxJxAOA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=I6L6fF1IGCkxP7R1WOYHK+h6DuwKS+y+j4Ef0zAd3uq58CpHPQr6h00g9U9YbGyqI5PB4xsNWgpKppDNUMM8XepyOOeSEGh3B/ZS8fijbmt9Eqs4Z7srooEmWFPyxGmpVqekaeDhnYkz9mxm1MjWc+nynjn8CFeykJYXkuj4vAs= 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=Dn5Xouwt; 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="Dn5Xouwt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720850714; 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=StTQPxX63814NujkC6A5Pxe7Nfg2N7ZFXIfLU7x9v00=; b=Dn5XouwtdIRS9dmfNFttLcki1kmKvSgXPpPN0kiZ9qQtjxLk95LLutBN5Ol11L0Z7JyxlD 710pwyrf4Df5IsngXMPt36Iciu7tVaeL0aCn6bbcFrpEYgWEF2L8Fns4OemgEfmcDOErBx lP35hQGjU7NdiZjT8unNqDi31lNRkzY= 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-687-lNPKoEE4P8qR_ZcXtk_VlQ-1; Sat, 13 Jul 2024 02:05:11 -0400 X-MC-Unique: lNPKoEE4P8qR_ZcXtk_VlQ-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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4488819560AE; Sat, 13 Jul 2024 06:05: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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E54411956066; Sat, 13 Jul 2024 06:05: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 46D6588j2015522 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 13 Jul 2024 02:05:08 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46D658VI2015521; Sat, 13 Jul 2024 02:05:08 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 07/22] multipathd: remove redundant checks in handle_uninitialized_path() Date: Sat, 13 Jul 2024 02:04:51 -0400 Message-ID: <20240713060506.2015463-8-bmarzins@redhat.com> In-Reply-To: <20240713060506.2015463-1-bmarzins@redhat.com> References: <20240713060506.2015463-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 Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 51 +++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 276329c4..d6f4704b 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2629,9 +2629,8 @@ handle_uninitialized_path(struct vectors * vecs, struct path * pp, struct config *conf; int ret; - if (((pp->initialized == INIT_OK || pp->initialized == INIT_PARTIAL || - pp->initialized == INIT_REQUESTED_UDEV) && !pp->mpp) || - pp->initialized == INIT_REMOVED) + if (pp->initialized != INIT_NEW && pp->initialized != INIT_FAILED && + pp->initialized != INIT_MISSING_UDEV) return 0; if (pp->tick) @@ -2645,7 +2644,7 @@ handle_uninitialized_path(struct vectors * vecs, struct path * pp, max_checkint = conf->max_checkint; put_multipath_config(conf); - if (!pp->mpp && pp->initialized == INIT_MISSING_UDEV) { + if (pp->initialized == INIT_MISSING_UDEV) { if (pp->retriggers < retrigger_tries) { static const char change[] = "change"; ssize_t ret; @@ -2685,31 +2684,27 @@ handle_uninitialized_path(struct vectors * vecs, struct path * pp, newstate = check_path_state(pp); - 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; - } + 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; } return 0; } From patchwork Sat Jul 13 06:04: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: 13732329 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 75BBB19478 for ; Sat, 13 Jul 2024 06:05: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=1720850718; cv=none; b=HHmLUPeHz/VutAIDiRbxtGQ08PwW1xP2V5by5QfWkS1nYJygkOYNoEsNfYk3skX+Ih9id40mNUAqQnUV1n5A7B03V9vQ7X8SXyOX66cXVwjIAOUwdu0z7gCl2uv1fcvGq8j7hHF5qVJfkYQonCT3b9SXarwKQN9feCkpxndYbv8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720850718; c=relaxed/simple; bh=ZKHDUZJy1OIWdQDzl0hD/hEmcyAcrjhR+4vKf7TXLmg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WcqbTvTNyWDMs9fxa69gQ74i96NRVG2mdvCDOBfqdJ/mgx65jEjghkSLXAPUp72JexaLsrNOVHoNQfgJRRcgzOuFnZ5olSqhe1oHR+QPYNBycAmKpc+V4L9qax6jFs9e9moZCj4eZbDXb1JiMa4gyfhPRG4Tce16OR8FOEmD8v4= 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=Cz09yXXc; 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="Cz09yXXc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720850715; 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=PF0b7A/ozjZrD5535kI+QlzRaSCtmp1I3uKUQtdRyj4=; b=Cz09yXXcQHTMPcyY1c1tcYwqLt+9W7RExJJ0F4hikRo/ulj4d1lXH9oo3ezrhpYUBYsjaj HjI3rp2nqr5y6cLmsCBOMaBBpQVLdVjbu/pYMih+KyiME4f45w2LnS0k7TV8dLiRe2Yc3i 3+kjK7rxuvdfZ2xRS+PycIy/Z0q7OEY= 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-648-JejWUkEcMDOU8YPNnRVDdw-1; Sat, 13 Jul 2024 02:05:11 -0400 X-MC-Unique: JejWUkEcMDOU8YPNnRVDdw-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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 87F8D195608B; Sat, 13 Jul 2024 06:05: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 1BEC61955E80; Sat, 13 Jul 2024 06:05: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 46D658na2015526 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 13 Jul 2024 02:05:08 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46D658Xp2015525; Sat, 13 Jul 2024 02:05:08 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 08/22] multipathd: check paths immediately after failing udev initialization Date: Sat, 13 Jul 2024 02:04:52 -0400 Message-ID: <20240713060506.2015463-9-bmarzins@redhat.com> In-Reply-To: <20240713060506.2015463-1-bmarzins@redhat.com> References: <20240713060506.2015463-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 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. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- multipathd/main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/multipathd/main.c b/multipathd/main.c index d6f4704b..234fbf7d 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 Sat Jul 13 06:04: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: 13732330 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 A3ECC23746 for ; Sat, 13 Jul 2024 06:05: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=1720850718; cv=none; b=Z7Vl7bp0ddtrVAg+2Drc50rWVpVObM1Y094IPe4XzDgVaNlww+29zD4f2tKEkIe7aYH3QL49fuGQgViiX3gjCzDyYZScJnRPh2Fmm9zTb8njDChIejmKETAyQLYLwLSQCadFzR6qsI0ITeFcJrxrrObcjZFQMWosJz5dQJhGG78= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720850718; c=relaxed/simple; bh=pN8qun/VX0ZmNIv6QY6Fvlh3OvFx74Ya8XL7hw4ybuA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mGI06RUX7GO14b92MHuMZ5A4V/8d/eN7K9wKUd4RIfA00YjCUstvIR9Pp6EbR44GjXgsrU2pBcJVs6tm+INieakCXgeB/NvSHKOQrA6nMFl13pUsRoHwXFQl8bfCTeXLzL5NlI4oAKyQuzhWeuf1KcOvzgKpIKd9YHxmXmbovq4= 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=Rh1rurZL; 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="Rh1rurZL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720850715; 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=xo939ORJrzxw8SsxYJBz/uEPiFs4/a/F+fs2IUb3tIs=; b=Rh1rurZLZYtuFy2AHeAosvx/BmdgD2ijn297QXj3oQCfe/EfRWVfinscXnsvUxvNvMYydG 7j+BPl1t4DNl2dCNp7FTV5pLinSE6gpR4EAFVe/8ujSaOiksOhx1iwzzRzq8zSb2VfvaZ6 nGRo/sA0vU0xfPcf9gCjR3AxWrFcIWo= 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-625-k9I2STZmPvukvppnp_U5UA-1; Sat, 13 Jul 2024 02:05:11 -0400 X-MC-Unique: k9I2STZmPvukvppnp_U5UA-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 AE36E196CDF5; Sat, 13 Jul 2024 06:05: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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3DE15195606C; Sat, 13 Jul 2024 06:05: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 46D658jB2015530 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 13 Jul 2024 02:05:08 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46D6589L2015529; Sat, 13 Jul 2024 02:05:08 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 09/22] multipathd: set pp->tick = max_checkint in handle_uninitialized_path Date: Sat, 13 Jul 2024 02:04:53 -0400 Message-ID: <20240713060506.2015463-10-bmarzins@redhat.com> In-Reply-To: <20240713060506.2015463-1-bmarzins@redhat.com> References: <20240713060506.2015463-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 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. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- multipathd/main.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 234fbf7d..5e89fae5 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 Sat Jul 13 06:04: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: 13732327 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 26E3B200A3 for ; Sat, 13 Jul 2024 06:05: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=1720850717; cv=none; b=rxA6ShBC2t62ojMadHm11p5IwBxLglpM6IMQzdHkBv+fgcek8tytOFD34FZyqtf4bsKUj08eTwwTwlVT8Bx6+uM1zbfEl+6dTZ6mAuuknh62wnW5JoeQt+fXQuJoY7ygfXQvVYwWmHBTToqEES4oWYC75CqejJZcREaBcivSxrM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720850717; c=relaxed/simple; bh=rgp/z9PDO2WSdI0mHw2Ch951oZjH8ZWHBqhn1kRer+g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=b5Ixk3KITRzVvcOUnl5/Br0rI31WzGtg+sQag2TXja7uyB8kylRuOAtPZe9FBEML6zL0DytF6NitNJPHybnJdk6Arf1HR2ZlKC/Y/Yc1J9GiIkeD/c5f9Kgf3+GP2qUz13gVUUjTHIzFtIYUvVBbNQWZPxu2cSe8r5L7uUV+L9c= 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=DdkqNpVw; 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="DdkqNpVw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720850715; 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=oWgXM8pC5rdsTWVk/9wioNOTmnMRs1WU1gF1pTR+2Pc=; b=DdkqNpVwU0CY8KKFADgW7vT0C6Rh11AhQjbSe0AYFjvRQUOdtfus2yGl7MtVnXsqNlDxfK pRVAM0jGzWhOKpDXg58jPPVspt9Xf19c+blhtwyR/wpwgb+w/XeRZukHdc+CBYxSOiZXEM e9UJmOBANNhiHNphxyOn5N7+vVD+LUQ= 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-335-ikvbCmu6PaSMl9NYFG5qGQ-1; Sat, 13 Jul 2024 02:05:11 -0400 X-MC-Unique: ikvbCmu6PaSMl9NYFG5qGQ-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 AE5C2195608F; Sat, 13 Jul 2024 06:05: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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 482FF1956066; Sat, 13 Jul 2024 06:05: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 46D658F52015534 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 13 Jul 2024 02:05:09 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46D658kH2015533; Sat, 13 Jul 2024 02:05:08 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 10/22] multipathd: return 0 from path_check() if that path wasn't checked Date: Sat, 13 Jul 2024 02:04:54 -0400 Message-ID: <20240713060506.2015463-11-bmarzins@redhat.com> In-Reply-To: <20240713060506.2015463-1-bmarzins@redhat.com> References: <20240713060506.2015463-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_state() returns PATH_WILD or PATH_UNCHECKED, then the path wasn't correctly checked, and path_check() should return 0. 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 5e89fae5..43bd5936 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 Sat Jul 13 06:04: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: 13732331 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 8F597210EE for ; Sat, 13 Jul 2024 06:05: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=1720850718; cv=none; b=Nc3A2xfZy1ca7FzdY2NnuQJgn2cjFjNHOj5bQFbKQ4GtITRBYob7qLB/u9crfEfiUWNgZEMtZ99NbTXQyC0XTblFeMTchKeuC4fScZKoLi94sqfh8SOlJu+y/aVTESXBVk2nS2UJk0VTLLi0ThSruUsewj6dq5SON7fyLh3C0Q0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720850718; c=relaxed/simple; bh=7qu/Bi0KGbrx6bqYMjTbrsniQnycbjNi0H/35mFfwPU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CvWbvPeDcw8ttjbfhqsNqtipGlSwEzqISDst4IqtdRcVFQwaZfn/DkaAtWraKDF+eS7he6KmfMjjWXwmW/COrsCg9glPVy6ACQkWs+TaPa9A2INMo+JvL++l4M2JVaPRwleDrDZqi9fl6skfhUB4XNOofaGOdvhWcN3XMRKm3xI= 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=UsfMGDUW; 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="UsfMGDUW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720850715; 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=zQ1Bx7uCpTeAyC/q0kBlyJOhxiqMyMu2wPlUh7IoZbY=; b=UsfMGDUWL+ujz9l4JfCuP0d08GHZ+VO/Iue7TTREmQSXDcc+dIcLXqZiVYXlgDkHW8pruw prR7LgcwYcVoVAcWmCAv8i1eTOPPacEYHklW/yfZervAbjFHYbV8yftsXQPAzkpjr/hqQ3 5hYmePjehdG9gJvsS8eVS1rUegqN7Ig= 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-452-g4S1flmYM2mXYYMBUzTsXQ-1; Sat, 13 Jul 2024 02:05:12 -0400 X-MC-Unique: g4S1flmYM2mXYYMBUzTsXQ-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 2ED4E19560A1; Sat, 13 Jul 2024 06:05: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 90D761955F3B; Sat, 13 Jul 2024 06:05: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 46D659Fn2015538 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 13 Jul 2024 02:05:09 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46D659vu2015537; Sat, 13 Jul 2024 02:05:09 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 11/22] multipathd: reorder path state checks Date: Sat, 13 Jul 2024 02:04:55 -0400 Message-ID: <20240713060506.2015463-12-bmarzins@redhat.com> In-Reply-To: <20240713060506.2015463-1-bmarzins@redhat.com> References: <20240713060506.2015463-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 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. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- multipathd/main.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 43bd5936..fbd253ca 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 Sat Jul 13 06:04: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: 13732336 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 009543B782 for ; Sat, 13 Jul 2024 06:05: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=1720850719; cv=none; b=K5FXEhgU6GX3EQtoLKHklMXbRMCg7Edx+ha73PeLRGfnekLJPr7Jgl7bJQM/Oj6nvPQwmByn1Jsermxtw9XRoM8c5tqyZxsqTu5RECY4HbE5sShO/PjIVX1U/yLg5wkUIFGjL3QCR0fSgD8SQKeFV3fFg1o5v6GMu6LW8xx3dnw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720850719; c=relaxed/simple; bh=ZgD+uJgEs9s+86l16h0KNjgHP8FtysMlg5xPgvcv1TU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZwoAAa1fYJu62V14HT+A+ahm0fb/vAftjjyA+I4tL5KdoZJxK9x+4aNf5afzlb4Y8UpxhYXVcwhXgc9GmetWmSm9aaDo2+oks9F7lhrCyhqxTPF11nEks7GeWl89Xhoehk8x1n3/MA06mY8kyitQZ8P6/s4PoE11oLkV5zjsa+M= 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=MUNnbiLz; 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="MUNnbiLz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720850717; 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=xfYjI/qywwsJao7pyUZ4xwEsI7GQxoxJTRSeviTTR4U=; b=MUNnbiLzgwSxPZoM1XsZ8ODhs9rFxefAJ3UZA7jlIAGmemDgwd2lPdeBks+Xdpc64Em6Po qCxxVPO9NSCFOvpkZFUIi3RubLyzun6sPmv+gwudoCvyWm3syiudZdImeaBa+ENUYX9ZZ0 /GtB3zB5qhGruAqzlvuj0Jg2L3N/mEw= 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-365-9K4trWV_PKuAz0iNNHzERg-1; Sat, 13 Jul 2024 02:05:11 -0400 X-MC-Unique: 9K4trWV_PKuAz0iNNHzERg-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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0DFFC19560AA; Sat, 13 Jul 2024 06:05: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 9DCE61955E85; Sat, 13 Jul 2024 06:05: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 46D659qe2015542 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 13 Jul 2024 02:05:09 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46D659P22015541; Sat, 13 Jul 2024 02:05:09 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 12/22] multipathd: adjust when mpp is synced with the kernel Date: Sat, 13 Jul 2024 02:04:56 -0400 Message-ID: <20240713060506.2015463-13-bmarzins@redhat.com> In-Reply-To: <20240713060506.2015463-1-bmarzins@redhat.com> References: <20240713060506.2015463-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 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 fbd253ca..179fec24 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2342,6 +2342,37 @@ check_path_state(struct path *pp) return newstate; } +static void +do_check_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 +check_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_check_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_check_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) + check_mpp(vecs, mpp, ticks); vector_foreach_slot(vecs->pathvec, pp, i) pp->is_checked = false; checker_state = CHECKER_RUNNING; From patchwork Sat Jul 13 06:04: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: 13732326 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 CC3931CD37 for ; Sat, 13 Jul 2024 06:05: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=1720850717; cv=none; b=OnB3+omeUtOIuxHU25/MMq5WjXd5XD6uDK+BA0UgncwJhri3SwB5vpnAcqdQz+RY2J/xE6U/8rPLchaO8TT/IY7jeDa5IilS7y1hy5MDje8Zgj1oq8YqF266+mUshQUeFziW6xFX31KDDHH88qHHoPEgOs71Cc6o7vQ2kZYDgv4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720850717; c=relaxed/simple; bh=DdYLj+660JXH9mtO0tAMVe91VJrUvJWrdOeX7malbMw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=r9nAZ3UXb7aCqvY0koO6oJ0h8/LnrimheRkpViAdZ9iwTykzoK7rSQnThnfv2+6MD8Y321LCNp7X5yKTQXltrkDO3VpP3v8EyGxl9i05Z36jEgebSxrgHSjgPrWEd4i5LydVHtIkDFk4dIPHiECU+EfmWjj4NP5UPGh5GsnibTg= 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=B3iPZG4p; 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="B3iPZG4p" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720850714; 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=+21VEqFsIMxTSc2nz8lS0bPGLiqoR6Dnw/+Q6mrmFTQ=; b=B3iPZG4p1TIP+OTqCT7X7BmdUxJHnvWtq4A+kisHWYBl+u67l/Vt3b+rdLLRaDj9+yeFmX A1WnviBfk0s0V2/ECtNxR+XCD5RxrLNGczSwNC0GMDQEMMezqzVT8fdahT0uwJ/9KD48cU L/fqK4/9Y98a9XOJ44uqGrdPFq1FQTQ= 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-452-chHrUItENRuUXWbysS6TuQ-1; Sat, 13 Jul 2024 02:05:12 -0400 X-MC-Unique: chHrUItENRuUXWbysS6TuQ-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 1917D195609F; Sat, 13 Jul 2024 06:05: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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C2DD23000181; Sat, 13 Jul 2024 06:05: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 46D659im2015546 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 13 Jul 2024 02:05:09 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46D659md2015545; Sat, 13 Jul 2024 02:05:09 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 13/22] multipathd: resync map after setup_map in ev_remove_path Date: Sat, 13 Jul 2024 02:04:57 -0400 Message-ID: <20240713060506.2015463-14-bmarzins@redhat.com> In-Reply-To: <20240713060506.2015463-1-bmarzins@redhat.com> References: <20240713060506.2015463-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 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 179fec24..3c84c2a0 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,33 +1440,35 @@ 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 */ mpp->action = ACT_RELOAD; + strlcpy(devt, pp->dev_t, sizeof(devt)); if (domap(mpp, params, 1) == DOMAP_FAIL) { condlog(0, "%s: failed in domap for " "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 + */ + 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 Sat Jul 13 06:04: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: 13732343 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 36316200A0 for ; Sat, 13 Jul 2024 06:05:24 +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=1720850725; cv=none; b=RYDngrdMtByqxYAcxHhSina8+o8g6dNj2DuUZtPp09OlLswA4iXk72Buiubm+XkkkyfBHec9fCisymEaGgIleeh66dvRi3xNU/9LqolDyeQRCqaBgPhXeA1Gux+B2rxa5QNeS7+xhWijvd2ApEhiZVjrJkdIm0ieOp3GvuUyd7M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720850725; c=relaxed/simple; bh=5SGw1gHJ53LojK5SiLiLfBzyUDgTMg7qPj8AE8wCq38=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=t/qehW6Kaj1J+kEoP/cY29I0wzZ+WZbzp0xpBpQGlbcVKuOSPOWbep8JYIC9m0wWUw0vobEqEly9tXMM2JlkcIHmeOYTuoJKJssdO7jagf/2Uqr7uRiP02lK1rIX3B7516nb2OUCRjfPGQ4FlEBQ5JS1H7VyQZqnPJEJfmpAhic= 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=HV1sxE/e; 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="HV1sxE/e" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720850723; 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=tx6YpNWFw5WUfSOZRRz3iv8PT2zeIEaHtowZzHg+DNI=; b=HV1sxE/ebey5wzTIplXop27aOXB/DJV3OFZOR9VYxbNf3RzML0HN6H5b21vWosbBlbXzyf uj8oAfQE6z/J8kWFjcWJyZeJnPYa0HCM0rpSdSN/fFhkzUA/VjPhnyGCPFTDls23TzYif+ Gk68plkB36Y2H7UOp6Plj20OEN6+/Os= 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-693-XFuZx02VPgKU-Zw7asFcEg-1; Sat, 13 Jul 2024 02:05:12 -0400 X-MC-Unique: XFuZx02VPgKU-Zw7asFcEg-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 7A64A19560AB; Sat, 13 Jul 2024 06:05: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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1734019560AE; Sat, 13 Jul 2024 06:05: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 46D6592a2015550 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 13 Jul 2024 02:05:09 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46D659QD2015549; Sat, 13 Jul 2024 02:05:09 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 14/22] multipathd: resync map after setup_map in resize_map Date: Sat, 13 Jul 2024 02:04:58 -0400 Message-ID: <20240713060506.2015463-15-bmarzins@redhat.com> In-Reply-To: <20240713060506.2015463-1-bmarzins@redhat.com> References: <20240713060506.2015463-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 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 3c84c2a0..c9cb9ac8 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 Sat Jul 13 06:04: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: 13732324 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 922E61BDE6 for ; Sat, 13 Jul 2024 06:05: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=1720850717; cv=none; b=EdJeqcL6LNKA9+vkDn9KctRlPeWYWfCOwKRQQQ+uclh/mLwz99e4mHPDscMtciJJhpU2BpIPCn4lIE4qk366GxTf8blwYVmayqsvW1z+ZUXasdzhxXfrwuyBeQXkef77YxMJALfhg8insNkaXVO+wpNGWKM8n1JR8QZ7ruzcJA4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720850717; c=relaxed/simple; bh=IETw3ODevM6KfeOpsr6LslEN1KgDvJXdWZUclGg1SEI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=P8PArnEewP+zIuArxGJLrzsLY7s8URxlYJ1BMk1JO4W+BVWIvvGjD8Ant8skeBfs1yG5GrjJRVnTgWGPfY824dI8Ncte9zhmzpMC0+Y5WuNWTKVz31Gd/2Fq24DHF1u5/It/Pa483vwOh8z9TwwJNTdxXiD4Zfxg4WEZfoHg+zM= 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=cdLbtvTP; 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="cdLbtvTP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720850714; 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=HAhUDORWizI+NjiHunctu7FdBIaEabTEdxYMcq6vtv0=; b=cdLbtvTPmmP1p43bS7JIRgQKq0ZrkS/YyRQLBjaoCQLekDL7VagGEho9xWRHkhoDfZ1hna e33AaEiJ6FgQckGlQcw+xfZyIRe8twcIMpxEJTEROFL51/zyQ8QymruudP7Stt+/Ygn8ND WBiUV7OZahv2r1LhYrrFXVGLedPZzDU= 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-8UL0UzvdNWaY6aiw3QVU2g-1; Sat, 13 Jul 2024 02:05:12 -0400 X-MC-Unique: 8UL0UzvdNWaY6aiw3QVU2g-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 7F0A719560AA; Sat, 13 Jul 2024 06:05: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 1B0541955F3B; Sat, 13 Jul 2024 06:05: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 46D659nR2015554 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 13 Jul 2024 02:05:09 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46D659DX2015553; Sat, 13 Jul 2024 02:05:09 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 15/22] multipathd: always resync map in reload_and_sync_map Date: Sat, 13 Jul 2024 02:04:59 -0400 Message-ID: <20240713060506.2015463-16-bmarzins@redhat.com> In-Reply-To: <20240713060506.2015463-1-bmarzins@redhat.com> References: <20240713060506.2015463-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 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. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- multipathd/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index c9cb9ac8..0f763e29 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 Sat Jul 13 06:05: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: 13732332 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 44CD929406 for ; Sat, 13 Jul 2024 06:05: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=1720850719; cv=none; b=bEw40sxNq+HBsZMgQsofqmJ4d4L4cQdys1ZNcGFg+C3LgnA/RLDi/eWYdIZ6xXevIQwynV9IB/jXD+a/vNgtV5TBSGZD7AUMJToq5TSvmV3gGe4dfnx0ukL/0Jxv7Hk5W5jHtim+JYUI7/abqRFgcY91NKLYi1VdRr76qYgsVrU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720850719; c=relaxed/simple; bh=42ev6G5X9EDDz17ZaVYZMZWDLHalnefha1KxgxyivQw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=paqA0nKR7DHdmR9eshnDzPBL9jRVc5ScDcYCn9Xd7997PWXv+0ywlZHHQ4WJMkQSKWVOlgV0gp8ZMb3pfj5AtSxQfmULLdKajoWqZT6s40gTcXHscOE4u0cO488v2NY9zRxmmpKxjMpxwl9SIBfft+lv/5wu6kUdoiwrd3djffw= 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=Fzrx+gOM; 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="Fzrx+gOM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720850716; 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=AI8ZXgC0fqweJEmaQuLatbI2yhcnKql8selzn32kDCs=; b=Fzrx+gOMH8n93i7jjqnZ8SHOmfPjt0BKOC2CFxEaeeiJ5ABsVbicqTCIvzKtK/N8+pP+xi 9KlbgAldZ5AlgJpo8jJhpXZjShdHabR4oM8qDuL2BVgP9kgx0XW0+tF8KSJMes6XE2WB8J M76QRrQBcU+Cc13sev6ai7Ufpt6uQ4k= 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-500-EC_iDAeEP5unYGycop9AlQ-1; Sat, 13 Jul 2024 02:05:12 -0400 X-MC-Unique: EC_iDAeEP5unYGycop9AlQ-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 AA3F71955F42; Sat, 13 Jul 2024 06:05: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 420821956066; Sat, 13 Jul 2024 06:05: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 46D659Si2015558 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 13 Jul 2024 02:05:10 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46D659Am2015557; Sat, 13 Jul 2024 02:05:09 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 16/22] multipathd: correctly handle paths removed for a wwid change Date: Sat, 13 Jul 2024 02:05:00 -0400 Message-ID: <20240713060506.2015463-17-bmarzins@redhat.com> In-Reply-To: <20240713060506.2015463-1-bmarzins@redhat.com> References: <20240713060506.2015463-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, make check_path() return -1 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 returns -1. Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 33 ++++++++++++++++++++------------- multipathd/main.h | 2 +- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 0f763e29..e32af693 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 @@ -2377,7 +2382,8 @@ check_mpp(struct vectors * vecs, struct multipath *mpp, unsigned int ticks) } /* - * Returns '1' if the path has been checked and '0' otherwise + * Returns '1' if the path has been checked, -1 if the path was removed, + * and '0' otherwise */ static int check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) @@ -2434,8 +2440,7 @@ 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)? -1 : 0; } if (!pp->mpp->is_checked) { do_check_mpp(vecs, pp->mpp); @@ -2635,7 +2640,7 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) } /* - * Returns -1 if the path was blacklisted, and 0 otherwise + * Returns -1 if the path was removed, and 0 otherwise */ static int handle_uninitialized_path(struct vectors * vecs, struct path * pp, @@ -2706,6 +2711,12 @@ handle_uninitialized_path(struct vectors * vecs, struct path * pp, ev_add_path(pp, vecs, 1); pp->tick = 1; } else if (ret == PATHINFO_SKIPPED) { + 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 -1; } } @@ -2794,13 +2805,9 @@ 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 < 0) i--; - } else + else num_paths += rc; if (++paths_checked % 128 == 0 && (lock_has_waiters(&vecs->lock) || 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 Sat Jul 13 06:05: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: 13732325 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 CA1881CAB5 for ; Sat, 13 Jul 2024 06:05: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=1720850717; cv=none; b=LHVbMnLSGxvct02Uubc75RcpZ6cO3UXqSTocwRLkEqsvHvsjprV3PxaBgCr4S1Tjh78+rKKyLxViGdQPEPJqqaZqhAHyHgZe7dst1VtFWKhXE4dlo0lDCBxUSB8q5I0atU+tkz2WE3pxGCRQR0yGkf52R1AB9XFGqaa4z1RTvUY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720850717; c=relaxed/simple; bh=n/eDPfgVF9RnkAcJ/TAiyCxk0nmd647vgQhMx5TtsTA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=O0x+G7jCBTAOU35b0skPiBm+WS5Esl1UfilrSmfEmsldOOn3/h2w+qHTU0DbKOGTno4FvUn5UrsDSqwh7W9S3FQFYao333cYV/Ve8FgjdJ+UvZHDXQfPT6v3L+C/8KX9FtHAr2o3Mo62FdQswcfJaRz2/MLIYu4I2hPdrWPBPdY= 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=AS1ySwoB; 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="AS1ySwoB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720850714; 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=1UV0dfmzQP60H5+aM3SwQ15PlX0Ja+rcIYcikk0OTEs=; b=AS1ySwoB7M9EBFQR0Q3rzWsxDtwh1ot2VvVOCTxNDCfORoa7SwWnMrwi4C1C4ePOpailpQ FJr7mPT2JxvyTpYCSDyPq9/i39BC4Dm9pCVGviLI4vfAlHN/1LOt1PAgUEKjKY12N/ch4F 0/k40f/si35b39DeZFPC57JkqGVWdcg= 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-652-OoC7INSDMkSgB6J9qUmubg-1; Sat, 13 Jul 2024 02:05:12 -0400 X-MC-Unique: OoC7INSDMkSgB6J9qUmubg-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 B08931955F43; Sat, 13 Jul 2024 06:05: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 668A2195606C; Sat, 13 Jul 2024 06:05: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 46D65AL82015562 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 13 Jul 2024 02:05:10 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46D65AxY2015561; Sat, 13 Jul 2024 02:05:10 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 17/22] multipathd: handle changed wwid when adding partial path Date: Sat, 13 Jul 2024 02:05:01 -0400 Message-ID: <20240713060506.2015463-18-bmarzins@redhat.com> In-Reply-To: <20240713060506.2015463-1-bmarzins@redhat.com> References: <20240713060506.2015463-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. Signed-off-by: Benjamin Marzinski --- multipathd/cli_handlers.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index 0643be15..5d8ba3a6 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 Sat Jul 13 06:05: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: 13732337 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 DFC6F19478 for ; Sat, 13 Jul 2024 06:05:18 +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=1720850720; cv=none; b=u7hfr5ZYC/66Ah+Y2oCFmzlPJtM9OdRzHPtK2u0RbPvEMEyeKM6Qif7Q+tUyj/APZ8SIogZd83gPkNlBZUc0Px+0J8KpGaX21AHP4MC+AM1oKC+odPy3b/1AoLWW9orAa/a1z8eBs1s2EA5sf2JVb+LKeaCSb6gYEfknVPufCbE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720850720; c=relaxed/simple; bh=KRrZiGCaSUVaDkrcSCNHXMY05HLhvjWTHndE7OpmB34=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UwMlWGKZa8+KIZM0RqyZ+fxBFAWzLKF4m+1yoBFMsxiahzJSbKJdOt8TlFqjcuZsGXjnxcejlHUPp9nktfPGCf/JqlId3luAkfVC7kTa3UVDtur0g0ld6dznQJIaoQgIr5OTKC/vSIUQNvIuf36dcjCmgYQ2liv5A3tcORXZ5hM= 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=VwxfbTjK; 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="VwxfbTjK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720850717; 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=QllqKhk9nE3UhLl1kNsKRnbT0TpQj8pJM4wZJYDnBNQ=; b=VwxfbTjKji7KEkSv4svMtxbjgMhJRBm5G8W/QgJ3YqEbaoZm5x8YEYdqZHVTQEcHmWQIKK JijOMu9bkmrpefnJ7hyN5BRlIywD3qTJk/jgV+WW2gY5EiElyrE3gFzTnQMx3NfGX/UiVT VviEKa1IgvX/KR85GUXz7mKAztBm/cw= 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-396--zdGa-rgNTi3XUXQzMgsNw-1; Sat, 13 Jul 2024 02:05:13 -0400 X-MC-Unique: -zdGa-rgNTi3XUXQzMgsNw-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 2025119560AA; Sat, 13 Jul 2024 06:05: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 AB4531955F3B; Sat, 13 Jul 2024 06:05: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 46D65AYl2015566 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 13 Jul 2024 02:05:10 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46D65ApF2015565; Sat, 13 Jul 2024 02:05:10 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 18/22] multipathd: don't read conf->checkint twice in check_path Date: Sat, 13 Jul 2024 02:05:02 -0400 Message-ID: <20240713060506.2015463-19-bmarzins@redhat.com> In-Reply-To: <20240713060506.2015463-1-bmarzins@redhat.com> References: <20240713060506.2015463-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. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- multipathd/main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index e32af693..daf668eb 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2510,9 +2510,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 Sat Jul 13 06:05: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: 13732338 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 C512A3A1B6 for ; Sat, 13 Jul 2024 06:05: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=1720850720; cv=none; b=LOgJuCTMnpFlCjl0cmvPOEDM0r5pKskK4wQBvoU6iSctJlPzZO+lY13G3gPrZIJAX3Vi/3GXIJBADpFmHvTmNs1m8tR6eBqRf60I4Z09OC7nDt5QVqjuCH+mveZGIqHbX/MUxTJgdYoPIlh5Dqhff5VaOMvWNlx4HCgVmlCqnv8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720850720; c=relaxed/simple; bh=UgpOLZvJcSAO42qfd//iC2MecIxeNepMwJUH85gx0ug=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uDzp+l46I5dvge6LiW1vEaPjefby6Erqc5T25l3KmB5VXO7q4Y2tM4vxocaJEz6NhLTIuiezMsbxxEPHqQzMIjm7vB1sqaDwrKK2MxnDZRVsTeaEXPCAgdjBeOoYgbaiErRD7yKn53oznnPdPB8Jw72uifvl3X9gqe33vyyAjc4= 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=eOuNfiK7; 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="eOuNfiK7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720850717; 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=KIJjceIgCuVfdt5qgOlWOqLjdtq+BC1ahvWyAXy99UQ=; b=eOuNfiK7BPZA5VgR6XEq2zhl7+IqyTQXPmhVwPLgkB0azPfU6R1jby1/VgMc2B6u37Zqax 1NHtoqirmIe+TCaCHzK41x1sYziZlHO//MtCUOdiBQ80P7SbYh8CFmdTI+dAbex1PKNYXr Km6fYbD3etC4x0cC8UijMyn8ACbMykY= 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-396-Vr7-oh7cMTiHM7kgblpoag-1; Sat, 13 Jul 2024 02:05:13 -0400 X-MC-Unique: Vr7-oh7cMTiHM7kgblpoag-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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 25CE61956080; Sat, 13 Jul 2024 06:05: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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B2ED61955F40; Sat, 13 Jul 2024 06:05: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 46D65AMk2015570 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 13 Jul 2024 02:05:10 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46D65AiV2015569; Sat, 13 Jul 2024 02:05:10 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 19/22] multipathd: make multipath devices manage their path check times Date: Sat, 13 Jul 2024 02:05:03 -0400 Message-ID: <20240713060506.2015463-20-bmarzins@redhat.com> In-Reply-To: <20240713060506.2015463-1-bmarzins@redhat.com> References: <20240713060506.2015463-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 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 at least twice as long as conf->max_checkint, and 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 a path isn't checked on the goal index, then pp->tick for the next check after the goal_idx 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 | 13 ++++++ libmultipath/config.h | 1 + libmultipath/structs.c | 1 + libmultipath/structs.h | 1 + multipathd/main.c | 90 ++++++++++++++++++++++++++++++++++-------- 5 files changed, 89 insertions(+), 17 deletions(-) diff --git a/libmultipath/config.c b/libmultipath/config.c index 83fa7369..ca584372 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -982,6 +982,19 @@ 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 at least twice as large + * as checkint and is a multiple of all possible values of + * pp->checkint. + */ + if (conf->max_checkint % conf->checkint == 0) { + conf->adjust_int = 2 * 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 1583e001..472e1001 100644 --- a/libmultipath/structs.c +++ b/libmultipath/structs.c @@ -148,6 +148,7 @@ uninitialize_path(struct path *pp) pp->dmstate = PSTATE_UNDEF; 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 daf668eb..42ccb92f 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2386,7 +2386,7 @@ check_mpp(struct vectors * vecs, struct multipath *mpp, unsigned int ticks) * and '0' otherwise */ 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; @@ -2398,14 +2398,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 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(); checkint = conf->checkint; max_checkint = conf->max_checkint; @@ -2417,12 +2409,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 0; @@ -2584,7 +2570,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) { @@ -2637,6 +2622,76 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) return 1; } +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 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(); + 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; + + /* + * the path checker is pending + */ + if (pp->tick != 0) { + pp->pending_ticks++; + 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 + * + * Every adjust_int seconds, each multipath device should try to + * check all of its paths on its goal_idx. If a path isn't checked + * on the goal_idx, then pp->tick for the next check after the + * goal_idx 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 (next_idx > goal_idx && next_idx - goal_idx < pp->checkint) + pp->tick--; + + return r; +} + /* * Returns -1 if the path was removed, and 0 otherwise */ @@ -2799,7 +2854,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 Sat Jul 13 06:05: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: 13732342 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 DD1E03D551 for ; Sat, 13 Jul 2024 06:05:22 +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=1720850724; cv=none; b=BsfiySuCFjdzmg6qNrGgeZnMgo1iZqcqPL3mQ+6YG+iGQidEjEap6sNFE5pEpYtRhJ5VY7WEbbpG6X6UEyMWgE73+2XHII9zuuA50PJT64xE70cpeR1xMQ1fh9TBJl6q+ZwNxF+8m/HZBCzRpl/puEX0KRXiBhXEsPiDgVx9loI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720850724; c=relaxed/simple; bh=Jo/SqeBFw7Ygw7zArwnrXOkuPtdGlzR3k4XbE1VEiXg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=C9fqyq1LwEbe0780dOb7/M/YxrtOGO5AlZ4UfcwEWmnmyT20an1vARdn35bX9JYt5dlq8bxtNsaangTsoPeRs9hGo3rtgi1p6/tm3BVOAiISwUvTjHqvPSzJgeZ7NkFOG5eUBDEhAaKFmIY+6lYbqEOv8e7vM4M7yWt5QwriYNM= 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=WvtxLIVM; 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="WvtxLIVM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720850722; 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=wqtdwzK1FkdwmPRtNlx74vpTnaXXGhqtPdWqxX2t4Rc=; b=WvtxLIVMdIyqJ20IbWlhrTHtUn9j0C7GHS4HN2EL7365A7YbqhNaXa8reYwQflnM4JKefP czwX/OtMIpiBbLnsPb6YM2JQ7z+ihS4oWCUmez486VgRIJkvuaFQoYqsJIWMm8NbTAjkEZ diSXN/mb3BvqGKcVtjyLMjQ4wXeT4cI= 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-681-k_8SoIbMN6ibqCBKBASxPw-1; Sat, 13 Jul 2024 02:05:13 -0400 X-MC-Unique: k_8SoIbMN6ibqCBKBASxPw-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 298421944D30; Sat, 13 Jul 2024 06:05: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 D4B5E1955E85; Sat, 13 Jul 2024 06:05: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 46D65Aqq2015574 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 13 Jul 2024 02:05:10 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46D65AqT2015573; Sat, 13 Jul 2024 02:05:10 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 20/22] multipathd: factor out actual path checking loop from checkerloop Date: Sat, 13 Jul 2024 02:05:04 -0400 Message-ID: <20240713060506.2015463-21-bmarzins@redhat.com> In-Reply-To: <20240713060506.2015463-1-bmarzins@redhat.com> References: <20240713060506.2015463-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. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- multipathd/main.c | 65 +++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 42ccb92f..27e18a0c 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2782,6 +2782,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 < 0) + i--; + else + *num_paths_p += rc; + 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) { @@ -2813,7 +2845,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; @@ -2832,16 +2864,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) check_mpp(vecs, mpp, ticks); @@ -2849,32 +2879,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 < 0) - i--; - else - num_paths += rc; - 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 Sat Jul 13 06:05: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: 13732339 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 2E50F20328 for ; Sat, 13 Jul 2024 06:05:19 +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=1720850720; cv=none; b=UBZ++3/KZaLR7/kICsRaoOaYoh00n8zaEoY90AqHctBYz9N+ffAan9Qhc8Xc4Vxle3rad2uuCDr7099M6xOmjcdFX1F9WYrlv0DIV1Z7y3FpZOAmWXZEymZDPHk4ChdpQUHrFO5jjL3QuBrprekb0EUSBtbWGWn2LBFXH91CWn0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720850720; c=relaxed/simple; bh=3e+uQ1J31NGi4+5IsLm/1FNAFmRYgNg23wxt3EHTH7A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lqiCtlqEmr07kCXVF6zZl/qIzhMT1O8BDSxH36IoT0QEjQAnXhV9RlipzjYwyzDzF+mSkeIT2+3oOu8SsdUPz2lYDY+GC85N6BZHLhWigdUyGMyBgLwTKpbvr2+LF9MBvbfl6cKj+z3R/l5gh7apff2fDhuPHoShB/z/nOgbj/o= 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=XdlVXGd8; 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="XdlVXGd8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720850718; 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=mQ8m675KpiZw+7LTUB8+0A3MmVZA8ARQ7XQW6UJwFYI=; b=XdlVXGd8FfKsl+o3fLrLvN8p8owmh4AiRj00AvsNRRCcB5FHFxH0Hd3dDL3pef9kqKf8f3 lPd2q0yPQ0vP/dQONckVX+pbPjOIBYYw+ynmXlolddapr5wJ/M01kTILJGB6/puedQz6Jh MTumXjTe+BaueovZ/mmQapmUl9FGQFc= 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-396-0rKf8eD6Md2TS_8RRR19PQ-1; Sat, 13 Jul 2024 02:05:13 -0400 X-MC-Unique: 0rKf8eD6Md2TS_8RRR19PQ-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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 377B219560B0; Sat, 13 Jul 2024 06:05: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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E176D19560AE; Sat, 13 Jul 2024 06:05: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 46D65AWr2015578 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 13 Jul 2024 02:05:10 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46D65AM62015577; Sat, 13 Jul 2024 02:05:10 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 21/22] multipathd: check paths in order by mpp Date: Sat, 13 Jul 2024 02:05:05 -0400 Message-ID: <20240713060506.2015463-22-bmarzins@redhat.com> In-Reply-To: <20240713060506.2015463-1-bmarzins@redhat.com> References: <20240713060506.2015463-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 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 60360c76..704e0f21 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 27e18a0c..d51bc852 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2356,7 +2356,6 @@ do_check_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 ? @@ -2428,7 +2427,7 @@ do_check_path (struct vectors * vecs, struct path * pp) condlog(0, "%s: path wwid change detected. Removing", pp->dev); return handle_path_wwid_change(pp, vecs)? -1 : 0; } - if (!pp->mpp->is_checked) { + if (pp->mpp->synced_count == 0) { do_check_mpp(vecs, pp->mpp); /* if update_multipath_strings orphaned the path, quit early */ if (!pp->mpp) @@ -2787,18 +2786,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 > 0) + *num_paths_p += 1; + 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 < 0) i--; else @@ -2871,7 +2909,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) check_mpp(vecs, mpp, ticks); From patchwork Sat Jul 13 06:05: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: 13732341 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 C7A694779F for ; Sat, 13 Jul 2024 06:05:20 +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=1720850722; cv=none; b=afBqtx63u/GQDV8X7umUrsqVBhz34Dkpc1GvHE0sk6o3m7EkBzTpi+RN6KQyjm/xPeiU0/PYWfPbQUZb34TgjsuuzaSyL0vpA5ACPSliU3f4WCB1yyif0p02RbtmU5rW3ZHypAao4CHBY6HkAeKUT1i0OywUJDpHmjV7PslEDBM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720850722; c=relaxed/simple; bh=686pmFl19U+ak3w9ISHGiH0H0AhnmLYZduFRPNXnisg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=B2KXfQxpCwHeEnPQcA9DZR5VJV3Ws9ex5Et7eHWWP9ULLLgKa+c0GAb9xstpn26nLTmhQsc/GJyXUYh1PlyPtMonmFRm245iunHy2QkLMCzBhsVGyS2Nfj0F4C0ONg2IkU50pOkgmkaCF9fDzJLJ64fOFH79ffxuKJ38WOKs3bE= 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=X/6Q2GOe; 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="X/6Q2GOe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720850719; 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=pWEmIkuaMaDCYVxaDT0udVn8mwz9u88SGvwdXym7BEE=; b=X/6Q2GOeO5ihtS8WUWZFO+WItA1zLYUiS+kclH2CiqGQkv54q7G9galmUaMny4A0DRN6am U8QRKWY1S38o4jY5MkchZ+gNMRxV9omXKPIrgV/AYYjbtMPbpKho2OyMSrPz+gE3PhLu/S mDCKNTlHOQZx9bsOwImK1ES28ecKHiY= 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-612-i_2XinIiNH6wPFOTPO0CSA-1; Sat, 13 Jul 2024 02:05:13 -0400 X-MC-Unique: i_2XinIiNH6wPFOTPO0CSA-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 B5D341955F44; Sat, 13 Jul 2024 06:05: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 302E31955F3B; Sat, 13 Jul 2024 06:05:12 +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 46D65AR02015582 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 13 Jul 2024 02:05:10 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 46D65AOU2015581; Sat, 13 Jul 2024 02:05:10 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 22/22] multipathd: clean up the correct wwid in check_path_wwid_change Date: Sat, 13 Jul 2024 02:05:06 -0400 Message-ID: <20240713060506.2015463-23-bmarzins@redhat.com> In-Reply-To: <20240713060506.2015463-1-bmarzins@redhat.com> References: <20240713060506.2015463-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 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. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- multipathd/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index d51bc852..50b6f3eb 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)) {