linux-xiaomi-chiron/drivers
Satya Tangirala a892c8d52c block: Inline encryption support for blk-mq
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>
2020-05-14 09:47:53 -06:00
..
accessibility
acpi
amba
android
ata block: move dma_pad handling from blk_rq_map_sg into the callers 2020-04-22 10:47:39 -06:00
atm
auxdisplay
base driver core: remove device_create_vargs 2020-05-09 16:15:13 -06:00
bcma
block null_blk: Support REQ_OP_ZONE_APPEND 2020-05-12 20:36:28 -06:00
bluetooth
bus
cdrom cdrom: factor out a cdrom_multisession helper 2020-05-04 10:13:42 -06:00
char
clk
clocksource
connector
counter
cpufreq
cpuidle
crypto
dax
dca
devfreq
dio
dma
dma-buf
edac
eisa
extcon
firewire
firmware
fpga
fsi
gnss
gpio
gpu
greybus
hid
hsi
hv
hwmon hwmon: (jc42) Fix name to have no illegal characters 2020-04-18 10:13:07 -07:00
hwspinlock
hwtracing
i2c
i3c
ide ide-cd: rename cdrom_read_tocentry 2020-05-04 10:13:42 -06:00
idle
iio
infiniband
input
interconnect
iommu
ipack
irqchip Merge branch 'irq/gic-v4.1-fixes-5.7' into irq/irqchip-5.7 2020-04-17 08:59:55 +01:00
isdn
leds
lightnvm
macintosh
mailbox
mcb
md block: Inline encryption support for blk-mq 2020-05-14 09:47:53 -06:00
media
memory
memstick
message
mfd
misc
mmc
most
mtd bdi: remove the name field in struct backing_dev_info 2020-05-09 16:15:13 -06:00
mux
net
nfc
ntb
nubus
nvdimm
nvme nvme: fix possible hang when ns scanning fails during error recovery 2020-05-09 16:07:58 -06:00
nvmem
of of: unittest: kmemleak in duplicate property update 2020-04-17 08:31:34 -05:00
opp
oprofile
parisc
parport
pci
pcmcia
perf
phy
pinctrl
platform
pnp
power
powercap
pps
ps3
ptp
pwm
rapidio
ras
regulator
remoteproc
reset
rpmsg
rtc
s390 dasd: use blk_drop_partitions instead of badly reimplementing it 2020-04-20 11:32:59 -06:00
sbus
scsi scsi: sd_zbc: emulate ZONE_APPEND commands 2020-05-12 20:36:28 -06:00
sfi
sh
siox
slimbus
soc
soundwire
spi
spmi
ssb
staging
target
tc
tee
thermal
thunderbolt
tty
uio
usb
vdpa
vfio
vhost
video
virt
virtio
visorbus
vlynq
vme
w1
watchdog
xen xen: branch for v5.7-rc2 2020-04-17 10:35:17 -07:00
zorro
Kconfig
Makefile