On 30.01.2017 17:34, Alberto Garcia wrote: > On Mon 30 Jan 2017 05:14:41 PM CET, Alberto Garcia wrote: > >> This patch keeps the index of the last used (i.e. non-zero) entry in >> the refcount table and updates it every time the table changes. The >> refcount-block overlap check then uses that index instead of reading >> the whole table. > > Note that while I decided to go for this approach the patch can be made > much simpler by simply stopping at the first empty entry in the refcount > table: > > if ((chk & QCOW2_OL_REFCOUNT_BLOCK) && s->refcount_table) { > for (i = 0; i < s->refcount_table_size; i++) { > if (!(s->refcount_table[i] & REFT_OFFSET_MASK)) { > break; > } > if (overlaps_with(s->refcount_table[i] & REFT_OFFSET_MASK, > s->cluster_size)) { > return QCOW2_OL_REFCOUNT_BLOCK; > } > } > } > > I don't think QEMU produces files where refcount_table[i] == 0 but > refcount_table[i + 1] != 0. Do they even make sense? In any case, my > patch would cover those cases too, but this simplified version wouldn't.
I think it would be reasonable enough to assume that such images don't exist (and if they do, we don't do overlap checks above the hole -- that isn't exactly the end of the world). But your patch looks simple enough as it is. Max
signature.asc
Description: OpenPGP digital signature