diff options
| author | Mikulas Patocka <[email protected]> | 2015-02-13 13:24:41 +0000 |
|---|---|---|
| committer | Mike Snitzer <[email protected]> | 2015-02-16 16:11:13 +0000 |
| commit | 7145c241a1bf2841952c3e297c4080b357b3e52d (patch) | |
| tree | 12c9a8ffce670390ea5b518fbe6d9b64f90f05b9 /lib/string_helpers.c | |
| parent | dm crypt: don't allocate pages for a partial request (diff) | |
| download | kernel-7145c241a1bf2841952c3e297c4080b357b3e52d.tar.gz kernel-7145c241a1bf2841952c3e297c4080b357b3e52d.zip | |
dm crypt: avoid deadlock in mempools
Fix a theoretical deadlock introduced in the previous commit ("dm crypt:
don't allocate pages for a partial request").
The function crypt_alloc_buffer may be called concurrently. If we allocate
from the mempool concurrently, there is a possibility of deadlock. For
example, if we have mempool of 256 pages, two processes, each wanting
256, pages allocate from the mempool concurrently, it may deadlock in a
situation where both processes have allocated 128 pages and the mempool
is exhausted.
To avoid such a scenario we allocate the pages under a mutex. In order
to not degrade performance with excessive locking, we try non-blocking
allocations without a mutex first and if that fails, we fallback to a
blocking allocations with a mutex.
Signed-off-by: Mikulas Patocka <[email protected]>
Signed-off-by: Mike Snitzer <[email protected]>
Diffstat (limited to 'lib/string_helpers.c')
0 files changed, 0 insertions, 0 deletions
