]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
dm crypt: fix async split
authorMilan Broz <mbroz@redhat.com>
Tue, 21 Oct 2008 16:45:02 +0000 (17:45 +0100)
committerAlasdair G Kergon <agk@redhat.com>
Tue, 21 Oct 2008 16:45:02 +0000 (17:45 +0100)
commit393b47ef23bbcf16890c907d0144b5a8ec4caebf
tree8f3f26715fe81ef5fb78a6f30a46e163873de6b9
parentb635b00e0e159d858486fd899c4021d1d67757e2
dm crypt: fix async split

When writing io, dm-crypt has to allocate a new cloned bio
and encrypt the data into newly-allocated pages attached to this bio.
In rare cases, because of hw restrictions (e.g. physical segment limit)
or memory pressure, sometimes more than one cloned bio has to be used,
each processing a different fragment of the original.

Currently there is one waitqueue which waits for one fragment to finish
and continues processing the next fragment.

But when using asynchronous crypto this doesn't work, because several
fragments may be processed asynchronously or in parallel and there is
only one crypt context that cannot be shared between the bio fragments.
The result may be corruption of the data contained in the encrypted bio.

The patch fixes this by allocating new dm_crypt_io structs (with new
crypto contexts) and running them independently.

The fragments contains a pointer to the base dm_crypt_io struct to
handle reference counting, so the base one is properly deallocated
after all the fragments are finished.

In a low memory situation, this only uses one additional object from the
mempool.  If the mempool is empty, the next allocation simple waits for
previous fragments to complete.

Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
drivers/md/dm-crypt.c