diff mbox series

[3/7] block: respect blk_crypto_bio_sectors_alignment() in bounce.c

Message ID 20210114154723.2495814-4-satyat@google.com (mailing list archive)
State New, archived
Headers show
Series ensure bios aren't split in middle of crypto data unit | expand

Commit Message

Satya Tangirala Jan. 14, 2021, 3:47 p.m. UTC
Make __blk_queue_bounce respect blk_crypto_bio_sectors_alignment()
when calling bio_split().

Signed-off-by: Satya Tangirala <satyat@google.com>
---
 block/bounce.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Christoph Hellwig Jan. 21, 2021, 5:13 p.m. UTC | #1
On Thu, Jan 14, 2021 at 03:47:19PM +0000, Satya Tangirala wrote:
> Make __blk_queue_bounce respect blk_crypto_bio_sectors_alignment()
> when calling bio_split().

bounce.c is legacy code that no new driver should use and which we
need to phase out ASAP.  It should be entirely exclusive vs use of a
modern feature like inline crypto.
diff mbox series

Patch

diff --git a/block/bounce.c b/block/bounce.c
index d3f51acd6e3b..7800e2a5a0f8 100644
--- a/block/bounce.c
+++ b/block/bounce.c
@@ -305,6 +305,9 @@  static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig,
 	if (!bounce)
 		return;
 
+	sectors = round_down(sectors,
+			     blk_crypto_bio_sectors_alignment(*bio_orig));
+
 	if (!passthrough && sectors < bio_sectors(*bio_orig)) {
 		bio = bio_split(*bio_orig, sectors, GFP_NOIO, &bounce_bio_split);
 		bio_chain(bio, *bio_orig);