]> Gentwo Git Trees - linux/.git/commit
block: make bio auto-integrity deadlock safe
authorChristoph Hellwig <hch@lst.de>
Mon, 3 Nov 2025 10:16:45 +0000 (05:16 -0500)
committerJens Axboe <axboe@kernel.dk>
Tue, 4 Nov 2025 19:41:50 +0000 (12:41 -0700)
commitec7f31b2a2d3bf6b9e4d4b8cd156587f1d0607d5
tree21994cdf1650c7122359446262910261d164a48c
parenteef09f742be2a89126742f9f6f6a0d5d7c83cba8
block: make bio auto-integrity deadlock safe

The current block layer automatic integrity protection allocates the
actual integrity buffer, which has three problems:

 - because it happens at the bottom of the I/O stack and doesn't use a
   mempool it can deadlock under load
 - because the data size in a bio is almost unbounded when using lage
   folios it can relatively easily exceed the maximum kmalloc size
 - even when it does not exceed the maximum kmalloc size, it could
   exceed the maximum segment size of the device

Fix this by limiting the I/O size so that we can allocate at least a
2MiB integrity buffer, i.e. 128MiB for 8 byte PI and 512 byte integrity
intervals, and create a mempool as a last resort for this maximum size,
mirroring the scheme used for bvecs.  As a nice upside none of this
can fail now, so we remove the error handling and open code the
trivial addition of the bip vec.

The new allocation helpers sit outside of bio-integrity-auto.c because
I plan to reuse them for file system based PI in the near future.

Fixes: 7ba1ba12eeef ("block: Block layer data integrity support")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Anuj Gupta <anuj20.g@samsung.com>
Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bio-integrity-auto.c
block/bio-integrity.c
block/blk-settings.c
include/linux/bio-integrity.h
include/linux/blk-integrity.h