All of lore.kernel.org
 help / color / mirror / Atom feed
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
Subject: Re: [PATCH 35/44] libmultipath: use libmp_pathinfo() in update_multipath_table()
Date: Thu, 11 Jul 2024 01:16:21 -0400	[thread overview]
Message-ID: <Zo9qpc0sry9Td0Jm@redhat.com> (raw)
In-Reply-To: <20240709213935.177028-36-mwilck@suse.com>

On Tue, Jul 09, 2024 at 11:39:26PM +0200, Martin Wilck wrote:
> This allows us to remove dm_get_status(), and dm_get_map(), of which
> update_multipath_table() was the last caller.
> 
> Signed-off-by: Martin Wilck <mwilck@suse.com>
> ---
>  libmultipath/devmapper.c   | 89 --------------------------------------
>  libmultipath/devmapper.h   |  2 -
>  libmultipath/structs_vec.c | 22 +++++-----
>  3 files changed, 12 insertions(+), 101 deletions(-)
> 
> diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
> index 185c76b..105e838 100644
> --- a/libmultipath/devmapper.c
> +++ b/libmultipath/devmapper.c
> @@ -804,45 +804,6 @@ static int dm_get_dm_uuid(const char *mapname, char uuid[DM_UUID_LEN])
>  			     (mapinfo_t) { .uuid = uuid });
>  }
>  
> -int dm_get_map(const char *name, unsigned long long *size, char **outparams)
> -{
> -	struct dm_task __attribute__((cleanup(cleanup_dm_task))) *dmt = NULL;
> -	uint64_t start, length;
> -	char *target_type = NULL;
> -	char *params = NULL;
> -
> -	if (!(dmt = libmp_dm_task_create(DM_DEVICE_TABLE)))
> -		return DMP_ERR;
> -
> -	if (!dm_task_set_name(dmt, name))
> -		return DMP_ERR;
> -
> -	errno = 0;
> -	if (!libmp_dm_task_run(dmt)) {
> -		dm_log_error(3, DM_DEVICE_TABLE, dmt);
> -		if (dm_task_get_errno(dmt) == ENXIO)
> -			return DMP_NOT_FOUND;
> -		else
> -			return DMP_ERR;
> -	}
> -
> -	/* Fetch 1st target */
> -	if (dm_get_next_target(dmt, NULL, &start, &length,
> -			       &target_type, &params) != NULL || !params)
> -		/* more than one target or not found target */
> -		return DMP_NOT_FOUND;
> -
> -	if (size)
> -		*size = length;
> -
> -	if (!outparams)
> -		return DMP_OK;
> -	else {
> -		*outparams = strdup(params);
> -		return *outparams ? DMP_OK : DMP_ERR;
> -	}
> -}
> -
>  bool is_mpath_uuid(const char uuid[DM_UUID_LEN])
>  {
>  	return !strncmp(uuid, UUID_PREFIX, UUID_PREFIX_LEN);
> @@ -886,56 +847,6 @@ static bool is_mpath_part_uuid(const char part_uuid[DM_UUID_LEN],
>  	return !strcmp(part_uuid + nc, map_uuid);
>  }
>  
> -int dm_get_status(const char *name, char **outstatus)
> -{
> -	int r = DMP_ERR;
> -	struct dm_task __attribute__((cleanup(cleanup_dm_task))) *dmt = NULL;
> -	uint64_t start, length;
> -	char *target_type = NULL;
> -	char *status = NULL;
> -
> -	if (!(dmt = libmp_dm_task_create(DM_DEVICE_STATUS)))
> -		return r;
> -
> -	if (!dm_task_set_name(dmt, name))
> -		goto out;
> -
> -	errno = 0;
> -	if (!libmp_dm_task_run(dmt)) {
> -		dm_log_error(3, DM_DEVICE_STATUS, dmt);
> -		if (dm_task_get_errno(dmt) == ENXIO)
> -			r = DMP_NOT_FOUND;
> -		goto out;
> -	}
> -
> -	r = DMP_NOT_FOUND;
> -	/* Fetch 1st target */
> -	if (dm_get_next_target(dmt, NULL, &start, &length,
> -			       &target_type, &status) != NULL)
> -		goto out;
> -
> -	if (!target_type || strcmp(target_type, TGT_MPATH) != 0)
> -		goto out;
> -
> -	if (!status) {
> -		condlog(2, "got null status.");
> -		goto out;
> -	}
> -
> -	if (!outstatus)
> -		r = DMP_OK;
> -	else {
> -		*outstatus = strdup(status);
> -		r = *outstatus ? DMP_OK : DMP_ERR;
> -	}
> -out:
> -	if (r != DMP_OK)
> -		condlog(0, "%s: %s: error getting map status string: %d",
> -			__func__, name, r);
> -
> -	return r;
> -}
> -
>  int dm_is_mpath(const char *name)
>  {
>  	char uuid[DM_UUID_LEN];
> diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h
> index ed5e866..cb5151e 100644
> --- a/libmultipath/devmapper.h
> +++ b/libmultipath/devmapper.h
> @@ -126,8 +126,6 @@ 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_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,
> diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
> index ccc4efc..770e498 100644
> --- a/libmultipath/structs_vec.c
> +++ b/libmultipath/structs_vec.c
> @@ -484,30 +484,32 @@ int
>  update_multipath_table (struct multipath *mpp, vector pathvec, int flags)
>  {
>  	int r = DMP_ERR;
> -	char *params = NULL;
> +	char __attribute__((cleanup(cleanup_charp))) *params = NULL;
> +	char __attribute__((cleanup(cleanup_charp))) *status = NULL;
>  
>  	if (!mpp)
>  		return r;
>  
> -	r = dm_get_map(mpp->alias, &mpp->size, &params);

Shouldn't we update mpp->size like we were with dm_get_map()?

-Ben

> +	r = libmp_mapinfo(DM_MAP_BY_NAME,
> +			  (mapid_t) { .str = mpp->alias },
> +			  (mapinfo_t) {
> +				  .target = &params,
> +				  .status = &status,
> +				  .tgt_type = TGT_MPATH
> +			  });
> +
>  	if (r != DMP_OK) {
> -		condlog(2, "%s: %s", mpp->alias, (r == DMP_ERR)? "error getting table" : "map not present");
> +		condlog(2, "%s: %s", mpp->alias, dmp_errstr(r));
>  		return r;
>  	}
>  
>  	if (disassemble_map(pathvec, params, mpp)) {
>  		condlog(2, "%s: cannot disassemble map", mpp->alias);
> -		free(params);
>  		return DMP_ERR;
>  	}
>  
> -	free(params);
> -	params = NULL;
> -	if (dm_get_status(mpp->alias, &params) != DMP_OK)
> -		condlog(2, "%s: %s", mpp->alias, (r == DMP_ERR)? "error getting status" : "map not present");
> -	else if (disassemble_status(params, mpp))
> +	if (disassemble_status(status, mpp))
>  		condlog(2, "%s: cannot disassemble status", mpp->alias);
> -	free(params);
>  
>  	/* FIXME: we should deal with the return value here */
>  	update_pathvec_from_dm(pathvec, mpp, flags);
> -- 
> 2.45.2


  reply	other threads:[~2024-07-11  5:16 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-09 21:38 [PATCH 00/44] multipath-tools: devmapper API refactored Martin Wilck
2024-07-09 21:38 ` [PATCH 01/44] multipath-tools CI: more fixes for arm/v7 Martin Wilck
2024-07-10  7:06   ` Martin Wilck
2024-07-09 21:38 ` [PATCH 02/44] multipath-tools CI: fix dmevents test for Debian Sid, arm/v7 Martin Wilck
2024-07-09 21:38 ` [PATCH 03/44] create-config.mk: use printf instead of /bin/echo Martin Wilck
2024-07-09 21:38 ` [PATCH 04/44] multipathd.service.in: use @BINDIR@ instead of /sbin Martin Wilck
2024-07-09 21:38 ` [PATCH 05/44] Makefile.inc: replace @BINDIR@ with $(TGTDIR)/$(bindir) Martin Wilck
2024-07-09 21:38 ` [PATCH 06/44] kpartx.rules: use @BINDIR@ to locate kpartx Martin Wilck
2024-07-10 16:30   ` Benjamin Marzinski
2024-07-10 20:15     ` Martin Wilck
2024-07-09 21:38 ` [PATCH 07/44] multipath-tools: Remove hard-coded paths to executables Martin Wilck
2024-07-09 21:38 ` [PATCH 08/44] multipath-tools: compile_commands.json fixes Martin Wilck
2024-07-09 21:39 ` [PATCH 09/44] multipath-tools: .gitignore: ignore o.wrap files for CI helpers Martin Wilck
2024-07-09 21:39 ` [PATCH 10/44] libmultipath: remove unused includes in devmapper.h Martin Wilck
2024-07-09 21:39 ` [PATCH 11/44] libmultipath: use DM_DEVICE_INFO in dm_mapname() Martin Wilck
2024-07-09 21:39 ` [PATCH 12/44] multipath-tools: don't call dm_task_no_open_count() Martin Wilck
2024-07-09 21:39 ` [PATCH 13/44] libmpathutil: export cleanup_udev_device() Martin Wilck
2024-07-09 21:39 ` [PATCH 14/44] libmpathutil: add cleanup_vector() Martin Wilck
2024-07-09 21:39 ` [PATCH 15/44] libmultipath: add cleanup helpers for struct multipath Martin Wilck
2024-07-09 21:39 ` [PATCH 16/44] libmultipath: add cleanup_dm_task(), and use it in devmapper.c Martin Wilck
2024-07-10 20:12   ` Benjamin Marzinski
2024-07-10 20:18     ` Martin Wilck
2024-07-09 21:39 ` [PATCH 17/44] libmultipath: add libmp_mapinfo() Martin Wilck
2024-07-10 22:53   ` Benjamin Marzinski
2024-07-11 11:00     ` Martin Wilck
2024-07-09 21:39 ` [PATCH 18/44] libmultipath tests: add tests for libmp_mapinfo() Martin Wilck
2024-07-09 21:39 ` [PATCH 19/44] libmultipath: implement dm_get_info() and dm_map_present() with new API Martin Wilck
2024-07-09 21:39 ` [PATCH 20/44] libmultipath: remove dm_get_prefixed_uuid() Martin Wilck
2024-07-09 21:39 ` [PATCH 21/44] libmultipath: is_mpath_part(): improve parsing Martin Wilck
2024-07-10 22:54   ` Benjamin Marzinski
2024-07-11 11:08     ` Martin Wilck
2024-07-11 17:01       ` Benjamin Marzinski
2024-07-11 17:41         ` Martin Wilck
2024-07-09 21:39 ` [PATCH 22/44] libmultipath: rename dm_get_uuid() -> dm_get_wwid() Martin Wilck
2024-07-09 21:39 ` [PATCH 23/44] libmultipath: improve dm_get_wwid() return value logic Martin Wilck
2024-07-10 23:34   ` Benjamin Marzinski
2024-07-11 12:25     ` Martin Wilck
2024-07-11 16:38       ` Benjamin Marzinski
2024-07-11 22:00       ` Martin Wilck
2024-07-09 21:39 ` [PATCH 24/44] libmultipath: reimplement dm_map_name() with new API Martin Wilck
2024-07-10 23:41   ` Benjamin Marzinski
2024-07-09 21:39 ` [PATCH 25/44] libmultipath: reimplement dm_map_present_by_uuid() Martin Wilck
2024-07-09 21:39 ` [PATCH 26/44] libmultipath: reimplement dm_get_opencount() with new API Martin Wilck
2024-07-09 21:39 ` [PATCH 27/44] libmpathpersist: skip redundant dm_map_present() call Martin Wilck
2024-07-09 21:39 ` [PATCH 28/44] libmultipath: implement dm_is_mpath() with new API Martin Wilck
2024-07-11  0:21   ` Benjamin Marzinski
2024-07-11 12:32     ` Martin Wilck
2024-07-09 21:39 ` [PATCH 29/44] libmultipath: implement dm_get_multipath() " Martin Wilck
2024-07-09 21:39 ` [PATCH 30/44] libmultipath: use libmp_mapinfo() in _dm_flush_map() Martin Wilck
2024-07-09 21:39 ` [PATCH 31/44] libmultipath: add is_mpath_uuid() helper Martin Wilck
2024-07-11  3:38   ` Benjamin Marzinski
2024-07-11 12:56     ` Martin Wilck
2024-07-11 18:39       ` Benjamin Marzinski
2024-07-11 18:59         ` Martin Wilck
2024-07-09 21:39 ` [PATCH 32/44] libmultipath: add is_mpath_part_uuid() helper Martin Wilck
2024-07-09 21:39 ` [PATCH 33/44] libmultipath: add dmp_errstr() helper Martin Wilck
2024-07-09 21:39 ` [PATCH 34/44] libmultipath: use libmp_mapinfo() in do_foreach_partmaps() Martin Wilck
2024-07-09 21:39 ` [PATCH 35/44] libmultipath: use libmp_pathinfo() in update_multipath_table() Martin Wilck
2024-07-11  5:16   ` Benjamin Marzinski [this message]
2024-07-11 15:29     ` Martin Wilck
2024-07-09 21:39 ` [PATCH 36/44] libmultipath: update mpp->dmi " Martin Wilck
2024-07-09 21:39 ` [PATCH 37/44] libmultipath: drop extra call to dm_map_present() in domap() Martin Wilck
2024-07-09 21:39 ` [PATCH 38/44] libmultipath: split off update_multipath_table__() Martin Wilck
2024-07-09 21:39 ` [PATCH 39/44] multipath: implement check_usable_paths() with libmp_pathinfo() Martin Wilck
2024-07-11  5:38   ` Benjamin Marzinski
2024-07-09 21:39 ` [PATCH 40/44] multipathd: implement add_map_without_path() with libmp_mapinfo() Martin Wilck
2024-07-11  6:11   ` Benjamin Marzinski
2024-07-09 21:39 ` [PATCH 41/44] libmultipath: simplify dm_get_maps() Martin Wilck
2024-07-09 21:39 ` [PATCH 42/44] llibmultipath: fix return code check for dm_is_suspended() Martin Wilck
2024-07-11  6:27   ` Benjamin Marzinski
2024-07-11 15:35     ` Martin Wilck
2024-07-09 21:39 ` [PATCH 43/44] libmpathpersist: use libmp_mapinfo() in get_mpvec() Martin Wilck
2024-07-11  6:43   ` Benjamin Marzinski
2024-07-09 21:39 ` [PATCH 44/44] libmpathpersist: use mpp->alias in do_mpath_persistent_reserve_out() Martin Wilck
2024-07-11  6:55 ` [PATCH 00/44] multipath-tools: devmapper API refactored 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=Zo9qpc0sry9Td0Jm@redhat.com \
    --to=bmarzins@redhat.com \
    --cc=christophe.varoqui@opensvc.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=martin.wilck@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.