Commit 1029c365 authored by Mike Hibler's avatar Mike Hibler
Browse files

Build option (disabled) to align included free ranges on hash boundaries.

Part of an effort to make delta images more precise. But the increased size
of the images means this probably isn't worth it. Revisit when I have more
time (ha, ha!)
parent f9aed8d9
......@@ -113,6 +113,7 @@ WITH_FAT = @WINSUPPORT@
# Note: requires WITH_CRYPTO
WITH_HASH = 1
WITH_HASHALIGN = 0
include $(OBJDIR)/Makeconf
......@@ -234,6 +235,9 @@ SUBDIRCFLAGS += -DHASHSTATS
SUBDIRS += hashmap
ZIPLIBS += hashmap/libhashmap.a
LIBS += -lcrypto $(PTHREADLIBS)
ifeq ($(WITH_HASHALIGN),1)
CFLAGS += -DWITH_HASHALIGN
endif
endif
ifeq ($(WITH_RANGEMAP),1)
......
......@@ -62,6 +62,9 @@
#include "range.h"
#ifdef WITH_HASH
#include "hashmap/hashmap.h"
#ifdef WITH_HASHALIGN
#include "imagehash.h"
#endif
#endif
/*
......@@ -475,6 +478,12 @@ main(int argc, char *argv[])
compat = COMPRESSED_V3;
break;
case 'F':
#ifdef WITH_HASHALIGN
if (strcmp(optarg, "ha") == 0) {
frangesize = -1;
break;
}
#endif
frangesize = atoi(optarg);
if (frangesize < 0)
usage();
......@@ -1546,7 +1555,66 @@ mergeskips(int verbose)
prevp = &skips;
while (*prevp) {
prange = *prevp;
#ifdef WITH_HASHALIGN
/*
* Free ranges should line up with hash ranges
*/
if (frangesize < 0) {
unsigned int hbsize, toff, tsize;
int didit = 0;
hbsize = bytestosec(HASHBLK_SIZE); /* XXX */
toff = prange->start % hbsize;
if (prange->size < hbsize ||
(toff &&
prange->size < (hbsize - toff) + hbsize))
goto dropall;
if (toff) {
tsize = hbsize - toff;
toff = prange->start;
if (zerofrange)
addfixupfunc(zerofixup,
sectobytes(toff),
0,
sectobytes(tsize),
NULL, 0,
RELOC_NONE);
prange->start += tsize;
prange->size -= tsize;
total += tsize;
didit++;
}
tsize = prange->size % hbsize;
if (tsize) {
toff = prange->start + prange->size
- tsize;
if (zerofrange)
addfixupfunc(zerofixup,
sectobytes(toff),
0,
sectobytes(tsize),
NULL, 0,
RELOC_NONE);
prange->size -= tsize;
total += tsize;
didit++;
}
if (didit)
culled++;
assert(prange->size >= hbsize);
assert((prange->start % hbsize) == 0);
assert((prange->size % hbsize) == 0);
prevp = &prange->next;
} else
#endif
if (prange->size < (uint32_t)frangesize) {
#ifdef WITH_HASHALIGN
dropall:
#endif
if (debug > 2)
fprintf(stderr,
"dropping range [%u-%u]\n",
......
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