Linux Device Mapper development
 help / color / mirror / Atom feed
From: "Benjamin Marzinski" <bmarzins@redhat.com>
To: Martin Wilck <mwilck@suse.com>
Cc: dm-devel@redhat.com
Subject: Re: [PATCH 16/19] libmultipath: coalesce_paths: fix size mismatch handling
Date: Thu, 29 Nov 2018 14:53:20 -0600	[thread overview]
Message-ID: <20181129205320.GL5077@octiron.msp.redhat.com> (raw)
In-Reply-To: <20181121101839.30784-17-mwilck@suse.com>

On Wed, Nov 21, 2018 at 11:18:36AM +0100, Martin Wilck wrote:
> When there are paths with the same WWID but different sizes, and
> coalesce_paths() walks the pathvec, it checks paths _after_
> the current one for size mismatch and sets ACT_REJECT. However,
> these paths will be reached in the main loop later, and this time
> the already handled paths will not be checked for size mismatch;
> thus a map could be created, possibly even with mismatching
> devices.
> 
> Fix that by tracking which paths were already discarded, and
> skipping them in the main loop later.

Previously, multipath would retry if coalesce_paths returned
DOMAP_RETRY. With this patch, DOMAP_RETRY isn't returned, so that no
longer happens. Is this intentional?

Also, I would prefer if coalesce_paths always used named constants for
the return values, instead of converting them to numbers.

-Ben
 
> Signed-off-by: Martin Wilck <mwilck@suse.com>
> ---
>  libmultipath/configure.c | 33 +++++++++++++++++++++++++--------
>  libmultipath/util.h      | 16 ++++++++++++++++
>  2 files changed, 41 insertions(+), 8 deletions(-)
> 
> diff --git a/libmultipath/configure.c b/libmultipath/configure.c
> index 406cd4c9..4ed3cc23 100644
> --- a/libmultipath/configure.c
> +++ b/libmultipath/configure.c
> @@ -1009,6 +1009,7 @@ int coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid,
>  	vector pathvec = vecs->pathvec;
>  	struct config *conf;
>  	int allow_queueing;
> +	uint64_t *size_mismatch_seen;
>  
>  	/* ignore refwwid if it's empty */
>  	if (refwwid && !strlen(refwwid))
> @@ -1019,6 +1020,14 @@ int coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid,
>  			pp1->mpp = NULL;
>  		}
>  	}
> +
> +	if (VECTOR_SIZE(pathvec) == 0)
> +		return 0;
> +	size_mismatch_seen = calloc((VECTOR_SIZE(pathvec) - 1) / 64 + 1,
> +				    sizeof(uint64_t));
> +	if (size_mismatch_seen == NULL)
> +		return 1;
> +
>  	vector_foreach_slot (pathvec, pp1, k) {
>  		int invalid;
>  		/* skip this path for some reason */
> @@ -1038,8 +1047,8 @@ int coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid,
>  			continue;
>  		}
>  
> -		/* 2. if path already coalesced */
> -		if (pp1->mpp)
> +		/* 2. if path already coalesced, or seen and discarded */
> +		if (pp1->mpp || is_bit_set_in_array(k, size_mismatch_seen))
>  			continue;
>  
>  		/* 3. if path has disappeared */
> @@ -1088,9 +1097,10 @@ int coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid,
>  				 * ouch, avoid feeding that to the DM
>  				 */
>  				condlog(0, "%s: size %llu, expected %llu. "
> -					"Discard", pp2->dev_t, pp2->size,
> +					"Discard", pp2->dev, pp2->size,
>  					mpp->size);
>  				mpp->action = ACT_REJECT;
> +				set_bit_in_array(i, size_mismatch_seen);
>  			}
>  		}
>  		verify_paths(mpp, vecs);
> @@ -1119,8 +1129,10 @@ int coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid,
>  					"ignoring" : "removing");
>  				remove_map(mpp, vecs, 0);
>  				continue;
> -			} else /* if (r == DOMAP_RETRY) */
> -				return r;
> +			} else /* if (r == DOMAP_RETRY) */ {
> +				r = 1;
> +				goto out;
> +			}
>  		}
>  		if (r == DOMAP_DRY)
>  			continue;
> @@ -1161,8 +1173,10 @@ int coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid,
>  
>  		if (newmp) {
>  			if (mpp->action != ACT_REJECT) {
> -				if (!vector_alloc_slot(newmp))
> -					return 1;
> +				if (!vector_alloc_slot(newmp)) {
> +					r = 1;
> +					goto out;
> +				}
>  				vector_set_slot(newmp, mpp);
>  			}
>  			else
> @@ -1193,7 +1207,10 @@ int coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid,
>  				condlog(2, "%s: remove (dead)", alias);
>  		}
>  	}
> -	return 0;
> +	r = 0;
> +out:
> +	free(size_mismatch_seen);
> +	return r;
>  }
>  
>  struct udev_device *get_udev_device(const char *dev, enum devtypes dev_type)
> diff --git a/libmultipath/util.h b/libmultipath/util.h
> index a818e29a..1f13c913 100644
> --- a/libmultipath/util.h
> +++ b/libmultipath/util.h
> @@ -3,6 +3,7 @@
>  
>  #include <sys/types.h>
>  #include <inttypes.h>
> +#include <stdbool.h>
>  
>  size_t strchop(char *);
>  int basenamecpy (const char *src, char *dst, size_t size);
> @@ -39,4 +40,19 @@ struct scandir_result {
>  };
>  void free_scandir_result(struct scandir_result *);
>  
> +static inline bool is_bit_set_in_array(unsigned int bit, const uint64_t *arr)
> +{
> +	return arr[bit / 64] & (1ULL << (bit % 64)) ? 1 : 0;
> +}
> +
> +static inline void set_bit_in_array(unsigned int bit, uint64_t *arr)
> +{
> +	arr[bit / 64] |= (1ULL << (bit % 64));
> +}
> +
> +static inline void clear_bit_in_array(unsigned int bit, uint64_t *arr)
> +{
> +	arr[bit / 64] &= ~(1ULL << (bit % 64));
> +}
> +
>  #endif /* _UTIL_H */
> -- 
> 2.19.1

  reply	other threads:[~2018-11-29 20:53 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-21 10:18 [PATCH 00/19] multipath-tools: improve logging at -v3 Martin Wilck
2018-11-21 10:18 ` [PATCH 01/19] tests/hwtable: set multipath_dir in local configuration Martin Wilck
2018-11-21 10:18 ` [PATCH 02/19] tests/hwtable: adjust to new checker API Martin Wilck
2018-11-21 10:18 ` [PATCH 03/19] multipath-tools: decrease verbosity of state messages Martin Wilck
2018-11-21 10:18 ` [PATCH 04/19] libmultipath: decrease verbosity of pathinfo messages Martin Wilck
2018-11-21 10:18 ` [PATCH 05/19] libmultipath: decrease verbosity of TUR checker messages Martin Wilck
2018-11-21 10:18 ` [PATCH 06/19] libmultipath: avoid frequent messages from filter_property() Martin Wilck
2018-11-21 10:18 ` [PATCH 07/19] libmultipath: decrease log level of "disassembled" messages Martin Wilck
2018-11-21 10:18 ` [PATCH 08/19] libmultipath: decrease log level of word splitting Martin Wilck
2018-11-29 20:49   ` Benjamin Marzinski
2018-12-03 23:53   ` Benjamin Marzinski
2018-11-21 10:18 ` [PATCH 09/19] libmultipath: increase log level of map removal Martin Wilck
2018-11-21 10:18 ` [PATCH 10/19] multipathd: decrease log level of checker timing Martin Wilck
2018-11-21 10:18 ` [PATCH 11/19] libmultipath: decrease log level of "prioritizer refcount" message Martin Wilck
2018-11-21 10:18 ` [PATCH 12/19] libmpathpersist/update_map_pr: decrease log level for nop Martin Wilck
2018-11-21 10:18 ` [PATCH 13/19] libmultipath: simplify devt2devname() Martin Wilck
2018-11-21 10:18 ` [PATCH 14/19] libmultipath: decrease log level for failed VPD c9 Martin Wilck
2018-11-21 10:18 ` [PATCH 15/19] libmultipath: adopt_paths: check for size match Martin Wilck
2018-11-21 10:18 ` [PATCH 16/19] libmultipath: coalesce_paths: fix size mismatch handling Martin Wilck
2018-11-29 20:53   ` Benjamin Marzinski [this message]
2018-12-03 10:34     ` Martin Wilck
2018-11-21 10:18 ` [PATCH 17/19] tests: add unit tests for bitmask functions Martin Wilck
2018-11-21 10:18 ` [PATCH 18/19] multipathd: uev_remove_path: remove redundant orphan_paths call Martin Wilck
2018-11-21 10:18 ` [PATCH 19/19] libmultipath: improve logging from orphan_paths Martin Wilck
2018-11-29 20:54 ` [PATCH 00/19] multipath-tools: improve logging at -v3 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=20181129205320.GL5077@octiron.msp.redhat.com \
    --to=bmarzins@redhat.com \
    --cc=dm-devel@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox