From patchwork Wed Aug 28 22:17: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: 13782034 X-Patchwork-Delegate: bmarzins@redhat.com 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 7A6B81AD9D3 for ; Wed, 28 Aug 2024 22:18:06 +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=1724883488; cv=none; b=PG/yKXvr808L2IVqjgXbrGVAPMsVw2H5Xy5OFjHXfldR3wK+KChaFRjD0d3bjU65tOhwdutedipS2zmTWQzoPgmgnBJ644nzgSufZQB0NG9tGpP6R8BTvQ4dwl9Xvt12sZhFhjS54KvVYeLb4i6a0n07D7qK2kbehR3fDftbwls= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724883488; c=relaxed/simple; bh=uW5LtGGGu/5snZvoFpFCNJdN9pHKvhVUvfM7KLExQPw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cBXmzh13tQzFASfMtYTY5TJlfKNhqtjZDoi5ed5ZNJQwHEslo3JRbLefHDV/8sI1LwUT15239STtbddrdLlsfYj5I2vhhJLiZL3JSiVjBv7ZAKu9WTq8mjmour78DW+mg+OyBKNJeGXewcjlSCe7i7vrkpA0twkCY44OxV3Sx6U= 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=TFQ+9MjF; 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="TFQ+9MjF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724883485; 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=ZbDnBVmv4BmV4N/CWWj/sxZiw2kHqULTacfChANmC2Y=; b=TFQ+9MjFo0t4/HrfAhfnW++7YD1ORvVwSg7NJzDBBaJJKmC4tQLhZkADbDNrvIFkfTrfyc gbjCVh+dPcUZ4bIxckee4I675e3hkjE6BIqth9fP7awV5NtD749Goug6MT7dQwsFRTMWyG PvZYcEbJGixHJMDxEmXR02bozgoyEOk= 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-611-a53SGdDTNd2qLaDwI4kLwg-1; Wed, 28 Aug 2024 18:18:01 -0400 X-MC-Unique: a53SGdDTNd2qLaDwI4kLwg-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 7E53A1955F4A; Wed, 28 Aug 2024 22:18:00 +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 2081E1956052; Wed, 28 Aug 2024 22:17:59 +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 47SMHwsS4060600 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 28 Aug 2024 18:17:58 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 47SMHwCS4060599; Wed, 28 Aug 2024 18:17:58 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 07/15] libmultipath: change path_offline to path_sysfs_state Date: Wed, 28 Aug 2024 18:17:49 -0400 Message-ID: <20240828221757.4060548-8-bmarzins@redhat.com> In-Reply-To: <20240828221757.4060548-1-bmarzins@redhat.com> References: <20240828221757.4060548-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 Instead of pp->offline being a binary value, change it to show the actual result of looking at the sysfs state, and rename it to pp->sysfs_state. Also change the function name from path_offline() to path_sysfs_state(). Adapt the tests for pp->offline. This should not change how multipath currently works. pp->sysfs_state will be used in future patches. Signed-off-by: Benjamin Marzinski --- libmultipath/discovery.c | 65 ++++++++++++++++--------------- libmultipath/discovery.h | 2 +- libmultipath/libmultipath.version | 3 +- libmultipath/print.c | 2 +- libmultipath/structs.h | 2 +- multipathd/main.c | 4 +- 6 files changed, 41 insertions(+), 37 deletions(-) diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index e0f46ff2..6ccdfa0b 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -1076,18 +1076,16 @@ detect_alua(struct path * pp) return; } - if (pp->fd == -1 || pp->offline) + if (pp->fd == -1 || pp->sysfs_state == PATH_DOWN) return; ret = get_target_port_group(pp); if (ret < 0 || get_asymmetric_access_state(pp, ret) < 0) { - int state; - if (ret == -RTPG_INQUIRY_FAILED) return; - state = path_offline(pp); - if (state != PATH_UP) + path_sysfs_state(pp); + if (pp->sysfs_state != PATH_UP) return; pp->tpgs = TPGS_NONE; @@ -1800,7 +1798,7 @@ common_sysfs_pathinfo (struct path * pp) } int -path_offline (struct path * pp) +path_sysfs_state(struct path * pp) { struct udev_device * parent; char buff[SCSI_STATE_SIZE]; @@ -1814,7 +1812,8 @@ path_offline (struct path * pp) subsys_type = "nvme"; } else { - return PATH_UP; + pp->sysfs_state = PATH_UP; + goto out; } parent = pp->udev; @@ -1827,16 +1826,18 @@ path_offline (struct path * pp) if (!parent) { condlog(1, "%s: failed to get sysfs information", pp->dev); - return PATH_REMOVED; + pp->sysfs_state = PATH_REMOVED; + goto out; } memset(buff, 0x0, SCSI_STATE_SIZE); err = sysfs_attr_get_value(parent, "state", buff, sizeof(buff)); if (!sysfs_attr_value_ok(err, sizeof(buff))) { if (err == -ENXIO) - return PATH_REMOVED; + pp->sysfs_state = PATH_REMOVED; else - return PATH_DOWN; + pp->sysfs_state = PATH_DOWN; + goto out; } @@ -1844,31 +1845,34 @@ path_offline (struct path * pp) if (pp->bus == SYSFS_BUS_SCSI) { if (!strncmp(buff, "offline", 7)) { - pp->offline = 1; - return PATH_DOWN; + pp->sysfs_state = PATH_DOWN; + goto out; + } else if (!strncmp(buff, "blocked", 7) || + !strncmp(buff, "quiesce", 7)) { + pp->sysfs_state = PATH_PENDING; + goto out; + } else if (!strncmp(buff, "running", 7)) { + pp->sysfs_state = PATH_UP; + goto out; } - pp->offline = 0; - if (!strncmp(buff, "blocked", 7) || - !strncmp(buff, "quiesce", 7)) - return PATH_PENDING; - else if (!strncmp(buff, "running", 7)) - return PATH_UP; } else if (pp->bus == SYSFS_BUS_NVME) { if (!strncmp(buff, "dead", 4)) { - pp->offline = 1; - return PATH_DOWN; + pp->sysfs_state = PATH_DOWN; + goto out; + } else if (!strncmp(buff, "new", 3) || + !strncmp(buff, "deleting", 8)) { + pp->sysfs_state = PATH_PENDING; + goto out; + } else if (!strncmp(buff, "live", 4)) { + pp->sysfs_state = PATH_UP; + goto out; } - pp->offline = 0; - if (!strncmp(buff, "new", 3) || - !strncmp(buff, "deleting", 8)) - return PATH_PENDING; - else if (!strncmp(buff, "live", 4)) - return PATH_UP; } - - return PATH_DOWN; + pp->sysfs_state = PATH_DOWN; +out: + return pp->sysfs_state; } static int @@ -2052,8 +2056,7 @@ get_prio (struct path * pp) old_prio = pp->priority; pp->priority = prio_getprio(p, pp); if (pp->priority < 0) { - /* this changes pp->offline, but why not */ - int state = path_offline(pp); + int state = path_sysfs_state(pp); if (state == PATH_DOWN || state == PATH_PENDING) { pp->priority = old_prio; @@ -2424,7 +2427,7 @@ int pathinfo(struct path *pp, struct config *conf, int mask) return PATHINFO_SKIPPED; } - path_state = path_offline(pp); + path_state = path_sysfs_state(pp); if (path_state == PATH_REMOVED) goto blank; else if (mask & DI_NOIO) { diff --git a/libmultipath/discovery.h b/libmultipath/discovery.h index f3e0c618..7d42eae5 100644 --- a/libmultipath/discovery.h +++ b/libmultipath/discovery.h @@ -33,7 +33,7 @@ struct config; int path_discovery (vector pathvec, int flag); int path_get_tpgs(struct path *pp); /* This function never returns TPGS_UNDEF */ int do_tur (char *); -int path_offline (struct path *); +int path_sysfs_state(struct path *); int start_checker(struct path * pp, struct config * conf, int daemon, int state); int get_state(struct path * pp); diff --git a/libmultipath/libmultipath.version b/libmultipath/libmultipath.version index 21d48da6..6439d3a7 100644 --- a/libmultipath/libmultipath.version +++ b/libmultipath/libmultipath.version @@ -146,7 +146,7 @@ global: path_discovery; path_get_tpgs; pathinfo; - path_offline; + path_sysfs_state; print_all_paths; print_foreign_topology; print_multipath_topology__; @@ -160,6 +160,7 @@ global: remove_wwid; replace_wwids; reset_checker_classes; + start_checker; select_all_tg_pt; select_action; select_find_multipaths_timeout; diff --git a/libmultipath/print.c b/libmultipath/print.c index e536c5c0..00c03ace 100644 --- a/libmultipath/print.c +++ b/libmultipath/print.c @@ -514,7 +514,7 @@ snprint_offline (struct strbuf *buff, const struct path * pp) { if (!pp || !pp->mpp) return append_strbuf_str(buff, "unknown"); - else if (pp->offline) + else if (pp->sysfs_state == PATH_DOWN) return append_strbuf_str(buff, "offline"); else return append_strbuf_str(buff, "running"); diff --git a/libmultipath/structs.h b/libmultipath/structs.h index 074faca6..d8231e95 100644 --- a/libmultipath/structs.h +++ b/libmultipath/structs.h @@ -362,7 +362,7 @@ struct path { unsigned int tick; unsigned int pending_ticks; int bus; - int offline; + int sysfs_state; int state; int dmstate; int chkrstate; diff --git a/multipathd/main.c b/multipathd/main.c index 4f752adb..33a57041 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -96,7 +96,7 @@ void * mpath_pr_event_handler_fn (void * ); do { \ if (pp->mpp && checker_selected(&pp->checker) && \ lvl <= libmp_verbosity) { \ - if (pp->offline) \ + if (pp->sysfs_state == PATH_DOWN) \ condlog(lvl, "%s: %s - path offline", \ pp->mpp->alias, pp->dev); \ else { \ @@ -2320,7 +2320,7 @@ check_path_state(struct path *pp) int newstate; struct config *conf; - newstate = path_offline(pp); + newstate = path_sysfs_state(pp); if (newstate == PATH_UP) { conf = get_multipath_config(); pthread_cleanup_push(put_multipath_config, conf);