Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP4:Update
libkdumpfile.36085
diskdump-Add-struct-mdf_flatmap-to-hold-flatten...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File diskdump-Add-struct-mdf_flatmap-to-hold-flattened-fo.patch of Package libkdumpfile.36085
From: Petr Tesarik <petr@tesarici.cz> Date: Wed, 25 Sep 2024 09:03:09 +0200 Subject: diskdump: Add struct mdf_flatmap to hold flattened format data References: bsc#1223399 Upstream: merged Git-commit: 38670238f126d58a1467e2f9b13838c574228e61 The translation between flattened offsets and rearranged offsets is currently implemented using flatmap and flatoffs. Put both data structures into a newly introduced struct mdf_flatmap. This should make it easier to separate flattened format handling from struct disk_dump_priv. Signed-off-by: Petr Tesarik <ptesarik@suse.com> --- src/kdumpfile/diskdump.c | 60 +++++++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 22 deletions(-) --- a/src/kdumpfile/diskdump.c +++ b/src/kdumpfile/diskdump.c @@ -170,6 +170,15 @@ struct page_desc { uint64_t page_flags; /**< Page flags. */ }; +/** Offset mapping for a file in the flattened format. */ +struct flattened_file_map { + /** Map (rearranged) offset to an index in the offset arrray. */ + addrxlat_map_t *map; + + /** Differences between flattened and rearranged file offsets. */ + off_t *offs; +}; + /** PFN region mapping. */ struct pfn_rgn { kdump_pfn_t pfn; /**< Starting PFN. */ @@ -186,11 +195,8 @@ struct disk_dump_priv { struct pfn_rgn *pfn_rgn; /**< PFN region map. */ size_t pfn_rgn_num; /**< Number of elements in the map. */ - /** File offset mapping for flattened files. */ - addrxlat_map_t *flatmap; - - /** Differences between flattened and rearranged file offsets. */ - off_t *flatoffs; + /** File offset mappings for flattened files. */ + struct flattened_file_map *flatmap; }; struct setup_data { @@ -230,8 +236,8 @@ flattened_pread(kdump_ctx_t *ctx, void * const addrxlat_range_t *range, *end; off_t off; - range = addrxlat_map_ranges(ddp->flatmap); - end = range + addrxlat_map_len(ddp->flatmap); + range = addrxlat_map_ranges(ddp->flatmap->map); + end = range + addrxlat_map_len(ddp->flatmap->map); for (off = pos; range < end && off > range->endoff; ++range) off -= range->endoff + 1; while (range < end && len) { @@ -242,11 +248,12 @@ flattened_pread(kdump_ctx_t *ctx, void * seglen = len; if (range->meth != ADDRXLAT_SYS_METH_NONE) { + off_t *flatoffs = ddp->flatmap->offs; unsigned segidx = range->meth; kdump_status ret; ret = fcache_pread(ctx->shared->fcache, buf, seglen, - pos + ddp->flatoffs[segidx]); + pos + flatoffs[segidx]); if (ret != KDUMP_OK) return ret; } else @@ -301,12 +308,12 @@ flattened_get_chunk(kdump_ctx_t *ctx, st const addrxlat_range_t *range, *end; off_t off; - range = addrxlat_map_ranges(ddp->flatmap); - end = range + addrxlat_map_len(ddp->flatmap); + range = addrxlat_map_ranges(ddp->flatmap->map); + end = range + addrxlat_map_len(ddp->flatmap->map); for (off = pos; range < end && off > range->endoff; ++range) off -= range->endoff + 1; if (len <= range->endoff + 1 - off) { - pos += ddp->flatoffs[range->meth]; + pos += ddp->flatmap->offs[range->meth]; return fcache_get_chunk(ctx->shared->fcache, fch, len, pos); } @@ -1076,8 +1083,8 @@ init_flattened_file(kdump_ctx_t *ctx) off_t flatpos; kdump_status status; - ddp->flatmap = addrxlat_map_new(); - if (!ddp->flatmap) + ddp->flatmap->map = addrxlat_map_new(); + if (!ddp->flatmap->map) return set_error(ctx, KDUMP_ERR_SYSTEM, "Cannot allocate %s", "flattened map"); @@ -1109,20 +1116,20 @@ init_flattened_file(kdump_ctx_t *ctx) unsigned newlen = segidx + FLATOFFS_ALLOC_INC; off_t *newbuf; - newbuf = realloc(ddp->flatoffs, - sizeof(*ddp->flatoffs) * newlen); + newbuf = realloc(ddp->flatmap->offs, + sizeof(*ddp->flatmap->offs) * newlen); if (!newbuf) return set_error(ctx, KDUMP_ERR_SYSTEM, "Cannot allocate %s", "flattened offset array"); - ddp->flatoffs = newbuf; + ddp->flatmap->offs = newbuf; } flatpos += sizeof(hdr); - ddp->flatoffs[segidx] = flatpos - pos; + ddp->flatmap->offs[segidx] = flatpos - pos; range.endoff = size - 1; range.meth = segidx; - if (addrxlat_map_set(ddp->flatmap, pos, &range) != ADDRXLAT_OK) + if (addrxlat_map_set(ddp->flatmap->map, pos, &range) != ADDRXLAT_OK) return set_error(ctx, KDUMP_ERR_SYSTEM, "Cannot allocate %s", "flattened map entry"); @@ -1142,8 +1149,14 @@ init_flattened_file(kdump_ctx_t *ctx) static kdump_status init_flattened_maps(kdump_ctx_t *ctx) { + struct disk_dump_priv *ddp = ctx->shared->fmtdata; kdump_status status; + ddp->flatmap = calloc(1, sizeof(*ddp->flatmap)); + if (!ddp->flatmap) + return set_error(ctx, KDUMP_ERR_SYSTEM, + "Cannot allocate %s", "flatmap array"); + status = init_flattened_file(ctx); if (status != KDUMP_OK) return set_error(ctx, status, @@ -1231,10 +1244,13 @@ diskdump_cleanup(struct kdump_shared *sh if (ddp) { if (ddp->pfn_rgn) free(ddp->pfn_rgn); - if (ddp->flatmap) - addrxlat_map_decref(ddp->flatmap); - if (ddp->flatoffs) - free(ddp->flatoffs); + if (ddp->flatmap) { + if (ddp->flatmap->map) + addrxlat_map_decref(ddp->flatmap->map); + if (ddp->flatmap->offs) + free(ddp->flatmap->offs); + free(ddp->flatmap); + } free(ddp); shared->fmtdata = NULL; }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor