Re: [Qemu-block] [Qemu-devel] [PATCH 2/6] qcow2: simplify qcow2_cache_put() and qcow2_cache_entry_mark_dirty()

2015-05-06 Thread Stefan Hajnoczi
On Tue, May 05, 2015 at 03:06:52PM +0200, Alberto Garcia wrote: On Fri 01 May 2015 04:31:52 PM CEST, Stefan Hajnoczi wrote: int qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, void **table) { -int i; +int i = (*table - c-table_array) / c-table_size; -for (i = 0;

Re: [Qemu-block] [Qemu-devel] [PATCH 2/6] qcow2: simplify qcow2_cache_put() and qcow2_cache_entry_mark_dirty()

2015-05-05 Thread Alberto Garcia
On Fri 01 May 2015 04:31:52 PM CEST, Stefan Hajnoczi wrote: int qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, void **table) { -int i; +int i = (*table - c-table_array) / c-table_size; -for (i = 0; i c-size; i++) { -if (table_addr(c, i) == *table) { -

Re: [Qemu-block] [Qemu-devel] [PATCH 2/6] qcow2: simplify qcow2_cache_put() and qcow2_cache_entry_mark_dirty()

2015-05-05 Thread Eric Blake
On 04/30/2015 04:11 AM, Alberto Garcia wrote: Since all tables are now stored together, it is possible to obtain the position of a particular table directly from its address, so the operation becomes O(1). Signed-off-by: Alberto Garcia be...@igalia.com --- block/qcow2-cache.c | 22