From: Benjamin Marzinski <bmarzins@redhat.com>
To: Martin Wilck <martin.wilck@suse.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>,
dm-devel@lists.linux.dev, Martin Wilck <mwilck@suse.com>
Subject: Re: [PATCH v2 18/49] libmultipath: Use symbolic return values for dm_is_mpath()
Date: Mon, 15 Jul 2024 18:14:54 -0400 [thread overview]
Message-ID: <ZpWfXvsVP70TQlf1@redhat.com> (raw)
In-Reply-To: <20240712171458.77611-19-mwilck@suse.com>
On Fri, Jul 12, 2024 at 07:14:26PM +0200, Martin Wilck wrote:
> Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
> ---
> libmpathpersist/mpath_persist_int.c | 2 +-
> libmultipath/devmapper.c | 22 ++++++++--------------
> libmultipath/devmapper.h | 6 ++++++
> multipath/main.c | 4 ++--
> multipathd/dmevents.c | 19 +++++++++++++------
> multipathd/main.c | 2 +-
> 6 files changed, 31 insertions(+), 24 deletions(-)
>
> diff --git a/libmpathpersist/mpath_persist_int.c b/libmpathpersist/mpath_persist_int.c
> index 178c2f5..6da0401 100644
> --- a/libmpathpersist/mpath_persist_int.c
> +++ b/libmpathpersist/mpath_persist_int.c
> @@ -185,7 +185,7 @@ static int mpath_get_map(vector curmp, vector pathvec, int fd, char **palias,
>
> condlog(3, "alias = %s", alias);
>
> - if (dm_map_present(alias) && dm_is_mpath(alias) != 1){
> + if (dm_map_present(alias) && dm_is_mpath(alias) != DM_IS_MPATH_YES) {
> condlog(3, "%s: not a multipath device.", alias);
> goto out;
> }
> diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
> index a63154f..3abdc26 100644
> --- a/libmultipath/devmapper.c
> +++ b/libmultipath/devmapper.c
> @@ -846,15 +846,9 @@ static int dm_type_match(const char *name, char *type)
> return DM_TYPE_NOMATCH;
> }
>
> -/*
> - * returns:
> - * 1 : is multipath device
> - * 0 : is not multipath device
> - * -1 : error
> - */
> int dm_is_mpath(const char *name)
> {
> - int r = -1;
> + int r = DM_IS_MPATH_ERR;
> struct dm_task __attribute__((cleanup(cleanup_dm_task))) *dmt = NULL;
> struct dm_info info;
> uint64_t start, length;
> @@ -876,7 +870,7 @@ int dm_is_mpath(const char *name)
> if (!dm_task_get_info(dmt, &info))
> goto out;
>
> - r = 0;
> + r = DM_IS_MPATH_NO;
>
> if (!info.exists)
> goto out;
> @@ -895,10 +889,10 @@ int dm_is_mpath(const char *name)
> if (!target_type || strcmp(target_type, TGT_MPATH) != 0)
> goto out;
>
> - r = 1;
> + r = DM_IS_MPATH_YES;
> out:
> - if (r < 0)
> - condlog(3, "%s: dm command failed in %s: %s", name, __FUNCTION__, strerror(errno));
> + if (r == DM_IS_MPATH_ERR)
> + condlog(3, "%s: dm command failed in %s: %s", name, __func__, strerror(errno));
> return r;
> }
>
> @@ -1039,7 +1033,7 @@ int _dm_flush_map (const char *mapname, int flags, int retries)
> unsigned long long mapsize;
> char *params = NULL;
>
> - if (dm_is_mpath(mapname) != 1)
> + if (dm_is_mpath(mapname) != DM_IS_MPATH_YES)
> return DM_FLUSH_OK; /* nothing to do */
>
> /* if the device currently has no partitions, do not
> @@ -1086,7 +1080,7 @@ int _dm_flush_map (const char *mapname, int flags, int retries)
> }
> condlog(4, "multipath map %s removed", mapname);
> return DM_FLUSH_OK;
> - } else if (dm_is_mpath(mapname) != 1) {
> + } else if (dm_is_mpath(mapname) != DM_IS_MPATH_YES) {
> condlog(4, "multipath map %s removed externally",
> mapname);
> return DM_FLUSH_OK; /* raced. someone else removed it */
> @@ -1316,7 +1310,7 @@ int dm_get_maps(vector mp)
> }
>
> do {
> - if (dm_is_mpath(names->name) != 1)
> + if (dm_is_mpath(names->name) != DM_IS_MPATH_YES)
> goto next;
>
> mpp = dm_get_multipath(names->name);
> diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h
> index ff28575..9438c2d 100644
> --- a/libmultipath/devmapper.h
> +++ b/libmultipath/devmapper.h
> @@ -46,6 +46,12 @@ int dm_map_present (const char *name);
> int dm_map_present_by_uuid(const char *uuid);
> int dm_get_map(const char *name, unsigned long long *size, char **outparams);
> int dm_get_status(const char *name, char **outstatus);
> +
> +enum {
> + DM_IS_MPATH_NO,
> + DM_IS_MPATH_YES,
> + DM_IS_MPATH_ERR,
> +};
> int dm_is_mpath(const char *name);
>
> enum {
> diff --git a/multipath/main.c b/multipath/main.c
> index ce702e7..c82bc86 100644
> --- a/multipath/main.c
> +++ b/multipath/main.c
> @@ -247,7 +247,7 @@ static int check_usable_paths(struct config *conf,
> goto out;
> }
>
> - if (dm_is_mpath(mapname) != 1) {
> + if (dm_is_mpath(mapname) != DM_IS_MPATH_YES) {
> condlog(1, "%s is not a multipath map", devpath);
> goto free;
> }
> @@ -1080,7 +1080,7 @@ main (int argc, char *argv[])
> goto out;
> }
> if (cmd == CMD_FLUSH_ONE) {
> - if (dm_is_mpath(dev) != 1) {
> + if (dm_is_mpath(dev) != DM_IS_MPATH_YES) {
> condlog(0, "%s is not a multipath device", dev);
> r = RTVL_FAIL;
> goto out;
> diff --git a/multipathd/dmevents.c b/multipathd/dmevents.c
> index 3fbdc55..af1e12e 100644
> --- a/multipathd/dmevents.c
> +++ b/multipathd/dmevents.c
> @@ -168,9 +168,13 @@ static int dm_get_events(void)
> while (names->dev) {
> uint32_t event_nr;
>
> - /* Don't delete device if dm_is_mpath() fails without
> - * checking the device type */
> - if (dm_is_mpath(names->name) == 0)
> + /*
> + * Don't delete device if dm_is_mpath() fails without
> + * checking the device type.
> + * IOW, only delete devices from the event list for which
> + * we positively know that they aren't multipath devices.
> + */
> + if (dm_is_mpath(names->name) == DM_IS_MPATH_NO)
> goto next;
>
> event_nr = dm_event_nr(names);
> @@ -206,9 +210,12 @@ int watch_dmevents(char *name)
> struct dev_event *dev_evt, *old_dev_evt;
> int i;
>
> - /* We know that this is a multipath device, so only fail if
> - * device-mapper tells us that we're wrong */
> - if (dm_is_mpath(name) == 0) {
> + /*
> + * We know that this is a multipath device, so only fail if
> + * device-mapper tells us that we're wrong
> + * IOW, don't fail for DM generic errors.
> + */
> + if (dm_is_mpath(name) == DM_IS_MPATH_NO) {
> condlog(0, "%s: not a multipath device. can't watch events",
> name);
> return -1;
> diff --git a/multipathd/main.c b/multipathd/main.c
> index 58afe14..132bb2e 100644
> --- a/multipathd/main.c
> +++ b/multipathd/main.c
> @@ -865,7 +865,7 @@ ev_add_map (char * dev, const char * alias, struct vectors * vecs)
> int reassign_maps;
> struct config *conf;
>
> - if (dm_is_mpath(alias) != 1) {
> + if (dm_is_mpath(alias) != DM_IS_MPATH_YES) {
> condlog(4, "%s: not a multipath map", alias);
> return 0;
> }
> --
> 2.45.2
next prev parent reply other threads:[~2024-07-15 22:15 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-12 17:14 [PATCH v2 00/49] multipath-tools: devmapper API refactored Martin Wilck
2024-07-12 17:14 ` [PATCH v2 01/49] multipath-tools CI: more fixes for arm/v7 Martin Wilck
2024-07-12 17:14 ` [PATCH v2 02/49] multipath-tools CI: fix dmevents test for Debian Sid, arm/v7 Martin Wilck
2024-07-12 17:14 ` [PATCH v2 03/49] create-config.mk: use printf instead of /bin/echo Martin Wilck
2024-07-12 17:14 ` [PATCH v2 04/49] multipathd.service.in: use @BINDIR@ instead of /sbin Martin Wilck
2024-07-12 17:14 ` [PATCH v2 05/49] Makefile.inc: replace @BINDIR@ with $(TGTDIR)/$(bindir) Martin Wilck
2024-07-12 17:14 ` [PATCH v2 06/49] kpartx.rules: use @BINDIR@ to locate kpartx Martin Wilck
2024-07-15 22:08 ` Benjamin Marzinski
2024-07-12 17:14 ` [PATCH v2 07/49] multipath-tools: Remove hard-coded paths to executables Martin Wilck
2024-07-12 17:14 ` [PATCH v2 08/49] multipath-tools: compile_commands.json fixes Martin Wilck
2024-07-12 17:14 ` [PATCH v2 09/49] multipath-tools: .gitignore: ignore o.wrap files for CI helpers Martin Wilck
2024-07-12 17:14 ` [PATCH v2 10/49] libmultipath: remove unused includes in devmapper.h Martin Wilck
2024-07-12 17:14 ` [PATCH v2 11/49] libmultipath: use DM_DEVICE_INFO in dm_mapname() Martin Wilck
2024-07-12 17:14 ` [PATCH v2 12/49] multipath-tools: don't call dm_task_no_open_count() Martin Wilck
2024-07-12 17:14 ` [PATCH v2 13/49] libmpathutil: export cleanup_udev_device() Martin Wilck
2024-07-12 17:14 ` [PATCH v2 14/49] libmpathutil: add cleanup_vector() Martin Wilck
2024-07-12 17:14 ` [PATCH v2 15/49] libmultipath: add cleanup helpers for struct multipath Martin Wilck
2024-07-12 17:14 ` [PATCH v2 16/49] libmultipath: add cleanup_dm_task(), and use it in devmapper.c Martin Wilck
2024-07-15 22:13 ` Benjamin Marzinski
2024-07-12 17:14 ` [PATCH v2 17/49] libmultipath: rename dm_type()->dm_type_match() and use symbolic values Martin Wilck
2024-07-15 22:14 ` Benjamin Marzinski
2024-07-12 17:14 ` [PATCH v2 18/49] libmultipath: Use symbolic return values for dm_is_mpath() Martin Wilck
2024-07-15 22:14 ` Benjamin Marzinski [this message]
2024-07-12 17:14 ` [PATCH v2 19/49] libmultipath: add libmp_mapinfo() Martin Wilck
2024-07-15 22:41 ` Benjamin Marzinski
2024-07-16 15:51 ` Martin Wilck
2024-07-16 20:19 ` Benjamin Marzinski
2024-07-12 17:14 ` [PATCH v2 20/49] libmultipath tests: add tests for libmp_mapinfo() Martin Wilck
2024-07-12 17:14 ` [PATCH v2 21/49] libmultipath: implement dm_get_info() and dm_map_present() with new API Martin Wilck
2024-07-12 17:14 ` [PATCH v2 22/49] libmultipath: remove dm_get_prefixed_uuid() Martin Wilck
2024-07-12 17:14 ` [PATCH v2 23/49] libmultipath: is_mpath_part(): improve parsing Martin Wilck
2024-07-12 17:14 ` [PATCH v2 24/49] libmultipath: rename dm_get_uuid() -> dm_get_wwid() Martin Wilck
2024-07-12 17:14 ` [PATCH v2 25/49] libmultipath: improve dm_get_wwid() return value logic Martin Wilck
2024-07-15 22:42 ` Benjamin Marzinski
2024-07-12 17:14 ` [PATCH v2 26/49] libmultipath: reimplement dm_map_name() with new API Martin Wilck
2024-07-15 22:42 ` Benjamin Marzinski
2024-07-12 17:14 ` [PATCH v2 27/49] libmultipath: reimplement dm_map_present_by_uuid() Martin Wilck
2024-07-12 17:14 ` [PATCH v2 28/49] libmultipath: reimplement dm_get_opencount() with new API Martin Wilck
2024-07-12 17:14 ` [PATCH v2 29/49] libmpathpersist: skip redundant dm_map_present() call Martin Wilck
2024-07-12 17:14 ` [PATCH v2 30/49] libmultipath: implement dm_is_mpath() with new API Martin Wilck
2024-07-15 22:43 ` Benjamin Marzinski
2024-07-12 17:14 ` [PATCH v2 31/49] libmultipath: implement dm_get_multipath() " Martin Wilck
2024-07-12 17:14 ` [PATCH v2 32/49] libmultipath: use libmp_mapinfo() in _dm_flush_map() Martin Wilck
2024-07-12 17:14 ` [PATCH v2 33/49] libmultipath: add is_mpath_uuid() helper Martin Wilck
2024-07-15 22:43 ` Benjamin Marzinski
2024-07-12 17:14 ` [PATCH v2 34/49] libmultipath: add is_mpath_part_uuid() helper Martin Wilck
2024-07-12 17:14 ` [PATCH v2 35/49] libmultipath: add dmp_errstr() helper Martin Wilck
2024-07-12 17:14 ` [PATCH v2 36/49] libmultipath: use libmp_mapinfo() in do_foreach_partmaps() Martin Wilck
2024-07-12 17:14 ` [PATCH v2 37/49] libmultipath: use libmp_pathinfo() in update_multipath_table() Martin Wilck
2024-07-15 22:44 ` Benjamin Marzinski
2024-07-12 17:14 ` [PATCH v2 38/49] libmultipath: update mpp->dmi " Martin Wilck
2024-07-12 17:14 ` [PATCH v2 39/49] libmultipath: drop extra call to dm_map_present() in domap() Martin Wilck
2024-07-12 17:14 ` [PATCH v2 40/49] libmultipath: split off update_multipath_table__() Martin Wilck
2024-07-12 17:14 ` [PATCH v2 41/49] multipath: implement check_usable_paths() with libmp_pathinfo() Martin Wilck
2024-07-15 22:45 ` Benjamin Marzinski
2024-07-12 17:14 ` [PATCH v2 42/49] multipathd: implement add_map_without_path() with libmp_mapinfo() Martin Wilck
2024-07-15 22:47 ` Benjamin Marzinski
2024-07-12 17:14 ` [PATCH v2 43/49] libmultipath: simplify dm_get_maps() Martin Wilck
2024-07-12 17:14 ` [PATCH v2 44/49] libmpathpersist: use libmp_mapinfo() in mpath_get_map() Martin Wilck
2024-07-15 22:48 ` Benjamin Marzinski
2024-07-12 17:14 ` [PATCH v2 45/49] libmpathpersist: use mpp->alias in do_mpath_persistent_reserve_out() Martin Wilck
2024-07-12 17:14 ` [PATCH v2 46/49] libmultipath: fix deferred_remove logic in remove_partmap() Martin Wilck
2024-07-15 22:49 ` Benjamin Marzinski
2024-07-12 17:14 ` [PATCH v2 47/49] libmultipath: don't call do_foreach_partmaps() recursively Martin Wilck
2024-07-15 22:51 ` Benjamin Marzinski
2024-07-12 17:14 ` [PATCH v2 48/49] libmultipath: Move UUID check into libmp_pathinfo__() Martin Wilck
2024-07-15 23:24 ` Benjamin Marzinski
2024-07-12 17:14 ` [PATCH v2 49/49] multipath-tools tests: fix directio test with real device Martin Wilck
2024-07-15 23:25 ` 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=ZpWfXvsVP70TQlf1@redhat.com \
--to=bmarzins@redhat.com \
--cc=christophe.varoqui@opensvc.com \
--cc=dm-devel@lists.linux.dev \
--cc=martin.wilck@suse.com \
--cc=mwilck@suse.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.