aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSatya Tangirala <satyat@google.com>2021-01-21 23:03:30 +0000
committerEric Biggers <ebiggers@google.com>2021-06-16 23:28:29 -0700
commit6820929287dde814772e90836b4e67eb1194c86c (patch)
tree32dce45ac857ff7c771855857bcc9d3cb7615d47
parenteb50b73c6f02ede580a4baed9ae6a6c1def9cc2b (diff)
downloadlinux-old/wip-blk-crypto-alignment.tar.gz
blk-crypto: relax alignment requirements for bvecs in biosold/wip-blk-crypto-alignment
In order to support direct I/O on encrypted files as well as possibly other future use cases such as filesystem metadata encryption, we need to relax the restriction that if a bio has an encryption context, then all its bvecs must be be aligned to the encryption context's data unit size. Instead we'll just require that the bio's total size be aligned to the data unit size (in addition to the usual logical_block_size alignment requirement on bvecs). Now that the rest of the block layer has been updated to be compatible with the new requirements, update __blk_crypto_bio_prep() accordingly to just validate the alignment of the total size. Co-developed-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Satya Tangirala <satyat@google.com>
-rw-r--r--block/blk-crypto.c19
1 files changed, 2 insertions, 17 deletions
diff --git a/block/blk-crypto.c b/block/blk-crypto.c
index c5bdaafffa29f0..06f81e64151d31 100644
--- a/block/blk-crypto.c
+++ b/block/blk-crypto.c
@@ -200,22 +200,6 @@ bool bio_crypt_ctx_mergeable(struct bio_crypt_ctx *bc1, unsigned int bc1_bytes,
return !bc1 || bio_crypt_dun_is_contiguous(bc1, bc1_bytes, bc2->bc_dun);
}
-/* Check that all I/O segments are data unit aligned. */
-static bool bio_crypt_check_alignment(struct bio *bio)
-{
- const unsigned int data_unit_size =
- bio->bi_crypt_context->bc_key->crypto_cfg.data_unit_size;
- struct bvec_iter iter;
- struct bio_vec bv;
-
- bio_for_each_segment(bv, bio, iter) {
- if (!IS_ALIGNED(bv.bv_len | bv.bv_offset, data_unit_size))
- return false;
- }
-
- return true;
-}
-
blk_status_t __blk_crypto_init_request(struct request *rq)
{
return blk_ksm_get_slot_for_key(rq->q->ksm, rq->crypt_ctx->bc_key,
@@ -271,7 +255,8 @@ bool __blk_crypto_bio_prep(struct bio **bio_ptr)
goto fail;
}
- if (!bio_crypt_check_alignment(bio)) {
+ if (!IS_ALIGNED(bio->bi_iter.bi_size,
+ bc_key->crypto_cfg.data_unit_size)) {
bio->bi_status = BLK_STS_IOERR;
goto fail;
}