block: make copy-on-read a per-request flag
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Wed, 18 Jan 2012 14:40:42 +0000 (14:40 +0000)
committerKevin Wolf <kwolf@redhat.com>
Thu, 26 Jan 2012 10:45:26 +0000 (11:45 +0100)
commit470c05047a09cda3de16bb3f98a130d9537357a4
treec101557e6ff36ca1fe1465884062433358f85714
parent2d3735d3bf61d5c8e154a197a11535cc65044334
block: make copy-on-read a per-request flag

Previously copy-on-read could only be enabled for all requests to a
block device.  This means requests coming from the guest as well as
QEMU's internal requests would perform copy-on-read when enabled.

For image streaming we want to support finer-grained behavior than just
populating the image file from its backing image.  Image streaming
supports partial streaming where a common backing image is preserved.
In this case guest requests should not perform copy-on-read because they
would indiscriminately copy data which should be left in a backing image
from the backing chain.

Introduce a per-request flag for copy-on-read so that a block device can
process both regular and copy-on-read requests.  Overlapping reads and
writes still need to be serialized for correctness when copy-on-read is
happening, so add an in-flight reference count to track this.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c
block.h
block_int.h
trace-events