From 4bb57341bd99a7d1af1a6a9ed84122369f362ba0 Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Thu, 7 Jul 2016 09:47:19 +0100 Subject: [PATCH] libdm: enable creation of filemap regions with histograms --- libdm/libdm-stats.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c index 55f10104b..6504289f0 100644 --- a/libdm/libdm-stats.c +++ b/libdm/libdm-stats.c @@ -4247,6 +4247,7 @@ static uint64_t *_stats_create_file_regions(struct dm_stats *dms, int fd, { struct _extent *extents = NULL; uint64_t *regions = NULL, i; + char *hist_arg = NULL; struct statfs fsbuf; struct stat buf; @@ -4279,6 +4280,12 @@ static uint64_t *_stats_create_file_regions(struct dm_stats *dms, int fd, if (!(extents = _stats_get_extents_for_file(dms->mem, fd, count))) return_0; + if (bounds) { + /* _build_histogram_arg enables precise if vals < 1ms. */ + if (!(hist_arg = _build_histogram_arg(bounds, &precise))) + goto_out; + } + /* make space for end-of-table marker */ if (!(regions = dm_malloc((1 + *count) * sizeof(*regions)))) { log_error("Could not allocate memory for region IDs."); @@ -4286,9 +4293,9 @@ static uint64_t *_stats_create_file_regions(struct dm_stats *dms, int fd, } for (i = 0; i < *count; i++) { - if (!_stats_create_region(dms, regions + i, - extents[i].start, extents[i].len, -1, - precise, NULL, dms->program_id, "")) { + if (!_stats_create_region(dms, regions + i, extents[i].start, + extents[i].len, -1, precise, hist_arg, + dms->program_id, "")) { log_error("Failed to create region " FMTu64 " of " FMTu64 " at " FMTu64 ".", i, *count, extents[i].start); @@ -4321,12 +4328,6 @@ uint64_t *dm_stats_create_regions_from_fd(struct dm_stats *dms, int fd, { uint64_t *regions, count = 0; - if (bounds) { - log_error("File mapped groups with histograms are not " - "yet supported."); - return NULL; - } - if (alias && !group) { log_error("Cannot set alias without grouping regions."); return NULL;