mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 21:21:41 +00:00
a892c8d52c
We must have some way of letting a storage device driver know what encryption context it should use for en/decrypting a request. However, it's the upper layers (like the filesystem/fscrypt) that know about and manages encryption contexts. As such, when the upper layer submits a bio to the block layer, and this bio eventually reaches a device driver with support for inline encryption, the device driver will need to have been told the encryption context for that bio. We want to communicate the encryption context from the upper layer to the storage device along with the bio, when the bio is submitted to the block layer. To do this, we add a struct bio_crypt_ctx to struct bio, which can represent an encryption context (note that we can't use the bi_private field in struct bio to do this because that field does not function to pass information across layers in the storage stack). We also introduce various functions to manipulate the bio_crypt_ctx and make the bio/request merging logic aware of the bio_crypt_ctx. We also make changes to blk-mq to make it handle bios with encryption contexts. blk-mq can merge many bios into the same request. These bios need to have contiguous data unit numbers (the necessary changes to blk-merge are also made to ensure this) - as such, it suffices to keep the data unit number of just the first bio, since that's all a storage driver needs to infer the data unit number to use for each data block in each bio in a request. blk-mq keeps track of the encryption context to be used for all the bios in a request with the request's rq_crypt_ctx. When the first bio is added to an empty request, blk-mq will program the encryption context of that bio into the request_queue's keyslot manager, and store the returned keyslot in the request's rq_crypt_ctx. All the functions to operate on encryption contexts are in blk-crypto.c. Upper layers only need to call bio_crypt_set_ctx with the encryption key, algorithm and data_unit_num; they don't have to worry about getting a keyslot for each encryption context, as blk-mq/blk-crypto handles that. Blk-crypto also makes it possible for request-based layered devices like dm-rq to make use of inline encryption hardware by cloning the rq_crypt_ctx and programming a keyslot in the new request_queue when necessary. Note that any user of the block layer can submit bios with an encryption context, such as filesystems, device-mapper targets, etc. Signed-off-by: Satya Tangirala <satyat@google.com> Reviewed-by: Eric Biggers <ebiggers@google.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
40 lines
1.6 KiB
Makefile
40 lines
1.6 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
#
|
|
# Makefile for the kernel block layer
|
|
#
|
|
|
|
obj-$(CONFIG_BLOCK) := bio.o elevator.o blk-core.o blk-sysfs.o \
|
|
blk-flush.o blk-settings.o blk-ioc.o blk-map.o \
|
|
blk-exec.o blk-merge.o blk-softirq.o blk-timeout.o \
|
|
blk-lib.o blk-mq.o blk-mq-tag.o blk-stat.o \
|
|
blk-mq-sysfs.o blk-mq-cpumap.o blk-mq-sched.o ioctl.o \
|
|
genhd.o ioprio.o badblocks.o partitions/ blk-rq-qos.o
|
|
|
|
obj-$(CONFIG_BOUNCE) += bounce.o
|
|
obj-$(CONFIG_BLK_SCSI_REQUEST) += scsi_ioctl.o
|
|
obj-$(CONFIG_BLK_DEV_BSG) += bsg.o
|
|
obj-$(CONFIG_BLK_DEV_BSGLIB) += bsg-lib.o
|
|
obj-$(CONFIG_BLK_CGROUP) += blk-cgroup.o
|
|
obj-$(CONFIG_BLK_CGROUP_RWSTAT) += blk-cgroup-rwstat.o
|
|
obj-$(CONFIG_BLK_DEV_THROTTLING) += blk-throttle.o
|
|
obj-$(CONFIG_BLK_CGROUP_IOLATENCY) += blk-iolatency.o
|
|
obj-$(CONFIG_BLK_CGROUP_IOCOST) += blk-iocost.o
|
|
obj-$(CONFIG_MQ_IOSCHED_DEADLINE) += mq-deadline.o
|
|
obj-$(CONFIG_MQ_IOSCHED_KYBER) += kyber-iosched.o
|
|
bfq-y := bfq-iosched.o bfq-wf2q.o bfq-cgroup.o
|
|
obj-$(CONFIG_IOSCHED_BFQ) += bfq.o
|
|
|
|
obj-$(CONFIG_BLK_CMDLINE_PARSER) += cmdline-parser.o
|
|
obj-$(CONFIG_BLK_DEV_INTEGRITY) += bio-integrity.o blk-integrity.o
|
|
obj-$(CONFIG_BLK_DEV_INTEGRITY_T10) += t10-pi.o
|
|
obj-$(CONFIG_BLK_MQ_PCI) += blk-mq-pci.o
|
|
obj-$(CONFIG_BLK_MQ_VIRTIO) += blk-mq-virtio.o
|
|
obj-$(CONFIG_BLK_MQ_RDMA) += blk-mq-rdma.o
|
|
obj-$(CONFIG_BLK_DEV_ZONED) += blk-zoned.o
|
|
obj-$(CONFIG_BLK_WBT) += blk-wbt.o
|
|
obj-$(CONFIG_BLK_DEBUG_FS) += blk-mq-debugfs.o
|
|
obj-$(CONFIG_BLK_DEBUG_FS_ZONED)+= blk-mq-debugfs-zoned.o
|
|
obj-$(CONFIG_BLK_SED_OPAL) += sed-opal.o
|
|
obj-$(CONFIG_BLK_PM) += blk-pm.o
|
|
obj-$(CONFIG_BLK_INLINE_ENCRYPTION) += keyslot-manager.o blk-crypto.o
|