]> git.baikalelectronics.ru Git - kernel.git/commit
dm crypt: fix error with too large bios
authorMikulas Patocka <mpatocka@redhat.com>
Tue, 30 Aug 2016 20:38:42 +0000 (16:38 -0400)
committerMike Snitzer <snitzer@redhat.com>
Tue, 30 Aug 2016 23:44:11 +0000 (19:44 -0400)
commitc63e7df1feec1e32bc0e924684c3964dedf97b6e
tree2d90f9196beeb6fc12fe2d3917b780f063733838
parentbc74ad7bf76bbd9568a53ad5b5cec51ec9791f72
dm crypt: fix error with too large bios

When dm-crypt processes writes, it allocates a new bio in
crypt_alloc_buffer().  The bio is allocated from a bio set and it can
have at most BIO_MAX_PAGES vector entries, however the incoming bio can be
larger (e.g. if it was allocated by bcache).  If the incoming bio is
larger, bio_alloc_bioset() fails and an error is returned.

To avoid the error, we test for a too large bio in the function
crypt_map() and use dm_accept_partial_bio() to split the bio.
dm_accept_partial_bio() trims the current bio to the desired size and
asks DM core to send another bio with the rest of the data.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org # v3.16+
drivers/md/dm-crypt.c