diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2021-02-10 15:26:23 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-03-04 09:39:57 +0100 |
commit | 5c5bb514651aa174f15001b2624aca7b89976af6 (patch) | |
tree | b98970a58b94613ae069f26a4504ad757c27d3ec /include/linux/device-mapper.h | |
parent | c0a82e0117b341423633ff09ad8a8db60f950871 (diff) | |
download | linux-stable-5c5bb514651aa174f15001b2624aca7b89976af6.tar.gz linux-stable-5c5bb514651aa174f15001b2624aca7b89976af6.tar.bz2 linux-stable-5c5bb514651aa174f15001b2624aca7b89976af6.zip |
dm: fix deadlock when swapping to encrypted device
commit a666e5c05e7c4aaabb2c5d58117b0946803d03d2 upstream.
The system would deadlock when swapping to a dm-crypt device. The reason
is that for each incoming write bio, dm-crypt allocates memory that holds
encrypted data. These excessive allocations exhaust all the memory and the
result is either deadlock or OOM trigger.
This patch limits the number of in-flight swap bios, so that the memory
consumed by dm-crypt is limited. The limit is enforced if the target set
the "limit_swap_bios" variable and if the bio has REQ_SWAP set.
Non-swap bios are not affected becuase taking the semaphore would cause
performance degradation.
This is similar to request-based drivers - they will also block when the
number of requests is over the limit.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/device-mapper.h')
-rw-r--r-- | include/linux/device-mapper.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index ff60ba537cf2..cde6708644ae 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -315,6 +315,11 @@ struct dm_target { * on max_io_len boundary. */ bool split_discard_bios:1; + + /* + * Set if we need to limit the number of in-flight bios when swapping. + */ + bool limit_swap_bios:1; }; /* Each target can link one of these into the table */ |