Hello community, here is the log from the commit of package ndctl for openSUSE:Factory checked in at 2019-08-27 15:23:35 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ndctl (Old) and /work/SRC/openSUSE:Factory/.ndctl.new.7948 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ndctl" Tue Aug 27 15:23:35 2019 rev:23 rq:725562 version:64.1 Changes: -------- --- /work/SRC/openSUSE:Factory/ndctl/ndctl.changes 2019-06-06 18:19:25.848648982 +0200 +++ /work/SRC/openSUSE:Factory/.ndctl.new.7948/ndctl.changes 2019-08-27 15:23:38.336772840 +0200 @@ -1,0 +2,34 @@ +Wed Aug 21 18:15:16 UTC 2019 - Michal Suchanek <[email protected]> + +- Refresh patches with upstream status: + ndctl_check_Ensure_mmap_of_BTT_sections_work_with_64K_page-sizes.patch + ndctl-namespace-Handle-create-namespace-in-label-less-mode.patch + ndctl-list-Introduce-region-capability-objects.patch + +------------------------------------------------------------------- +Mon Aug 19 13:19:55 UTC 2019 - Michal Suchanek <[email protected]> + +- ndctl/namespace: Handle 'create-namespace' in label-less mode (bsc#1145471 ltc#179886). + + ndctl-namespace-Handle-create-namespace-in-label-less-mode.patch + +------------------------------------------------------------------- +Mon Aug 19 11:27:59 UTC 2019 - Michal Suchanek <[email protected]> + +- ndctl: Use the same align value as original namespace on reconfigure (bsc#1145577 ltc#178224). + + ndctl-Use-the-same-align-value-as-original-namespace-on-reconfigure.patch +- ndctl/lib: Fix duplicate bus detection (bsc#1145573 ltc#180249). + + ndctl-ndctl-lib-Fix-duplicate-bus-detection.patch + +------------------------------------------------------------------- +Fri Aug 16 14:31:46 UTC 2019 - Michal Suchanek <[email protected]> + +- ndctl/list: Introduce region capability objects (bsc#1145772 ltc#178159). + + ndctl-list-Introduce-region-capability-objects.patch + +------------------------------------------------------------------- +Tue Aug 13 12:56:24 UTC 2019 - Michal Suchanek <[email protected]> + +- ndctl, check: Ensure mmap of BTT sections work with 64K page-sizes (bsc#1145421 ltc#176079). + + ndctl_check_Ensure_mmap_of_BTT_sections_work_with_64K_page-sizes.patch + +------------------------------------------------------------------- New: ---- ndctl-Use-the-same-align-value-as-original-namespace-on-reconfigure.patch ndctl-list-Introduce-region-capability-objects.patch ndctl-namespace-Handle-create-namespace-in-label-less-mode.patch ndctl-ndctl-lib-Fix-duplicate-bus-detection.patch ndctl_check_Ensure_mmap_of_BTT_sections_work_with_64K_page-sizes.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ndctl.spec ++++++ --- /var/tmp/diff_new_pack.FZBfUE/_old 2019-08-27 15:23:39.260772375 +0200 +++ /var/tmp/diff_new_pack.FZBfUE/_new 2019-08-27 15:23:39.264772373 +0200 @@ -28,6 +28,11 @@ URL: https://github.com/pmem/ndctl # Snapshot tarball can be created using: ./make-git-shapshot.sh [gitcommit] Source0: %{name}-%{version}.tar.gz +Patch1: %{name}_check_Ensure_mmap_of_BTT_sections_work_with_64K_page-sizes.patch +Patch2: %{name}-list-Introduce-region-capability-objects.patch +Patch3: %{name}-Use-the-same-align-value-as-original-namespace-on-reconfigure.patch +Patch4: %{name}-ndctl-lib-Fix-duplicate-bus-detection.patch +Patch5: %{name}-namespace-Handle-create-namespace-in-label-less-mode.patch BuildRequires: autoconf BuildRequires: automake BuildRequires: keyutils-devel @@ -86,6 +91,7 @@ %prep %setup -q +%autopatch -p1 %build echo "%{version}" > version ++++++ ndctl-Use-the-same-align-value-as-original-namespace-on-reconfigure.patch ++++++ >From patchwork Wed Aug 7 04:44:16 2019 X-Patchwork-Submitter: "Aneesh Kumar K.V" <[email protected]> X-Patchwork-Id: 11080973 From: "Aneesh Kumar K.V" <[email protected]> To: [email protected] Subject: [PATCH] ndctl: Use the same align value as original namespace on reconfigure Date: Wed, 7 Aug 2019 10:14:16 +0530 Message-Id: <[email protected]> When using reconfigure command to add a `name` to the namespace we end up updating the align attribute. Avoid this by using the value from the original namespace. Do this only if we are keeping the namespace mode same. Signed-off-by: Aneesh Kumar K.V <[email protected]> --- ndctl/namespace.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ndctl/namespace.c b/ndctl/namespace.c index 1f212a2b3a9b..24e51bb35ae1 100644 --- a/ndctl/namespace.c +++ b/ndctl/namespace.c @@ -596,6 +596,22 @@ static int validate_namespace_options(struct ndctl_region *region, return -ENXIO; } } else { + + /* + * If we are tryint to reconfigure with the same namespace mode + * Use the align details from the origin namespace. Otherwise + * pick the align details from seed namespace + */ + if (ndns && p->mode == ndctl_namespace_get_mode(ndns)) { + struct ndctl_pfn *ns_pfn = ndctl_namespace_get_pfn(ndns); + struct ndctl_dax *ns_dax = ndctl_namespace_get_dax(ndns); + if (ns_pfn) + p->align = ndctl_pfn_get_align(ns_pfn); + else if (ns_dax) + p->align = ndctl_dax_get_align(ns_dax); + else + p->align = sysconf(_SC_PAGE_SIZE); + } else /* * Use the seed namespace alignment as the default if we need * one. If we don't then use PAGE_SIZE so the size_align ++++++ ndctl-list-Introduce-region-capability-objects.patch ++++++ >From da2820a80483791498b50bd5b5932076b7c17b1a Mon Sep 17 00:00:00 2001 From: Dan Williams <[email protected]> Date: Wed, 6 Mar 2019 23:19:45 -0800 Subject: [PATCH] ndctl/list: Introduce region capability objects Patch-mainline: v65 Git-commit: da2820a80483791498b50bd5b5932076b7c17b1a For common capabilities that a region can create provide a json object of the following form: "capabilities":[ { "mode":"sector", "sector_sizes":[ 512, 520, 528, 4096, 4104, 4160, 4224 ] }, { "mode":"fsdax", "alignments":[ 4096, 2097152, 1073741824 ] }, { "mode":"devdax", "alignments":[ 4096, 2097152, 1073741824 ] } ] This replaces the "supported_alignments" and "supported sector sizes" fields which ended up being too repetitive at the namespace level. Cc: Oliver O'Halloran <[email protected]> Signed-off-by: Dan Williams <[email protected]> Signed-off-by: Vishal Verma <[email protected]> --- Documentation/ndctl/ndctl-list.txt | 9 ++- ndctl/list.c | 12 ++++ util/json.c | 89 ++++++++++++++++++++++++------ util/json.h | 2 + 4 files changed, 93 insertions(+), 19 deletions(-) diff --git a/Documentation/ndctl/ndctl-list.txt b/Documentation/ndctl/ndctl-list.txt index bdd69add9f22..80ad6100060f 100644 --- a/Documentation/ndctl/ndctl-list.txt +++ b/Documentation/ndctl/ndctl-list.txt @@ -175,6 +175,12 @@ include::xable-region-options.txt[] --idle:: Include idle (not enabled) devices in the listing +-C:: +--capabilities:: + Include region capabilities in the listing, i.e. supported + namespace modes and variable properties like sector sizes and + alignments. + -M:: --media-errors:: Include media errors (badblocks) in the listing. Note that the @@ -222,7 +228,8 @@ include::xable-region-options.txt[] Everything '-v' provides, plus automatically enable --dimms, --buses, and --regions. + - *-vvv* - Everything '-vv' provides, plus --health, --idle, and --firmware. + Everything '-vv' provides, plus --health, --capabilities, + --idle, and --firmware. include::human-option.txt[] diff --git a/ndctl/list.c b/ndctl/list.c index 506404db11b0..1c3e34d58ddb 100644 --- a/ndctl/list.c +++ b/ndctl/list.c @@ -36,6 +36,7 @@ static struct { bool media_errors; bool human; bool firmware; + bool capabilities; int verbose; } list; @@ -53,6 +54,8 @@ static unsigned long listopts_to_flags(void) flags |= UTIL_JSON_HUMAN; if (list.verbose) flags |= UTIL_JSON_VERBOSE; + if (list.capabilities) + flags |= UTIL_JSON_CAPABILITIES; return flags; } @@ -186,6 +189,12 @@ static struct json_object *region_to_json(struct ndctl_region *region, if ((flags & UTIL_JSON_MEDIA_ERRORS) && jbbs) json_object_object_add(jregion, "badblocks", jbbs); + if (flags & UTIL_JSON_CAPABILITIES) { + jobj = util_region_capabilities_to_json(region); + if (jobj) + json_object_object_add(jregion, "capabilities", jobj); + } + pd = ndctl_region_get_persistence_domain(region); switch (pd) { case PERSISTENCE_CPU_CACHE: @@ -450,6 +459,8 @@ int cmd_list(int argc, const char **argv, struct ndctl_ctx *ctx) "include namespace info (default)"), OPT_BOOLEAN('X', "device-dax", &list.dax, "include device-dax info"), + OPT_BOOLEAN('C', "capabilities", &list.capabilities, + "include region capability info"), OPT_BOOLEAN('i', "idle", &list.idle, "include idle devices"), OPT_BOOLEAN('M', "media-errors", &list.media_errors, "include media errors"), @@ -487,6 +498,7 @@ int cmd_list(int argc, const char **argv, struct ndctl_ctx *ctx) list.idle = true; list.firmware = true; list.health = true; + list.capabilities = true; case 2: list.dimms = true; list.buses = true; diff --git a/util/json.c b/util/json.c index c732f1b77522..babdc8c47565 100644 --- a/util/json.c +++ b/util/json.c @@ -321,7 +321,7 @@ struct json_object *util_daxctl_devs_to_list(struct daxctl_region *region, } #define _SZ(get_max, get_elem, type) \ -static struct json_object *type##_build_size_array(struct type *arg) \ +static struct json_object *util_##type##_build_size_array(struct ndctl_##type *arg) \ { \ struct json_object *arr = json_object_new_array(); \ int i; \ @@ -346,11 +346,78 @@ err: \ return NULL; \ } #define SZ(type, kind) _SZ(ndctl_##type##_get_num_##kind##s, \ - ndctl_##type##_get_supported_##kind, ndctl_##type) + ndctl_##type##_get_supported_##kind, type) SZ(pfn, alignment) SZ(dax, alignment) SZ(btt, sector_size) -//SZ(namespace, sector_size) + +struct json_object *util_region_capabilities_to_json(struct ndctl_region *region) +{ + struct json_object *jcaps, *jcap, *jobj; + struct ndctl_btt *btt = ndctl_region_get_btt_seed(region); + struct ndctl_pfn *pfn = ndctl_region_get_pfn_seed(region); + struct ndctl_dax *dax = ndctl_region_get_dax_seed(region); + + if (!btt || !pfn || !dax) + return NULL; + + jcaps = json_object_new_array(); + if (!jcaps) + return NULL; + + if (btt) { + jcap = json_object_new_object(); + if (!jcap) + goto err; + json_object_array_add(jcaps, jcap); + + jobj = json_object_new_string("sector"); + if (!jobj) + goto err; + json_object_object_add(jcap, "mode", jobj); + jobj = util_btt_build_size_array(btt); + if (!jobj) + goto err; + json_object_object_add(jcap, "sector_sizes", jobj); + } + + if (pfn) { + jcap = json_object_new_object(); + if (!jcap) + goto err; + json_object_array_add(jcaps, jcap); + + jobj = json_object_new_string("fsdax"); + if (!jobj) + goto err; + json_object_object_add(jcap, "mode", jobj); + jobj = util_pfn_build_size_array(pfn); + if (!jobj) + goto err; + json_object_object_add(jcap, "alignments", jobj); + } + + if (dax) { + jcap = json_object_new_object(); + if (!jcap) + goto err; + json_object_array_add(jcaps, jcap); + + jobj = json_object_new_string("devdax"); + if (!jobj) + goto err; + json_object_object_add(jcap, "mode", jobj); + jobj = util_dax_build_size_array(dax); + if (!jobj) + goto err; + json_object_object_add(jcap, "alignments", jobj); + } + + return jcaps; +err: + json_object_put(jcaps); + return NULL; +} struct json_object *util_daxctl_region_to_json(struct daxctl_region *region, const char *ident, unsigned long flags) @@ -788,7 +855,7 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns, { struct json_object *jndns = json_object_new_object(); enum ndctl_pfn_loc loc = NDCTL_PFN_LOC_NONE; - struct json_object *jobj, *jbbs = NULL, *size_array = NULL; + struct json_object *jobj, *jbbs = NULL; const char *locations[] = { [NDCTL_PFN_LOC_NONE] = "none", [NDCTL_PFN_LOC_RAM] = "mem", @@ -798,7 +865,6 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns, unsigned int sector_size = UINT_MAX; enum ndctl_namespace_mode mode; const char *bdev = NULL, *name; - const char *size_array_name; unsigned int bb_count = 0; struct ndctl_btt *btt; struct ndctl_pfn *pfn; @@ -986,19 +1052,6 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns, json_object_object_add(jndns, "numa_node", jobj); } - if (pfn) { - size_array_name = "supported_alignments"; - size_array = ndctl_pfn_build_size_array(pfn); - } else if (dax) { - size_array_name = "supported_alignments"; - size_array = ndctl_dax_build_size_array(dax); - } else if (btt) { - size_array_name = "supported sector sizes"; - size_array = ndctl_btt_build_size_array(btt); - } - if (size_array && flags & UTIL_JSON_VERBOSE) - json_object_object_add(jndns, size_array_name, size_array); - if (pfn) jbbs = util_pfn_badblocks_to_json(pfn, &bb_count, flags); else if (dax) diff --git a/util/json.h b/util/json.h index e292973dbbbf..7c3f64932cec 100644 --- a/util/json.h +++ b/util/json.h @@ -24,6 +24,7 @@ enum util_json_flags { UTIL_JSON_DAX_DEVS = (1 << 3), UTIL_JSON_HUMAN = (1 << 4), UTIL_JSON_VERBOSE = (1 << 5), + UTIL_JSON_CAPABILITIES = (1 << 6), }; struct json_object; @@ -56,4 +57,5 @@ struct json_object *util_json_object_hex(unsigned long long val, struct json_object *util_dimm_health_to_json(struct ndctl_dimm *dimm); struct json_object *util_dimm_firmware_to_json(struct ndctl_dimm *dimm, unsigned long flags); +struct json_object *util_region_capabilities_to_json(struct ndctl_region *region); #endif /* __NDCTL_JSON_H__ */ -- 2.22.0 ++++++ ndctl-namespace-Handle-create-namespace-in-label-less-mode.patch ++++++ >From 7966c92c9da72b0640eec1341bdee959ce746957 Mon Sep 17 00:00:00 2001 From: Dan Williams <[email protected]> Date: Sat, 27 Jul 2019 14:40:36 -0700 Subject: [PATCH] ndctl/namespace: Handle 'create-namespace' in label-less mode Patch-mainline: v66 Git-commit: 7966c92c9da72b0640eec1341bdee959ce746957 A common confusion with ndctl is that 'create-namespace' does not work in the label-less case. In the label-less case there is no capacity to allocate as the size if already hard-coded by the region boundary. However, users typically do something like the following in the label-less case: # ndctl list { "dev":"namespace1.0", "mode":"raw", "size":"127.00 GiB (136.37 GB)", "sector_size":512, "blockdev":"pmem1" } # ndctl destroy-namespace namespace1.0 -f destroyed 1 namespace # ndctl create-namespace failed to create namespace: Resource temporarily unavailable In other words they destroy the raw mode namespace that they don't want, and seek to create a new default configuration namespace. Since there is no "available_capacity" in the label-less case the 'create' attempt fails. Fix this by recognizing that the user wants a default sized namespace and just reconfigure the raw namespace. Signed-off-by: Dan Williams <[email protected]> Signed-off-by: Vishal Verma <[email protected]> --- ndctl/namespace.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ndctl/namespace.c b/ndctl/namespace.c index 58a9e3c53474..a654460ce4c5 100644 --- a/ndctl/namespace.c +++ b/ndctl/namespace.c @@ -791,9 +791,13 @@ static int namespace_create(struct ndctl_region *region) return -EAGAIN; } - available = ndctl_region_get_max_available_extent(region); - if (available == ULLONG_MAX) - available = ndctl_region_get_available_size(region); + if (ndctl_region_get_nstype(region) == ND_DEVICE_NAMESPACE_IO) + available = ndctl_region_get_size(region); + else { + available = ndctl_region_get_max_available_extent(region); + if (available == ULLONG_MAX) + available = ndctl_region_get_available_size(region); + } if (!available || p.size > available) { debug("%s: insufficient capacity size: %llx avail: %llx\n", devname, p.size, available); -- 2.22.0 ++++++ ndctl-ndctl-lib-Fix-duplicate-bus-detection.patch ++++++ >From patchwork Wed Aug 7 17:51:39 2019 X-Patchwork-Submitter: Dan Williams <[email protected]> X-Patchwork-Id: 11082723 Subject: [ndctl PATCH] ndctl/lib: Fix duplicate bus detection From: Dan Williams <[email protected]> Date: Wed, 07 Aug 2019 10:51:39 -0700 Message-ID: <156520029994.1268132.13388510714364773911.st...@dwillia2-desk3.amr.corp.intel.com> After an ndctl_invalidate() event the next add_bus() invocation attempts to rescan for new bus objects and drop duplicate instances that match existing bus objects. However, the implementation mistakenly expects that ndctl_bus_get_provider_name() returns a unique identifier per-bus, but it is perfectly acceptable for unique buses to share a 'provider name'. Use the bus device-name to disambiguate buses with the same 'provider name'. Reported-by: Aneesh Kumar K.V <[email protected]> Tested-by: Aneesh Kumar K.V <[email protected]> Signed-off-by: Dan Williams <[email protected]> --- ndctl/lib/libndctl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index 4d9cc7e29c6b..6596f94edef8 100644 --- a/ndctl/lib/libndctl.c +++ b/ndctl/lib/libndctl.c @@ -889,7 +889,9 @@ static void *add_bus(void *parent, int id, const char *ctl_base) ndctl_bus_foreach(ctx, bus_dup) if (strcmp(ndctl_bus_get_provider(bus_dup), - ndctl_bus_get_provider(bus)) == 0) { + ndctl_bus_get_provider(bus)) == 0 + && strcmp(ndctl_bus_get_devname(bus_dup), + ndctl_bus_get_devname(bus)) == 0) { free_bus(bus, NULL); free(path); return bus_dup; ++++++ ndctl_check_Ensure_mmap_of_BTT_sections_work_with_64K_page-sizes.patch ++++++ >From 28de2eec24e602f65fb2750f172f7c12c30a5aee Mon Sep 17 00:00:00 2001 From: Vaibhav Jain <[email protected]> Date: Tue, 6 Aug 2019 16:20:12 +0530 Subject: [PATCH] ndctl, check: Ensure mmap of BTT sections work with 64K page-sizes Patch-mainline: v66 Git-commit: 28de2eec24e602f65fb2750f172f7c12c30a5aee On PPC64 which uses a 64K page-size, ndctl-check-namespace fails on a BTT namespace with following error: # ndctl check-namespace namespace0.0 -vv namespace0.0: namespace_check: checking namespace0.0 namespace0.0: btt_discover_arenas: found 1 BTT arena namespace0.0: btt_create_mappings: mmap arena[0].info [sz = 0x1000, off = 0x1000] failed: Invalid argument error checking namespaces: Invalid argument checked 0 namespaces An error occurs when btt_create_mappings() tries to mmap the sections of the BTT device which are usually 4K offset aligned. However the mmap() syscall expects the 'offset' argument to be in multiples of page-size, hence it returns EINVAL causing the btt_create_mappings() to error out. To fix this, wrap mmap(2) and munmap(2) with helpers that perform the mmap to a system page boundary, and then adjust the returned pointers if needed, and update btt_create_mappings() to use these. Reported-by: Harish Sriram <[email protected]> Signed-off-by: Vaibhav Jain <[email protected]> Signed-off-by: Vishal Verma <[email protected]> --- ndctl/check.c | 93 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 67 insertions(+), 26 deletions(-) diff --git a/ndctl/check.c b/ndctl/check.c index 8a7125053865..5969012eba84 100644 --- a/ndctl/check.c +++ b/ndctl/check.c @@ -907,59 +907,100 @@ static int btt_discover_arenas(struct btt_chk *bttc) return ret; } -static int btt_create_mappings(struct btt_chk *bttc) +/* + * Wrap call to mmap(2) to work with btt device offsets that are not aligned + * to system page boundary. It works by rounding down the requested offset + * to sys_page_size when calling mmap(2) and then returning a fixed-up pointer + * to the correct offset in the mmaped region. + */ +static void *btt_mmap(struct btt_chk *bttc, size_t length, off_t offset) { - struct arena_info *a; - int mmap_flags; - int i; + off_t page_offset; + int prot_flags; + uint8_t *addr; if (!bttc->opts->repair) - mmap_flags = PROT_READ; + prot_flags = PROT_READ; else - mmap_flags = PROT_READ|PROT_WRITE; + prot_flags = PROT_READ|PROT_WRITE; + + /* Calculate the page_offset from the system page boundary */ + page_offset = offset - rounddown(offset, bttc->sys_page_size); + + /* Update the offset and length with the page_offset calculated above */ + offset -= page_offset; + length += page_offset; + + addr = mmap(NULL, length, prot_flags, MAP_SHARED, bttc->fd, offset); + + /* If needed fixup the return pointer to correct offset requested */ + if (addr != MAP_FAILED) + addr += page_offset; + + dbg(bttc, "addr = %p, length = %#lx, offset = %#lx, page_offset = %#lx\n", + (void *) addr, length, offset, page_offset); + + return addr == MAP_FAILED ? NULL : addr; +} + +static void btt_unmap(struct btt_chk *bttc, void *ptr, size_t length) +{ + off_t page_offset; + uintptr_t addr = (uintptr_t) ptr; + + /* Calculate the page_offset from system page boundary */ + page_offset = addr - rounddown(addr, bttc->sys_page_size); + + addr -= page_offset; + length += page_offset; + + munmap((void *) addr, length); + dbg(bttc, "addr = %p, length = %#lx, page_offset = %#lx\n", + (void *) addr, length, page_offset); +} + +static int btt_create_mappings(struct btt_chk *bttc) +{ + struct arena_info *a; + int i; for (i = 0; i < bttc->num_arenas; i++) { a = &bttc->arena[i]; a->map.info_len = BTT_INFO_SIZE; - a->map.info = mmap(NULL, a->map.info_len, mmap_flags, - MAP_SHARED, bttc->fd, a->infooff); - if (a->map.info == MAP_FAILED) { + a->map.info = btt_mmap(bttc, a->map.info_len, a->infooff); + if (!a->map.info) { err(bttc, "mmap arena[%d].info [sz = %#lx, off = %#lx] failed: %s\n", i, a->map.info_len, a->infooff, strerror(errno)); return -errno; } a->map.data_len = a->mapoff - a->dataoff; - a->map.data = mmap(NULL, a->map.data_len, mmap_flags, - MAP_SHARED, bttc->fd, a->dataoff); - if (a->map.data == MAP_FAILED) { + a->map.data = btt_mmap(bttc, a->map.data_len, a->dataoff); + if (!a->map.data) { err(bttc, "mmap arena[%d].data [sz = %#lx, off = %#lx] failed: %s\n", i, a->map.data_len, a->dataoff, strerror(errno)); return -errno; } a->map.map_len = a->logoff - a->mapoff; - a->map.map = mmap(NULL, a->map.map_len, mmap_flags, - MAP_SHARED, bttc->fd, a->mapoff); - if (a->map.map == MAP_FAILED) { + a->map.map = btt_mmap(bttc, a->map.map_len, a->mapoff); + if (!a->map.map) { err(bttc, "mmap arena[%d].map [sz = %#lx, off = %#lx] failed: %s\n", i, a->map.map_len, a->mapoff, strerror(errno)); return -errno; } a->map.log_len = a->info2off - a->logoff; - a->map.log = mmap(NULL, a->map.log_len, mmap_flags, - MAP_SHARED, bttc->fd, a->logoff); - if (a->map.log == MAP_FAILED) { + a->map.log = btt_mmap(bttc, a->map.log_len, a->logoff); + if (!a->map.log) { err(bttc, "mmap arena[%d].log [sz = %#lx, off = %#lx] failed: %s\n", i, a->map.log_len, a->logoff, strerror(errno)); return -errno; } a->map.info2_len = BTT_INFO_SIZE; - a->map.info2 = mmap(NULL, a->map.info2_len, mmap_flags, - MAP_SHARED, bttc->fd, a->info2off); - if (a->map.info2 == MAP_FAILED) { + a->map.info2 = btt_mmap(bttc, a->map.info2_len, a->info2off); + if (!a->map.info2) { err(bttc, "mmap arena[%d].info2 [sz = %#lx, off = %#lx] failed: %s\n", i, a->map.info2_len, a->info2off, strerror(errno)); return -errno; @@ -977,15 +1018,15 @@ static void btt_remove_mappings(struct btt_chk *bttc) for (i = 0; i < bttc->num_arenas; i++) { a = &bttc->arena[i]; if (a->map.info) - munmap(a->map.info, a->map.info_len); + btt_unmap(bttc, a->map.info, a->map.info_len); if (a->map.data) - munmap(a->map.data, a->map.data_len); + btt_unmap(bttc, a->map.data, a->map.data_len); if (a->map.map) - munmap(a->map.map, a->map.map_len); + btt_unmap(bttc, a->map.map, a->map.map_len); if (a->map.log) - munmap(a->map.log, a->map.log_len); + btt_unmap(bttc, a->map.log, a->map.log_len); if (a->map.info2) - munmap(a->map.info2, a->map.info2_len); + btt_unmap(bttc, a->map.info2, a->map.info2_len); } } -- 2.22.0
