Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.180 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796070370; b=iMpYIj0folOXdcTZwm4/TRiGG+2JBShxykqdcx1nKbCpmPkCwxrtuEk3hrOs6eXXYfLL gqQhqYbB3W3yNGXOZczqjrnEEEFePv1KtNpl/dJo97ulWUPk/2erSQRm8TXpXaUrVXC4Y ztohI+Nhn6SBT55CrR/pFpOEuLPs4GPPsNvFfhFcnT1G9z+Xq2qiR+kXvntDfh5ZepQU5 ryS/O+E3omqqtBzWhknTBciUs0MQLlwDbEmNNIdwv5n0O1Y32L5TWuaSKAhfEiqCYxmq7 NLre5dSqCyakqRep0YTaLsP1+1OGwTrrz+6kJeXTmJEtzphs5avyRZLM7OxUTUjb6Qg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796070370; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=216hjfz9oGJBO4zhyegPHTaCY2q4I6zH6t46NpRMI08=; b=rr/Gz3NAj9tFqvzZ4WrYJXpfllmQ8dVBEm37Z7EG2nymGSF+krmisHmVantn4PBg+sO1 dRaBCdH0YxRi7QO7fX0DXR3odup+JJZeLTUxxOaqEvJqwSJURcUrxvu6mC7Td0dgSEz86 U63Qn+WPxlheUqgc0SCD4xPK24XJk0Y+s6mB/5VHAQrIatq96BmD0v6w8q2q5zjS5bbej tHcjYSTUHPv5ChUoYL+yAC+0CS0PXCu7N4JN/V/MLCd29ujpAa9KxPRcpb4OUM+3HfrhS YHm1Z/S/RcSkPmGFRMuSZKdzt4BacJHJ8oB0gLKFLmHpI3BHW0nLkiY6QEqRPnadv6Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=purestorage.com; spf=pass smtp.mailfrom=purestorage.com; dkim=pass header.d=purestorage.com header.i=@purestorage.com header.a=rsa-sha256 header.s=google2022 header.b=LgZ5RTW3; arc=none smtp.remote-ip=74.125.82.180 Received: from mail-dy1-f180.google.com (mail-dy1-f180.google.com [74.125.82.180]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4891B606A32E for ; Mon, 30 Nov 2026 20:26:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4891B606A32E Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.a=rsa-sha256 header.s=google2022 header.b=LgZ5RTW3 Received: by mail-dy1-f180.google.com with SMTP id 5a478bee46e88-3869f03af6aso10246732eec.1 for ; Mon, 30 Nov 2026 12:26:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1796070369; x=1796675169; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=216hjfz9oGJBO4zhyegPHTaCY2q4I6zH6t46NpRMI08=; b=LgZ5RTW3MPkS2NipHeqbSoXGzLI0mQHDp6bSetrw/UrlfRqg/NzdV1sPskA2DA6CSL baBt+052wwnrZUKhT584qRJ37B784NiBQYknyAE8F5bHECfWlaArGsV/KRghyrT8caLI 6/ukW5vDhA6bj/mML8GvNb4eZJgfr+kFYvs6RVbgRizYqz6j4J55nhnITrrT7L7pcCcu mecQlgSkCj1liHv3r205k85nhmOCaIuxp0xK7me0D8sTYfPcvVnAhI2eTnyS6iLbHNPb LJzb8GKCkfpKEmBxIDOXORb5ABRGGsboQTLiQ+k2ElIxKAgJM2r0A/mEYfHsFJg+4Mb7 Y2oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796070369; x=1796675169; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=216hjfz9oGJBO4zhyegPHTaCY2q4I6zH6t46NpRMI08=; b=TsOlIYxuKGk5cCTdnCIzf6By4MqNVpCWw4tYX5k9Z+Ktl4tqxqPOndx1MUO9aaPL9f ln8qm4TT3Y2cusw5TZ6jN0FamPEJit0Dp3rtyHMtU/FmEuCJ51SmU4AMzocGKer7N+sO iPyxVoOI3n4Uv3NxYII0o4UWINokjgGHN7D+spkWyX/PEfBQkUVNTCfBpaDCmGSSRMhB KFv1i6YsSZIRqrJab3ZS/Zp54+u0j1Zsa3XdJ9r87LYnvgAPyQAdq7hLvt8lKoNAd43X CnqQVVB47BzKhON5neRbgTjP85L7D00aaMdK/Wza0LhFUNUX4t1u06BIbGj5bNuSZlFy nCPw== X-Gm-Message-State: APuU4Z9B4vgd9TDuYOyLH8xVL8wjIvzuPObqxyNkVsV3yDiUMrTzP45p aD9dtNK/eR1JdgEGiOgzBjAhKHoRjJPC3hX/2EzzRqe2U62+XsY5TRRkxyfPEEhFy0spDq9CmH7 osksywjr0Gx77cpjGvW3bFJfUnob5e6kBpD2VWy0AK+uzPAq5P3ep+Pt+htlqkxfiojKDiGci7o 4VtvRyicn4Ui8TlXr8H4s3ymumENKeO3S8SoU9eHm7a7/ZuTI= X-Gm-Gg: AZFdTZd2ka5f7IYGkb3ZtSEFHr4uiNq1ocftzM33cypQ7+LTBSVQD4ltyPpqGL8Lh+G NVkm4midF/4rDTR4mJTtvCMFWnDF3kZsMdpE5CAPGJr42RsBE63lPbRMdas6D4ndhNJdvnuA6iZ r+Tz0aX0zHQMLtW9HcPdMGFp7ySiP8j6DdU8ad1a4yJLMjbQjjaoIARH5/G1G68624vlTI8++/D BQ+6DHXZS/Skjgb4pKE1HLIOGY5Cq2SIWowMKPS5H9faaNKk8NfN441IlA5O8gE97ckriQvMNyo xWCl1qhibG9AVhDLX8DSGp5b2qinJf8RlCPeXGMGUs+nGJlT1D/adVw/1Srr5UDWVZaFCMNcUoA CS9IzvQP8EWhJLvWw5XERWpz0h2dg/9LOMXSEsWIymTSy1zdZgXzzF0vmSivS51ZRb7XlDjAPl0 3rCJ8Tbh4wbS68ckVaZTUgGI25Tnjpwv2rCpNufMEYLml3/QKXnTEAuloFjD9qYcXySzZ4qp+S9 PGD870BJwjNrkm3uVOMemG0elJL9MPg5VyN6hhTYzy2rdvHrLZGjzl+uPxiFjTI1U+myx2d9oSd xfKyQ6rMoDN/9jYl/a1YkZbfEQgHC9wHz74hsi17/Y3wN0baO55sLC/UIzjFOLLA+8mgR2NRlDm lfV04PkFdYgFgIs0hrk4EueFgKMPmz15QTQFEIQjQedlxUSGPNzCodirxbGDy0yOeM2b/bhVCqa FGyc6OyYrjDCz8358DsnjLromjtQ== X-Received: by 2002:a05:7301:1a85:b0:36a:79cd:12df with SMTP id 5a478bee46e88-3856fe5ae43mr34366328eec.9.1796070368822; Mon, 30 Nov 2026 12:26:08 -0800 (PST) Received: from brian--MacBookPro18.purestorage.com ([170.85.204.103]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-38707b612cbsm31332814eec.4.2026.11.30.12.26.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 30 Nov 2026 12:26:08 -0800 (PST) From: Brian Bunker To: dm-devel@lists.linux.dev Cc: Benjamin Marzinski , Martin Wilck , Christophe Varoqui Subject: [PATCH v5 1/1] multipathd: recheck WWIDs of re-added paths with the device Date: Mon, 30 Nov 2026 12:25:58 -0800 Message-ID: <20261130202558.28849-2-brian@purestorage.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261130202558.28849-1-brian@purestorage.com> References: <20261130202558.28849-1-brian@purestorage.com> X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit multipathd takes a path's WWID from udev. When a change uevent reports a different WWID, uev_update_path() removes the path from its map and re-adds it through uev_add_path(), which places it in whatever map owns the new WWID. The removal can block for seconds while the map is suspended, so by the time the path is re-added, the WWID in the uevent may no longer be what the device reports. If it is wrong, the path goes into the map of a different LUN and I/O for one LUN is silently sent to another. If recheck_wwid is set and the path is up, confirm the WWID with the device over SG_IO before such a re-add puts the path into a map, as recheck_wwid already does when a failed path comes back. If the device doesn't confirm it, or its WWID can't be read, leave the path out of the map: orphan it, clear its WWID and mark it INIT_MISSING_UDEV, so the checker retriggers udev after retrigger_delay and the path is re-added from fresh data. A path that isn't up is checked by recheck_wwid once it comes up. To tell these re-adds from ordinary adds, turn the need_do_map argument of uev_add_path() and ev_add_path() into enum path_add_mode, with a new PATH_ADD_REINIT value that behaves like PATH_ADD_MAP. It is passed only for the re-add at the end of uev_update_path() after udev reported a changed WWID. The re-add after a udev retrigger, and ordinary adds, are unchanged, so udev data obtained by a retrigger is trusted. Split check_path_wwid() out of check_path_wwid_change() so that a failure to read the device's WWID can be told apart from a match. check_path_wwid_change() still returns true only on a mismatch. Document the new case under recheck_wwid in multipath.conf(5). Signed-off-by: Brian Bunker --- multipath/multipath.conf.5.in | 8 ++-- multipathd/cli_handlers.c | 2 +- multipathd/main.c | 74 +++++++++++++++++++++++++++-------- multipathd/main.h | 13 +++++- 4 files changed, 75 insertions(+), 22 deletions(-) diff --git a/multipath/multipath.conf.5.in b/multipath/multipath.conf.5.in index a577dfc8..432a9538 100644 --- a/multipath/multipath.conf.5.in +++ b/multipath/multipath.conf.5.in @@ -1382,9 +1382,11 @@ The default is: \fB\(dqNONE\(dq\fR If set to \fIyes\fR, when a failed path is restored, its wwid is rechecked. If the wwid has changed, the path is removed from the current multipath device, and re-added as a new path. Multipathd will also recheck a path's wwid if it is -manually re-added. This option only works for SCSI devices that are configured -to use the default uid_attribute, \fIID_SERIAL\fR, or sysfs for getting their -wwid. +manually re-added, and before re-adding an up path whose wwid udev reported as +changed. If the device doesn't confirm the new wwid, or its wwid can't be read, +the path is left out of the multipath device and udev is asked to report its +wwid again. This option only works for SCSI devices that are configured to use +the default uid_attribute, \fIID_SERIAL\fR, or sysfs for getting their wwid. .RS .TP The default is: \fBno\fR diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index f5a13c46..9b4a04c2 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -673,7 +673,7 @@ cli_add_path (void *v, struct strbuf *reply, void *data) return 1; } } - return ev_add_path(pp, vecs, 1); + return ev_add_path(pp, vecs, PATH_ADD_MAP); blacklisted: append_strbuf_str(reply, "blacklisted\n"); condlog(2, "%s: path blacklisted", param); diff --git a/multipathd/main.c b/multipathd/main.c index 9bce4d6b..e32128a3 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1086,15 +1086,25 @@ handle_path_wwid_change(struct path *pp, struct vectors *vecs) return removed; } -bool -check_path_wwid_change(struct path *pp) +enum wwid_check_result { + WWID_CHECK_MATCH, + WWID_CHECK_MISMATCH, + WWID_CHECK_FAILED, +}; + +/* + * Compare pp->wwid with the WWID that the device reports over SG_IO. + * WWID_CHECK_FAILED means that the device's WWID couldn't be read, so + * nothing is known about whether it matches. + */ +static enum wwid_check_result check_path_wwid(struct path *pp) { char wwid[WWID_SIZE]; int len = 0; size_t i; if (!strlen(pp->wwid)) - return false; + return WWID_CHECK_MATCH; /* Get the real fresh device wwid by sgio. sysfs still has old * data, so only get_vpd_sgio will work to get the new wwid */ @@ -1103,7 +1113,7 @@ check_path_wwid_change(struct path *pp) if (len <= 0) { condlog(2, "%s: failed to check wwid by sgio: len = %d", pp->dev, len); - return false; + return WWID_CHECK_FAILED; } /*Strip any trailing blanks */ @@ -1115,10 +1125,15 @@ check_path_wwid_change(struct path *pp) if (strncmp(wwid, pp->wwid, WWID_SIZE)) { condlog(0, "%s: wwid '%s' doesn't match wwid '%s' from device", pp->dev, pp->wwid, wwid); - return true; + return WWID_CHECK_MISMATCH; } - return false; + return WWID_CHECK_MATCH; +} + +bool check_path_wwid_change(struct path *pp) +{ + return check_path_wwid(pp) == WWID_CHECK_MISMATCH; } /* @@ -1128,7 +1143,7 @@ check_path_wwid_change(struct path *pp) static int uev_update_path (struct uevent *uev, struct vectors * vecs); static int -uev_add_path (struct uevent *uev, struct vectors * vecs, int need_do_map) +uev_add_path(struct uevent *uev, struct vectors *vecs, enum path_add_mode mode) { struct path *pp; int ret = 0, i; @@ -1180,7 +1195,7 @@ uev_add_path (struct uevent *uev, struct vectors * vecs, int need_do_map) DI_ALL | DI_BLACKLIST); pthread_cleanup_pop(1); if (r == PATHINFO_OK && !prev_mpp) - ret = ev_add_path(pp, vecs, need_do_map); + ret = ev_add_path(pp, vecs, mode); else if (r == PATHINFO_OK && !strncmp(pp->wwid, prev_mpp->wwid, WWID_SIZE)) { /* @@ -1255,7 +1270,7 @@ uev_add_path (struct uevent *uev, struct vectors * vecs, int need_do_map) conf = get_multipath_config(); pp->checkint = conf->checkint; put_multipath_config(conf); - ret = ev_add_path(pp, vecs, need_do_map); + ret = ev_add_path(pp, vecs, mode); } else { condlog(0, "%s: failed to store path info, " "dropping event", @@ -1297,8 +1312,7 @@ sysfs_get_ro (struct path *pp) * 0: added * 1: error */ -int -ev_add_path (struct path * pp, struct vectors * vecs, int need_do_map) +int ev_add_path(struct path *pp, struct vectors *vecs, enum path_add_mode mode) { struct multipath * mpp; char *params __attribute__((cleanup(cleanup_charp))) = NULL; @@ -1315,6 +1329,30 @@ ev_add_path (struct path * pp, struct vectors * vecs, int need_do_map) condlog(0, "%s: failed to get path uid", pp->dev); goto fail; /* leave path added to pathvec */ } + /* + * This path is being re-added because udev reported a different WWID + * than it had before. The uevent may have been queued long before we + * got here, and adding a path to the map of a different LUN corrupts + * data. If recheck_wwid is set and the path is up, confirm the WWID + * with the device first. If the device doesn't confirm it, or can't + * be read, leave the path out and let the checker retrigger udev to + * get a fresh WWID. A path that isn't up is checked by recheck_wwid + * when it comes up. + */ + if (mode == PATH_ADD_REINIT && pp->recheck_wwid == RECHECK_WWID_ON && + (pp->state == PATH_UP || pp->state == PATH_GHOST) && + check_path_wwid(pp) != WWID_CHECK_MATCH) { + struct config *conf; + + condlog(2, "%s: not adding path, wwid '%s' not confirmed by device", + pp->dev, pp->wwid); + memset(pp->wwid, 0, WWID_SIZE); + pp->initialized = INIT_MISSING_UDEV; + conf = get_multipath_config(); + pp->tick = conf->retrigger_delay; + put_multipath_config(conf); + goto fail; + } mpp = find_mp_by_wwid(vecs->mpvec, pp->wwid); if (mpp && pp->size && mpp->size != pp->size) { condlog(0, "%s: failed to add new path %s, device size mismatch", mpp->alias, pp->dev); @@ -1375,7 +1413,7 @@ rescan: if (ro == 1) mpp->force_readonly = 1; - if (!need_do_map) + if (mode == PATH_ADD_NO_MAP) return 0; if (!dm_map_present(mpp->alias)) { @@ -1656,6 +1694,7 @@ uev_update_path (struct uevent *uev, struct vectors * vecs) struct path * pp; struct config *conf; int needs_reinit = 0; + enum path_add_mode reinit_mode = PATH_ADD_MAP; switch ((rc = change_foreign(uev->udev))) { case FOREIGN_OK: @@ -1706,6 +1745,7 @@ uev_update_path (struct uevent *uev, struct vectors * vecs) uev->kernel, wwid, pp->wwid); ev_remove_path(pp, vecs, 1); needs_reinit = 1; + reinit_mode = PATH_ADD_REINIT; goto out; } else if (pp->initialized == INIT_PARTIAL) { udev_device_unref(pp->udev); @@ -1789,7 +1829,7 @@ out: } /* pp->initialized must not be INIT_PARTIAL if needs_reinit is set */ if (needs_reinit) - retval = uev_add_path(uev, vecs, 1); + retval = uev_add_path(uev, vecs, reinit_mode); return retval; } @@ -1905,13 +1945,13 @@ uev_trigger (struct uevent * uev, void * trigger_data) */ list_for_each_entry_safe(merge_uev, tmp, &uev->merge_node, node) { if (!strncmp(merge_uev->action, "add", 3)) - r += uev_add_path(merge_uev, vecs, 0); + r += uev_add_path(merge_uev, vecs, PATH_ADD_NO_MAP); if (!strncmp(merge_uev->action, "remove", 6)) r += uev_remove_path(merge_uev, vecs, 0); } if (!strncmp(uev->action, "add", 3)) - r += uev_add_path(uev, vecs, 1); + r += uev_add_path(uev, vecs, PATH_ADD_MAP); if (!strncmp(uev->action, "remove", 6)) r += uev_remove_path(uev, vecs, 1); if (!strncmp(uev->action, "change", 6)) @@ -3015,7 +3055,7 @@ update_uninitialized_path(struct vectors * vecs, struct path * pp) pthread_cleanup_pop(1); /* INIT_OK implies ret == PATHINFO_OK */ if (pp->initialized == INIT_OK) { - ev_add_path(pp, vecs, 1); + ev_add_path(pp, vecs, PATH_ADD_MAP); pp->tick = 1; } else if (ret == PATHINFO_SKIPPED) { int i; @@ -3036,7 +3076,7 @@ update_uninitialized_path(struct vectors * vecs, struct path * pp) CHECK_PATH_REMOVED : CHECK_PATH_SKIPPED; } - ev_add_path(pp, vecs, 1); + ev_add_path(pp, vecs, PATH_ADD_MAP); pp->tick = 1; } return CHECK_PATH_CHECKED; diff --git a/multipathd/main.h b/multipathd/main.h index b66208ec..e3b4268f 100644 --- a/multipathd/main.h +++ b/multipathd/main.h @@ -36,7 +36,18 @@ enum daemon_status wait_for_state_change_if(enum daemon_status oldstate, unsigned long ms); void schedule_reconfigure(enum force_reload_types requested_type); int need_to_delay_reconfig (struct vectors *); -int ev_add_path (struct path *, struct vectors *, int); +/* + * PATH_ADD_REINIT is PATH_ADD_MAP for a path that is being re-added + * because udev reported a different WWID than it had before. If + * recheck_wwid is set and the path is up, its WWID is confirmed with + * the device before the path is put into a map. + */ +enum path_add_mode { + PATH_ADD_NO_MAP, + PATH_ADD_MAP, + PATH_ADD_REINIT, +}; +int ev_add_path(struct path *, struct vectors *, enum path_add_mode); int ev_remove_path (struct path *, struct vectors *, int); int ev_add_map (char *, const char *, struct vectors *); int flush_map(struct multipath *, struct vectors *); -- 2.56.0