]> git.baikalelectronics.ru Git - kernel.git/commit
dm snapshot: fix race during exception creation
authorMikulas Patocka <mpatocka@redhat.com>
Mon, 21 Jul 2008 11:00:34 +0000 (12:00 +0100)
committerAlasdair G Kergon <agk@redhat.com>
Mon, 21 Jul 2008 11:00:34 +0000 (12:00 +0100)
commit3be97a3639a8af827891dc64238ba89daace3527
treef9435bed2d582e4cd3e91e4d6fb18a18f62aa019
parent4a7edbf315600e55ef232a33c9920481f54a7d4d
dm snapshot: fix race during exception creation

Fix a race condition that returns incorrect data when a write causes an
exception to be allocated whilst a read is still in flight.

The race condition happens as follows:
* A read to non-reallocated sector in the snapshot is submitted so that the
  read is routed to the original device.
* A write to the original device is submitted. The write causes an exception
  that reallocates the block.  The write proceeds.
* The original read is dequeued and reads the wrong data.

This race can be triggered with CFQ scheduler and one thread writing and
multiple threads reading simultaneously.

(This patch relies upon the earlier dm-kcopyd-per-device.patch to avoid a
deadlock.)

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
drivers/md/dm-snap.c