Files
qemu-esp-boards/block
Vladimir Sementsov-Ogievskiy f8d59dfb40 block/backup: fix fleecing scheme: use serialized writes
Fleecing scheme works as follows: we want a kind of temporary snapshot
of active drive A. We create temporary image B, with B->backing = A.
Then we start backup(sync=none) from A to B. From this point, B reads
as point-in-time snapshot of A (A continues to be active drive,
accepting guest IO).

This scheme needs some additional synchronization between reads from B
and backup COW operations, otherwise, the following situation is
theoretically possible:

(assume B is qcow2, client is NBD client, reading from B)

1. client starts reading and take qcow2 mutex in qcow2_co_preadv, and
   goes up to l2 table loading (assume cache miss)

2) guest write => backup COW => qcow2 write =>
   try to take qcow2 mutex => waiting

3. l2 table loaded, we see that cluster is UNALLOCATED, go to
   "case QCOW2_CLUSTER_UNALLOCATED" and unlock mutex before
   bdrv_co_preadv(bs->backing, ...)

4) aha, mutex unlocked, backup COW continues, and we finally finish
   guest write and change cluster in our active disk A

5. actually, do bdrv_co_preadv(bs->backing, ...) and read
   _new updated_ data.

To avoid this, let's make backup writes serializing, to not intersect
with reads from B.

Note: we expand range of handled cases from (sync=none and
B->backing = A) to just (A in backing chain of B), to finally allow
safe reading from B during backup for all cases when A in backing chain
of B, i.e. B formally looks like point-in-time snapshot of A.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2018-07-10 13:10:29 +02:00
..
2016-10-07 14:14:06 +02:00
2018-07-10 13:04:25 +02:00
2018-07-10 13:10:25 +02:00
2018-07-10 13:04:25 +02:00
2018-07-05 10:29:19 +02:00
2018-05-15 16:11:41 +02:00
2018-02-09 05:05:11 +01:00
2018-07-10 13:04:25 +02:00
2018-07-05 10:29:19 +02:00
2018-06-29 14:20:56 +02:00
2017-07-17 11:34:11 +08:00
2018-07-10 13:04:25 +02:00
2018-06-11 16:18:45 +02:00
2018-07-02 23:23:45 -04:00
2018-07-02 14:45:23 +02:00
2018-06-29 14:20:56 +02:00
2018-06-15 14:49:44 +02:00