From 138e4336fd8422623df7daa362b98a4899f5fbec Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Mon, 12 Dec 2016 22:49:31 +0000 Subject: [PATCH] libdm: fix region overlap tests --- libdm/libdm-stats.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c index 56a38f27e..8c0428ea8 100644 --- a/libdm/libdm-stats.c +++ b/libdm/libdm-stats.c @@ -3880,6 +3880,12 @@ static int _stats_group_check_overlap(const struct dm_stats *dms, i++; } + /* A single region cannot overlap itself. */ + if (i == 1) { + dm_pool_free(dms->mem, map); + return 1; + } + /* sort by extent.start */ qsort(map, count, sizeof(*map), _extent_start_compare); @@ -3915,7 +3921,7 @@ merge: goto merge; dm_pool_free(dms->mem, map); - return overlap; + return (overlap == 0); } static void _stats_copy_histogram_bounds(struct dm_histogram *to,