freebsd-nq/usr.bin/mkimg
Marcel Moolenaar 852a0932c1 Improve performance of mking(1) by keeping a list of "chunks" in memory,
that keeps track of a particular region of the image. In particular the
image_data() function needs to return to the caller whether a region
contains data or is all zeroes. This required reading the region from
the temporary file and comparing the bytes. When image_data() is used
multiple times for the same region, this will get painful fast.

With a chunk describing a region of the image, we now also have a way
to refer to the image provided on the command line. This means we don't
need to copy the image into a temporary file. We just keep track of the
file descriptor and offset within the source file on a per-chunk basis.

For streams (pipes, sockets, fifos, etc) we now use the temporary file
as a swap file. We read from the input file and create a chunk of type
"zeroes" for each sequence of zeroes that's a multiple of the sector
size. Otherwise, we allocte from the swap file, mmap(2) it, read into
the mmap(2)'d memory and create a chunk representing data.

For regular files, we use SEEK_HOLE and SEEK_DATA to handle sparse files
eficiently and create a chunk of type zeroes for holes and a chunk of
type data for data regions. For data regions, we still compare the bytes
we read to handle differences between a file system's block size and our
sector size.

After reading all files, image_write() is used by schemes to scribble in
the reserved sectors. Since this never amounts to much, keep this data
in memory in chunks of exactly 1 sector.

The output image is created by looking using the chunk list to find the
data and write it out to the output file. For chunks of type "zeroes"
we prefer to seek, but fall back to writing zeroes to handle pipes.
For chunks of type "file" and "memoty" we simply write.

The net effect of this is that for reasonably large images the execution
time drops from 1-2 minutes to 10-20 seconds. A typical speedup is about
5 to 8 times, depending on partition sizes, output format whether in
input files are sparse or not.

Bump version to 20141001.
2014-10-01 21:03:17 +00:00
..
tests Add baseline files for QCOW2. 2014-09-24 22:58:10 +00:00
apm.c Fix partition alignment and image rounding when any of -P (block size), 2014-09-19 23:16:02 +00:00
bsd.c Fix partition alignment and image rounding when any of -P (block size), 2014-09-19 23:16:02 +00:00
ebr.c Fix partition alignment and image rounding when any of -P (block size), 2014-09-19 23:16:02 +00:00
format.c MFuser/marcel/mkimg: 2014-05-15 19:19:57 +00:00
format.h MFuser/marcel/mkimg: 2014-05-15 19:19:57 +00:00
gpt.c Fix partition alignment and image rounding when any of -P (block size), 2014-09-19 23:16:02 +00:00
image.c Improve performance of mking(1) by keeping a list of "chunks" in memory, 2014-10-01 21:03:17 +00:00
image.h Add image_data() for checking whether a sequence of blocks has data. 2014-07-15 04:39:23 +00:00
Makefile Improve performance of mking(1) by keeping a list of "chunks" in memory, 2014-10-01 21:03:17 +00:00
mbr.c Fix partition alignment and image rounding when any of -P (block size), 2014-09-19 23:16:02 +00:00
mkimg.1 Update the usage message and the man page to account for the new long 2014-09-27 17:58:03 +00:00
mkimg.c Update the usage message and the man page to account for the new long 2014-09-27 17:58:03 +00:00
mkimg.h Fix partition alignment and image rounding when any of -P (block size), 2014-09-19 23:16:02 +00:00
pc98.c Fix partition alignment and image rounding when any of -P (block size), 2014-09-19 23:16:02 +00:00
qcow.c Finish QCOW version 2 and stop making it conditional. 2014-09-24 22:45:03 +00:00
raw.c Add VHD support to mkimg(1). VHD is used by Xen and Microsoft's Hyper-V 2014-07-03 20:31:43 +00:00
scheme.c Fix partition alignment and image rounding when any of -P (block size), 2014-09-19 23:16:02 +00:00
scheme.h Fix partition alignment and image rounding when any of -P (block size), 2014-09-19 23:16:02 +00:00
vhd.c Suffix the cookie constants with ULL to silence warnings from compilers 2014-10-01 20:37:15 +00:00
vmdk.c Create a redundant grain directory and table. Previously we were 2014-08-09 04:47:12 +00:00
vtoc8.c Fix partition alignment and image rounding when any of -P (block size), 2014-09-19 23:16:02 +00:00