From 73d1df6dd6cbb4dc3b4b16553b744cee32520d4a Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Thu, 24 Jan 2019 15:20:12 +0100 Subject: [PATCH] bdev/crypto: align I/O buffers for encrypt In patch fbec702944 (bdev/crypto: Set QAT alignment requirement) we added an alignment requirement for I/O buffers, but the internally-allocated buffers for encryption haven't respected it. We now allocate those buffers with the crypto bdev's required alignment. It is only required for QAT and we do it unconditionally, but we don't want to strcmp the driver name in the hot I/O path just for that - the code is to be refactored anyway. Change-Id: I2cbc04408ddc5574f212b63536a05eb73ceba104 Signed-off-by: Darek Stojaczyk Reviewed-on: https://review.gerrithub.io/c/441908 Reviewed-by: Paul Luse Reviewed-by: Ben Walker Reviewed-by: Jim Harris Tested-by: SPDK CI Jenkins --- lib/bdev/crypto/vbdev_crypto.c | 3 ++- test/unit/lib/bdev/crypto.c/crypto_ut.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/bdev/crypto/vbdev_crypto.c b/lib/bdev/crypto/vbdev_crypto.c index b8ae8cbcc..309aeec2a 100644 --- a/lib/bdev/crypto/vbdev_crypto.c +++ b/lib/bdev/crypto/vbdev_crypto.c @@ -598,7 +598,8 @@ _crypto_operation(struct spdk_bdev_io *bdev_io, enum rte_crypto_cipher_operation * has a buffer, which ours always will. So, until we modify that API * or better yet the current ZCOPY work lands, this is the best we can do. */ - io_ctx->cry_iov.iov_base = spdk_dma_malloc(total_length, 0x10, NULL); + io_ctx->cry_iov.iov_base = spdk_dma_malloc(total_length, + spdk_bdev_get_buf_align(bdev_io->bdev), NULL); if (!io_ctx->cry_iov.iov_base) { SPDK_ERRLOG("ERROR trying to allocate write buffer for encryption!\n"); rc = -ENOMEM; diff --git a/test/unit/lib/bdev/crypto.c/crypto_ut.c b/test/unit/lib/bdev/crypto.c/crypto_ut.c index fc52cb530..6908765c6 100644 --- a/test/unit/lib/bdev/crypto.c/crypto_ut.c +++ b/test/unit/lib/bdev/crypto.c/crypto_ut.c @@ -58,6 +58,7 @@ DEFINE_STUB(spdk_bdev_io_type_supported, bool, (struct spdk_bdev *bdev, DEFINE_STUB_V(spdk_bdev_module_release_bdev, (struct spdk_bdev *bdev)); DEFINE_STUB_V(spdk_bdev_close, (struct spdk_bdev_desc *desc)); DEFINE_STUB(spdk_bdev_get_name, const char *, (const struct spdk_bdev *bdev), 0); +DEFINE_STUB(spdk_bdev_get_buf_align, size_t, (const struct spdk_bdev *bdev), 0); DEFINE_STUB(spdk_bdev_get_io_channel, struct spdk_io_channel *, (struct spdk_bdev_desc *desc), 0); DEFINE_STUB_V(spdk_bdev_unregister, (struct spdk_bdev *bdev, spdk_bdev_unregister_cb cb_fn, void *cb_arg));