All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit 29628dee authored by Mike Hibler's avatar Mike Hibler

Cleanup, start to figure out best way to create delta with no sigs.

parent 22e3ffff
......@@ -752,16 +752,7 @@ main(int argc, char **argv)
argv[1], ndz2.ndz->hashtype, ndz2.ndz->hashblksize);
exit(1);
}
#if 1
/* XXX just duplicate image 2 */
{
struct ndz_rangemap *foo;
foo = ndz_rangemap_init(NDZ_LOADDR, NDZ_HIADDR-NDZ_LOADDR);
delta.map = ndz_compute_delta(foo, ndz2.sigmap);
}
#else
delta.map = ndz_compute_delta(ndz1.sigmap, ndz2.sigmap);
#endif
delta.map = ndz_compute_delta_sigmap(ndz1.sigmap, ndz2.sigmap);
if (delta.map == NULL) {
fprintf(stderr, "Could not compute delta for %s and %s\n",
argv[0], argv[1]);
......@@ -784,8 +775,34 @@ main(int argc, char **argv)
fflush(stdout);
#endif
}
/*
* Compute a delta map from the images themselves.
* Same deal, but construct the delta map from the ranges maps.
*/
else {
fprintf(stderr, "No can do without sigfiles right now!\n");
delta.map = ndz_compute_delta(ndz1.map, ndz2.map);
if (delta.map == NULL) {
fprintf(stderr, "Could not compute delta for %s and %s\n",
argv[0], argv[1]);
exit(1);
}
/*
* Delta map has same range as full image.
* XXX doesn't belong here.
*/
delta.ndz->maplo = ndz2.ndz->maplo;
delta.ndz->maphi = ndz2.ndz->maphi;
#if 1
printf("==== Delta map ");
ndz_hashmap_dump(delta.map, (debug==0));
printf("==== Old map stats:");
ndz_rangemap_dumpstats(ndz1.map);
printf("==== New map stats:");
ndz_rangemap_dumpstats(ndz2.map);
fflush(stdout);
#endif
exit(2);
}
......
......@@ -26,21 +26,6 @@
*
* Since chunks are independently compressed, we can manipulate them
* independently.
*
* TODO:
* - In _read entire chunk at once, optionally return a pointer to the
* header struct. Alternatively, at least have a 1M buffer, read
* incrementally, and keep a high water mark that we have read so far.
*
* - Add a _reopen call when seeking backward in the same chunk. Still
* have to reset the zlib state, but don't have to reread the compressed
* data.
*
* - In _create, return a pointer to where the header should go so caller
* can fill it in. Option to _flush to say whether to write the header
* out or not.
*
* - Page-align the buffer.
*/
#include <unistd.h>
......
......@@ -38,6 +38,8 @@
#include "libndz.h"
#define COMPDELTA_DEBUG
char *
ndz_hash_dump(unsigned char *h, int hlen)
{
......@@ -349,8 +351,22 @@ struct deltainfo {
int omapdone;
};
/*
* Compute a "reasonably accurate" delta given the hash maps of two
* images. Where hash ranges of the two maps exactly overlap, we can
* use the hashes to determine whether to include the range. Otherwise,
* if they partially overlap, we just include the entirety of the new
* range, rather than determining the exact sets of overlaps and computing
* hashes on those.
*
* Why is this "reasonably accurate"? Since these are hash maps, no range
* is larger than hashblksize sectors (typically 128 sectors), so any single
* partial overlap will be contained in a small area. Worst case scenario
* is that one sector has been added or removed from each hashblksize range.
* This would cause us to create a full image.
*/
static int
compdelta(struct ndz_rangemap *nmap, struct ndz_range *range, void *arg)
compfastdelta(struct ndz_rangemap *nmap, struct ndz_range *range, void *arg)
{
struct deltainfo *dinfo = arg;
struct ndz_rangemap *omap = dinfo->omap;
......@@ -476,7 +492,36 @@ ndz_compute_delta(struct ndz_rangemap *omap, struct ndz_rangemap *nmap)
dinfo.omap = omap;
dinfo.dmap = dmap;
dinfo.omapdone = 0;
#if 0
(void) ndz_rangemap_iterate(nmap, compdelta, &dinfo);
#endif
return dmap;
}
/*
* This is much easier as we don't need to hash anything or worry about
* computing hash alignments.
*/
struct ndz_rangemap *
ndz_compute_delta_sigmap(struct ndz_rangemap *omap, struct ndz_rangemap *nmap)
{
struct ndz_rangemap *dmap;
struct deltainfo dinfo;
if (omap == NULL || nmap == NULL)
return NULL;
dmap = ndz_rangemap_init(nmap->loaddr, nmap->hiaddr);
if (dmap == NULL) {
fprintf(stderr, "Could not allocate delta map\n");
return NULL;
}
dinfo.omap = omap;
dinfo.dmap = dmap;
dinfo.omapdone = 0;
(void) ndz_rangemap_iterate(nmap, compfastdelta, &dinfo);
return dmap;
}
......
......@@ -111,6 +111,8 @@ char *ndz_hash_dump(unsigned char *h, int hlen);
void ndz_hashmap_dump(struct ndz_rangemap *map, int summaryonly);
struct ndz_rangemap *ndz_compute_delta(struct ndz_rangemap *omap,
struct ndz_rangemap *nmap);
struct ndz_rangemap *ndz_compute_delta_sigmap(struct ndz_rangemap *omap,
struct ndz_rangemap *nmap);
#endif /* _LIBNDZ_H_ */
......
......@@ -486,8 +486,8 @@ ndz_rangemap_dump(struct ndz_rangemap *map, int summaryonly,
ndz_rangemap_dumpstats(map);
for (range = map->head.next; range; range = range->next) {
if (!summaryonly) {
printf("\t%p: %c[%lu - %lu]",
range, *map->hint == range ? '*' : ' ',
printf("\t%c[%lu - %lu]",
*map->hint == range ? '*' : ' ',
(unsigned long)range->start, (unsigned long)range->end);
if (range->data) {
printf(", ");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment