diff --git a/.gitignore b/.gitignore
index 1f38794..345c6b9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-SOURCES/LVM2.2.02.130.tgz
+SOURCES/LVM2.2.02.166.tgz
diff --git a/.lvm2.metadata b/.lvm2.metadata
index 1faaa1c..59744c7 100644
--- a/.lvm2.metadata
+++ b/.lvm2.metadata
@@ -1 +1 @@
-9503a12881cb408aec6b774f0c92384c814d9684 SOURCES/LVM2.2.02.130.tgz
+5e2dd5bcae8a55c1721bf5c24e8c263895818b44 SOURCES/LVM2.2.02.166.tgz
diff --git a/SOURCES/lvm2-2_02_131-disallow-usage-of-stripe-and-stripesize-when-creating-cache-pool.patch b/SOURCES/lvm2-2_02_131-disallow-usage-of-stripe-and-stripesize-when-creating-cache-pool.patch
deleted file mode 100644
index 6dcfefd..0000000
--- a/SOURCES/lvm2-2_02_131-disallow-usage-of-stripe-and-stripesize-when-creating-cache-pool.patch
+++ /dev/null
@@ -1,38 +0,0 @@
- WHATS_NEW        | 1 +
- tools/lvcreate.c | 5 ++++-
- 2 files changed, 5 insertions(+), 1 deletion(-)
-
-diff --git a/WHATS_NEW b/WHATS_NEW
-index 5260321..1147dad 100644
---- a/WHATS_NEW
-+++ b/WHATS_NEW
-@@ -1,5 +1,6 @@
- Version 2.02.131 - 
- =====================================
-+  Disallow usage of --stripe and --stripesize when creating cache pool.
-   Swapping of LV identifiers handles more complex LVs.
-   Fix VG metadata comparison failure while scanning the VG for lvmetad.
-   Ignore persistent cache if configuration changed. (2.02.127)
-diff --git a/tools/lvcreate.c b/tools/lvcreate.c
-index 364a16a..7bba761 100644
---- a/tools/lvcreate.c
-+++ b/tools/lvcreate.c
-@@ -770,7 +770,8 @@ static int _lvcreate_params(struct cmd_context *cmd,
- 					    CACHE_POOL_ARGS,
- 					    LVCREATE_ARGS,
- 					    POOL_ARGS,
--					    SIZE_ARGS,
-+					    extents_ARG,
-+					    size_ARG,
- 					    cache_ARG,
- 					    chunksize_ARG,
- 					    -1))
-@@ -1096,6 +1097,8 @@ static int _determine_cache_argument(struct volume_group *vg,
- 		}
- 		/* FIXME How to handle skip flag? */
- 		if (arg_from_list_is_set(cmd, "is unsupported with cache conversion",
-+					 stripes_ARG,
-+					 stripesize_ARG,
- 					 setactivationskip_ARG,
- 					 ignoreactivationskip_ARG,
- 					 -1))
diff --git a/SOURCES/lvm2-2_02_131-dmstats-fixups.patch b/SOURCES/lvm2-2_02_131-dmstats-fixups.patch
deleted file mode 100644
index be12a79..0000000
--- a/SOURCES/lvm2-2_02_131-dmstats-fixups.patch
+++ /dev/null
@@ -1,521 +0,0 @@
- libdm/libdm-stats.c | 223 ++++++++++++++++++++++++++++++----------------------
- tools/dmsetup.c     |   1 +
- 2 files changed, 131 insertions(+), 93 deletions(-)
-
-diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
-index 93c7760..ee62fe6 100644
---- a/libdm/libdm-stats.c
-+++ b/libdm/libdm-stats.c
-@@ -144,17 +144,24 @@ struct dm_stats *dm_stats_create(const char *program_id)
- 		return_NULL;
- 
- 	/* FIXME: better hint. */
--	if (!(dms->mem = dm_pool_create("stats_pool", 4096)))
--		goto_bad;
-+	if (!(dms->mem = dm_pool_create("stats_pool", 4096))) {
-+		dm_free(dms);
-+		return_NULL;
-+	}
- 
- 	if (!(dms->hist_mem = dm_pool_create("histogram_pool", hist_hint)))
--		return_0;
-+		goto_bad;
- 
- 	if (!program_id || !strlen(program_id))
- 		dms->program_id = _program_id_from_proc();
- 	else
- 		dms->program_id = dm_strdup(program_id);
- 
-+	if (!dms->program_id) {
-+		dm_pool_destroy(dms->hist_mem);
-+		goto_bad;
-+	}
-+
- 	dms->major = -1;
- 	dms->minor = -1;
- 	dms->name = NULL;
-@@ -171,6 +178,7 @@ struct dm_stats *dm_stats_create(const char *program_id)
- 	return dms;
- 
- bad:
-+	dm_pool_destroy(dms->mem);
- 	dm_free(dms);
- 	return NULL;
- }
-@@ -186,15 +194,15 @@ static int _stats_region_present(const struct dm_stats_region *region)
- static void _stats_histograms_destroy(struct dm_pool *mem,
- 				      struct dm_stats_region *region)
- {
--	uint64_t n;
--
- 	/* Unpopulated handle. */
- 	if (!region->counters)
- 		return;
- 
--	for (n = _nr_areas_region(region) - 1; n; n--)
--		if (region->counters[n].histogram)
--			dm_pool_free(mem, region->counters[n].histogram);
-+	/*
-+	 * Only the first histogram needs to be freed explicitly.
-+	 */
-+	if (region->counters[0].histogram)
-+		dm_pool_free(mem, region->counters[0].histogram);
- }
- 
- static void _stats_region_destroy(struct dm_stats_region *region)
-@@ -316,11 +324,54 @@ int dm_stats_driver_supports_histogram(void)
- 	return _stats_check_precise_timestamps(NULL);
- }
- 
-+static int _fill_hist_arg(char *hist_arg, size_t hist_len, uint64_t scale,
-+			  struct dm_histogram *bounds)
-+{
-+	int i, l, len = 0, nr_bins;
-+	char *arg = hist_arg;
-+	uint64_t value;
-+
-+	nr_bins = bounds->nr_bins;
-+
-+	for (i = 0; i < nr_bins; i++) {
-+		value = bounds->bins[i].upper / scale;
-+		if ((l = dm_snprintf(arg, hist_len - len, FMTu64"%s", value,
-+				     (i == (nr_bins - 1)) ? "" : ",")) < 0)
-+			return_0;
-+		len += l;
-+		arg += l;
-+	}
-+	return 1;
-+}
-+
-+static void *_get_hist_arg(struct dm_histogram *bounds, uint64_t scale,
-+			   size_t *len)
-+{
-+	struct dm_histogram_bin *entry, *bins;
-+	size_t hist_len = 1; /* terminating '\0' */
-+	double value;
-+
-+	entry = bins = bounds->bins;
-+
-+	entry += bounds->nr_bins - 1;
-+	while(entry >= bins) {
-+		value = (double) (entry--)->upper;
-+		/* Use lround to avoid size_t -> double cast warning. */
-+		hist_len += 1 + (size_t) lround(log10(value / scale));
-+		if (entry != bins)
-+			hist_len++; /* ',' */
-+	}
-+
-+	*len = hist_len;
-+
-+	return dm_zalloc(hist_len);
-+}
-+
- static char *_build_histogram_arg(struct dm_histogram *bounds, int *precise)
- {
- 	struct dm_histogram_bin *entry, *bins;
--	size_t hist_len = 1, len = 0;
--	char *hist_arg, *arg = NULL;
-+	size_t hist_len;
-+	char *hist_arg;
- 	uint64_t scale;
- 
- 	entry = bins = bounds->bins;
-@@ -331,53 +382,37 @@ static char *_build_histogram_arg(struct dm_histogram *bounds, int *precise)
- 		return NULL;
- 	}
- 
-+	/* Validate entries and set *precise if precision < 1ms. */
- 	entry += bounds->nr_bins - 1;
--	while(entry >= bins) {
--		double value;
-+	while (entry >= bins) {
- 		if (entry != bins) {
- 			if (entry->upper < (entry - 1)->upper) {
- 				log_error("Histogram boundaries must be in "
- 					  "order of increasing magnitude.");
- 				return 0;
- 			}
--			hist_len++; /* ',' */
- 		}
- 
- 		/*
- 		 * Only enable precise_timestamps automatically if any
- 		 * value in the histogram bounds uses precision < 1ms.
- 		 */
--		if (!*precise && (entry->upper % NSEC_PER_MSEC))
-+		if (((entry--)->upper % NSEC_PER_MSEC) && !*precise)
- 			*precise = 1;
--
--		value = (double) (entry--)->upper;
--		/* Use lround to avoid size_t -> double cast warning. */
--		hist_len += 1 + (size_t) lround(log10(value));
- 	}
- 
--	if (!(hist_arg = dm_zalloc(hist_len))) {
-+	scale = (*precise) ? 1 : NSEC_PER_MSEC;
-+
-+	/* Calculate hist_len and allocate a character buffer. */
-+	if (!(hist_arg = _get_hist_arg(bounds, scale, &hist_len))) {
- 		log_error("Could not allocate memory for histogram argument.");
- 		return 0;
- 	}
- 
--	arg = hist_arg;
--
--	if (*precise)
--		scale = 1;
--	else
--		scale = (*precise) ? 1 : NSEC_PER_MSEC;
-+	/* Fill hist_arg with boundary strings. */
-+	if (!_fill_hist_arg(hist_arg, hist_len, scale, bounds))
-+		goto_bad;
- 
--	for (entry = bins; entry < (bins + bounds->nr_bins); entry++) {
--		uint64_t value;
--		ssize_t l = 0;
--		int last = !(entry < (bins + bounds->nr_bins - 1));
--		value = entry->upper / scale;
--		if ((l = dm_snprintf(arg, hist_len - len, FMTu64"%s", value,
--				     (last) ? "" : ",")) < 0)
--			goto_bad;
--		len += (size_t) l;
--		arg += (size_t) l;
--	}
- 	return hist_arg;
- 
- bad:
-@@ -419,13 +454,13 @@ static int _stats_parse_histogram_spec(struct dm_stats *dms,
- 				       const char *histogram)
- {
- 	static const char *_valid_chars = "0123456789,";
--	uint64_t scale = region->timescale;
-+	uint64_t scale = region->timescale, this_val = 0;
- 	struct dm_pool *mem = dms->hist_mem;
- 	struct dm_histogram_bin cur;
- 	struct dm_histogram hist;
- 	int nr_bins = 1;
--	const char *c, *v;
--	char *p;
-+	const char *c, *v, *val_start;
-+	char *p, *endptr = NULL;
- 
- 	/* Advance past "histogram:". */
- 	histogram = strchr(histogram, ':');
-@@ -466,9 +501,8 @@ static int _stats_parse_histogram_spec(struct dm_stats *dms,
- 				  histogram);
- 			goto bad;
- 		} else {
--			const char *val_start = c;
--			char *endptr = NULL;
--			uint64_t this_val = 0;
-+			val_start = c;
-+			endptr = NULL;
- 
- 			this_val = strtoull(val_start, &endptr, 10);
- 			if (!endptr) {
-@@ -592,11 +626,11 @@ static int _stats_parse_list_region(struct dm_stats *dms,
- 
- static int _stats_parse_list(struct dm_stats *dms, const char *resp)
- {
--	struct dm_pool *mem = dms->mem;
--	struct dm_stats_region cur;
- 	uint64_t max_region = 0, nr_regions = 0;
-+	struct dm_stats_region cur, fill;
-+	struct dm_pool *mem = dms->mem;
- 	FILE *list_rows;
--	/* FIXME: determine correct maximum line length based on kernel format */
-+	/* FIXME: use correct maximum line length for kernel format */
- 	char line[256];
- 
- 	if (!resp) {
-@@ -631,7 +665,6 @@ static int _stats_parse_list(struct dm_stats *dms, const char *resp)
- 
- 		/* handle holes in the list of region_ids */
- 		if (cur.region_id > max_region) {
--			struct dm_stats_region fill;
- 			memset(&fill, 0, sizeof(fill));
- 			fill.region_id = DM_STATS_REGION_NOT_PRESENT;
- 			do {
-@@ -707,54 +740,51 @@ static int _stats_parse_histogram(struct dm_pool *mem, char *hist_str,
- 				  struct dm_histogram **histogram,
- 				  struct dm_stats_region *region)
- {
-+	struct dm_histogram hist, *bounds = region->bounds;
- 	static const char *_valid_chars = "0123456789:";
- 	int nr_bins = region->bounds->nr_bins;
--	struct dm_histogram hist, *bounds = region->bounds;
-+	const char *c, *v, *val_start;
- 	struct dm_histogram_bin cur;
--	uint64_t sum = 0;
--	const char *c, *v;
-+	uint64_t sum = 0, this_val;
-+	char *endptr = NULL;
- 	int bin = 0;
- 
- 	c = hist_str;
- 
--	dm_pool_begin_object(mem, sizeof(cur));
-+	if (!dm_pool_begin_object(mem, sizeof(cur)))
-+		return_0;
- 
- 	hist.nr_bins = nr_bins;
- 
--	dm_pool_grow_object(mem, &hist, sizeof(hist));
-+	if (!dm_pool_grow_object(mem, &hist, sizeof(hist)))
-+		goto_bad;
- 
- 	do {
- 		memset(&cur, 0, sizeof(cur));
- 		for (v = _valid_chars; *v; v++)
- 			if (*c == *v)
- 				break;
--		if (!*v) {
--			stack;
-+		if (!*v)
- 			goto badchar;
--		}
- 
--		if (*c == ',') {
--			log_error("Invalid histogram: %s", hist_str);
--			return 0;
--		} else {
--			const char *val_start = c;
--			char *endptr = NULL;
--			uint64_t this_val = 0;
-+		if (*c == ',')
-+			goto badchar;
-+		else {
-+			val_start = c;
-+			endptr = NULL;
- 
- 			this_val = strtoull(val_start, &endptr, 10);
- 			if (!endptr) {
- 				log_error("Could not parse histogram value.");
--				return 0;
-+				goto bad;
- 			}
- 			c = endptr; /* Advance to colon, or end. */
- 
- 			if (*c == ':')
- 				c++;
--			else if (*c & (*c != '\n')) {
-+			else if (*c & (*c != '\n'))
- 				/* Expected ':', '\n', or NULL. */
--				stack;
- 				goto badchar;
--			}
- 
- 			if (*c == ':')
- 				c++;
-@@ -763,7 +793,8 @@ static int _stats_parse_histogram(struct dm_pool *mem, char *hist_str,
- 			cur.count = this_val;
- 			sum += this_val;
- 
--			dm_pool_grow_object(mem, &cur, sizeof(cur));
-+			if (!dm_pool_grow_object(mem, &cur, sizeof(cur)))
-+				goto_bad;
- 
- 			bin++;
- 		}
-@@ -778,6 +809,8 @@ static int _stats_parse_histogram(struct dm_pool *mem, char *hist_str,
- 
- badchar:
- 	log_error("Invalid character in histogram data: '%c' (0x%x)", *c, *c);
-+bad:
-+	dm_pool_abandon_object(mem);
- 	return 0;
- }
- 
-@@ -786,8 +819,8 @@ static int _stats_parse_region(struct dm_stats *dms, const char *resp,
- 			       uint64_t timescale)
- {
- 	struct dm_histogram *hist = NULL;
--	struct dm_stats_counters cur;
- 	struct dm_pool *mem = dms->mem;
-+	struct dm_stats_counters cur;
- 	FILE *stats_rows = NULL;
- 	uint64_t start, len;
- 	char row[256];
-@@ -1040,12 +1073,12 @@ static int _stats_create_region(struct dm_stats *dms, uint64_t *region_id,
- 				int precise, const char *hist_arg,
- 				const char *program_id,	const char *aux_data)
- {
--	struct dm_task *dmt = NULL;
--	char msg[1024], range[64];
- 	const char *err_fmt = "Could not prepare @stats_create %s.";
- 	const char *precise_str = PRECISE_ARG;
- 	const char *resp, *opt_args = NULL;
--	int r = 0, nr_opt = 0; /* number of optional args. */
-+	char msg[1024], range[64], *endptr = NULL;
-+	struct dm_task *dmt = NULL;
-+	int r = 0, nr_opt = 0;
- 
- 	if (!_stats_bound(dms))
- 		return_0;
-@@ -1105,7 +1138,6 @@ static int _stats_create_region(struct dm_stats *dms, uint64_t *region_id,
- 	}
- 
- 	if (region_id) {
--		char *endptr = NULL;
- 		*region_id = strtoull(resp, &endptr, 10);
- 		if (resp == endptr)
- 			goto_out;
-@@ -1195,11 +1227,11 @@ static struct dm_task *_stats_print_region(struct dm_stats *dms,
- 				    uint64_t region_id, unsigned start_line,
- 				    unsigned num_lines, unsigned clear)
- {
--	struct dm_task *dmt = NULL;
- 	/* @stats_print[_clear] <region_id> [<start_line> <num_lines>] */
- 	const char *clear_str = "_clear", *lines_fmt = "%u %u";
- 	const char *msg_fmt = "@stats_print%s " FMTu64 " %s";
- 	const char *err_fmt = "Could not prepare @stats_print %s.";
-+	struct dm_task *dmt = NULL;
- 	char msg[1024], lines[64];
- 
- 	if (start_line || num_lines)
-@@ -1292,6 +1324,8 @@ int dm_stats_populate(struct dm_stats *dms, const char *program_id,
- 		      uint64_t region_id)
- {
- 	int all_regions = (region_id == DM_STATS_REGIONS_ALL);
-+	struct dm_task *dmt = NULL; /* @stats_print task */
-+	const char *resp;
- 
- 	if (!_stats_bound(dms))
- 		return_0;
-@@ -1311,9 +1345,6 @@ int dm_stats_populate(struct dm_stats *dms, const char *program_id,
- 
- 	dm_stats_walk_start(dms);
- 	do {
--		struct dm_task *dmt = NULL; /* @stats_print task */
--		const char *resp;
--
- 		region_id = (all_regions)
- 			     ? dm_stats_get_current_region(dms) : region_id;
- 
-@@ -1967,10 +1998,12 @@ static struct dm_histogram *_alloc_dm_histogram(int nr_bins)
- struct dm_histogram *dm_histogram_bounds_from_string(const char *bounds_str)
- {
- 	static const char *_valid_chars = "0123456789,muns";
--	struct dm_histogram *dmh;
-+	uint64_t this_val = 0, mult = 1;
-+	const char *c, *v, *val_start;
- 	struct dm_histogram_bin *cur;
--	const char *c, *v;
-+	struct dm_histogram *dmh;
- 	int nr_entries = 1;
-+	char *endptr;
- 
- 	c = bounds_str;
- 
-@@ -2003,9 +2036,8 @@ struct dm_histogram *dm_histogram_bounds_from_string(const char *bounds_str)
- 				  bounds_str);
- 			goto bad;
- 		} else {
--			const char *val_start = c;
--			char *endptr = NULL;
--			uint64_t this_val = 0, mult = 1;
-+			val_start = c;
-+			endptr = NULL;
- 
- 			this_val = strtoull(val_start, &endptr, 10);
- 			if (!endptr) {
-@@ -2058,10 +2090,10 @@ bad:
- 
- struct dm_histogram *dm_histogram_bounds_from_uint64(const uint64_t *bounds)
- {
--	struct dm_histogram *dmh;
-+	const uint64_t *entry = bounds;
- 	struct dm_histogram_bin *cur;
-+	struct dm_histogram *dmh;
- 	int nr_entries = 1;
--	const uint64_t *entry = bounds;
- 
- 	if (!bounds || !bounds[0]) {
- 		log_error("Could not parse empty histogram bounds array");
-@@ -2113,6 +2145,7 @@ void dm_histogram_bounds_destroy(struct dm_histogram *bounds)
-  */
- static void _scale_bound_value_to_suffix(uint64_t *bound, const char **suffix)
- {
-+	*suffix = "ns";
- 	if (!(*bound % NSEC_PER_SEC)) {
- 		*bound /= NSEC_PER_SEC;
- 		*suffix = "s";
-@@ -2191,12 +2224,14 @@ const char *dm_histogram_to_string(const struct dm_histogram *dmh, int bin,
- 				   int width, int flags)
- {
- 	int minwidth, bounds, values, start, last;
--	uint64_t lower, upper; /* bounds of the current bin. */
-+	uint64_t lower, upper, val_u64; /* bounds of the current bin. */
- 	/* Use the histogram pool for string building. */
- 	struct dm_pool *mem = dmh->dms->hist_mem;
- 	char buf[64], bounds_buf[64];
- 	const char *sep = "";
-+	int bounds_width;
- 	ssize_t len = 0;
-+	float val_flt;
- 
- 	bounds = flags & DM_HISTOGRAM_BOUNDS_MASK;
- 	values = flags & DM_HISTOGRAM_VALUES;
-@@ -2222,12 +2257,11 @@ const char *dm_histogram_to_string(const struct dm_histogram *dmh, int bin,
- 	/* Set bounds string to the empty string. */
- 	bounds_buf[0] = '\0';
- 
--	dm_pool_begin_object(mem, 64);
-+	if (!dm_pool_begin_object(mem, 64))
-+		return_0;
- 
- 	for (bin = start; bin <= last; bin++) {
- 		if (bounds) {
--			int bounds_width;
--
- 			/* Default bounds width depends on time suffixes. */
- 			bounds_width = (!(flags & DM_HISTOGRAM_SUFFIX))
- 					? BOUND_WIDTH_NOSUFFIX
-@@ -2260,15 +2294,14 @@ const char *dm_histogram_to_string(const struct dm_histogram *dmh, int bin,
- 
- 		if (flags & DM_HISTOGRAM_PERCENT) {
- 			dm_percent_t pr;
--			float value;
- 			pr = dm_histogram_get_bin_percent(dmh, bin);
--			value = dm_percent_to_float(pr);
-+			val_flt = dm_percent_to_float(pr);
- 			len = dm_snprintf(buf, sizeof(buf), "%s%*.2f%%%s",
--					  bounds_buf, width, value, sep);
-+					  bounds_buf, width, val_flt, sep);
- 		} else if (values) {
--			uint64_t value = dmh->bins[bin].count;
-+			val_u64 = dmh->bins[bin].count;
- 			len = dm_snprintf(buf, sizeof(buf), "%s%*"PRIu64"%s",
--					  bounds_buf, width, value, sep);
-+					  bounds_buf, width, val_u64, sep);
- 		} else if (bounds)
- 			len = dm_snprintf(buf, sizeof(buf), "%s%s", bounds_buf,
- 					  sep);
-@@ -2277,9 +2310,13 @@ const char *dm_histogram_to_string(const struct dm_histogram *dmh, int bin,
- 			goto_bad;
- 
- 		width = minwidth; /* re-set histogram column width. */
--		dm_pool_grow_object(mem, buf, (size_t) len);
-+		if (!dm_pool_grow_object(mem, buf, (size_t) len))
-+			goto_bad;
- 	}
--	dm_pool_grow_object(mem, "\0", 1);
-+
-+	if (!dm_pool_grow_object(mem, "\0", 1))
-+		goto_bad;
-+
- 	return (const char *) dm_pool_end_object(mem);
- 
- bad:
-diff --git a/tools/dmsetup.c b/tools/dmsetup.c
-index 61ad5a9..8b7ad74 100644
---- a/tools/dmsetup.c
-+++ b/tools/dmsetup.c
-@@ -4674,6 +4674,7 @@ static int _do_stats_create_regions(struct dm_stats *dms,
- 		return_0;
- 
- 	if (!(dmt = dm_task_create(DM_DEVICE_TABLE))) {
-+		dm_histogram_bounds_destroy(bounds);
- 		dm_stats_destroy(dms);
- 		return_0;
- 	}
diff --git a/SOURCES/lvm2-2_02_131-do-not-check-for-full-thin-pool-when-activating-without-messages.patch b/SOURCES/lvm2-2_02_131-do-not-check-for-full-thin-pool-when-activating-without-messages.patch
deleted file mode 100644
index 42cd4ec..0000000
--- a/SOURCES/lvm2-2_02_131-do-not-check-for-full-thin-pool-when-activating-without-messages.patch
+++ /dev/null
@@ -1,29 +0,0 @@
- WHATS_NEW_DM          | 4 ++++
- libdm/libdm-deptree.c | 2 +-
- 2 files changed, 5 insertions(+), 1 deletion(-)
-
-diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
-index b509d68..9e30786 100644
---- a/WHATS_NEW_DM
-+++ b/WHATS_NEW_DM
-@@ -1,3 +1,7 @@
-+Version 1.02.108 - 
-+=====================================
-+  Do not check for full thin pool when activating without messages (1.02.107).
-+
- Version 1.02.107 - 5th September 2015
- =====================================
-   Parse thin-pool status with one single routine internally.
-diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
-index d40362d..7b7ca5b 100644
---- a/libdm/libdm-deptree.c
-+++ b/libdm/libdm-deptree.c
-@@ -1633,7 +1633,7 @@ static int _node_send_messages(struct dm_tree_node *dnode,
- 		return 0;
- 	}
- 
--	if (!send)
-+	if (!have_messages || !send)
- 		return 1; /* transaction_id is matching */
- 
- 	dm_list_iterate_items(tmsg, &seg->thin_messages) {
diff --git a/SOURCES/lvm2-2_02_131-fix-devices-filter-to-be-applied-before-disk-accessing-filters.patch b/SOURCES/lvm2-2_02_131-fix-devices-filter-to-be-applied-before-disk-accessing-filters.patch
deleted file mode 100644
index ac09dee..0000000
--- a/SOURCES/lvm2-2_02_131-fix-devices-filter-to-be-applied-before-disk-accessing-filters.patch
+++ /dev/null
@@ -1,137 +0,0 @@
- WHATS_NEW                  |  1 +
- lib/commands/toolcontext.c | 64 +++++++++++++++++++++++++++-------------------
- 2 files changed, 39 insertions(+), 26 deletions(-)
-
-diff --git a/WHATS_NEW b/WHATS_NEW
-index 6441cc1..0e77789 100644
---- a/WHATS_NEW
-+++ b/WHATS_NEW
-@@ -16,6 +16,7 @@ Version 2.02.133 -
- 
- Version 2.02.131 - 
- =====================================
-+  Fix devices/filter to be applied before disk-accessing filters. (2.02.112)
-   Fix vgimportclone cache_dir path name (2.02.115).
-   Disallow usage of --stripe and --stripesize when creating cache pool.
-   Swapping of LV identifiers handles more complex LVs.
-diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
-index 11affee..c8d96ca 100644
---- a/lib/commands/toolcontext.c
-+++ b/lib/commands/toolcontext.c
-@@ -1069,7 +1069,7 @@ static struct dev_filter *_init_lvmetad_filter_chain(struct cmd_context *cmd)
- 			nr_filt++;
- 	}
- 
--	/* regex filter. Optional. */
-+	/* global regex filter. Optional. */
- 	if ((cn = find_config_tree_node(cmd, devices_global_filter_CFG, NULL))) {
- 		if (!(filters[nr_filt] = regex_filter_create(cn->v))) {
- 			log_error("Failed to create global regex device filter");
-@@ -1078,6 +1078,17 @@ static struct dev_filter *_init_lvmetad_filter_chain(struct cmd_context *cmd)
- 		nr_filt++;
- 	}
- 
-+	/* regex filter. Optional. */
-+	if (!lvmetad_used()) {
-+		if ((cn = find_config_tree_node(cmd, devices_filter_CFG, NULL))) {
-+			if (!(filters[nr_filt] = regex_filter_create(cn->v))) {
-+				log_error("Failed to create regex device filter");
-+				goto bad;
-+			}
-+			nr_filt++;
-+		}
-+	}
-+
- 	/* device type filter. Required. */
- 	if (!(filters[nr_filt] = lvm_type_filter_create(cmd->dev_types))) {
- 		log_error("Failed to create lvm type filter");
-@@ -1145,26 +1156,24 @@ bad:
-  *     md component filter -> fw raid filter
-  *
-  *   - cmd->filter - the filter chain used for lvmetad responses:
-- *     persistent filter -> usable device filter(FILTER_MODE_POST_LVMETAD) ->
-- *     regex filter
-+ *     persistent filter -> regex_filter -> usable device filter(FILTER_MODE_POST_LVMETAD)
-  *
-  *   - cmd->full_filter - the filter chain used for all the remaining situations:
-- *     lvmetad_filter -> filter
-+ *     cmd->lvmetad_filter -> cmd->filter
-  *
-- * If lvmetad isnot used, there's just one filter chain:
-+ * If lvmetad is not used, there's just one filter chain:
-  *
-  *   - cmd->filter == cmd->full_filter:
-- *     persistent filter -> regex filter -> sysfs filter ->
-- *     global regex filter -> type filter ->
-- *     usable device filter(FILTER_MODE_NO_LVMETAD) ->
-- *     mpath component filter -> partitioned filter ->
-- *     md component filter -> fw raid filter
-+ *     persistent filter -> sysfs filter -> global regex filter ->
-+ *     regex_filter -> type filter -> usable device filter(FILTER_MODE_NO_LVMETAD) ->
-+ *     mpath component filter -> partitioned filter -> md component filter -> fw raid filter
-  *
-  */
- int init_filters(struct cmd_context *cmd, unsigned load_persistent_cache)
- {
- 	const char *dev_cache;
- 	struct dev_filter *filter = NULL, *filter_components[2] = {0};
-+	int nr_filt;
- 	struct stat st;
- 	const struct dm_config_node *cn;
- 	struct timespec ts, cts;
-@@ -1193,26 +1202,26 @@ int init_filters(struct cmd_context *cmd, unsigned load_persistent_cache)
- 	 */
- 	/* filter component 0 */
- 	if (lvmetad_used()) {
--		if (!(filter_components[0] = usable_filter_create(cmd->dev_types, FILTER_MODE_POST_LVMETAD))) {
-+		nr_filt = 0;
-+		if ((cn = find_config_tree_array(cmd, devices_filter_CFG, NULL))) {
-+			if (!(filter_components[nr_filt] = regex_filter_create(cn->v))) {
-+				log_verbose("Failed to create regex device filter.");
-+				goto bad;
-+			}
-+			nr_filt++;
-+		}
-+		if (!(filter_components[nr_filt] = usable_filter_create(cmd->dev_types, FILTER_MODE_POST_LVMETAD))) {
- 			log_verbose("Failed to create usable device filter.");
- 			goto bad;
- 		}
-+		nr_filt++;
-+		if (!(filter = composite_filter_create(nr_filt, 0, filter_components)))
-+			goto_bad;
- 	} else {
--		filter_components[0] = cmd->lvmetad_filter;
-+		filter = cmd->lvmetad_filter;
- 		cmd->lvmetad_filter = NULL;
- 	}
- 
--	/* filter component 1 */
--	if ((cn = find_config_tree_array(cmd, devices_filter_CFG, NULL))) {
--		if (!(filter_components[1] = regex_filter_create(cn->v)))
--			goto_bad;
--		/* we have two filter components - create composite filter */
--		if (!(filter = composite_filter_create(2, 0, filter_components)))
--			goto_bad;
--	} else
--		/* we have only one filter component - no need to create composite filter */
--		filter = filter_components[0];
--
- 	if (!(dev_cache = find_config_tree_str(cmd, devices_cache_CFG, NULL)))
- 		goto_bad;
- 
-@@ -1224,9 +1233,12 @@ int init_filters(struct cmd_context *cmd, unsigned load_persistent_cache)
- 	cmd->filter = filter;
- 
- 	if (lvmetad_used()) {
--		filter_components[0] = cmd->lvmetad_filter;
--		filter_components[1] = cmd->filter;
--		if (!(cmd->full_filter = composite_filter_create(2, 0, filter_components)))
-+		nr_filt = 0;
-+		filter_components[nr_filt] = cmd->lvmetad_filter;
-+		nr_filt++;
-+		filter_components[nr_filt] = cmd->filter;
-+		nr_filt++;
-+		if (!(cmd->full_filter = composite_filter_create(nr_filt, 0, filter_components)))
- 			goto_bad;
- 	} else
- 		cmd->full_filter = filter;
diff --git a/SOURCES/lvm2-2_02_131-fix-vg-metadata-comparison-failure-while-scanning-the-vg-for-lvmetad.patch b/SOURCES/lvm2-2_02_131-fix-vg-metadata-comparison-failure-while-scanning-the-vg-for-lvmetad.patch
deleted file mode 100644
index b5374a9..0000000
--- a/SOURCES/lvm2-2_02_131-fix-vg-metadata-comparison-failure-while-scanning-the-vg-for-lvmetad.patch
+++ /dev/null
@@ -1,28 +0,0 @@
- WHATS_NEW           | 1 +
- lib/cache/lvmetad.c | 2 +-
- 2 files changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/WHATS_NEW b/WHATS_NEW
-index 5de648c..9ddecbc 100644
---- a/WHATS_NEW
-+++ b/WHATS_NEW
-@@ -1,5 +1,6 @@
- Version 2.02.131 - 
- =====================================
-+  Fix VG metadata comparison failure while scanning the VG for lvmetad.
-   Ignore persistent cache if configuration changed. (2.02.127)
- 
- Version 2.02.130 - 5th September 2015
-diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
-index b2e2f55..0fff65a 100644
---- a/lib/cache/lvmetad.c
-+++ b/lib/cache/lvmetad.c
-@@ -1174,7 +1174,7 @@ static struct volume_group *lvmetad_pvscan_vg(struct cmd_context *cmd, struct vo
- 		if (!vgmeta_ret) {
- 			vgmeta_ret = vgmeta;
- 		} else {
--			if (!compare_config(vgmeta_ret->root, vgmeta->root)) {
-+			if (compare_config(vgmeta_ret->root, vgmeta->root)) {
- 				log_error("VG metadata comparison failed");
- 				dm_config_destroy(vgmeta);
- 				dm_config_destroy(vgmeta_ret);
diff --git a/SOURCES/lvm2-2_02_131-fix-vgimportclone-cache_dir-path-name.patch b/SOURCES/lvm2-2_02_131-fix-vgimportclone-cache_dir-path-name.patch
deleted file mode 100644
index cdc432d..0000000
--- a/SOURCES/lvm2-2_02_131-fix-vgimportclone-cache_dir-path-name.patch
+++ /dev/null
@@ -1,37 +0,0 @@
- WHATS_NEW                | 1 +
- scripts/vgimportclone.sh | 4 ++--
- 2 files changed, 3 insertions(+), 2 deletions(-)
-
-diff --git a/WHATS_NEW b/WHATS_NEW
-index f41475c..1718c29 100644
---- a/WHATS_NEW
-+++ b/WHATS_NEW
-@@ -1,5 +1,6 @@
- Version 2.02.131 - 
- =====================================
-+  Fix vgimportclone cache_dir path name (2.02.115).
-   Disallow usage of --stripe and --stripesize when creating cache pool.
-   Swapping of LV identifiers handles more complex LVs.
-   Fix VG metadata comparison failure while scanning the VG for lvmetad.
-diff --git a/scripts/vgimportclone.sh b/scripts/vgimportclone.sh
-index 388d14c..af8cf5c 100755
---- a/scripts/vgimportclone.sh
-+++ b/scripts/vgimportclone.sh
-@@ -1,7 +1,7 @@
- #!/bin/bash
- 
- # Copyright (C) 2009 Chris Procter All rights reserved.
--# Copyright (C) 2009 Red Hat, Inc. All rights reserved.
-+# Copyright (C) 2009-2015 Red Hat, Inc. All rights reserved.
- #
- # This file is part of LVM2.
- #
-@@ -239,7 +239,7 @@ LVMCONF=${TMP_LVM_SYSTEM_DIR}/lvm.conf
- 
- CMD_CONFIG_LINE="devices { \
-                    scan = [ \"${TMP_LVM_SYSTEM_DIR}\" ] \
--                   cache_dir = \"$TMP_LVM_SYSTEM_DIR}/cache\"
-+                   cache_dir = \"${TMP_LVM_SYSTEM_DIR}/cache\"
-                    global_filter = [ \"a|.*|\" ] \
-                    ${FILTER}
-                  } \
diff --git a/SOURCES/lvm2-2_02_131-ignore-persistent-cache-if-configuration-changed.patch b/SOURCES/lvm2-2_02_131-ignore-persistent-cache-if-configuration-changed.patch
deleted file mode 100644
index 05ae6f8..0000000
--- a/SOURCES/lvm2-2_02_131-ignore-persistent-cache-if-configuration-changed.patch
+++ /dev/null
@@ -1,49 +0,0 @@
- WHATS_NEW          | 4 ++++
- tools/lvmcmdline.c | 8 +++++++-
- 2 files changed, 11 insertions(+), 1 deletion(-)
-
-diff --git a/WHATS_NEW b/WHATS_NEW
-index e74fd55..5de648c 100644
---- a/WHATS_NEW
-+++ b/WHATS_NEW
-@@ -1,3 +1,7 @@
-+Version 2.02.131 - 
-+=====================================
-+  Ignore persistent cache if configuration changed. (2.02.127)
-+
- Version 2.02.130 - 5th September 2015
- =====================================
-   Fix use of uninitialized device status if reading outdated .cache record.
-diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
-index b7809c7..d3bace7 100644
---- a/tools/lvmcmdline.c
-+++ b/tools/lvmcmdline.c
-@@ -1478,6 +1478,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
- 	char *arg_new, *arg;
- 	int i;
- 	int skip_hyphens;
-+	int refresh_done = 0;
- 
- 	init_error_message_produced(0);
- 
-@@ -1554,6 +1555,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
- 			log_error("Updated config file invalid. Aborting.");
- 			return ECMD_FAILED;
- 		}
-+		refresh_done = 1;
- 	}
- 
- 	if (!_prepare_profiles(cmd))
-@@ -1562,7 +1564,11 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
- 	if (!cmd->initialized.connections && !_cmd_no_meta_proc(cmd) && !init_connections(cmd))
- 		return_ECMD_FAILED;
- 
--	if (!cmd->initialized.filters && !_cmd_no_meta_proc(cmd) && !init_filters(cmd, 1))
-+	/* Note: Load persistent cache only if we haven't refreshed toolcontext!
-+	 *       If toolcontext has been refreshed, it means config has changed
-+	 *       and we can't rely on persistent cache anymore.
-+	 */
-+	if (!cmd->initialized.filters && !_cmd_no_meta_proc(cmd) && !init_filters(cmd, !refresh_done))
- 		return_ECMD_FAILED;
- 
- 	if (arg_count(cmd, readonly_ARG))
diff --git a/SOURCES/lvm2-2_02_131-standardise-error-paths.patch b/SOURCES/lvm2-2_02_131-standardise-error-paths.patch
deleted file mode 100644
index 72485e7..0000000
--- a/SOURCES/lvm2-2_02_131-standardise-error-paths.patch
+++ /dev/null
@@ -1,2169 +0,0 @@
-commit fb8220fb6961e563d6a760a70bd1e1b27a62bde0
-Author: Alasdair G Kergon <agk@redhat.com>
-Date:   Sat Sep 5 23:56:30 2015 +0100
-
-    style: Standardise some error paths.
----
- daemons/cmirrord/functions.c   |   4 +-
- daemons/lvmetad/lvmetad-core.c |   2 +-
- lib/metadata/metadata.c        |   3 +-
- libdm/libdm-file.c             |   4 +-
- libdm/libdm-report.c           |   2 +-
- libdm/libdm-stats.c            | 197 +++++++++--------
- liblvm/lvm_pv.c                |   5 +-
- tools/dmsetup.c                | 475 +++++++++++++++++++++--------------------
- 8 files changed, 355 insertions(+), 337 deletions(-)
-
-diff --git a/daemons/cmirrord/functions.c b/daemons/cmirrord/functions.c
-index 61b3e11..4f36cc6 100644
---- a/daemons/cmirrord/functions.c
-+++ b/daemons/cmirrord/functions.c
-@@ -1445,7 +1445,7 @@ static int disk_status_info(struct log_c *lc, struct dm_ulog_request *rq)
- 	char *data = (char *)rq->data;
- 	struct stat statbuf;
- 
--	if(fstat(lc->disk_fd, &statbuf)) {
-+	if (fstat(lc->disk_fd, &statbuf)) {
- 		rq->error = -errno;
- 		return -errno;
- 	}
-@@ -1508,7 +1508,7 @@ static int disk_status_table(struct log_c *lc, struct dm_ulog_request *rq)
- 	char *data = (char *)rq->data;
- 	struct stat statbuf;
- 
--	if(fstat(lc->disk_fd, &statbuf)) {
-+	if (fstat(lc->disk_fd, &statbuf)) {
- 		rq->error = -errno;
- 		return -errno;
- 	}
-diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
-index 19e8723..89aaaf8 100644
---- a/daemons/lvmetad/lvmetad-core.c
-+++ b/daemons/lvmetad/lvmetad-core.c
-@@ -578,7 +578,7 @@ static void mark_outdated_pv(lvmetad_state *s, const char *vgid, const char *pvi
- 		    !(cft_vgid = make_text_node(outdated_pvs, "vgid", dm_pool_strdup(outdated_pvs->mem, vgid),
- 						outdated_pvs->root, NULL)))
- 			abort();
--		if(!dm_hash_insert(s->vgid_to_outdated_pvs, cft_vgid->v->v.str, outdated_pvs))
-+		if (!dm_hash_insert(s->vgid_to_outdated_pvs, cft_vgid->v->v.str, outdated_pvs))
- 			abort();
- 		DEBUGLOG(s, "created outdated_pvs list for VG %s", vgid);
- 	}
-diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
-index 8757331..b45f850 100644
---- a/lib/metadata/metadata.c
-+++ b/lib/metadata/metadata.c
-@@ -319,10 +319,11 @@ static struct pv_list *_copy_pvl(struct dm_pool *pvmem, struct pv_list *pvl_from
- 	if (!(pvl_to->pv = dm_pool_alloc(pvmem, sizeof(*pvl_to->pv))))
- 		goto_bad;
- 
--	if(!_copy_pv(pvmem, pvl_to->pv, pvl_from->pv))
-+	if (!_copy_pv(pvmem, pvl_to->pv, pvl_from->pv))
- 		goto_bad;
- 
- 	return pvl_to;
-+
- bad:
- 	dm_pool_free(pvmem, pvl_to);
- 	return NULL;
-diff --git a/libdm/libdm-file.c b/libdm/libdm-file.c
-index 52f9d45..e4beddd 100644
---- a/libdm/libdm-file.c
-+++ b/libdm/libdm-file.c
-@@ -119,8 +119,8 @@ int dm_create_lockfile(const char *lockfile)
- 	char buffer[50];
- 	int retries = 0;
- 
--	if((fd = open(lockfile, O_CREAT | O_WRONLY,
--		      (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH))) < 0) {
-+	if ((fd = open(lockfile, O_CREAT | O_WRONLY,
-+		       (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH))) < 0) {
- 		log_error("Cannot open lockfile [%s], error was [%s]",
- 			  lockfile, strerror(errno));
- 		return 0;
-diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
-index 6416f18..10ab7df 100644
---- a/libdm/libdm-report.c
-+++ b/libdm/libdm-report.c
-@@ -4195,7 +4195,7 @@ static void _destroy_rows(struct dm_report *rh)
- 	 * pool allocation this will also free all subsequently allocated
- 	 * rows from the report and any associated string data.
- 	 */
--	if(rh->first_row)
-+	if (rh->first_row)
- 		dm_pool_free(rh->mem, rh->first_row);
- 	rh->first_row = NULL;
- 	dm_list_init(&rh->rows);
-diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
-index 736aae5..93c7760 100644
---- a/libdm/libdm-stats.c
-+++ b/libdm/libdm-stats.c
-@@ -105,7 +105,7 @@ static char *_program_id_from_proc(void)
- 
- 	if (!fgets(buf, sizeof(buf), comm)) {
- 		log_error("Could not read from %s", PROC_SELF_COMM);
--		if(fclose(comm))
-+		if (fclose(comm))
- 			stack;
- 		return NULL;
- 	}
-@@ -145,7 +145,7 @@ struct dm_stats *dm_stats_create(const char *program_id)
- 
- 	/* FIXME: better hint. */
- 	if (!(dms->mem = dm_pool_create("stats_pool", 4096)))
--		goto_out;
-+		goto_bad;
- 
- 	if (!(dms->hist_mem = dm_pool_create("histogram_pool", hist_hint)))
- 		return_0;
-@@ -169,7 +169,8 @@ struct dm_stats *dm_stats_create(const char *program_id)
- 	dms->regions = NULL;
- 
- 	return dms;
--out:
-+
-+bad:
- 	dm_free(dms);
- 	return NULL;
- }
-@@ -354,7 +355,7 @@ static char *_build_histogram_arg(struct dm_histogram *bounds, int *precise)
- 		hist_len += 1 + (size_t) lround(log10(value));
- 	}
- 
--	if(!(hist_arg = dm_zalloc(hist_len))) {
-+	if (!(hist_arg = dm_zalloc(hist_len))) {
- 		log_error("Could not allocate memory for histogram argument.");
- 		return 0;
- 	}
-@@ -373,14 +374,16 @@ static char *_build_histogram_arg(struct dm_histogram *bounds, int *precise)
- 		value = entry->upper / scale;
- 		if ((l = dm_snprintf(arg, hist_len - len, FMTu64"%s", value,
- 				     (last) ? "" : ",")) < 0)
--			goto out;
-+			goto_bad;
- 		len += (size_t) l;
- 		arg += (size_t) l;
- 	}
- 	return hist_arg;
--out:
-+
-+bad:
- 	log_error("Could not build histogram arguments.");
- 	dm_free(hist_arg);
-+
- 	return NULL;
- }
- 
-@@ -392,16 +395,17 @@ static struct dm_task *_stats_send_message(struct dm_stats *dms, char *msg)
- 		return_0;
- 
- 	if (!_set_stats_device(dms, dmt))
--		goto_out;
-+		goto_bad;
- 
- 	if (!dm_task_set_message(dmt, msg))
--		goto_out;
-+		goto_bad;
- 
- 	if (!dm_task_run(dmt))
--		goto_out;
-+		goto_bad;
- 
- 	return dmt;
--out:
-+
-+bad:
- 	dm_task_destroy(dmt);
- 	return NULL;
- }
-@@ -425,7 +429,7 @@ static int _stats_parse_histogram_spec(struct dm_stats *dms,
- 
- 	/* Advance past "histogram:". */
- 	histogram = strchr(histogram, ':');
--	if(!histogram) {
-+	if (!histogram) {
- 		log_error("Could not parse histogram description.");
- 		return 0;
- 	}
-@@ -444,21 +448,23 @@ static int _stats_parse_histogram_spec(struct dm_stats *dms,
- 	hist.region = region;
- 	hist.dms = dms;
- 
--	if(!dm_pool_grow_object(mem, &hist, sizeof(hist)))
--		goto_out;
-+	if (!dm_pool_grow_object(mem, &hist, sizeof(hist)))
-+		goto_bad;
- 
- 	c = histogram;
- 	do {
--		for(v = _valid_chars; *v; v++)
-+		for (v = _valid_chars; *v; v++)
- 			if (*c == *v)
- 				break;
--		if(!*v)
-+		if (!*v) {
-+			stack;
- 			goto badchar;
-+		}
- 
- 		if (*c == ',') {
- 			log_error("Invalid histogram description: %s",
- 				  histogram);
--			goto out;
-+			goto bad;
- 		} else {
- 			const char *val_start = c;
- 			char *endptr = NULL;
-@@ -467,15 +473,17 @@ static int _stats_parse_histogram_spec(struct dm_stats *dms,
- 			this_val = strtoull(val_start, &endptr, 10);
- 			if (!endptr) {
- 				log_error("Could not parse histogram boundary.");
--				goto out;
-+				goto bad;
- 			}
- 
- 			c = endptr; /* Advance to units, comma, or end. */
- 
- 			if (*c == ',')
- 				c++;
--			else if (*c || (*c == ' ')) /* Expected ',' or NULL. */
-+			else if (*c || (*c == ' ')) { /* Expected ',' or NULL. */
-+				stack;
- 				goto badchar;
-+			}
- 
- 			if (*c == ',')
- 				c++;
-@@ -484,7 +492,7 @@ static int _stats_parse_histogram_spec(struct dm_stats *dms,
- 			cur.count = 0;
- 
- 			if (!dm_pool_grow_object(mem, &cur, sizeof(cur)))
--				goto_out;
-+				goto_bad;
- 
- 			nr_bins++;
- 		}
-@@ -493,7 +501,7 @@ static int _stats_parse_histogram_spec(struct dm_stats *dms,
- 	/* final upper bound. */
- 	cur.upper = UINT64_MAX;
- 	if (!dm_pool_grow_object(mem, &cur, sizeof(cur)))
--		goto_out;
-+		goto_bad;
- 
- 	region->bounds = dm_pool_end_object(mem);
- 
-@@ -507,7 +515,7 @@ static int _stats_parse_histogram_spec(struct dm_stats *dms,
- 
- badchar:
- 	log_error("Invalid character in histogram: '%c' (0x%x)", *c, *c);
--out:
-+bad:
- 	dm_pool_abandon_object(mem);
- 	return 0;
- }
-@@ -614,12 +622,12 @@ static int _stats_parse_list(struct dm_stats *dms, const char *resp)
- 		return_0;
- 
- 	if (!dm_pool_begin_object(mem, 1024))
--		goto_out;
-+		goto_bad;
- 
- 	while(fgets(line, sizeof(line), list_rows)) {
- 
- 		if (!_stats_parse_list_region(dms, &cur, line))
--			goto_out;
-+			goto_bad;
- 
- 		/* handle holes in the list of region_ids */
- 		if (cur.region_id > max_region) {
-@@ -628,12 +636,12 @@ static int _stats_parse_list(struct dm_stats *dms, const char *resp)
- 			fill.region_id = DM_STATS_REGION_NOT_PRESENT;
- 			do {
- 				if (!dm_pool_grow_object(mem, &fill, sizeof(fill)))
--					goto_out;
-+					goto_bad;
- 			} while (max_region++ < (cur.region_id - 1));
- 		}
- 
- 		if (!dm_pool_grow_object(mem, &cur, sizeof(cur)))
--			goto_out;
-+			goto_bad;
- 
- 		max_region++;
- 		nr_regions++;
-@@ -647,10 +655,12 @@ static int _stats_parse_list(struct dm_stats *dms, const char *resp)
- 		stack;
- 
- 	return 1;
--out:
--	if(fclose(list_rows))
-+
-+bad:
-+	if (fclose(list_rows))
- 		stack;
- 	dm_pool_abandon_object(mem);
-+
- 	return 0;
- }
- 
-@@ -675,17 +685,17 @@ int dm_stats_list(struct dm_stats *dms, const char *program_id)
- 	}
- 
- 	if (!(dmt = _stats_send_message(dms, msg)))
--		return 0;
-+		return_0;
- 
- 	if (!_stats_parse_list(dms, dm_task_get_message_response(dmt))) {
- 		log_error("Could not parse @stats_list response.");
--		goto out;
-+		goto bad;
- 	}
- 
- 	dm_task_destroy(dmt);
- 	return 1;
- 
--out:
-+bad:
- 	dm_task_destroy(dmt);
- 	return 0;
- }
-@@ -715,15 +725,17 @@ static int _stats_parse_histogram(struct dm_pool *mem, char *hist_str,
- 
- 	do {
- 		memset(&cur, 0, sizeof(cur));
--		for(v = _valid_chars; *v; v++)
-+		for (v = _valid_chars; *v; v++)
- 			if (*c == *v)
- 				break;
--		if(!*v)
-+		if (!*v) {
-+			stack;
- 			goto badchar;
-+		}
- 
- 		if (*c == ',') {
- 			log_error("Invalid histogram: %s", hist_str);
--			goto out;
-+			return 0;
- 		} else {
- 			const char *val_start = c;
- 			char *endptr = NULL;
-@@ -732,15 +744,17 @@ static int _stats_parse_histogram(struct dm_pool *mem, char *hist_str,
- 			this_val = strtoull(val_start, &endptr, 10);
- 			if (!endptr) {
- 				log_error("Could not parse histogram value.");
--				goto out;
-+				return 0;
- 			}
- 			c = endptr; /* Advance to colon, or end. */
- 
- 			if (*c == ':')
- 				c++;
--			else if (*c & (*c != '\n'))
-+			else if (*c & (*c != '\n')) {
- 				/* Expected ':', '\n', or NULL. */
-+				stack;
- 				goto badchar;
-+			}
- 
- 			if (*c == ':')
- 				c++;
-@@ -764,7 +778,6 @@ static int _stats_parse_histogram(struct dm_pool *mem, char *hist_str,
- 
- badchar:
- 	log_error("Invalid character in histogram data: '%c' (0x%x)", *c, *c);
--out:
- 	return 0;
- }
- 
-@@ -788,7 +801,7 @@ static int _stats_parse_region(struct dm_stats *dms, const char *resp,
- 	region->start = UINT64_MAX;
- 
- 	if (!dm_pool_begin_object(mem, 512))
--		goto_out;
-+		goto_bad;
- 
- 	/*
- 	 * dm_task_get_message_response() returns a 'const char *' but
-@@ -796,7 +809,7 @@ static int _stats_parse_region(struct dm_stats *dms, const char *resp,
- 	 */
- 	stats_rows = fmemopen((char *)resp, strlen(resp), "r");
- 	if (!stats_rows)
--		goto_out;
-+		goto_bad;
- 
- 	/*
- 	 * Output format for each step-sized area of a region:
-@@ -844,7 +857,7 @@ static int _stats_parse_region(struct dm_stats *dms, const char *resp,
- 			   &cur.total_read_nsecs, &cur.total_write_nsecs);
- 		if (r != 15) {
- 			log_error("Could not parse @stats_print row.");
--			goto out;
-+			goto bad;
- 		}
- 
- 		/* scale time values up if needed */
-@@ -862,7 +875,7 @@ static int _stats_parse_region(struct dm_stats *dms, const char *resp,
- 			char *hist_str = strchr(row, ':');
- 			if (!hist_str) {
- 				log_error("Could not parse histogram value.");
--				goto out;
-+				goto bad;
- 			}
- 			/* Find space preceding histogram. */
- 			while (hist_str && *(hist_str - 1) != ' ')
-@@ -874,15 +887,15 @@ static int _stats_parse_region(struct dm_stats *dms, const char *resp,
- 			 */
- 			if (!_stats_parse_histogram(dms->hist_mem, hist_str,
- 						    &hist, region))
--				goto out;
-+				goto_bad;
- 			hist->dms = dms;
- 			hist->region = region;
- 		}
- 
- 		cur.histogram = hist;
- 
--		if(!dm_pool_grow_object(mem, &cur, sizeof(cur)))
--			goto_out;
-+		if (!dm_pool_grow_object(mem, &cur, sizeof(cur)))
-+			goto_bad;
- 
- 		if (region->start == UINT64_MAX) {
- 			region->start = start;
-@@ -899,12 +912,12 @@ static int _stats_parse_region(struct dm_stats *dms, const char *resp,
- 
- 	return 1;
- 
--out:
--
-+bad:
- 	if (stats_rows)
--		if(fclose(stats_rows))
-+		if (fclose(stats_rows))
- 			stack;
- 	dm_pool_abandon_object(mem);
-+
- 	return 0;
- }
- 
-@@ -1017,7 +1030,7 @@ int dm_stats_get_region_nr_histogram_bins(const struct dm_stats *dms,
- 		     ? dms->cur_region : region_id ;
- 
- 	if (!dms->regions[region_id].bounds)
--		return 0;
-+		return_0;
- 
- 	return dms->regions[region_id].bounds->nr_bins;
- }
-@@ -1083,7 +1096,7 @@ static int _stats_create_region(struct dm_stats *dms, uint64_t *region_id,
- 	}
- 
- 	if (!(dmt = _stats_send_message(dms, msg)))
--		goto out;
-+		goto_out;
- 
- 	resp = dm_task_get_message_response(dmt);
- 	if (!resp) {
-@@ -1101,9 +1114,10 @@ static int _stats_create_region(struct dm_stats *dms, uint64_t *region_id,
- 	r = 1;
- 
- out:
--	if(dmt)
-+	if (dmt)
- 		dm_task_destroy(dmt);
- 	dm_free((void *) opt_args);
-+
- 	return r;
- }
- 
-@@ -1116,9 +1130,8 @@ int dm_stats_create_region(struct dm_stats *dms, uint64_t *region_id,
- 	int r = 0;
- 
- 	/* Nanosecond counters and histograms both need precise_timestamps. */
--	if ((precise || bounds)
--	    && !_stats_check_precise_timestamps(dms))
--		return 0;
-+	if ((precise || bounds) && !_stats_check_precise_timestamps(dms))
-+		return_0;
- 
- 	if (bounds) {
- 		/* _build_histogram_arg enables precise if vals < 1ms. */
-@@ -1129,6 +1142,7 @@ int dm_stats_create_region(struct dm_stats *dms, uint64_t *region_id,
- 	r = _stats_create_region(dms, region_id, start, len, step,
- 				 precise, hist_arg, program_id, aux_data);
- 	dm_free(hist_arg);
-+
- out:
- 	return r;
- }
-@@ -1143,17 +1157,15 @@ int dm_stats_delete_region(struct dm_stats *dms, uint64_t region_id)
- 
- 	if (!dm_snprintf(msg, sizeof(msg), "@stats_delete " FMTu64, region_id)) {
- 		log_error("Could not prepare @stats_delete message.");
--		goto out;
-+		return 0;
- 	}
- 
- 	dmt = _stats_send_message(dms, msg);
- 	if (!dmt)
--		goto_out;
-+		return_0;
- 	dm_task_destroy(dmt);
--	return 1;
- 
--out:
--	return 0;
-+	return 1;
- }
- 
- int dm_stats_clear_region(struct dm_stats *dms, uint64_t region_id)
-@@ -1166,17 +1178,17 @@ int dm_stats_clear_region(struct dm_stats *dms, uint64_t region_id)
- 
- 	if (!dm_snprintf(msg, sizeof(msg), "@stats_clear " FMTu64, region_id)) {
- 		log_error("Could not prepare @stats_clear message.");
--		goto out;
-+		return 0;
- 	}
- 
- 	dmt = _stats_send_message(dms, msg);
-+
- 	if (!dmt)
--		goto_out;
-+		return_0;
-+
- 	dm_task_destroy(dmt);
--	return 1;
- 
--out:
--	return 0;
-+	return 1;
- }
- 
- static struct dm_task *_stats_print_region(struct dm_stats *dms,
-@@ -1194,22 +1206,19 @@ static struct dm_task *_stats_print_region(struct dm_stats *dms,
- 		if (!dm_snprintf(lines, sizeof(lines),
- 				 lines_fmt, start_line, num_lines)) {
- 			log_error(err_fmt, "row specification");
--			goto out;
-+			return NULL;
- 		}
- 
- 	if (!dm_snprintf(msg, sizeof(msg), msg_fmt, (clear) ? clear_str : "",
- 			 region_id, (start_line || num_lines) ? lines : "")) {
- 		log_error(err_fmt, "message");
--		goto out;
-+		return NULL;
- 	}
- 
- 	if (!(dmt = _stats_send_message(dms, msg)))
--		goto out;
-+		return_NULL;
- 
- 	return dmt;
--
--out:
--	return NULL;
- }
- 
- char *dm_stats_print_region(struct dm_stats *dms, uint64_t region_id,
-@@ -1226,7 +1235,7 @@ char *dm_stats_print_region(struct dm_stats *dms, uint64_t region_id,
- 				  start_line, num_lines, clear);
- 
- 	if (!dmt)
--		return 0;
-+		return_0;
- 
- 	resp = dm_pool_strdup(dms->mem, dm_task_get_message_response(dmt));
- 	dm_task_destroy(dmt);
-@@ -1245,7 +1254,7 @@ void dm_stats_buffer_destroy(struct dm_stats *dms, char *buffer)
- uint64_t dm_stats_get_nr_regions(const struct dm_stats *dms)
- {
- 	if (!dms || !dms->regions)
--		return 0;
-+		return_0;
- 	return dms->nr_regions;
- }
- 
-@@ -1255,10 +1264,10 @@ uint64_t dm_stats_get_nr_regions(const struct dm_stats *dms)
- int dm_stats_region_present(const struct dm_stats *dms, uint64_t region_id)
- {
- 	if (!dms->regions)
--		return 0;
-+		return_0;
- 
- 	if (region_id > dms->max_region)
--		return 0;
-+		return_0;
- 
- 	return _stats_region_present(&dms->regions[region_id]);
- }
-@@ -1293,12 +1302,12 @@ int dm_stats_populate(struct dm_stats *dms, const char *program_id,
- 
- 	if (all_regions && !dm_stats_list(dms, program_id)) {
- 		log_error("Could not parse @stats_list response.");
--		goto out;
-+		goto bad;
- 	}
- 
- 	/* successful list but no regions registered */
- 	if (!dms->nr_regions)
--		return 0;
-+		return_0;
- 
- 	dm_stats_walk_start(dms);
- 	do {
-@@ -1310,12 +1319,12 @@ int dm_stats_populate(struct dm_stats *dms, const char *program_id,
- 
- 		/* obtain all lines and clear counter values */
- 		if (!(dmt = _stats_print_region(dms, region_id, 0, 0, 1)))
--			goto_out;
-+			goto_bad;
- 
- 		resp = dm_task_get_message_response(dmt);
- 		if (!_dm_stats_populate_region(dms, region_id, resp)) {
- 			dm_task_destroy(dmt);
--			goto_out;
-+			goto_bad;
- 		}
- 
- 		dm_task_destroy(dmt);
-@@ -1325,7 +1334,7 @@ int dm_stats_populate(struct dm_stats *dms, const char *program_id,
- 
- 	return 1;
- 
--out:
-+bad:
- 	_stats_regions_destroy(dms);
- 	dms->regions = NULL;
- 	return 0;
-@@ -1620,10 +1629,10 @@ int dm_stats_get_service_time(const struct dm_stats *dms, double *svctm,
- 	double tput;
- 
- 	if (!dm_stats_get_throughput(dms, &tput, region_id, area_id))
--		return 0;
-+		return_0;
- 
- 	if (!dm_stats_get_utilization(dms, &util, region_id, area_id))
--		return 0;
-+		return_0;
- 
- 	/* avoid NAN with zero counter values */
- 	if ( (uint64_t) tput == 0 || (uint64_t) util == 0) {
-@@ -1973,23 +1982,26 @@ struct dm_histogram *dm_histogram_bounds_from_string(const char *bounds_str)
- 	c = bounds_str;
- 
- 	if (!(dmh = _alloc_dm_histogram(nr_entries)))
--		return 0;
-+		return_0;
- 
- 	dmh->nr_bins = nr_entries;
- 
- 	cur = dmh->bins;
- 
- 	do {
--		for(v = _valid_chars; *v; v++)
-+		for (v = _valid_chars; *v; v++)
- 			if (*c == *v)
- 				break;
--		if(!*v)
-+
-+		if (!*v) {
-+			stack;
- 			goto badchar;
-+		}
- 
- 		if (*c == ',') {
- 			log_error("Empty histogram bin not allowed: %s",
- 				  bounds_str);
--			goto out;
-+			goto bad;
- 		} else {
- 			const char *val_start = c;
- 			char *endptr = NULL;
-@@ -1998,7 +2010,7 @@ struct dm_histogram *dm_histogram_bounds_from_string(const char *bounds_str)
- 			this_val = strtoull(val_start, &endptr, 10);
- 			if (!endptr) {
- 				log_error("Could not parse histogram bound.");
--				goto out;
-+				goto bad;
- 			}
- 			c = endptr; /* Advance to units, comma, or end. */
- 
-@@ -2012,13 +2024,17 @@ struct dm_histogram *dm_histogram_bounds_from_string(const char *bounds_str)
- 					mult = NSEC_PER_USEC;
- 				else if (*c == 'n')
- 					mult = 1;
--				else
-+				else {
-+					stack;
- 					goto badchar;
-+				}
- 				c += 2; /* Advance over 'ms', 'us', or 'ns'. */
- 			} else if (*c == ',')
- 				c++;
--			else if (*c) /* Expected ',' or NULL. */
-+			else if (*c) { /* Expected ',' or NULL. */
-+				stack;
- 				goto badchar;
-+			}
- 
- 			if (*c == ',')
- 				c++;
-@@ -2035,7 +2051,7 @@ struct dm_histogram *dm_histogram_bounds_from_string(const char *bounds_str)
- 
- badchar:
- 	log_error("Invalid character in histogram: %c", *c);
--out:
-+bad:
- 	dm_free(dmh);
- 	return NULL;
- }
-@@ -2121,7 +2137,7 @@ static int _make_bounds_string(char *buf, size_t size, uint64_t lower,
- 	int bounds = flags & DM_HISTOGRAM_BOUNDS_MASK;
- 
- 	if (!bounds)
--		return 0;
-+		return_0;
- 
- 	*buf = '\0';
- 
-@@ -2258,14 +2274,15 @@ const char *dm_histogram_to_string(const struct dm_histogram *dmh, int bin,
- 					  sep);
- 
- 		if (len < 0)
--			goto_out;
-+			goto_bad;
- 
- 		width = minwidth; /* re-set histogram column width. */
- 		dm_pool_grow_object(mem, buf, (size_t) len);
- 	}
- 	dm_pool_grow_object(mem, "\0", 1);
- 	return (const char *) dm_pool_end_object(mem);
--out:
-+
-+bad:
- 	dm_pool_abandon_object(mem);
- 	return NULL;
- }
-diff --git a/liblvm/lvm_pv.c b/liblvm/lvm_pv.c
-index 24b2732..5933e0a 100644
---- a/liblvm/lvm_pv.c
-+++ b/liblvm/lvm_pv.c
-@@ -155,9 +155,8 @@ static struct dm_list *_lvm_list_pvs(lvm_t libh)
- 	} else {
- 		dm_list_init(&rc->pvslist);
- 		dm_list_init(&rc->vgslist);
--		if( !get_pvs_perserve_vg(cmd, &rc->pvslist, &rc->vgslist) ) {
--			return NULL;
--		}
-+		if (!get_pvs_perserve_vg(cmd, &rc->pvslist, &rc->vgslist))
-+			return_NULL;
- 
- 		/*
- 		 * If we have no PVs we still need to have access to cmd
-diff --git a/tools/dmsetup.c b/tools/dmsetup.c
-index 8983e18..61ad5a9 100644
---- a/tools/dmsetup.c
-+++ b/tools/dmsetup.c
-@@ -327,7 +327,7 @@ static int _parse_line(struct dm_task *dmt, char *buffer, const char *file,
- 		*comment = '\0';
- 
- 	if (!dm_task_add_target(dmt, start, size, ttype, ptr))
--		return 0;
-+		return_0;
- 
- 	return 1;
- }
-@@ -364,11 +364,11 @@ static int _parse_file(struct dm_task *dmt, const char *file)
- 	while (getline(&buffer, &buffer_size, fp) > 0)
- #endif
- 		if (!_parse_line(dmt, buffer, file ? : "on stdin", ++line))
--			goto out;
-+			goto_out;
- 
- 	r = 1;
- 
--      out:
-+out:
- 	memset(buffer, 0, buffer_size);
- #ifndef HAVE_GETLINE
- 	dm_free(buffer);
-@@ -421,33 +421,33 @@ static struct dm_task *_get_deps_task(int major, int minor)
- 	struct dm_info info;
- 
- 	if (!(dmt = dm_task_create(DM_DEVICE_DEPS)))
--		return NULL;
-+		return_NULL;
- 
- 	if (!dm_task_set_major(dmt, major) ||
- 	    !dm_task_set_minor(dmt, minor))
--		goto err;
-+		goto_bad;
- 
- 	if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
--		goto err;
-+		goto_bad;
- 
- 	if (_switches[INACTIVE_ARG] && !dm_task_query_inactive_table(dmt))
--		goto err;
-+		goto_bad;
- 
- 	if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
--		goto err;
-+		goto_bad;
- 
- 	if (!_task_run(dmt))
--		goto err;
-+		goto_bad;
- 
- 	if (!dm_task_get_info(dmt, &info))
--		goto err;
-+		goto_bad;
- 
- 	if (!info.exists)
--		goto err;
-+		goto_bad;
- 
- 	return dmt;
- 
--      err:
-+bad:
- 	dm_task_destroy(dmt);
- 	return NULL;
- }
-@@ -581,7 +581,7 @@ static int _do_timerfd_wait(void)
- 	ssize_t bytes;
- 
- 	if (_timer_fd < 0)
--		return 0;
-+		return_0;
- 
- 	/* read on timerfd returns a uint64_t in host byte order. */
- 	bytes = read(_timer_fd, &expired, sizeof(expired));
-@@ -646,9 +646,9 @@ static int _do_usleep_wait(void)
- 	 */
- 	if (!_last_sleep && !_now) {
- 		if (!(_last_sleep = dm_timestamp_alloc()))
--			goto_out;
-+			return_0;
- 		if (!(_now = dm_timestamp_alloc()))
--			goto_out;
-+			return_0;
- 		dm_timestamp_get(_now);
- 		this_interval = _interval;
- 		log_error("Using "FMTu64" as first interval.", this_interval);
-@@ -673,17 +673,15 @@ static int _do_usleep_wait(void)
- 			log_error("Report interval interrupted by signal.");
- 		if (errno == EINVAL)
- 			log_error("Report interval too short.");
--		goto out;
-+		return_0;
- 	}
- 
--	if(_count == 2) {
-+	if (_count == 2) {
- 		dm_timestamp_destroy(_last_sleep);
- 		dm_timestamp_destroy(_now);
- 	}
- 
- 	return 1;
--out:
--	return 0;
- }
- 
- static int _start_timer(void)
-@@ -838,7 +836,7 @@ static int _display_info_cols(struct dm_task *dmt, struct dm_info *info)
- 		dm_stats_bind_devno(obj.stats, info->major, info->minor);
- 
- 		if (!dm_stats_populate(obj.stats, _program_id, DM_STATS_REGIONS_ALL))
--			goto out;
-+			goto_out;
- 
- 		/* Update timestamps and handle end-of-interval accounting. */
- 		_update_interval_times();
-@@ -856,11 +854,11 @@ static int _display_info_cols(struct dm_task *dmt, struct dm_info *info)
- 		dm_stats_bind_devno(obj.stats, info->major, info->minor);
- 
- 		if (!dm_stats_list(obj.stats, _program_id))
--			goto out;
-+			goto_out;
- 
- 		/* No regions to report */
- 		if (!dm_stats_get_nr_regions(obj.stats))
--			goto out;
-+			goto_out;
- 	}
- 
- 	/*
-@@ -879,7 +877,7 @@ static int _display_info_cols(struct dm_task *dmt, struct dm_info *info)
- 	} dm_stats_walk_while(obj.stats);
- 	r = 1;
- 
--      out:
-+out:
- 	if (obj.deps_task)
- 		dm_task_destroy(obj.deps_task);
- 	if (obj.split_name)
-@@ -938,7 +936,7 @@ static int _display_info(struct dm_task *dmt)
- 	struct dm_info info;
- 
- 	if (!dm_task_get_info(dmt, &info))
--		return 0;
-+		return_0;
- 
- 	if (!_switches[COLS_ARG])
- 		_display_info_long(dmt, &info);
-@@ -953,14 +951,14 @@ static int _set_task_device(struct dm_task *dmt, const char *name, int optional)
- {
- 	if (name) {
- 		if (!dm_task_set_name(dmt, name))
--			return 0;
-+			return_0;
- 	} else if (_switches[UUID_ARG]) {
- 		if (!dm_task_set_uuid(dmt, _uuid))
--			return 0;
-+			return_0;
- 	} else if (_switches[MAJOR_ARG] && _switches[MINOR_ARG]) {
- 		if (!dm_task_set_major(dmt, _int_args[MAJOR_ARG]) ||
- 		    !dm_task_set_minor(dmt, _int_args[MINOR_ARG]))
--			return 0;
-+			return_0;
- 	} else if (!optional) {
- 		fprintf(stderr, "No device specified.\n");
- 		return 0;
-@@ -972,15 +970,15 @@ static int _set_task_device(struct dm_task *dmt, const char *name, int optional)
- static int _set_task_add_node(struct dm_task *dmt)
- {
- 	if (!dm_task_set_add_node(dmt, DEFAULT_DM_ADD_NODE))
--		return 0;
-+		return_0;
- 
- 	if (_switches[ADD_NODE_ON_RESUME_ARG] &&
- 	    !dm_task_set_add_node(dmt, DM_ADD_NODE_ON_RESUME))
--		return 0;
-+		return_0;
- 
- 	if (_switches[ADD_NODE_ON_CREATE_ARG] &&
- 	    !dm_task_set_add_node(dmt, DM_ADD_NODE_ON_CREATE))
--		return 0;
-+		return_0;
- 
- 	return 1;
- }
-@@ -1014,35 +1012,35 @@ static int _load(CMD_ARGS)
- 		file = argv[0];
- 
- 	if (!(dmt = dm_task_create(DM_DEVICE_RELOAD)))
--		return 0;
-+		return_0;
- 
- 	if (!_set_task_device(dmt, name, 0))
--		goto out;
-+		goto_out;
- 
- 	if (!_switches[NOTABLE_ARG] && !_parse_file(dmt, file))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[READ_ONLY] && !dm_task_set_ro(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[INACTIVE_ARG] && !dm_task_query_inactive_table(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (!_task_run(dmt))
--		goto out;
-+		goto_out;
- 
- 	r = 1;
- 
- 	if (_switches[VERBOSE_ARG])
- 		r = _display_info(dmt);
- 
--      out:
-+out:
- 	dm_task_destroy(dmt);
- 
- 	return r;
-@@ -1060,45 +1058,45 @@ static int _create(CMD_ARGS)
- 		file = argv[1];
- 
- 	if (!(dmt = dm_task_create(DM_DEVICE_CREATE)))
--		return 0;
-+		return_0;
- 
- 	if (!dm_task_set_name(dmt, argv[0]))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[UUID_ARG] && !dm_task_set_uuid(dmt, _uuid))
--		goto out;
-+		goto_out;
- 
- 	if (!_switches[NOTABLE_ARG] && !_parse_file(dmt, file))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[READ_ONLY] && !dm_task_set_ro(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[MAJOR_ARG] && !dm_task_set_major(dmt, _int_args[MAJOR_ARG]))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[MINOR_ARG] && !dm_task_set_minor(dmt, _int_args[MINOR_ARG]))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[UID_ARG] && !dm_task_set_uid(dmt, _int_args[UID_ARG]))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[GID_ARG] && !dm_task_set_gid(dmt, _int_args[GID_ARG]))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[MODE_ARG] && !dm_task_set_mode(dmt, _int_args[MODE_ARG]))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[INACTIVE_ARG] && !dm_task_query_inactive_table(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[READAHEAD_ARG] &&
- 	    !dm_task_set_read_ahead(dmt, _int_args[READAHEAD_ARG],
- 				    _read_ahead_flags))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[NOTABLE_ARG])
- 		dm_udev_set_sync_support(0);
-@@ -1108,10 +1106,10 @@ static int _create(CMD_ARGS)
- 			      DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG;
- 
- 	if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (!_set_task_add_node(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_udev_cookie)
- 		cookie = _udev_cookie;
-@@ -1121,11 +1119,11 @@ static int _create(CMD_ARGS)
- 
- 	if (!dm_task_set_cookie(dmt, &cookie, udev_flags) ||
- 	    !_task_run(dmt))
--		goto out;
-+		goto_out;
- 
- 	r = 1;
- 
--      out:
-+out:
- 	if (!_udev_cookie)
- 		(void) dm_udev_wait(cookie);
- 
-@@ -1144,26 +1142,26 @@ static int _do_rename(const char *name, const char *new_name, const char *new_uu
- 	uint16_t udev_flags = 0;
- 
- 	if (!(dmt = dm_task_create(DM_DEVICE_RENAME)))
--		return 0;
-+		return_0;
- 
- 	/* FIXME Kernel doesn't support uuid or device number here yet */
- 	if (!_set_task_device(dmt, name, 0))
--		goto out;
-+		goto_out;
- 
- 	if (new_uuid) {
- 		if (!dm_task_set_newuuid(dmt, new_uuid))
--			goto out;
-+			goto_out;
- 	} else if (!new_name || !dm_task_set_newname(dmt, new_name))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[INACTIVE_ARG] && !dm_task_query_inactive_table(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[NOUDEVRULES_ARG])
- 		udev_flags |= DM_UDEV_DISABLE_DM_RULES_FLAG |
-@@ -1177,11 +1175,11 @@ static int _do_rename(const char *name, const char *new_name, const char *new_uu
- 
- 	if (!dm_task_set_cookie(dmt, &cookie, udev_flags) ||
- 	    !_task_run(dmt))
--		goto out;
-+		goto_out;
- 
- 	r = 1;
- 
--      out:
-+out:
- 	if (!_udev_cookie)
- 		(void) dm_udev_wait(cookie);
- 
-@@ -1210,14 +1208,14 @@ static int _message(CMD_ARGS)
- 	char *endptr;
- 
- 	if (!(dmt = dm_task_create(DM_DEVICE_TARGET_MSG)))
--		return 0;
-+		return_0;
- 
- 	if (_switches[UUID_ARG] || _switches[MAJOR_ARG]) {
- 		if (!_set_task_device(dmt, NULL, 0))
--			goto out;
-+			goto_out;
- 	} else {
- 		if (!_set_task_device(dmt, argv[0], 0))
--			goto out;
-+			goto_out;
- 		argc--;
- 		argv++;
- 	}
-@@ -1228,7 +1226,7 @@ static int _message(CMD_ARGS)
- 		goto out;
- 	}
- 	if (!dm_task_set_sector(dmt, sector))
--		goto out;
-+		goto_out;
- 
- 	argc--;
- 	argv++;
-@@ -1255,19 +1253,19 @@ static int _message(CMD_ARGS)
- 	dm_free(str);
- 
- 	if (!i)
--		goto out;
-+		goto_out;
- 
- 	if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[INACTIVE_ARG] && !dm_task_query_inactive_table(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (!_task_run(dmt))
--		goto out;
-+		goto_out;
- 
- 	if ((response = dm_task_get_message_response(dmt))) {
- 		if (!*response || response[strlen(response) - 1] == '\n')
-@@ -1278,7 +1276,7 @@ static int _message(CMD_ARGS)
- 
- 	r = 1;
- 
--      out:
-+out:
- 	dm_task_destroy(dmt);
- 
- 	return r;
-@@ -1290,37 +1288,37 @@ static int _setgeometry(CMD_ARGS)
- 	struct dm_task *dmt;
- 
- 	if (!(dmt = dm_task_create(DM_DEVICE_SET_GEOMETRY)))
--		return 0;
-+		return_0;
- 
- 	if (_switches[UUID_ARG] || _switches[MAJOR_ARG]) {
- 		if (!_set_task_device(dmt, NULL, 0))
--			goto out;
-+			goto_out;
- 	} else {
- 		if (!_set_task_device(dmt, argv[0], 0))
--			goto out;
-+			goto_out;
- 		argc--;
- 		argv++;
- 	}
- 
- 	if (!dm_task_set_geometry(dmt, argv[0], argv[1], argv[2], argv[3]))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[INACTIVE_ARG] && !dm_task_query_inactive_table(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
--		goto out;
-+		goto_out;
- 
- 	/* run the task */
- 	if (!_task_run(dmt))
--		goto out;
-+		goto_out;
- 
- 	r = 1;
- 
--      out:
-+out:
- 	dm_task_destroy(dmt);
- 
- 	return r;
-@@ -1373,7 +1371,7 @@ static int _udevflags(CMD_ARGS)
- 					       0};
- 
- 	if (!(cookie = _get_cookie_value(argv[0])))
--		return 0;
-+		return_0;
- 
- 	flags = cookie >> DM_UDEV_FLAGS_SHIFT;
- 
-@@ -1405,7 +1403,7 @@ static int _udevcomplete(CMD_ARGS)
- 	uint32_t cookie;
- 
- 	if (!(cookie = _get_cookie_value(argv[0])))
--		return 0;
-+		return_0;
- 
- 	/*
- 	 * Strip flags from the cookie and use cookie magic instead.
-@@ -1519,7 +1517,7 @@ static int _udevcreatecookie(CMD_ARGS)
- 	uint32_t cookie;
- 
- 	if (!dm_udev_create_cookie(&cookie))
--		return 0;
-+		return_0;
- 
- 	if (cookie)
- 		printf("0x%08" PRIX32 "\n", cookie);
-@@ -1530,7 +1528,7 @@ static int _udevcreatecookie(CMD_ARGS)
- static int _udevreleasecookie(CMD_ARGS)
- {
- 	if (argv[0] && !(_udev_cookie = _get_cookie_value(argv[0])))
--		return 0;
-+		return_0;
- 
- 	if (!_udev_cookie) {
- 		log_error("No udev transaction cookie given.");
-@@ -1686,7 +1684,7 @@ static int _version(CMD_ARGS)
- 		printf("Library version:   %s\n", version);
- 
- 	if (!dm_driver_version(version, sizeof(version)))
--		return 0;
-+		return_0;
- 
- 	printf("Driver version:    %s\n", version);
- 
-@@ -1710,37 +1708,37 @@ static int _simple(int task, const char *name, uint32_t event_nr, int display)
- 	struct dm_task *dmt;
- 
- 	if (!(dmt = dm_task_create(task)))
--		return 0;
-+		return_0;
- 
- 	if (!_set_task_device(dmt, name, 0))
--		goto out;
-+		goto_out;
- 
- 	if (event_nr && !dm_task_set_event_nr(dmt, event_nr))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[NOFLUSH_ARG] && !dm_task_no_flush(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[INACTIVE_ARG] && !dm_task_query_inactive_table(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[NOLOCKFS_ARG] && !dm_task_skip_lockfs(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
--		goto out;
-+		goto_out;
- 
- 	/* FIXME: needs to coperate with udev */
- 	if (!_set_task_add_node(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[READAHEAD_ARG] &&
- 	    !dm_task_set_read_ahead(dmt, _int_args[READAHEAD_ARG],
- 				    _read_ahead_flags))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[NOUDEVRULES_ARG])
- 		udev_flags |= DM_UDEV_DISABLE_DM_RULES_FLAG |
-@@ -1753,7 +1751,7 @@ static int _simple(int task, const char *name, uint32_t event_nr, int display)
- 		udev_flags |= DM_UDEV_DISABLE_LIBRARY_FALLBACK;
- 
- 	if (udev_wait_flag && !dm_task_set_cookie(dmt, &cookie, udev_flags))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[RETRY_ARG] && task == DM_DEVICE_REMOVE)
- 		dm_task_retry_remove(dmt);
-@@ -1763,7 +1761,7 @@ static int _simple(int task, const char *name, uint32_t event_nr, int display)
- 
- 	r = _task_run(dmt);
- 
--      out:
-+out:
- 	if (!_udev_cookie && udev_wait_flag)
- 		(void) dm_udev_wait(cookie);
- 
-@@ -1817,19 +1815,19 @@ static int _process_all(const struct command *cmd, const char *subcommand, int a
- 	struct dm_task *dmt;
- 
- 	if (!(dmt = dm_task_create(DM_DEVICE_LIST)))
--		return 0;
-+		return_0;
- 
- 	if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (!_task_run(dmt)) {
- 		r = 0;
--		goto out;
-+		goto_out;
- 	}
- 
- 	if (!(names = dm_task_get_names(dmt))) {
- 		r = 0;
--		goto out;
-+		goto_out;
- 	}
- 
- 	if (!names->dev) {
-@@ -1845,7 +1843,7 @@ static int _process_all(const struct command *cmd, const char *subcommand, int a
- 		next = names->next;
- 	} while (next);
- 
--      out:
-+out:
- 	dm_task_destroy(dmt);
- 	return r;
- }
-@@ -1859,25 +1857,25 @@ static uint64_t _get_device_size(const char *name)
- 	void *next = NULL;
- 
- 	if (!(dmt = dm_task_create(DM_DEVICE_TABLE)))
--		return 0;
-+		return_0;
- 
- 	if (!_set_task_device(dmt, name, 0))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[INACTIVE_ARG] && !dm_task_query_inactive_table(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (!_task_run(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (!dm_task_get_info(dmt, &info) || !info.exists)
--		goto out;
-+		goto_out;
- 
- 	do {
- 		next = dm_get_next_target(dmt, next, &start, &length,
-@@ -1885,7 +1883,7 @@ static uint64_t _get_device_size(const char *name)
- 		size += length;
- 	} while (next);
- 
--      out:
-+out:
- 	dm_task_destroy(dmt);
- 	return size;
- }
-@@ -1902,37 +1900,37 @@ static int _error_device(CMD_ARGS)
- 	size = _get_device_size(name);
- 
- 	if (!(dmt = dm_task_create(DM_DEVICE_RELOAD)))
--		return 0;
-+		return_0;
- 
- 	if (!_set_task_device(dmt, name, 0))
--		goto error;
-+		goto_bad;
- 
- 	if (!dm_task_add_target(dmt, UINT64_C(0), size, "error", ""))
--		goto error;
-+		goto_bad;
- 
- 	if (_switches[READ_ONLY] && !dm_task_set_ro(dmt))
--		goto error;
-+		goto_bad;
- 
- 	if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
--		goto error;
-+		goto_bad;
- 
- 	if (_switches[INACTIVE_ARG] && !dm_task_query_inactive_table(dmt))
--		goto error;
-+		goto_bad;
- 
- 	if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
--		goto error;
-+		goto_bad;
- 
- 	if (!_task_run(dmt))
--		goto error;
-+		goto_bad;
- 
- 	if (!_simple(DM_DEVICE_RESUME, name, 0, 0)) {
- 		_simple(DM_DEVICE_CLEAR, name, 0, 0);
--		goto error;
-+		goto_bad;
- 	}
- 
- 	r = 1;
- 
--error:
-+bad:
- 	dm_task_destroy(dmt);
- 	return r;
- }
-@@ -2013,14 +2011,14 @@ static int _exec_command(const char *name)
- 	pid_t pid;
- 
- 	if (argc < 0)
--		return 0;
-+		return_0;
- 
- 	if (!dm_mknodes(name))
--		return 0;
-+		return_0;
- 
- 	n = snprintf(path, sizeof(path), "%s/%s", dm_dir(), name);
- 	if (n < 0 || n > (int) sizeof(path) - 1)
--		return 0;
-+		return_0;
- 
- 	if (!argc) {
- 		c = _command_to_exec;
-@@ -2038,7 +2036,7 @@ static int _exec_command(const char *name)
- 
- 		if (!argc) {
- 			argc = -1;
--			return 0;
-+			return_0;
- 		}
- 
- 		if (argc == ARGS_MAX) {
-@@ -2093,28 +2091,28 @@ static int _status(CMD_ARGS)
- 		ls_only = 1;
- 
- 	if (!(dmt = dm_task_create(cmdno)))
--		return 0;
-+		return_0;
- 
- 	if (!_set_task_device(dmt, name, 0))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[INACTIVE_ARG] && !dm_task_query_inactive_table(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[NOFLUSH_ARG] && !dm_task_no_flush(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (!_task_run(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (!dm_task_get_info(dmt, &info) || !info.exists)
--		goto out;
-+		goto_out;
- 
- 	if (!name)
- 		name = dm_task_get_name(dmt);
-@@ -2163,11 +2161,11 @@ static int _status(CMD_ARGS)
- 		printf("\n");
- 
- 	if (matched && _switches[EXEC_ARG] && _command_to_exec && !_exec_command(name))
--		goto out;
-+		goto_out;
- 
- 	r = 1;
- 
--      out:
-+out:
- 	dm_task_destroy(dmt);
- 	return r;
- }
-@@ -2181,13 +2179,13 @@ static int _targets(CMD_ARGS)
- 	struct dm_versions *last_target;
- 
- 	if (!(dmt = dm_task_create(DM_DEVICE_LIST_VERSIONS)))
--		return 0;
-+		return_0;
- 
- 	if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (!_task_run(dmt))
--		goto out;
-+		goto_out;
- 
- 	target = dm_task_get_versions(dmt);
- 
-@@ -2203,7 +2201,7 @@ static int _targets(CMD_ARGS)
- 
- 	r = 1;
- 
--      out:
-+out:
- 	dm_task_destroy(dmt);
- 	return r;
- }
-@@ -2224,26 +2222,26 @@ static int _info(CMD_ARGS)
- 	}
- 
- 	if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
--		return 0;
-+		return_0;
- 
- 	if (!_set_task_device(dmt, name, 0))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[INACTIVE_ARG] && !dm_task_query_inactive_table(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (!_task_run(dmt))
--		goto out;
-+		goto_out;
- 
- 	r = _display_info(dmt);
- 
--      out:
-+out:
- 	dm_task_destroy(dmt);
- 	return r;
- }
-@@ -2268,28 +2266,28 @@ static int _deps(CMD_ARGS)
- 	}
- 
- 	if (!(dmt = dm_task_create(DM_DEVICE_DEPS)))
--		return 0;
-+		return_0;
- 
- 	if (!_set_task_device(dmt, name, 0))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[INACTIVE_ARG] && !dm_task_query_inactive_table(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (!_task_run(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (!dm_task_get_info(dmt, &info))
--		goto out;
-+		goto_out;
- 
- 	if (!(deps = dm_task_get_deps(dmt)))
--		goto out;
-+		goto_out;
- 
- 	if (!info.exists) {
- 		printf("Device does not exist.\n");
-@@ -2322,7 +2320,7 @@ static int _deps(CMD_ARGS)
- 
- 	r = 1;
- 
--      out:
-+out:
- 	dm_task_destroy(dmt);
- 	return r;
- }
-@@ -2670,7 +2668,7 @@ static int _add_dep(CMD_ARGS)
- {
- 	if (names &&
- 	    !dm_tree_add_dev(_dtree, (unsigned) MAJOR(names->dev), (unsigned) MINOR(names->dev)))
--		return 0;
-+		return_0;
- 
- 	return 1;
- }
-@@ -2684,10 +2682,10 @@ static int _build_whole_deptree(const struct command *cmd)
- 		return 1;
- 
- 	if (!(_dtree = dm_tree_create()))
--		return 0;
-+		return_0;
- 
- 	if (!_process_all(cmd, NULL, 0, NULL, 0, _add_dep))
--		return 0;
-+		return_0;
- 
- 	return 1;
- }
-@@ -2695,7 +2693,7 @@ static int _build_whole_deptree(const struct command *cmd)
- static int _display_tree(CMD_ARGS)
- {
- 	if (!_build_whole_deptree(cmd))
--		return 0;
-+		return_0;
- 
- 	_display_tree_walk_children(dm_tree_find_node(_dtree, 0, 0), 0);
- 
-@@ -2732,7 +2730,7 @@ static int _show_units(void)
- {
- 	/* --nosuffix overrides --units */
- 	if (_switches[NOSUFFIX_ARG])
--		return 0;
-+		return_0;
- 
- 	return (_int_args[UNITS_ARG]) ? 1 : 0;
- }
-@@ -2944,8 +2942,10 @@ static int _dm_info_devno_disp(struct dm_report *rh, struct dm_pool *mem,
- 
- 	if (private) {
- 		if (!dm_device_get_name(info->major, info->minor,
--					1, buf, PATH_MAX))
-+					1, buf, PATH_MAX)) {
-+			stack;
- 			goto out_abandon;
-+		}
- 	}
- 	else {
- 		if (dm_snprintf(buf, sizeof(buf), "%d:%d",
-@@ -4375,7 +4375,7 @@ static int _report_init(const struct command *cmd, const char *subcommand)
- 	if (!(_report = dm_report_init_with_selection(&_report_type, _report_types,
- 				_report_fields, options, separator, flags, keys,
- 				selection, NULL, NULL)))
--		goto out;
-+		goto_out;
- 
- 	if ((_report_type & DR_TREE) && !_build_whole_deptree(cmd)) {
- 		err("Internal device dependency tree creation failed.");
-@@ -4431,19 +4431,19 @@ static int _mangle(CMD_ARGS)
- 	}
- 
- 	if (!(dmt = dm_task_create(DM_DEVICE_STATUS)))
--		return 0;
-+		return_0;
- 
- 	if (!(_set_task_device(dmt, name, 0)))
--		goto out;
-+		goto_out;
- 
- 	if (!_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (!_task_run(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (!dm_task_get_info(dmt, &info) || !info.exists)
--		goto out;
-+		goto_out;
- 
- 	uuid = dm_task_get_uuid(dmt);
- 
-@@ -4465,15 +4465,15 @@ static int _mangle(CMD_ARGS)
- 
- 	if (target_format == DM_STRING_MANGLING_NONE) {
- 		if (!(new_name = dm_task_get_name_unmangled(dmt)))
--			goto out;
-+			goto_out;
- 		if (!(new_uuid = dm_task_get_uuid_unmangled(dmt)))
--			goto out;
-+			goto_out;
- 	}
- 	else {
- 		if (!(new_name = dm_task_get_name_mangled(dmt)))
--			goto out;
-+			goto_out;
- 		if (!(new_uuid = dm_task_get_uuid_mangled(dmt)))
--			goto out;
-+			goto_out;
- 	}
- 
- 	/* We can't rename the UUID, the device must be reactivated manually. */
-@@ -4508,13 +4508,13 @@ static int _stats(CMD_ARGS);
- static int _bind_stats_device(struct dm_stats *dms, const char *name)
- {
- 	if (name && !dm_stats_bind_name(dms, name))
--		return 0;
-+		return_0;
- 	else if (_switches[UUID_ARG] && !dm_stats_bind_uuid(dms, _uuid))
--		return 0;
-+		return_0;
- 	else if (_switches[MAJOR_ARG] && _switches[MINOR_ARG]
- 		 && !dm_stats_bind_devno(dms, _int_args[MAJOR_ARG],
- 					 _int_args[MINOR_ARG]))
--		return 0;
-+		return_0;
- 
- 	return 1;
- }
-@@ -4524,10 +4524,10 @@ static int _stats_clear_regions(struct dm_stats *dms, uint64_t region_id)
- 	int allregions = (region_id == DM_STATS_REGIONS_ALL);
- 
- 	if (!dm_stats_list(dms, NULL))
--		goto_out;
-+		return_0;
- 
- 	if (!dm_stats_get_nr_regions(dms))
--		goto done;
-+		return 1;
- 
- 	dm_stats_walk_do(dms) {
- 		if (allregions)
-@@ -4535,21 +4535,18 @@ static int _stats_clear_regions(struct dm_stats *dms, uint64_t region_id)
- 
- 		if (!dm_stats_region_present(dms, region_id)) {
- 			log_error("No such region: %"PRIu64".", region_id);
--			goto out;
-+			return 0;
- 		}
- 		if (!dm_stats_clear_region(dms, region_id)) {
- 			log_error("Clearing statistics region %"PRIu64" failed.",
- 				  region_id);
--			goto out;
-+			return 0;
- 		}
- 		log_info("Cleared statistics region %"PRIu64".", region_id);
- 		dm_stats_walk_next_region(dms);
- 	} dm_stats_walk_while(dms);
--done:
--	return 1;
- 
--out:
--	return 0;
-+	return 1;
- }
- 
- static int _stats_clear(CMD_ARGS)
-@@ -4611,7 +4608,7 @@ static int _size_from_string(char *argptr, uint64_t *size, const char *name)
- 	uint64_t factor;
- 	char *endptr = NULL, unit_type;
- 	if (!argptr)
--		return 0;
-+		return_0;
- 
- 	*size = strtoull(argptr, &endptr, 10);
- 	if (endptr == argptr) {
-@@ -4674,30 +4671,30 @@ static int _do_stats_create_regions(struct dm_stats *dms,
- 	void *next = NULL;
- 
- 	if (histogram && !(bounds = dm_histogram_bounds_from_string(histogram)))
--		return 0;
-+		return_0;
- 
- 	if (!(dmt = dm_task_create(DM_DEVICE_TABLE))) {
- 		dm_stats_destroy(dms);
--		return 0;
-+		return_0;
- 	}
- 
- 	if (!_set_task_device(dmt, name, 0))
--		goto out;
-+		goto_out;
- 
- 	if (!dm_task_no_open_count(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (!_task_run(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (!dm_task_get_info(dmt, &info) || !info.exists)
--		goto out;
-+		goto_out;
- 
- 	if (!(devname = dm_task_get_name(dmt)))
--		goto out;
-+		goto_out;
- 
- 	do {
- 		uint64_t segment_start, segment_len;
-@@ -4797,7 +4794,7 @@ static int _stats_create(CMD_ARGS)
- 	if (_switches[AREA_SIZE_ARG])
- 		if (!_size_from_string(_string_args[AREA_SIZE_ARG],
- 				       &area_size, "areasize"))
--			return 0;
-+			return_0;
- 
- 	areas = (areas) ? areas : 1;
- 	/* bytes to sectors or -(areas): promote to signed before conversion */
-@@ -4806,7 +4803,7 @@ static int _stats_create(CMD_ARGS)
- 	if (_switches[START_ARG]) {
- 		if (!_size_from_string(_string_args[START_ARG],
- 				       &start, "start"))
--			return 0;
-+			return_0;
- 	}
- 
- 	/* bytes to sectors */
-@@ -4815,7 +4812,7 @@ static int _stats_create(CMD_ARGS)
- 	if (_switches[LENGTH_ARG]) {
- 		if (!_size_from_string(_string_args[LENGTH_ARG],
- 				       &len, "length"))
--			return 0;
-+			return_0;
- 	}
- 
- 	/* bytes to sectors */
-@@ -4831,13 +4828,13 @@ static int _stats_create(CMD_ARGS)
- 
- 	dms = dm_stats_create(DM_STATS_PROGRAM_ID);
- 	if (!_bind_stats_device(dms, name))
--		goto_out;
-+		goto_bad;
- 
- 	if (_switches[PRECISE_ARG]) {
- 		if (!dm_stats_driver_supports_precise()) {
- 			log_error("Using --precise requires driver version "
- 				  "4.32.0 or later.");
--			goto out;
-+			goto bad;
- 		}
- 	}
- 
-@@ -4845,7 +4842,7 @@ static int _stats_create(CMD_ARGS)
- 		if (!dm_stats_driver_supports_histogram()) {
- 			log_error("Using --bounds requires driver version "
- 				  "4.32.0 or later.");
--			goto out;
-+			goto bad;
- 		}
- 	}
- 
-@@ -4857,7 +4854,7 @@ static int _stats_create(CMD_ARGS)
- 					_switches[SEGMENTS_ARG],
- 					program_id, aux_data);
- 
--out:
-+bad:
- 	dm_stats_destroy(dms);
- 	return 0;
- }
-@@ -4869,6 +4866,7 @@ static int _stats_delete(CMD_ARGS)
- 	char *name = NULL;
- 	const char *program_id = DM_STATS_PROGRAM_ID;
- 	int allregions = _switches[ALL_REGIONS_ARG];
-+	int r = 0;
- 
- 	/* delete does not use a report */
- 	if (_report) {
-@@ -4908,9 +4906,11 @@ static int _stats_delete(CMD_ARGS)
- 	if (allregions && !dm_stats_list(dms, program_id))
- 		goto_out;
- 
--	if (allregions && !dm_stats_get_nr_regions(dms))
-+	if (allregions && !dm_stats_get_nr_regions(dms)) {
- 		/* no regions present */
--		goto done;
-+		r = 1;
-+		goto out;
-+	}
- 
- 	dm_stats_walk_do(dms) {
- 		if (_switches[ALL_REGIONS_ARG])
-@@ -4923,13 +4923,11 @@ static int _stats_delete(CMD_ARGS)
- 		dm_stats_walk_next_region(dms);
- 	} dm_stats_walk_while(dms);
- 
--done:
--	dm_stats_destroy(dms);
--	return 1;
-+	r = 1;
- 
- out:
- 	dm_stats_destroy(dms);
--	return 0;
-+	return r;
- }
- 
- static int _stats_print(CMD_ARGS)
-@@ -4939,6 +4937,7 @@ static int _stats_print(CMD_ARGS)
- 	uint64_t region_id;
- 	unsigned clear = (unsigned) _switches[CLEAR_ARG];
- 	int allregions = _switches[ALL_REGIONS_ARG];
-+	int r = 0;
- 
- 	/* print does not use a report */
- 	if (_report) {
-@@ -4969,8 +4968,10 @@ static int _stats_print(CMD_ARGS)
- 	if (!dm_stats_list(dms, NULL))
- 		goto_out;
- 
--	if (allregions && !dm_stats_get_nr_regions(dms))
--		goto done;
-+	if (allregions && !dm_stats_get_nr_regions(dms)) {
-+		r = 1;
-+		goto out;
-+	}
- 
- 	dm_stats_walk_do(dms) {
- 		if (_switches[ALL_REGIONS_ARG])
-@@ -4994,13 +4995,11 @@ static int _stats_print(CMD_ARGS)
- 
- 	} dm_stats_walk_while(dms);
- 
--done:
--	dm_stats_destroy(dms);
--	return 1;
-+	r = 1;
- 
- out:
- 	dm_stats_destroy(dms);
--	return 0;
-+	return r;
- }
- 
- static int _stats_report(CMD_ARGS)
-@@ -5028,25 +5027,27 @@ static int _stats_report(CMD_ARGS)
- 	}
- 
- 	if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
--		return 0;
-+		return_0;
- 
- 	if (!_set_task_device(dmt, name, 0))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
--		goto out;
-+		goto_out;
- 
- 	if (!_task_run(dmt))
--		goto out;
-+		goto_out;
- 
- 	r = _display_info(dmt);
- 
--      out:
-+out:
- 	dm_task_destroy(dmt);
-+
- 	if (!r && _report) {
- 		dm_report_free(_report);
- 		_report = NULL;
- 	}
-+
- 	return r;
- }
- 
-@@ -5321,7 +5322,7 @@ static int _stats(CMD_ARGS)
- 	 */
- 	if (!stats_cmd->fn(stats_cmd, subcommand, argc, argv, NULL,
- 			   multiple_devices))
--		return 0;
-+		return_0;
- 
- 	return 1;
- }
-@@ -5418,35 +5419,35 @@ static char *parse_loop_device_name(const char *dev, const char *dev_dir)
- 	char *device = NULL;
- 
- 	if (!(buf = dm_malloc(PATH_MAX)))
--		return NULL;
-+		return_NULL;
- 
- 	if (dev[0] == '/') {
- 		if (!(device = _get_abspath(dev)))
--			goto error;
-+			goto_bad;
- 
- 		if (strncmp(device, dev_dir, strlen(dev_dir)))
--			goto error;
-+			goto_bad;
- 
- 		/* If dev_dir does not end in a slash, ensure that the
- 		   following byte in the device string is "/".  */
- 		if (dev_dir[strlen(dev_dir) - 1] != '/' &&
- 		    device[strlen(dev_dir)] != '/')
--			goto error;
-+			goto_bad;
- 
- 		if (!dm_strncpy(buf, strrchr(device, '/') + 1, PATH_MAX))
--			goto error;
-+			goto_bad;
- 		dm_free(device);
- 	} else {
- 		/* check for device number */
- 		if (strncmp(dev, "loop", sizeof("loop") - 1))
--			goto error;
-+			goto_bad;
- 
- 		if (!dm_strncpy(buf, dev, PATH_MAX))
--			goto error;
-+			goto_bad;
- 	}
- 
- 	return buf;
--error:
-+bad:
- 	dm_free(device);
- 	dm_free(buf);
- 
-@@ -5476,10 +5477,10 @@ static int _loop_table(char *table, size_t tlen, char *file,
- 	}
- 
- 	if (fd < 0)
--		goto error;
-+		goto_bad;
- 
- 	if (fstat(fd, &fbuf))
--		goto error;
-+		goto_bad;
- 
- 	size = (fbuf.st_size - off);
- 	sectors = size >> SECTOR_SHIFT;
-@@ -5491,7 +5492,7 @@ static int _loop_table(char *table, size_t tlen, char *file,
- 
- #ifdef HAVE_SYS_STATVFS_H
- 	if (fstatvfs(fd, &fsbuf))
--		goto error;
-+		goto_bad;
- 
- 	/* FIXME Fragment size currently unused */
- 	blksize = fsbuf.f_frsize;
-@@ -5502,18 +5503,18 @@ static int _loop_table(char *table, size_t tlen, char *file,
- 
- 	if (dm_snprintf(table, tlen, "%llu %llu loop %s %llu\n", 0ULL,
- 			(long long unsigned)sectors, file, (long long unsigned)off) < 0)
--		return 0;
-+		return_0;
- 
- 	if (_switches[VERBOSE_ARG] > 1)
- 		fprintf(stderr, "Table: %s\n", table);
- 
- 	return 1;
- 
--error:
-+bad:
- 	if (fd > -1 && close(fd))
- 		log_sys_error("close", file);
- 
--	return 0;
-+	return_0;
- }
- 
- static int _process_losetup_switches(const char *base, int *argcp, char ***argvp,
-@@ -5536,7 +5537,7 @@ static int _process_losetup_switches(const char *base, int *argcp, char ***argvp
- 	while ((c = GETOPTLONG_FN(*argcp, *argvp, "ade:fo:v",
- 				  long_options, NULL)) != -1 ) {
- 		if (c == ':' || c == '?')
--			return 0;
-+			return_0;
- 		if (c == 'a')
- 			show_all++;
- 		if (c == 'd')
-@@ -5836,7 +5837,7 @@ static int _process_switches(int *argcp, char ***argvp, const char *dev_dir)
- 			_string_args[AUX_DATA_ARG] = optarg;
- 		}
- 		if (c == ':' || c == '?')
--			return 0;
-+			return_0;
- 		if (c == 'h' || ind == HELP_ARG)
- 			_switches[HELP_ARG]++;
- 		if (ind == BOUNDS_ARG) {
-@@ -6201,7 +6202,7 @@ unknown:
- 
- #ifdef UDEV_SYNC_SUPPORT
- 	if (!_set_up_udev_support(dev_dir))
--		goto out;
-+		goto_out;
- #endif
- 
- 	/*
-@@ -6215,7 +6216,7 @@ unknown:
- 		subcommand = (char *) "";
- 
- 	if (_switches[COLS_ARG] && !_report_init(cmd, subcommand))
--		goto out;
-+		goto_out;
- 
- 	if (_switches[COUNT_ARG])
- 		_count = ((uint32_t)_int_args[COUNT_ARG]) ? : UINT32_MAX;
diff --git a/SOURCES/lvm2-2_02_131-swapping-of-lv-identifiers-handles-more-complex-lvs.patch b/SOURCES/lvm2-2_02_131-swapping-of-lv-identifiers-handles-more-complex-lvs.patch
deleted file mode 100644
index 9a7541f..0000000
--- a/SOURCES/lvm2-2_02_131-swapping-of-lv-identifiers-handles-more-complex-lvs.patch
+++ /dev/null
@@ -1,66 +0,0 @@
- WHATS_NEW              |  1 +
- tools/lvconvert.c      |  4 ++--
- tools/lvconvert_poll.c | 13 +++++++++----
- 3 files changed, 12 insertions(+), 6 deletions(-)
-
-diff --git a/WHATS_NEW b/WHATS_NEW
-index 9ddecbc..5260321 100644
---- a/WHATS_NEW
-+++ b/WHATS_NEW
-@@ -1,5 +1,6 @@
- Version 2.02.131 - 
- =====================================
-+  Swapping of LV identifiers handles more complex LVs.
-   Fix VG metadata comparison failure while scanning the VG for lvmetad.
-   Ignore persistent cache if configuration changed. (2.02.127)
- 
-diff --git a/tools/lvconvert.c b/tools/lvconvert.c
-index 2bffb07..919537a 100644
---- a/tools/lvconvert.c
-+++ b/tools/lvconvert.c
-@@ -2489,14 +2489,14 @@ deactivate_pmslv:
- 	if (!detach_pool_metadata_lv(first_seg(pool_lv), &mlv))
- 		return_0;
- 
-+	/* Swap _pmspare and _tmeta name */
- 	if (!swap_lv_identifiers(cmd, mlv, pmslv))
- 		return_0;
- 
--	/* Used _pmspare will become _tmeta */
- 	if (!attach_pool_metadata_lv(first_seg(pool_lv), pmslv))
- 		return_0;
- 
--	/* Used _tmeta will become visible  _meta%d */
-+	/* Used _tmeta (now _pmspare) becomes _meta%d */
- 	if (!lv_rename_update(cmd, mlv, pms_path, 0))
- 		return_0;
- 
-diff --git a/tools/lvconvert_poll.c b/tools/lvconvert_poll.c
-index e3a3709..1b230bc 100644
---- a/tools/lvconvert_poll.c
-+++ b/tools/lvconvert_poll.c
-@@ -44,15 +44,20 @@ int swap_lv_identifiers(struct cmd_context *cmd,
- 			struct logical_volume *a, struct logical_volume *b)
- {
- 	union lvid lvid;
--	const char *name;
-+	const char *aname = a->name, *bname = b->name;
- 
- 	lvid = a->lvid;
- 	a->lvid = b->lvid;
- 	b->lvid = lvid;
- 
--	name = a->name;
--	a->name = b->name;
--	if (!lv_rename_update(cmd, b, name, 0))
-+	/* rename temporarily to 'unused' name */
-+	if (!lv_rename_update(cmd, a, "pmove_tmeta", 0))
-+		return_0;
-+	/* name rename 'b' to unused name of 'a' */
-+	if (!lv_rename_update(cmd, b, aname, 0))
-+		return_0;
-+	/* finish name swapping */
-+	if (!lv_rename_update(cmd, a, bname, 0))
- 		return_0;
- 
- 	return 1;
diff --git a/SOURCES/lvm2-2_02_133-check-for-space-in-thin-pool-before-creating-new-thin.patch b/SOURCES/lvm2-2_02_133-check-for-space-in-thin-pool-before-creating-new-thin.patch
deleted file mode 100644
index a02d919..0000000
--- a/SOURCES/lvm2-2_02_133-check-for-space-in-thin-pool-before-creating-new-thin.patch
+++ /dev/null
@@ -1,51 +0,0 @@
- WHATS_NEW               |  4 ++++
- lib/metadata/lv_manip.c | 23 ++++++++++++++++++-----
- 2 files changed, 22 insertions(+), 5 deletions(-)
-
-diff --git a/WHATS_NEW b/WHATS_NEW
-index 1718c29..0fa6bb6 100644
---- a/WHATS_NEW
-+++ b/WHATS_NEW
-@@ -1,3 +1,7 @@
-+Version 2.02.133 - 
-+======================================
-+  Check for enough space in thin-pool in command before creating new thin.
-+
- Version 2.02.131 - 
- =====================================
-   Fix vgimportclone cache_dir path name (2.02.115).
-diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
-index 88c516b..32aa666 100644
---- a/lib/metadata/lv_manip.c
-+++ b/lib/metadata/lv_manip.c
-@@ -7038,12 +7038,25 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
- 			}
- 		}
- 
--		if (seg_is_thin_volume(lp) &&
--		    lv_is_new_thin_pool(pool_lv)) {
-+		if (seg_is_thin_volume(lp)) {
- 			thin_pool_was_active = lv_is_active(pool_lv);
--			if (!check_new_thin_pool(pool_lv))
--				return_NULL;
--			/* New pool is now inactive */
-+			if (lv_is_new_thin_pool(pool_lv)) {
-+				if (!check_new_thin_pool(pool_lv))
-+					return_NULL;
-+				/* New pool is now inactive */
-+			} else {
-+				if (!activate_lv_excl_local(cmd, pool_lv)) {
-+					log_error("Aborting. Failed to locally activate thin pool %s.",
-+						  display_lvname(pool_lv));
-+					return 0;
-+				}
-+				if (!pool_below_threshold(first_seg(pool_lv))) {
-+					log_error("Cannot create new thin volume, free space in "
-+						  "thin pool %s reached threshold.",
-+						  display_lvname(pool_lv));
-+					return NULL;
-+				}
-+			}
- 		}
- 
- 		if (seg_is_cache(lp) &&
diff --git a/SOURCES/lvm2-2_02_133-enforce-writethrough-mode-for-cleaner-policy.patch b/SOURCES/lvm2-2_02_133-enforce-writethrough-mode-for-cleaner-policy.patch
deleted file mode 100644
index 58a3359..0000000
--- a/SOURCES/lvm2-2_02_133-enforce-writethrough-mode-for-cleaner-policy.patch
+++ /dev/null
@@ -1,30 +0,0 @@
- WHATS_NEW_DM          | 4 ++++
- libdm/libdm-deptree.c | 3 ++-
- 2 files changed, 6 insertions(+), 1 deletion(-)
-
-diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
-index 9e30786..71b25ba 100644
---- a/WHATS_NEW_DM
-+++ b/WHATS_NEW_DM
-@@ -1,3 +1,7 @@
-+Version 1.02.110 - 
-+======================================
-+  Enforce writethrough mode for cleaner policy.
-+
- Version 1.02.108 - 
- =====================================
-   Do not check for full thin pool when activating without messages (1.02.107).
-diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
-index 7b7ca5b..fc79e33 100644
---- a/libdm/libdm-deptree.c
-+++ b/libdm/libdm-deptree.c
-@@ -3456,7 +3456,8 @@ int dm_tree_node_add_cache_target(struct dm_tree_node *node,
- 		return_0;
- 
- 	seg->data_block_size = data_block_size;
--	seg->flags = feature_flags;
-+	/* Enforce WriteThough mode for cleaner policy */
-+	seg->flags = (strcmp(policy_name, "cleaner") == 0) ? DM_CACHE_FEATURE_WRITETHROUGH : feature_flags;
- 	seg->policy_name = policy_name;
- 
- 	/* FIXME: better validation missing */
diff --git a/SOURCES/lvm2-2_02_135-fix-resize-of-full-thin-pool-causing-data-loss.patch b/SOURCES/lvm2-2_02_135-fix-resize-of-full-thin-pool-causing-data-loss.patch
deleted file mode 100644
index e297080..0000000
--- a/SOURCES/lvm2-2_02_135-fix-resize-of-full-thin-pool-causing-data-loss.patch
+++ /dev/null
@@ -1,204 +0,0 @@
-commit 8aa13d867d8c707450bb1de1479e18a3bbbc324a
-Author: Peter Rajnoha <prajnoha@redhat.com>
-Date:   Tue Dec 1 13:10:31 2015 +0100
-
-    bz1274676
----
- lib/activate/dev_manager.c            | 11 ++++--
- libdm/.exported_symbols.Base          |  1 -
- libdm/.exported_symbols.DM_1_02_107   |  1 +
- libdm/libdevmapper.h                  |  5 +++
- libdm/libdm-deptree.c                 | 25 ++++++++++++--
- test/shell/lvextend-thin-bz1274676.sh | 63 +++++++++++++++++++++++++++++++++++
- 6 files changed, 100 insertions(+), 6 deletions(-)
-
-diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
-index c8e9589..e1f547f 100644
---- a/lib/activate/dev_manager.c
-+++ b/lib/activate/dev_manager.c
-@@ -3277,7 +3277,7 @@ static int _tree_action(struct dev_manager *dm, const struct logical_volume *lv,
- 		break;
- 	case SUSPEND:
- 		dm_tree_skip_lockfs(root);
--		if (!dm->flush_required && lv_is_mirror(lv) && !lv_is_pvmove(lv))
-+		if (!dm->flush_required && !lv_is_pvmove(lv))
- 			dm_tree_use_no_flush_suspend(root);
- 		/* Fall through */
- 	case SUSPEND_WITH_LOCKFS:
-@@ -3296,7 +3296,14 @@ static int _tree_action(struct dev_manager *dm, const struct logical_volume *lv,
- 		if (!dm_tree_preload_children(root, dlid, DLID_SIZE))
- 			goto_out;
- 
--		if (dm_tree_node_size_changed(root))
-+		if ((dm_tree_node_size_changed(root) < 0))
-+			dm->flush_required = 1;
-+
-+		/* Currently keep the code require flush for any
-+		 * non 'thin pool/volume, mirror' or with any size change */
-+		if (!lv_is_thin_volume(lv) &&
-+		    !lv_is_thin_pool(lv) &&
-+		    (!lv_is_mirror(lv) || dm_tree_node_size_changed(root)))
- 			dm->flush_required = 1;
- 
- 		if (action == ACTIVATE) {
-diff --git a/libdm/.exported_symbols.Base b/libdm/.exported_symbols.Base
-index f9c3cb1..27fef53 100644
---- a/libdm/.exported_symbols.Base
-+++ b/libdm/.exported_symbols.Base
-@@ -262,7 +262,6 @@ dm_tree_node_set_thin_external_origin
- dm_tree_node_set_thin_pool_discard
- dm_tree_node_set_thin_pool_error_if_no_space
- dm_tree_node_set_udev_flags
--dm_tree_node_size_changed
- dm_tree_preload_children
- dm_tree_retry_remove
- dm_tree_set_cookie
-diff --git a/libdm/.exported_symbols.DM_1_02_107 b/libdm/.exported_symbols.DM_1_02_107
-index 89d3464..0c7b7af 100644
---- a/libdm/.exported_symbols.DM_1_02_107
-+++ b/libdm/.exported_symbols.DM_1_02_107
-@@ -13,3 +13,4 @@ dm_stats_create_region
- dm_stats_driver_supports_histogram
- dm_stats_get_histogram
- dm_stats_get_region_nr_histogram_bins
-+dm_tree_node_size_changed
-diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
-index 098fa85..8d4b096 100644
---- a/libdm/libdevmapper.h
-+++ b/libdm/libdevmapper.h
-@@ -1252,6 +1252,11 @@ const char *dm_tree_node_get_name(const struct dm_tree_node *node);
- const char *dm_tree_node_get_uuid(const struct dm_tree_node *node);
- const struct dm_info *dm_tree_node_get_info(const struct dm_tree_node *node);
- void *dm_tree_node_get_context(const struct dm_tree_node *node);
-+/*
-+ * Returns  0 when node size and its children is unchanged.
-+ * Returns  1 when node or any of its children has increased size.
-+ * Rerurns -1 when node or any of its children has reduced size.
-+ */
- int dm_tree_node_size_changed(const struct dm_tree_node *dnode);
- 
- /*
-diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
-index fc79e33..0584079 100644
---- a/libdm/libdm-deptree.c
-+++ b/libdm/libdm-deptree.c
-@@ -220,7 +220,7 @@ struct load_properties {
- 	uint32_t read_ahead_flags;
- 
- 	unsigned segment_count;
--	unsigned size_changed;
-+	int size_changed;
- 	struct dm_list segs;
- 
- 	const char *new_name;
-@@ -2768,7 +2768,8 @@ static int _load_node(struct dm_tree_node *dnode)
- 
- 		existing_table_size = dm_task_get_existing_table_size(dmt);
- 		if ((dnode->props.size_changed =
--		     (existing_table_size == seg_start) ? 0 : 1)) {
-+		     (existing_table_size == seg_start) ? 0 :
-+		     (existing_table_size > seg_start) ? -1 : 1)) {
- 			/*
- 			 * Kernel usually skips size validation on zero-length devices
- 			 * now so no need to preload them.
-@@ -2864,8 +2865,10 @@ int dm_tree_preload_children(struct dm_tree_node *dnode,
- 		}
- 
- 		/* Propagate device size change change */
--		if (child->props.size_changed)
-+		if (child->props.size_changed > 0 && !dnode->props.size_changed)
- 			dnode->props.size_changed = 1;
-+		else if (child->props.size_changed < 0)
-+			dnode->props.size_changed = -1;
- 
- 		/* Resume device immediately if it has parents and its size changed */
- 		if (!dm_tree_node_num_children(child, 1) || !child->props.size_changed)
-@@ -4190,3 +4193,19 @@ void dm_tree_node_set_callback(struct dm_tree_node *dnode,
- 	dnode->callback = cb;
- 	dnode->callback_data = data;
- }
-+
-+/*
-+ * Backward compatible dm_tree_node_size_changed() implementations.
-+ *
-+ * Keep these at the end of the file to avoid adding clutter around the
-+ * current dm_tree_node_size_changed() version.
-+ */
-+#if defined(__GNUC__)
-+int dm_tree_node_size_changed_base(const struct dm_tree_node *dnode);
-+DM_EXPORT_SYMBOL_BASE(dm_tree_node_size_changed);
-+int dm_tree_node_size_changed_base(const struct dm_tree_node *dnode)
-+{
-+	/* Base does not make difference between smaller and bigger */
-+	return dm_tree_node_size_changed(dnode) ? 1 : 0;
-+}
-+#endif
-diff --git a/test/shell/lvextend-thin-bz1274676.sh b/test/shell/lvextend-thin-bz1274676.sh
-new file mode 100644
-index 0000000..facace0
---- /dev/null
-+++ b/test/shell/lvextend-thin-bz1274676.sh
-@@ -0,0 +1,63 @@
-+#!/bin/bash
-+# Copyright (C) 2015 Red Hat, Inc. All rights reserved.
-+#
-+# This copyrighted material is made available to anyone wishing to use,
-+# modify, copy, or redistribute it subject to the terms and conditions
-+# of the GNU General Public License v.2.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program; if not, write to the Free Software Foundation,
-+# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-+
-+# ensure there is no data loss during thin-pool resize
-+
-+export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false}
-+
-+. lib/inittest
-+
-+test -e LOCAL_LVMPOLLD && skip
-+
-+which md5sum || skip
-+
-+aux have_thin 1 0 0 || skip
-+
-+aux prepare_pvs 2 20
-+
-+vgcreate -s 512K $vg $(< DEVICES)
-+
-+lvcreate -L1M -V2M -n $lv1 -T $vg/pool
-+
-+# just ensure we check what we need to check
-+check lv_field $vg/pool size "1.00m"
-+check lv_field $vg/$lv1 size "2.00m"
-+
-+# prepare 2097152  file content
-+seq 0 315465 > 2M
-+md5sum 2M | cut -f 1 -d ' ' | tee MD5
-+dd if=2M of="$DM_DEV_DIR/mapper/$vg-$lv1" bs=512K conv=fdatasync 2>&1 >log &
-+#dd if=2M of="$DM_DEV_DIR/mapper/$vg-$lv1" bs=2M oflag=direct &
-+
-+# give it some time to fill thin-volume
-+# eventually loop to wait for 100% full pool...
-+sleep .1
-+lvs -a $vg
-+
-+# this must not 'block & wait' on suspending flush
-+# if it waits on thin-pool's target timeout
-+# it will harm queued data
-+lvextend -L+512k $vg/pool
-+lvextend -L+512k $vg/pool
-+
-+# collect 'dd' result
-+wait
-+cat log
-+
-+lvs -a $vg
-+
-+dd if="$DM_DEV_DIR/mapper/$vg-$lv1" of=2M-2 iflag=direct
-+md5sum 2M-2 | cut -f 1 -d ' '  | tee MD5-2
-+
-+# these 2 are supposed to match
-+diff MD5  MD5-2
-+
-+vgremove -f $vg
diff --git a/SOURCES/lvm2-2_02_140-restore-background-polling-processing-during-auto-activation.patch b/SOURCES/lvm2-2_02_140-restore-background-polling-processing-during-auto-activation.patch
deleted file mode 100644
index 0ef7cb7..0000000
--- a/SOURCES/lvm2-2_02_140-restore-background-polling-processing-during-auto-activation.patch
+++ /dev/null
@@ -1,74 +0,0 @@
- WHATS_NEW        | 4 ++++
- tools/pvscan.c   | 9 +++++++++
- tools/tools.h    | 2 ++
- tools/vgchange.c | 4 ++--
- 4 files changed, 17 insertions(+), 2 deletions(-)
-
-diff --git a/WHATS_NEW b/WHATS_NEW
-index 945b282..8c87a92 100644
---- a/WHATS_NEW
-+++ b/WHATS_NEW
-@@ -2,6 +2,10 @@ Version 2.02.142 -
- ====================================
-   Do not check for suspended devices if scanning for lvmetad update.
- 
-+Version 2.02.140 -
-+===================================
-+  Restore background polling processing during auto-activation (2.02.119).
-+
- Version 2.02.133 - 
- ======================================
-   Check for enough space in thin-pool in command before creating new thin.
-diff --git a/tools/pvscan.c b/tools/pvscan.c
-index 3adb91c..b3b5911 100644
---- a/tools/pvscan.c
-+++ b/tools/pvscan.c
-@@ -154,6 +154,15 @@ static int _auto_activation_handler(struct cmd_context *cmd,
- 		goto out;
- 	}
- 
-+	/*
-+	 * After sucessfull activation we need to initialise polling
-+	 * for all activated LVs in a VG. Possible enhancement would
-+	 * be adding --poll y|n cmdline option for pvscan and call
-+	 * init_background_polling routine in autoactivation handler.
-+	 */
-+	if (!(vgchange_background_polling(vg->cmd, vg)))
-+		goto_out;
-+
- 	r = 1;
- 
- out:
-diff --git a/tools/tools.h b/tools/tools.h
-index 4ed893f..634b101 100644
---- a/tools/tools.h
-+++ b/tools/tools.h
-@@ -183,4 +183,6 @@ int mirror_remove_missing(struct cmd_context *cmd,
- int vgchange_activate(struct cmd_context *cmd, struct volume_group *vg,
- 		       activation_change_t activate);
- 
-+int vgchange_background_polling(struct cmd_context *cmd, struct volume_group *vg);
-+
- #endif
-diff --git a/tools/vgchange.c b/tools/vgchange.c
-index 1d3c64a..d572220 100644
---- a/tools/vgchange.c
-+++ b/tools/vgchange.c
-@@ -174,7 +174,7 @@ static int _vgchange_monitoring(struct cmd_context *cmd, struct volume_group *vg
- 	return r;
- }
- 
--static int _vgchange_background_polling(struct cmd_context *cmd, struct volume_group *vg)
-+int vgchange_background_polling(struct cmd_context *cmd, struct volume_group *vg)
- {
- 	int polled;
- 
-@@ -999,7 +999,7 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
- 
- 	if (!arg_count(cmd, refresh_ARG) &&
- 	    background_polling())
--		if (!_vgchange_background_polling(cmd, vg))
-+		if (!vgchange_background_polling(cmd, vg))
- 			return_ECMD_FAILED;
- 
- 	if (arg_is_set(cmd, lockstart_ARG)) {
diff --git a/SOURCES/lvm2-2_02_142-do-not-check-for-suspended-devices-if-scanning-for-lvmetad-update.patch b/SOURCES/lvm2-2_02_142-do-not-check-for-suspended-devices-if-scanning-for-lvmetad-update.patch
deleted file mode 100644
index 6e6fb41..0000000
--- a/SOURCES/lvm2-2_02_142-do-not-check-for-suspended-devices-if-scanning-for-lvmetad-update.patch
+++ /dev/null
@@ -1,37 +0,0 @@
- WHATS_NEW                   | 4 ++++
- lib/filters/filter-usable.c | 9 +--------
- 2 files changed, 5 insertions(+), 8 deletions(-)
-
-diff --git a/WHATS_NEW b/WHATS_NEW
-index 0fa6bb6..945b282 100644
---- a/WHATS_NEW
-+++ b/WHATS_NEW
-@@ -1,3 +1,7 @@
-+Version 2.02.142 - 
-+====================================
-+  Do not check for suspended devices if scanning for lvmetad update.
-+
- Version 2.02.133 - 
- ======================================
-   Check for enough space in thin-pool in command before creating new thin.
-diff --git a/lib/filters/filter-usable.c b/lib/filters/filter-usable.c
-index 9377661..b24a30c 100644
---- a/lib/filters/filter-usable.c
-+++ b/lib/filters/filter-usable.c
-@@ -126,15 +126,8 @@ static int _passes_usable_filter(struct dev_filter *f, struct device *dev)
- 			break;
- 		case FILTER_MODE_PRE_LVMETAD:
- 			ucp.check_empty = 1;
--			/*
--			 * If we're scanning for lvmetad update,
--			 * we don't want to hang on blocked/suspended devices.
--			 * When the device is unblocked/resumed, surely,
--			 * there's going to be a CHANGE event so the device
--			 * gets scanned via udev rule anyway after resume.
--			 */
- 			ucp.check_blocked = 1;
--			ucp.check_suspended = 1;
-+			ucp.check_suspended = 0;
- 			ucp.check_error_target = 1;
- 			ucp.check_reserved = 1;
- 			break;
diff --git a/SOURCES/lvm2-2_02_155-fix-flushing-for-mirror-target.patch b/SOURCES/lvm2-2_02_155-fix-flushing-for-mirror-target.patch
deleted file mode 100644
index 5ecd0a8..0000000
--- a/SOURCES/lvm2-2_02_155-fix-flushing-for-mirror-target.patch
+++ /dev/null
@@ -1,77 +0,0 @@
- WHATS_NEW                  |  4 ++++
- lib/activate/activate.c    | 10 ++++++++++
- lib/activate/dev_manager.c | 13 +++++++------
- 3 files changed, 21 insertions(+), 6 deletions(-)
-
-diff --git a/WHATS_NEW b/WHATS_NEW
-index 8c87a92..6441cc1 100644
---- a/WHATS_NEW
-+++ b/WHATS_NEW
-@@ -1,3 +1,7 @@
-+Version 2.02.155 - 
-+====================================
-+  Fix flushing for mirror target.
-+
- Version 2.02.142 - 
- ====================================
-   Do not check for suspended devices if scanning for lvmetad update.
-diff --git a/lib/activate/activate.c b/lib/activate/activate.c
-index 7d2adf1..8b0fcb3 100644
---- a/lib/activate/activate.c
-+++ b/lib/activate/activate.c
-@@ -1900,6 +1900,16 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
- 		}
- 	}
- 
-+	/* Flush is ATM required for the tested cases
-+	 * NOTE: Mirror repair requires noflush for proper repair!
-+	 * TODO: Relax this limiting condition further */
-+	if (!flush_required &&
-+	    (lv_is_pvmove(ondisk_lv) ||
-+	    (!lv_is_mirror(ondisk_lv) && !lv_is_thin_pool(ondisk_lv) && !lv_is_thin_volume(ondisk_lv)))) {
-+		log_debug("Requiring flush for LV %s.", display_lvname(ondisk_lv));
-+		flush_required = 1;
-+	}
-+
- 	if (!monitor_dev_for_events(cmd, ondisk_lv, laopts, 0))
- 		/* FIXME Consider aborting here */
- 		stack;
-diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
-index e1f547f..c95dfbe 100644
---- a/lib/activate/dev_manager.c
-+++ b/lib/activate/dev_manager.c
-@@ -3277,7 +3277,7 @@ static int _tree_action(struct dev_manager *dm, const struct logical_volume *lv,
- 		break;
- 	case SUSPEND:
- 		dm_tree_skip_lockfs(root);
--		if (!dm->flush_required && !lv_is_pvmove(lv))
-+		if (!dm->flush_required)
- 			dm_tree_use_no_flush_suspend(root);
- 		/* Fall through */
- 	case SUSPEND_WITH_LOCKFS:
-@@ -3298,12 +3298,11 @@ static int _tree_action(struct dev_manager *dm, const struct logical_volume *lv,
- 
- 		if ((dm_tree_node_size_changed(root) < 0))
- 			dm->flush_required = 1;
--
- 		/* Currently keep the code require flush for any
--		 * non 'thin pool/volume, mirror' or with any size change */
--		if (!lv_is_thin_volume(lv) &&
--		    !lv_is_thin_pool(lv) &&
--		    (!lv_is_mirror(lv) || dm_tree_node_size_changed(root)))
-+		 * non 'thin pool/volume' and  size increase */
-+		else if (!lv_is_thin_volume(lv) &&
-+			 !lv_is_thin_pool(lv) &&
-+			 dm_tree_node_size_changed(root))
- 			dm->flush_required = 1;
- 
- 		if (action == ACTIVATE) {
-@@ -3347,6 +3346,8 @@ int dev_manager_activate(struct dev_manager *dm, const struct logical_volume *lv
- int dev_manager_preload(struct dev_manager *dm, const struct logical_volume *lv,
- 			struct lv_activate_opts *laopts, int *flush_required)
- {
-+	dm->flush_required = *flush_required;
-+
- 	if (!_tree_action(dm, lv, laopts, PRELOAD))
- 		return_0;
- 
diff --git a/SOURCES/lvm2-2_02_167-disable-lvconvert-of-thin-pool-to-raid-while-active.patch b/SOURCES/lvm2-2_02_167-disable-lvconvert-of-thin-pool-to-raid-while-active.patch
new file mode 100644
index 0000000..3301d1b
--- /dev/null
+++ b/SOURCES/lvm2-2_02_167-disable-lvconvert-of-thin-pool-to-raid-while-active.patch
@@ -0,0 +1,32 @@
+ WHATS_NEW                 | 4 ++++
+ lib/metadata/raid_manip.c | 5 +++++
+ 2 files changed, 9 insertions(+)
+
+diff --git a/WHATS_NEW b/WHATS_NEW
+index 977e578..5cbf4ec 100644
+--- a/WHATS_NEW
++++ b/WHATS_NEW
+@@ -1,3 +1,7 @@
++Version 2.02.167 - 
++======================================
++  Disable lvconvert of thin pool to raid while active.
++
+ Version 2.02.166 - 26th September 2016
+ ======================================
+   Fix lvm2-activation-generator to read all LVM2 config sources. (2.02.155)
+diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
+index e5fdf4f..5fc520e 100644
+--- a/lib/metadata/raid_manip.c
++++ b/lib/metadata/raid_manip.c
+@@ -776,6 +776,11 @@ static int _raid_add_images_without_commit(struct logical_volume *lv,
+ 		return 0;
+ 	}
+ 
++	if (lv_is_active(lv_lock_holder(lv)) && (old_count == 1) && (lv_is_thin_pool_data(lv) || lv_is_thin_pool_metadata(lv))) {
++		log_error("Can't add image to active thin pool LV %s yet. Deactivate first.", display_lvname(lv));
++		return 0;
++	}
++
+ 	if (!archive(lv->vg))
+ 		return_0;
+ 
diff --git a/SOURCES/lvm2-default-allow-changes-with-duplicate-pvs.patch b/SOURCES/lvm2-default-allow-changes-with-duplicate-pvs.patch
new file mode 100644
index 0000000..aa05052
--- /dev/null
+++ b/SOURCES/lvm2-default-allow-changes-with-duplicate-pvs.patch
@@ -0,0 +1,30 @@
+ conf/example.conf.in  | 2 +-
+ lib/config/defaults.h | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/conf/example.conf.in b/conf/example.conf.in
+index b1a2a9c..8e68165 100644
+--- a/conf/example.conf.in
++++ b/conf/example.conf.in
+@@ -311,7 +311,7 @@ devices {
+ 	# or activating LVs in it while a PV appears on multiple devices.
+ 	# Enabling this setting allows the VG to be used as usual even with
+ 	# uncertain devices.
+-	allow_changes_with_duplicate_pvs = 0
++	allow_changes_with_duplicate_pvs = 1
+ }
+ 
+ # Configuration section allocation.
+diff --git a/lib/config/defaults.h b/lib/config/defaults.h
+index d988779..985c832 100644
+--- a/lib/config/defaults.h
++++ b/lib/config/defaults.h
+@@ -45,7 +45,7 @@
+ #define DEFAULT_DATA_ALIGNMENT_DETECTION 1
+ #define DEFAULT_ISSUE_DISCARDS 0
+ #define DEFAULT_PV_MIN_SIZE_KB 2048
+-#define DEFAULT_ALLOW_CHANGES_WITH_DUPLICATE_PVS 0
++#define DEFAULT_ALLOW_CHANGES_WITH_DUPLICATE_PVS 1
+ 
+ #define DEFAULT_LOCKING_LIB "liblvm2clusterlock.so"
+ #define DEFAULT_ERROR_WHEN_FULL 0
diff --git a/SOURCES/lvm2-drop-unavailable-libblkid-2_24-BLKID_SUBLKS_BADCSUM-for-signature-detection.patch b/SOURCES/lvm2-drop-unavailable-libblkid-2_24-BLKID_SUBLKS_BADCSUM-for-signature-detection.patch
index f90e258..949983d 100644
--- a/SOURCES/lvm2-drop-unavailable-libblkid-2_24-BLKID_SUBLKS_BADCSUM-for-signature-detection.patch
+++ b/SOURCES/lvm2-drop-unavailable-libblkid-2_24-BLKID_SUBLKS_BADCSUM-for-signature-detection.patch
@@ -4,10 +4,10 @@
  3 files changed, 13 insertions(+), 14 deletions(-)
 
 diff --git a/configure b/configure
-index 3d650a1..31ceb35 100755
+index 8253bfc..587b978 100755
 --- a/configure
 +++ b/configure
-@@ -11217,12 +11217,12 @@ if test -n "$BLKID_CFLAGS"; then
+@@ -11951,12 +11951,12 @@ if test -n "$BLKID_CFLAGS"; then
      pkg_cv_BLKID_CFLAGS="$BLKID_CFLAGS"
   elif test -n "$PKG_CONFIG"; then
      if test -n "$PKG_CONFIG" && \
@@ -23,7 +23,7 @@ index 3d650a1..31ceb35 100755
  		      test "x$?" != "x0" && pkg_failed=yes
  else
    pkg_failed=yes
-@@ -11234,12 +11234,12 @@ if test -n "$BLKID_LIBS"; then
+@@ -11968,12 +11968,12 @@ if test -n "$BLKID_LIBS"; then
      pkg_cv_BLKID_LIBS="$BLKID_LIBS"
   elif test -n "$PKG_CONFIG"; then
      if test -n "$PKG_CONFIG" && \
@@ -39,7 +39,7 @@ index 3d650a1..31ceb35 100755
  		      test "x$?" != "x0" && pkg_failed=yes
  else
    pkg_failed=yes
-@@ -11260,9 +11260,9 @@ else
+@@ -11994,9 +11994,9 @@ else
          _pkg_short_errors_supported=no
  fi
          if test $_pkg_short_errors_supported = yes; then
@@ -51,7 +51,7 @@ index 3d650a1..31ceb35 100755
          fi
  	# Put the nasty error message in config.log where it belongs
  	echo "$BLKID_PKG_ERRORS" >&5
-@@ -11270,7 +11270,7 @@ fi
+@@ -12004,7 +12004,7 @@ fi
  	if test "$BLKID_WIPING" = maybe; then
  				BLKID_WIPING=no
  			   else
@@ -60,7 +60,7 @@ index 3d650a1..31ceb35 100755
  			   fi
  elif test $pkg_failed = untried; then
       	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-@@ -11278,7 +11278,7 @@ $as_echo "no" >&6; }
+@@ -12012,7 +12012,7 @@ $as_echo "no" >&6; }
  	if test "$BLKID_WIPING" = maybe; then
  				BLKID_WIPING=no
  			   else
@@ -70,10 +70,10 @@ index 3d650a1..31ceb35 100755
  else
  	BLKID_CFLAGS=$pkg_cv_BLKID_CFLAGS
 diff --git a/configure.in b/configure.in
-index 21ce581..6f1cd5b 100644
+index 33b5c76..9ed6226 100644
 --- a/configure.in
 +++ b/configure.in
-@@ -1193,12 +1193,12 @@ AC_MSG_RESULT($BLKID_WIPING)
+@@ -1302,12 +1302,12 @@ AC_MSG_RESULT($BLKID_WIPING)
  
  if test "$BLKID_WIPING" != no; then
  	pkg_config_init
@@ -89,10 +89,10 @@ index 21ce581..6f1cd5b 100644
  	if test "$BLKID_WIPING" = yes; then
  		BLKID_PC="blkid"
 diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
-index 82e37e0..ebc8d82 100644
+index 0246c09..bae984a 100644
 --- a/lib/device/dev-type.c
 +++ b/lib/device/dev-type.c
-@@ -625,8 +625,7 @@ static int _wipe_known_signatures_with_blkid(struct device *dev, const char *nam
+@@ -703,8 +703,7 @@ static int _wipe_known_signatures_with_blkid(struct device *dev, const char *nam
  						 BLKID_SUBLKS_TYPE |
  						 BLKID_SUBLKS_USAGE |
  						 BLKID_SUBLKS_VERSION |
@@ -101,4 +101,4 @@ index 82e37e0..ebc8d82 100644
 +						 BLKID_SUBLKS_MAGIC);
  
  	while (!blkid_do_probe(probe)) {
- 		if ((r_wipe = _blkid_wipe(probe, dev, name, types_to_exclude, types_no_prompt, yes, force)) == 1)
+ 		if ((r_wipe = _blkid_wipe(probe, dev, name, types_to_exclude, types_no_prompt, yes, force)) == 1) {
diff --git a/SOURCES/lvm2-lvmlockd-tech-preview-warning.patch b/SOURCES/lvm2-lvmlockd-tech-preview-warning.patch
deleted file mode 100644
index e3d1eda..0000000
--- a/SOURCES/lvm2-lvmlockd-tech-preview-warning.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-commit dc1c96b8bebbd6bfe9b774fdb13f904f976f29bd
-Author: David Teigland <teigland@redhat.com>
-Date:   Thu Jul 2 13:45:38 2015 -0500
-
-    lvmlockd: tech preview notice
----
- tools/toollib.c | 7 +++++++
- 1 file changed, 7 insertions(+)
-
-diff --git a/tools/toollib.c b/tools/toollib.c
-index 6b8ce22..b8edaea 100644
---- a/tools/toollib.c
-+++ b/tools/toollib.c
-@@ -981,6 +981,13 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd,
- 		vp_new->clustered = 0;
- 
- 	log_debug("Setting lock_type to %s", vp_new->lock_type);
-+
-+	if (is_lockd_type(vp_new->lock_type)) {
-+		log_print("WARNING: shared lock type \"%s\" and lvmlockd are Technology Preview.", vp_new->lock_type);
-+		log_print("For more information on Technology Preview features, visit:");
-+		log_print("https://access.redhat.com/support/offerings/techpreview/");
-+	}
-+
- 	return 1;
- }
- 
diff --git a/SOURCES/lvm2-remove-mpath-device-handling-from-udev-rules.patch b/SOURCES/lvm2-remove-mpath-device-handling-from-udev-rules.patch
deleted file mode 100644
index 168603b..0000000
--- a/SOURCES/lvm2-remove-mpath-device-handling-from-udev-rules.patch
+++ /dev/null
@@ -1,18 +0,0 @@
- udev/10-dm.rules.in | 4 ----
- 1 file changed, 4 deletions(-)
-
-diff --git a/udev/10-dm.rules.in b/udev/10-dm.rules.in
-index 2755530..8d7a8ca 100644
---- a/udev/10-dm.rules.in
-+++ b/udev/10-dm.rules.in
-@@ -120,10 +120,6 @@ ENV{DM_UDEV_RULES_VSN}="2"
- 
- ENV{DM_UDEV_DISABLE_DM_RULES_FLAG}!="1", ENV{DM_NAME}=="?*", SYMLINK+="(DM_DIR)/$env{DM_NAME}"
- 
--# We have to ignore further rule application for inappropriate events
--# and devices. But still send the notification if cookie exists.
--ENV{DM_UUID}=="mpath-?*", ENV{DM_ACTION}=="PATH_FAILED", GOTO="dm_disable"
--
- # Avoid processing and scanning a DM device in the other (foreign)
- # rules if it is in suspended state. However, we still keep 'disk'
- # and 'DM subsystem' related rules enabled in this case.
diff --git a/SOURCES/lvm2-revert-fix-for-lvconvert-repair-for-raid-lvs.patch b/SOURCES/lvm2-revert-fix-for-lvconvert-repair-for-raid-lvs.patch
new file mode 100644
index 0000000..77869ae
--- /dev/null
+++ b/SOURCES/lvm2-revert-fix-for-lvconvert-repair-for-raid-lvs.patch
@@ -0,0 +1,323 @@
+ WHATS_NEW                                     |   1 -
+ daemons/dmeventd/plugins/raid/dmeventd_raid.c |  42 +++--------
+ lib/metadata/lv.c                             |   7 ++
+ lib/metadata/raid_manip.c                     |   2 +-
+ test/shell/lvconvert-repair-raid.sh           | 104 ++------------------------
+ tools/lvconvert.c                             |  19 +++++
+ 6 files changed, 41 insertions(+), 134 deletions(-)
+
+diff --git a/WHATS_NEW b/WHATS_NEW
+index 25f6742..977e578 100644
+--- a/WHATS_NEW
++++ b/WHATS_NEW
+@@ -3,7 +3,6 @@ Version 2.02.166 - 26th September 2016
+   Fix lvm2-activation-generator to read all LVM2 config sources. (2.02.155)
+   Fix lvchange-rebuild-raid.sh to cope with older target versions.
+   Use dm_config_parse_without_dup_node_check() to speedup metadata reading.
+-  Fix lvconvert --repair regression
+   Fix reported origin lv field for cache volumes. (2.02.133)
+   Always specify snapshot cow LV for monitoring not internal LV. (2.02.165)
+   Fix lvchange --discard|--zero for active thin-pool.
+diff --git a/daemons/dmeventd/plugins/raid/dmeventd_raid.c b/daemons/dmeventd/plugins/raid/dmeventd_raid.c
+index bec594a..770fbc6 100644
+--- a/daemons/dmeventd/plugins/raid/dmeventd_raid.c
++++ b/daemons/dmeventd/plugins/raid/dmeventd_raid.c
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (C) 2005-2016 Red Hat, Inc. All rights reserved.
++ * Copyright (C) 2005-2015 Red Hat, Inc. All rights reserved.
+  *
+  * This file is part of LVM2.
+  *
+@@ -13,20 +13,14 @@
+  */
+ 
+ #include "lib.h"
+-#include "defaults.h"
+ #include "dmeventd_lvm.h"
+ #include "libdevmapper-event.h"
+ 
+-/* Hold enough elements for the mximum number of RAID images */
+-#define	RAID_DEVS_ELEMS	((DEFAULT_RAID_MAX_IMAGES + 63) / 64)
+-
+ struct dso_state {
+ 	struct dm_pool *mem;
+ 	char cmd_lvscan[512];
+ 	char cmd_lvconvert[512];
+-	uint64_t raid_devs[RAID_DEVS_ELEMS];
+ 	int failed;
+-	int warned;
+ };
+ 
+ DM_EVENT_LOG_FN("raid")
+@@ -37,39 +31,20 @@ static int _process_raid_event(struct dso_state *state, char *params, const char
+ {
+ 	struct dm_status_raid *status;
+ 	const char *d;
+-	int dead = 0, r = 1;
+ 
+ 	if (!dm_get_status_raid(state->mem, params, &status)) {
+ 		log_error("Failed to process status line for %s.", device);
+ 		return 0;
+ 	}
+ 
+-	d = status->dev_health;
+-	while ((d = strchr(d, 'D'))) {
+-		uint32_t dev = (uint32_t)(d - status->dev_health);
+-
+-		if (!(state->raid_devs[dev / 64] & (1 << (dev % 64))))
+-			log_error("Device #%u of %s array, %s, has failed.",
+-				  dev, status->raid_type, device);
+-
+-		state->raid_devs[dev / 64] |= (1 << (dev % 64));
+-		d++;
+-		dead = 1;
+-	}
+-
+-	if (dead) {
+-		if (status->insync_regions < status->total_regions) {
+-			if (!state->warned)
+-				log_warn("WARNING: waiting for resynchronization to finish "
+-					 "before initiating repair on RAID device %s", device);
+-
+-			state->warned = 1;
+-			goto out; /* Not yet done syncing with accessible devices */
+-		}
+-
++	if ((d = strchr(status->dev_health, 'D'))) {
+ 		if (state->failed)
+ 			goto out; /* already reported */
+ 
++		log_error("Device #%d of %s array, %s, has failed.",
++			  (int)(d - status->dev_health),
++			  status->raid_type, device);
++
+ 		state->failed = 1;
+ 		if (!dmeventd_lvm2_run_with_lock(state->cmd_lvscan))
+ 			log_warn("WARNING: Re-scan of RAID device %s failed.", device);
+@@ -77,7 +52,8 @@ static int _process_raid_event(struct dso_state *state, char *params, const char
+ 		/* if repair goes OK, report success even if lvscan has failed */
+ 		if (!dmeventd_lvm2_run_with_lock(state->cmd_lvconvert)) {
+ 			log_info("Repair of RAID device %s failed.", device);
+-			r = 0;
++			dm_pool_free(state->mem, status);
++			return 0;
+ 		}
+ 	} else {
+ 		state->failed = 0;
+@@ -88,7 +64,7 @@ static int _process_raid_event(struct dso_state *state, char *params, const char
+ out:
+ 	dm_pool_free(state->mem, status);
+ 
+-	return r;
++	return 1;
+ }
+ 
+ void process_event(struct dm_task *dmt,
+diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
+index 70036f9..53a1044 100644
+--- a/lib/metadata/lv.c
++++ b/lib/metadata/lv.c
+@@ -988,6 +988,7 @@ int lv_mirror_image_in_sync(const struct logical_volume *lv)
+ int lv_raid_image_in_sync(const struct logical_volume *lv)
+ {
+ 	unsigned s;
++	dm_percent_t percent;
+ 	char *raid_health;
+ 	struct lv_segment *seg, *raid_seg = NULL;
+ 
+@@ -1017,6 +1018,12 @@ int lv_raid_image_in_sync(const struct logical_volume *lv)
+ 		return 0;
+ 	}
+ 
++	if (!lv_raid_percent(raid_seg->lv, &percent))
++		return_0;
++
++	if (percent == DM_PERCENT_100)
++		return 1;
++
+ 	/* Find out which sub-LV this is. */
+ 	for (s = 0; s < raid_seg->area_count; s++)
+ 		if (seg_lv(raid_seg, s) == lv)
+diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
+index deb88a2..e5fdf4f 100644
+--- a/lib/metadata/raid_manip.c
++++ b/lib/metadata/raid_manip.c
+@@ -3658,7 +3658,7 @@ static int _lv_raid_rebuild_or_replace(struct logical_volume *lv,
+ 		return 0;
+ 	}
+ 
+-	if (!_raid_in_sync(lv)) {
++	if (!mirror_in_sync() && !_raid_in_sync(lv)) {
+ 		log_error("Unable to replace devices in %s/%s while it is"
+ 			  " not in-sync.", lv->vg->name, lv->name);
+ 		return 0;
+diff --git a/test/shell/lvconvert-repair-raid.sh b/test/shell/lvconvert-repair-raid.sh
+index b51d8fe..1ef91c4 100644
+--- a/test/shell/lvconvert-repair-raid.sh
++++ b/test/shell/lvconvert-repair-raid.sh
+@@ -22,52 +22,11 @@ aux lvmconf 'allocation/maximise_cling = 0' \
+ 
+ aux prepare_vg 8
+ 
+-function delay
+-{
+-	for d in $(< DEVICES)
+-	do
+-		aux delay_dev "$d" 0 $1 $(get first_extent_sector "$d")
+-	done
+-}
+-
+ # It's possible small raid arrays do have problems with reporting in-sync.
+ # So try bigger size
+-RAID_SIZE=32
+-
+-# Fast sync and repair afterwards
+-delay 0
+-
+-# RAID1 dual-leg single replace after initial sync
+-lvcreate --type raid1 -m 1 -L $RAID_SIZE -n $lv1 $vg "$dev1" "$dev2"
+-aux wait_for_sync $vg $lv1
+-aux disable_dev "$dev2"
+-lvconvert -y --repair $vg/$lv1
+-vgreduce --removemissing $vg
+-aux enable_dev "$dev2"
+-vgextend $vg "$dev2"
+-lvremove -ff $vg/$lv1
+-
+-# Delayed sync to allow for repair during rebuild
+-delay 50
+-
+-# RAID1 triple-leg single replace during initial sync
+-lvcreate --type raid1 -m 2 -L $RAID_SIZE -n $lv1 $vg "$dev1" "$dev2" "$dev3"
+-aux disable_dev "$dev2" "$dev3"
+-not lvconvert -y --repair $vg/$lv1
+-aux wait_for_sync $vg $lv1
+-lvconvert -y --repair $vg/$lv1
+-vgreduce --removemissing $vg
+-aux enable_dev "$dev2" "$dev3"
+-vgextend $vg "$dev2" "$dev3"
+-lvremove -ff $vg/$lv1
+-
+-
+-# Larger RAID size possible for striped RAID
+ RAID_SIZE=64
+ 
+-# Fast sync and repair afterwards
+-delay 0
+-# RAID5 single replace after initial sync
++# RAID5 single replace
+ lvcreate --type raid5 -i 2 -L $RAID_SIZE -n $lv1 $vg "$dev1" "$dev2" "$dev3"
+ aux wait_for_sync $vg $lv1
+ aux disable_dev "$dev3"
+@@ -75,69 +34,16 @@ lvconvert -y --repair $vg/$lv1
+ vgreduce --removemissing $vg
+ aux enable_dev "$dev3"
+ vgextend $vg "$dev3"
+-lvremove -ff $vg/$lv1
++lvremove -ff $vg
+ 
+-# Delayed sync to allow for repair during rebuild
+-delay 50
+-
+-# RAID5 single replace during initial sync
+-lvcreate --type raid5 -i 2 -L $RAID_SIZE -n $lv1 $vg "$dev1" "$dev2" "$dev3"
+-aux disable_dev "$dev3"
+-not lvconvert -y --repair $vg/$lv1
+-aux wait_for_sync $vg $lv1
+-lvconvert -y --repair $vg/$lv1
+-vgreduce --removemissing $vg
+-aux enable_dev "$dev3"
+-vgextend $vg "$dev3"
+-lvremove -ff $vg/$lv1
+-
+-# Fast sync and repair afterwards
+-delay 0
+-
+-# RAID6 double replace after initial sync
++# RAID6 double replace
+ lvcreate --type raid6 -i 3 -L $RAID_SIZE -n $lv1 $vg \
+     "$dev1" "$dev2" "$dev3" "$dev4" "$dev5"
+ aux wait_for_sync $vg $lv1
+ aux disable_dev "$dev4" "$dev5"
+ lvconvert -y --repair $vg/$lv1
+ vgreduce --removemissing $vg
+-aux enable_dev "$dev4" "$dev5"
+-vgextend $vg "$dev4" "$dev5"
+-lvremove -ff $vg/$lv1
+-
+-# Delayed sync to allow for repair during rebuild
+-delay 50
+-
+-# RAID6 single replace after initial sync
+-lvcreate --type raid6 -i 3 -L $RAID_SIZE -n $lv1 $vg \
+-    "$dev1" "$dev2" "$dev3" "$dev4" "$dev5"
+-aux disable_dev "$dev4"
+-not lvconvert -y --repair $vg/$lv1
+-delay 0 # Fast sync and repair afterwards
+-aux disable_dev "$dev4" # Need to disable again after changing delay
+-aux wait_for_sync $vg $lv1
+-lvconvert -y --repair $vg/$lv1
+-vgreduce --removemissing $vg
+ aux enable_dev "$dev4"
+-vgextend $vg "$dev4"
+-lvremove -ff $vg/$lv1
+-
+-# Delayed sync to allow for repair during rebuild
+-delay 50
+-
+-# RAID10 single replace after initial sync
+-lvcreate --type raid10 -m 1 -i 2 -L $RAID_SIZE -n $lv1 $vg \
+-    "$dev1" "$dev2" "$dev3" "$dev4"
+-aux disable_dev "$dev4"
+-not lvconvert -y --repair $vg/$lv1
+-delay 0 # Fast sync and repair afterwards
+-aux disable_dev "$dev4" # Need to disable again after changing delay
+-aux disable_dev "$dev1"
+-aux wait_for_sync $vg $lv1
+-lvconvert -y --repair $vg/$lv1
+-vgreduce --removemissing $vg
+-aux enable_dev "$dev4"
+-vgextend $vg "$dev4"
+-lvremove -ff $vg/$lv1
+-
++aux enable_dev "$dev5"
++vgextend $vg "$dev4" "$dev5"
+ vgremove -ff $vg
+diff --git a/tools/lvconvert.c b/tools/lvconvert.c
+index 3607247..d1d21b6 100644
+--- a/tools/lvconvert.c
++++ b/tools/lvconvert.c
+@@ -1826,6 +1826,7 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
+ 	struct dm_list *failed_pvs;
+ 	struct cmd_context *cmd = lv->vg->cmd;
+ 	struct lv_segment *seg = first_seg(lv);
++	dm_percent_t sync_percent;
+ 
+ 	if (_linear_type_requested(lp->type_str)) {
+ 		if (arg_is_set(cmd, mirrors_ARG) && (arg_uint_value(cmd, mirrors_ARG, 0) != 0)) {
+@@ -1973,6 +1974,24 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
+ 			return 0;
+ 		}
+ 
++		if (!lv_raid_percent(lv, &sync_percent)) {
++			log_error("Unable to determine sync status of %s.",
++				  display_lvname(lv));
++			return 0;
++		}
++
++		if (sync_percent != DM_PERCENT_100) {
++			log_warn("WARNING: %s is not in-sync.", display_lvname(lv));
++			log_warn("WARNING: Portions of the array may be unrecoverable.");
++
++			/*
++			 * The kernel will not allow a device to be replaced
++			 * in an array that is not in-sync unless we override
++			 * by forcing the array to be considered "in-sync".
++			 */
++			init_mirror_in_sync(1);
++		}
++
+ 		_lvconvert_raid_repair_ask(cmd, lp, &replace);
+ 
+ 		if (replace) {
diff --git a/SOURCES/lvm2-rhel7.patch b/SOURCES/lvm2-rhel7.patch
index af0ec98..4b0c686 100644
--- a/SOURCES/lvm2-rhel7.patch
+++ b/SOURCES/lvm2-rhel7.patch
@@ -1,18 +1,18 @@
  VERSION    | 2 +-
  VERSION_DM | 2 +-
- 2 files changed, 2 insertions(+), 2 deletions(-)
+ 2 files changed, 2 insertions(+), 2 deletions(-) 
 
 diff --git a/VERSION b/VERSION
 index dd4e60e..39d6c15 100644
 --- a/VERSION
 +++ b/VERSION
 @@ -1 +1 @@
--2.02.130(2) (2015-09-05)
-+2.02.130(2)-RHEL7 (2016-06-09)
+-2.02.166(2) (2016-09-26)
++2.02.166(2)-RHEL7 (2016-09-28)
 diff --git a/VERSION_DM b/VERSION_DM
 index d53f47a..005fbd4 100644
 --- a/VERSION_DM
 +++ b/VERSION_DM
 @@ -1 +1 @@
--1.02.107 (2015-09-05)
-+1.02.107-RHEL7 (2016-06-09)
+-1.02.135 (2016-09-26)
++1.02.135-RHEL7 (2016-09-28)
diff --git a/SPECS/lvm2.spec b/SPECS/lvm2.spec
index 7e93790..83e0aba 100644
--- a/SPECS/lvm2.spec
+++ b/SPECS/lvm2.spec
@@ -1,58 +1,57 @@
-%define device_mapper_version 1.02.107
-
-%define enable_cache 1
-%define enable_cluster 1
-%define enable_cmirror 1
-%define enable_lvmetad 1
-%define enable_lvmlockd 1
-%define enable_lvmpolld 1
-%define enable_python 1
-%define enable_thin 1
-
-%define systemd_version 189-3
-%define dracut_version 002-18
-%define util_linux_version 2.23
-%define bash_version 4.0
-%define corosync_version 1.99.9-1
-%define resource_agents_version 3.9.5-25
-%define dlm_version 3.99.1-1
-%define libselinux_version 1.30.19-4
-%define persistent_data_version 0.5.5-1
-%define sanlock_version 3.2.4-1
-
-%define enable_lockd_sanlock %{enable_lvmlockd}
-%define enable_lockd_dlm %{enable_lvmlockd}
+%global device_mapper_version 1.02.135
+
+%global enable_cache 1
+%global enable_cluster 1
+%global enable_cmirror 1
+%global enable_lvmetad 1
+%global enable_lvmlockd 1
+%global enable_lvmpolld 1
+%global enable_python 1
+%global enable_thin 1
+
+%global systemd_version 189-3
+%global dracut_version 002-18
+%global util_linux_version 2.23
+%global bash_version 4.0
+%global corosync_version 1.99.9-1
+%global resource_agents_version 3.9.5-25
+%global dlm_version 3.99.1-1
+%global libselinux_version 1.30.19-4
+%global persistent_data_version 0.6.3-1
+%global sanlock_version 3.3.0-1
+
+%global enable_lockd_sanlock %{enable_lvmlockd}
+%global enable_lockd_dlm %{enable_lvmlockd}
 
 %if 0%{?rhel}
   %ifnarch i686 x86_64 s390x
-    %define enable_cluster 0
-    %define enable_cmirror 0
-    %define enable_lockd_dlm 0
+    %global enable_cluster 0
+    %global enable_cmirror 0
+    %global enable_lockd_dlm 0
   %endif
 
   %ifnarch x86_64 ppc64le ppc64 aarch64
-    %define enable_lockd_sanlock 0
+    %global enable_lockd_sanlock 0
   %endif
 %endif
 
 %if %{enable_cluster}
-  %define configure_cluster --with-cluster=internal --with-clvmd=corosync
+  %global configure_cluster --with-cluster=internal --with-clvmd=corosync
   %if %{enable_cmirror}
-    %define configure_cmirror --enable-cmirrord
+    %global configure_cmirror --enable-cmirrord
   %endif
 %else
-    %define configure_cluster --with-cluster=internal --with-clvmd=none
+    %global configure_cluster --with-cluster=internal --with-clvmd=none
 %endif
 
-
 # Do not reset Release to 1 unless both lvm2 and device-mapper 
 # versions are increased together.
 
 Summary: Userland logical volume management tools 
 Name: lvm2
 Epoch: 7
-Version: 2.02.130
-Release: 5%{?dist}.5
+Version: 2.02.166
+Release: 1%{?dist}
 License: GPLv2
 Group: System Environment/Base
 URL: http://sources.redhat.com/lvm2
@@ -60,23 +59,9 @@ Source0: ftp://sources.redhat.com/pub/lvm2/releases/LVM2.%{version}.tgz
 Patch0: lvm2-rhel7.patch
 Patch1: lvm2-set-default-preferred_names.patch
 Patch2: lvm2-drop-unavailable-libblkid-2_24-BLKID_SUBLKS_BADCSUM-for-signature-detection.patch
-Patch3: lvm2-remove-mpath-device-handling-from-udev-rules.patch
-Patch4: lvm2-lvmlockd-tech-preview-warning.patch
-Patch5: lvm2-2_02_131-standardise-error-paths.patch
-Patch6: lvm2-2_02_131-dmstats-fixups.patch
-Patch7: lvm2-2_02_131-ignore-persistent-cache-if-configuration-changed.patch
-Patch8: lvm2-2_02_131-fix-vg-metadata-comparison-failure-while-scanning-the-vg-for-lvmetad.patch
-Patch9: lvm2-2_02_131-swapping-of-lv-identifiers-handles-more-complex-lvs.patch
-Patch10: lvm2-2_02_131-do-not-check-for-full-thin-pool-when-activating-without-messages.patch
-Patch11: lvm2-2_02_131-disallow-usage-of-stripe-and-stripesize-when-creating-cache-pool.patch
-Patch12: lvm2-2_02_131-fix-vgimportclone-cache_dir-path-name.patch
-Patch13: lvm2-2_02_133-check-for-space-in-thin-pool-before-creating-new-thin.patch
-Patch14: lvm2-2_02_133-enforce-writethrough-mode-for-cleaner-policy.patch
-Patch15: lvm2-2_02_135-fix-resize-of-full-thin-pool-causing-data-loss.patch
-Patch16: lvm2-2_02_142-do-not-check-for-suspended-devices-if-scanning-for-lvmetad-update.patch
-Patch17: lvm2-2_02_140-restore-background-polling-processing-during-auto-activation.patch
-Patch18: lvm2-2_02_155-fix-flushing-for-mirror-target.patch
-Patch19: lvm2-2_02_131-fix-devices-filter-to-be-applied-before-disk-accessing-filters.patch
+Patch3: lvm2-default-allow-changes-with-duplicate-pvs.patch
+Patch4: lvm2-revert-fix-for-lvconvert-repair-for-raid-lvs.patch
+Patch5: lvm2-2_02_167-disable-lvconvert-of-thin-pool-to-raid-while-active.patch
 
 BuildRequires: libselinux-devel >= %{libselinux_version}, libsepol-devel
 BuildRequires: libblkid-devel >= %{util_linux_version}
@@ -125,66 +110,51 @@ or more physical volumes and creating one or more logical volumes
 %patch0 -p1 -b .rhel7
 %patch1 -p1 -b .preferred_names
 %patch2 -p1 -b .blkid_sublks_badcsum
-%patch3 -p1 -b .multipath
-%patch4 -p1 -b .lvmlockd_tech_preview
-%patch5 -p1 -b .error_paths
-%patch6 -p1 -b .dmstats_fixups
-%patch7 -p1 -b .persistent_cache_ignore
-%patch8 -p1 -b .lvmetad_rescan_vg_meta_comparison
-%patch9 -p1 -b .lv_swapping_complex
-%patch10 -p1 -b .thin_no_messages_no_check
-%patch11 -p1 -b .disallow_stripe_for_cache_pool
-%patch12 -p1 -b .vgimportclone_cache_dir
-%patch13 -p1 -b .check_for_thin_pool_space
-%patch14 -p1 -b .writethrough_cleaner_policy
-%patch15 -p1 -b .thin_pool_resize_data_loss
-%patch16 -p1 -b .susp_devs_lvmetad_update
-%patch17 -p1 -b .background_polling_auto_activation
-%patch18 -p1 -b .flushing_mirror
-%patch19 -p1 -b .fix_filter_order
+%patch3 -p1 -b .default_allow_dup
+%patch4 -p1 -b .lvconvert_repair_raid
+%patch5 -p1 -b .lvconvert_disable_thin_pool_to_raid
 
 %build
-%define _default_pid_dir /run
-%define _default_dm_run_dir /run
-%define _default_run_dir /run/lvm
-%define _default_locking_dir /run/lock/lvm
+%global _default_pid_dir /run
+%global _default_dm_run_dir /run
+%global _default_run_dir /run/lvm
+%global _default_locking_dir /run/lock/lvm
 
-%define _udevdir %{_prefix}/lib/udev/rules.d
-%define _tmpfilesdir %{_prefix}/lib/tmpfiles.d
+%global _udevdir %{_prefix}/lib/udev/rules.d
+%global _tmpfilesdir %{_prefix}/lib/tmpfiles.d
 
-%define configure_udev --with-udevdir=%{_udevdir} --enable-udev_sync
+%global configure_udev --with-udevdir=%{_udevdir} --enable-udev_sync
 
 %if %{enable_cache}
-%define configure_cache --with-cache=internal
+%global configure_cache --with-cache=internal
 %endif
 
 %if %{enable_thin}
-%define configure_thin --with-thin=internal
+%global configure_thin --with-thin=internal
 %endif
 
 %if %{enable_lvmetad}
-%define configure_lvmetad --enable-lvmetad
+%global configure_lvmetad --enable-lvmetad
 %endif
 
 %if %{enable_lockd_dlm}
-%define configure_lockd_dlm --enable-lockd-dlm
+%global configure_lockd_dlm --enable-lockd-dlm
 %endif
 
 %if %{enable_lockd_sanlock}
-%define configure_lockd_sanlock --enable-lockd-sanlock
+%global configure_lockd_sanlock --enable-lockd-sanlock
 %endif
 
 %if %{enable_lvmpolld}
-%define configure_lvmpolld --enable-lvmpolld
+%global configure_lvmpolld --enable-lvmpolld
 %endif
 
 %if %{enable_python}
-%define configure_python --enable-python-bindings
+%global configure_python --enable-python2-bindings
 %endif
 
-%define configure_final --with-default-dm-run-dir=%{_default_dm_run_dir} --with-default-run-dir=%{_default_run_dir} --with-default-pid-dir=%{_default_pid_dir} --with-default-locking-dir=%{_default_locking_dir} --with-usrlibdir=%{_libdir} --enable-lvm1_fallback --enable-fsadm --with-pool=internal --enable-write_install --with-user= --with-group= --with-device-uid=0 --with-device-gid=6 --with-device-mode=0660 --enable-pkgconfig --enable-applib --enable-cmdlib --enable-dmeventd --enable-blkid_wiping %{?configure_python} %{?configure_cluster} %{?configure_cmirror} %{?configure_udev} %{?configure_thin} %{?configure_lvmetad} %{?configure_cache} %{?configure_lvmpolld} %{?configure_lockd_dlm} %{?configure_lockd_sanlock}
+%configure --with-default-dm-run-dir=%{_default_dm_run_dir} --with-default-run-dir=%{_default_run_dir} --with-default-pid-dir=%{_default_pid_dir} --with-default-locking-dir=%{_default_locking_dir} --with-usrlibdir=%{_libdir} --enable-lvm1_fallback --enable-fsadm --with-pool=internal --enable-write_install --with-user= --with-group= --with-device-uid=0 --with-device-gid=6 --with-device-mode=0660 --enable-pkgconfig --enable-applib --enable-cmdlib --enable-dmeventd --enable-blkid_wiping %{?configure_python} %{?configure_cluster} %{?configure_cmirror} %{?configure_udev} %{?configure_thin} %{?configure_lvmetad} %{?configure_cache} %{?configure_lvmpolld} %{?configure_lockd_dlm} %{?configure_lockd_sanlock}
 
-%configure %{?configure_final}
 make %{?_smp_mflags}
 
 %install
@@ -270,7 +240,6 @@ systemctl start lvm2-lvmpolld.socket
 %if %{enable_lvmpolld}
 %{_sbindir}/lvmpolld
 %endif
-%{_sbindir}/vgimportclone
 
 # Other files
 %defattr(444,root,root,-)
@@ -308,6 +277,7 @@ systemctl start lvm2-lvmpolld.socket
 %{_sbindir}/vgexport
 %{_sbindir}/vgextend
 %{_sbindir}/vgimport
+%{_sbindir}/vgimportclone
 %{_sbindir}/vgmerge
 %{_sbindir}/vgmknodes
 %{_sbindir}/vgreduce
@@ -318,6 +288,8 @@ systemctl start lvm2-lvmpolld.socket
 %{_sbindir}/vgsplit
 %{_mandir}/man5/lvm.conf.5.gz
 %{_mandir}/man7/lvmcache.7.gz
+%{_mandir}/man7/lvmraid.7.gz
+%{_mandir}/man7/lvmreport.7.gz
 %{_mandir}/man7/lvmthin.7.gz
 %{_mandir}/man7/lvmsystemid.7.gz
 %{_mandir}/man8/fsadm.8.gz
@@ -335,6 +307,7 @@ systemctl start lvm2-lvmpolld.socket
 %{_mandir}/man8/lvmconf.8.gz
 %{_mandir}/man8/lvmdiskscan.8.gz
 %{_mandir}/man8/lvmdump.8.gz
+%{_mandir}/man8/lvm-fullreport.8.gz
 %{_mandir}/man8/lvmsadc.8.gz
 %{_mandir}/man8/lvmsar.8.gz
 %{_mandir}/man8/lvreduce.8.gz
@@ -391,6 +364,7 @@ systemctl start lvm2-lvmpolld.socket
 %{_sysconfdir}/lvm/profile/thin-performance.profile
 %{_sysconfdir}/lvm/profile/cache-mq.profile
 %{_sysconfdir}/lvm/profile/cache-smq.profile
+%{_sysconfdir}/lvm/profile/lvmdbusd.profile
 %attr(700, -, -) %dir %{_sysconfdir}/lvm/backup
 %attr(700, -, -) %dir %{_sysconfdir}/lvm/cache
 %attr(700, -, -) %dir %{_sysconfdir}/lvm/archive
@@ -494,12 +468,12 @@ logical volumes, physical volumes, and volume groups.
 Summary: LVM locking daemon
 Group: System Environment/Base
 Requires: lvm2 = %{epoch}:%{version}-%{release}
-%if %{enable_lockd_dlm}
-Requires: dlm-lib >= %{dlm_version}
-%endif
 %if %{enable_lockd_sanlock}
 Requires: sanlock-lib >= %{sanlock_version}
 %endif
+%if %{enable_lockd_dlm}
+Requires: dlm-lib >= %{dlm_version}
+%endif
 Requires(post): systemd-units >= %{systemd_version}
 Requires(preun): systemd-units >= %{systemd_version}
 Requires(postun): systemd-units >= %{systemd_version}
@@ -686,7 +660,6 @@ is not used as the system init process.
 %package -n device-mapper
 Summary: Device mapper utility
 Version: %{device_mapper_version}
-Release: %{release}
 License: GPLv2
 Group: System Environment/Base
 URL: http://sources.redhat.com/dm
@@ -726,7 +699,6 @@ for the kernel device-mapper.
 %package -n device-mapper-devel
 Summary: Development libraries and headers for device-mapper
 Version: %{device_mapper_version}
-Release: %{release}
 License: LGPLv2
 Group: Development/Libraries
 Requires: device-mapper = %{epoch}:%{device_mapper_version}-%{release}
@@ -745,7 +717,6 @@ the device-mapper libraries.
 %package -n device-mapper-libs
 Summary: Device-mapper shared library
 Version: %{device_mapper_version}
-Release: %{release}
 License: LGPLv2
 Group: System Environment/Libraries
 Requires: device-mapper = %{epoch}:%{device_mapper_version}-%{release}
@@ -767,7 +738,11 @@ This package contains the device-mapper shared library, libdevmapper.
 Summary: Device-mapper event daemon
 Group: System Environment/Base
 Version: %{device_mapper_version}
-Release: %{release}
+# Older lvm2 versions had incorrect dependency on device-mapper-event
+# package where lvm2-libs had "Requires: device-mapper-event >="
+# instead of "Requires: device-mapper-event =". This was fixed in
+# lvm2-2.02.111-1 and later.
+Conflicts: lvm2-libs < 7:2.02.111
 Requires: device-mapper = %{epoch}:%{device_mapper_version}-%{release}
 Requires: device-mapper-event-libs = %{epoch}:%{device_mapper_version}-%{release}
 Requires(post): systemd-units
@@ -802,7 +777,6 @@ fi
 %package -n device-mapper-event-libs
 Summary: Device-mapper event daemon shared library
 Version: %{device_mapper_version}
-Release: %{release}
 License: LGPLv2
 Group: System Environment/Libraries
 
@@ -823,7 +797,6 @@ libdevmapper-event.
 %package -n device-mapper-event-devel
 Summary: Development libraries and headers for the device-mapper event daemon
 Version: %{device_mapper_version}
-Release: %{release}
 License: LGPLv2
 Group: Development/Libraries
 Requires: device-mapper-event = %{epoch}:%{device_mapper_version}-%{release}
@@ -840,21 +813,134 @@ the device-mapper event library.
 %{_libdir}/pkgconfig/devmapper-event.pc
 
 %changelog
-* Tue Jun 14 2016 Peter Rajnoha <prajnoha@redhat.com> - 7:2.02.130-5.el7_2.5
-- Fix devices/filter to be applied before disk-accessing filters. (2.02.112)
+* Wed Sep 28 2016 Peter Rajnoha <prajnoha@redhat.com> - 7:2.02.166-1
+- Disable lvconvert of thin pool to raid while active.
+- Use dm_config_parse_without_dup_node_check() to speedup metadata reading.
+- Fix lvm2-activation-generator to read all LVM2 config sources. (2.02.155)
+- Fix man entry for dmsetup status.
+- Introduce new dm_config_parse_without_dup_node_check().
+
+* Thu Sep 22 2016 Peter Rajnoha <prajnoha@redhat.com> - 7:2.02.165-4
+- Revert lvconvert --repair fix for RAID LVs.
+
+* Wed Sep 21 2016 Peter Rajnoha <prajnoha@redhat.com> - 7:2.02.165-3
+- Fix lvchange --discard|--zero for active thin-pool.
+- Fix lvconvert --repair regression for RAID LVs.
+- Always specify snapshot cow LV for monitoring not internal LV. (2.02.165)
+- Ensure memory allocated internally for --filemap histogram bounds are freed.
+- Fix missing display of last created dmstats file map.
+- Use --alloc normal for mirror logs even if the mimages were stricter.
+- Fix reported origin lv field for cache volumes. (2.02.133)
+- Fix lock-holder device for thin pool with inactive thin volumes.
+- Enforce 4MiB or 25% metadata free space for thin pool operations.
+- Fix lvmetad metadata validation when rescanning VG.
+
+* Wed Sep 14 2016 Peter Rajnoha <prajnoha@redhat.com> - 7:2.02.165-2
+- Fix possible NULL pointer dereference when checking for monitoring.
+- Add lvmreport(7) man page.
+- Report 0% as dirty (copy%) for cache without any used block.
+- Fix lvm2api reporting of cache data and metadata percent.
+- Restore reporting of metadata usage for cache volumes (2.02.155).
+
+* Wed Sep 07 2016 Peter Rajnoha <prajnoha@redhat.com> - 7:2.02.165-1
+- Support raid scrubbing on cache origin LV.
+- Add lvmraid(7) man page.
+- Use udev db to check for mpath components before running pvscan for lvmetad.
+- Improve explanation of udev fallback in libdevmapper.h.
+
+* Mon Sep 05 2016 Peter Rajnoha <prajnoha@redhat.com> - 7:2.02.164-5
+- Use udev db to check for mpath components before running pvscan for lvmetad.
+- Use devices/allow_changes_with_duplicate_pvs=1 by default.
+
+* Wed Aug 31 2016 Peter Rajnoha <prajnoha@redhat.com> - 7:2.02.164-4
+- Use lsblk -s and lsblk -O in lvmdump only if these options are supported.
+- Fix typo in report/columns_as_rows config option name recognition (2.02.99).
+- Do not monitor cache-pool metadata when LV is just being cleared.
+- Add allocation/cache_pool_max_chunks to prevent misuse of cache target.
+- Fix number of stripes shown in lvcreate raid10 message when too many.
+- Give error not segfault in lvconvert --splitmirrors when PV lies outside LV.
+- Avoid PV tags when checking allocation against parallel PVs. 
+
+* Wed Aug 24 2016 Peter Rajnoha <prajnoha@redhat.com> - 7:2.02.164-3
+- Disallow segtype and mirror conversions of raid10 volumes.
+- Fix dmeventd unmonitoring when segment type (and dso) changes.
+- Don't allow lvconvert --repair on raid0 devices or attempt to monitor them.
+- No longer adjust incorrect number of raid stripes supplied to lvcreate.
+- Move lcm and gcd to lib/misc.
+- Suppress some unnecessary --stripesize parameter warnings.
+- Fix 'pvmove -n name ...' to prohibit collocation of RAID SubLVs
+
+* Tue Aug 16 2016 Peter Rajnoha <prajnoha@redhat.com> - 7:2.02.164-2
+- Suppress some unnecessary --stripesize parameter warnings.
+- Fix selection of PVs when allocating raid0_meta.
+- Specify max stripes for raid LV types: raid0:64; 1:10; 4,5:63; 6:62; 10:32.
+- Avoid double suffix when naming _rmeta LV paired with _rimage LV.
+
+* Wed Aug 10 2016 Peter Rajnoha <prajnoha@redhat.com> - 7:2.02.163-1
+- Add profile for lvmdbusd which uses lvm shell json report output.
+- Restrict in-command modification of some parms in lvm shell.
+- Apply LVM_COMMAND_PROFILE early for lvm shell.
+- Refactor reporting so lvm shell log report collects whole of cmd execution.
+- Support LVM_*_FD envvars to redirect output to file descriptors.
+- Limit use of --corelog and --mirrorlog to mirrors in lvconvert.
+- Reject --nosync option for RAID6 LVs in lvcreate.
+- Do not refresh whole cmd context if profile dropped after processing LVM cmd.
+- Support straightforward lvconvert between striped and raid4 LVs. 
+- Support straightforward lvconvert between raid1 and mirror LVs. 
+- Report supported conversions when asked for unsupported raid lvconvert.
+- Add "--rebuild PV" option to lvchange to allow for PV selective rebuilds.
+- Preserve existing mirror region size when using --repair.
+- Forbid stripe parameters with lvconvert --repair.
+- Unify stripe size validation into get_stripe_params to catch missing cases.
+- Further lvconvert validation logic refactoring.
+- Add "lvm fullreport" man page.
+- Add dm_report_destroy_rows/dm_report_group_output_and_pop_all for lvm shell.
+- Adjust group handling and json production for lvm shell.
+
+* Fri Jul 29 2016 Peter Rajnoha <prajnoha@redhat.com> - 7:2.02.162-1
+- Extend vg_validate also to check raid configurations thoroughly.
+- Support lvconvert -Zn also when doing full cache pool conversion.
+- Suppress not zeroing warn when converting to thin LV for non-zeroing tpool.
+- Fix automatic updates of PV extension headers to newest version.
+- Improve lvconvert --trackchanges validation to require --splitmirrors 1.
+- Add note about lastlog built-in command to lvm man page.
+- Fix unrecognised segtype flag message.
+- lvconvert not clears cache pool metadata ONLY with -Zn. 
+- Add allocation/raid_stripe_all_devices to reinstate previous behaviour.
+- Create raid stripes across fixed small numbers of PVs instead of all PVs. 
+- Disallow lvconvert --replace with raid0* LVs. 
+- Fix some lvmetad changed VG metadata notifications that sent uncommitted data.
+- Fix json reporting to escape '"' character that may appear in reported string.
+
+* Thu Jul 28 2016 Peter Rajnoha <prajnoha@redhat.com> - 7:2.02.161-3
+- Improve lvmlockd message for lock-start.
+- Improve lvmlockd activation locking error message.
+- Improve lvmlockd error message about missing global lock.
+- Allow lvconvert with implied cache pool.
+- Fix vgsplit with external origin LV. (2.02.161)
+
+* Wed Jul 20 2016 Peter Rajnoha <prajnoha@redhat.com> - 7:2.02.161-2
+- Fix output redirection while executing blkdeactivate -m disablequeueing.
+
+* Wed Jul 20 2016 Peter Rajnoha <prajnoha@redhat.com> - 7:2.02.161-1
+- Update to latest upstream release with various fixes and
+  enhancements documented in WHATS_NEW and WHATS_NEW_DM file.
 
-* Thu Jun 09 2016 Peter Rajnoha <prajnoha@redhat.com> - 7:2.02.130-5.el7_2.4
-- Fix flushing for mirror target.
+* Wed Jul 06 2016 Alasdair Kergon <agk@redhat.com> - 7:2.02.160-1
+- Minor fixes from coverity.
+- vgimportclone is now a symlink.
 
-* Tue May 03 2016 Peter Rajnoha <prajnoha@redhat.com> - 7:2.02.130-5.el7_2.3
-- Restore background polling processing during auto-activation (2.02.119).
+* Wed Jul 06 2016 Alasdair Kergon <agk@redhat.com> - 7:2.02.159-1
+- Update to latest upstream release with various fixes and
+  enhancements documented in WHATS_NEW and WHATS_NEW_DM file.
 
-* Thu Mar 24 2016 Peter Rajnoha <prajnoha@redhat.com> - 7:2.02.130-5.el7_2.2
-- Do not check for suspended devices if scanning for lvmetad update.
+* Mon Jun 13 2016 Peter Rajnoha <prajnoha@redhat.com> - 7:2.02.156-1
+- Update to latest upstream release with various fixes and
+  enhancements documented in WHATS_NEW and WHATS_NEW_DM file.
 
-* Tue Dec 01 2015 Peter Rajnoha <prajnoha@redhat.com> - 7:2.02.130-5.el7_2.1
-- Fix possible data loss caused by lost buffered writes during thin pool
-  resize after reaching its capacity.
+* Wed May 04 2016 Peter Rajnoha <prajnoha@redhat.com> - 7:2.02.152-1
+- Update to latest upstream release with various fixes and
+  enhancements documented in WHATS_NEW and WHATS_NEW_DM file.
 
 * Wed Oct 14 2015 Peter Rajnoha <prajnoha@redhat.com> - 7:2.02.130-5
 - Fixup /etc/lvm/archive ownership.