All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Wilck <martin.wilck@suse.com>
To: Christophe Varoqui <christophe.varoqui@opensvc.com>,
	Benjamin Marzinski <bmarzins@redhat.com>
Cc: dm-devel@lists.linux.dev, Etienne AUJAMES <eaujames@ddn.com>
Subject: [PATCH 3/8] libmultipath: add mp_find_path_by_devt()
Date: Wed, 17 Apr 2024 20:46:39 +0200	[thread overview]
Message-ID: <20240417184644.6193-4-mwilck@suse.com> (raw)
In-Reply-To: <20240417184644.6193-1-mwilck@suse.com>

A helper function that searches a struct multipath by dev_t, and
works whether or not mpp->paths is currently available.

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 libmultipath/structs.c | 19 +++++++++++++++++++
 libmultipath/structs.h |  3 +++
 2 files changed, 22 insertions(+)

diff --git a/libmultipath/structs.c b/libmultipath/structs.c
index 74e31a1..e248fb5 100644
--- a/libmultipath/structs.c
+++ b/libmultipath/structs.c
@@ -526,6 +526,25 @@ find_path_by_devt (const struct _vector *pathvec, const char * dev_t)
 	return NULL;
 }
 
+struct path *mp_find_path_by_devt(const struct multipath *mpp, const char *devt)
+{
+	struct path *pp;
+	struct pathgroup *pgp;
+	unsigned int i, j;
+
+	pp = find_path_by_devt(mpp->paths, devt);
+	if (pp)
+		return pp;
+
+	vector_foreach_slot (mpp->pg, pgp, i){
+		vector_foreach_slot (pgp->paths, pp, j){
+			if (!strcmp(pp->dev_t, devt))
+				return pp;
+		}
+	}
+	return NULL;
+}
+
 static int do_pathcount(const struct multipath *mpp, const int *states,
 			unsigned int nr_states)
 {
diff --git a/libmultipath/structs.h b/libmultipath/structs.h
index 734905e..a25eb9d 100644
--- a/libmultipath/structs.h
+++ b/libmultipath/structs.h
@@ -568,6 +568,9 @@ struct path * find_path_by_devt (const struct _vector *pathvec, const char *devt
 struct path * find_path_by_dev (const struct _vector *pathvec, const char *dev);
 struct path * first_path (const struct multipath *mpp);
 
+struct path *mp_find_path_by_devt(const struct multipath *mpp, const char *devt);
+
+
 int pathcount (const struct multipath *, int);
 int count_active_paths(const struct multipath *);
 int count_active_pending_paths(const struct multipath *);
-- 
2.44.0


  parent reply	other threads:[~2024-04-17 18:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-17 18:46 [PATCH 0/8] multipath-tools: max_sectors_kb rework Martin Wilck
2024-04-17 18:46 ` [PATCH 1/8] multipath-tools: add TGTDIR option Martin Wilck
2024-04-17 18:46 ` [PATCH 2/8] libmultipath: move get_udev_for_mpp to sysfs.c Martin Wilck
2024-04-17 18:46 ` Martin Wilck [this message]
2024-04-17 18:46 ` [PATCH 4/8] Revert "libmultipath: fix max_sectors_kb on adding path" Martin Wilck
2024-04-17 18:46 ` [PATCH 5/8] libmultipath: Only set max_sectors_kb on map creation Martin Wilck
2024-04-17 18:46 ` [PATCH 6/8] libmultipath: set max_sectors_kb in adopt_paths() Martin Wilck
2024-04-17 18:46 ` [PATCH 7/8] libmultipath: add wildcard %k for printing max_sectors_kb Martin Wilck
2024-04-17 18:46 ` [PATCH 8/8] multipath.conf(5): update documentation for max_sectors_kb Martin Wilck
2024-04-18 18:40 ` [PATCH 0/8] multipath-tools: max_sectors_kb rework Benjamin Marzinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240417184644.6193-4-mwilck@suse.com \
    --to=martin.wilck@suse.com \
    --cc=bmarzins@redhat.com \
    --cc=christophe.varoqui@opensvc.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=eaujames@ddn.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.