Skip to content

Commit 7560680

Browse files
author
Mike Snitzer
committed
dm-crypt: stop constraining max_segment_size to PAGE_SIZE
This change effectively reverts commit 586b286 ("dm crypt: constrain crypt device's max_segment_size to PAGE_SIZE") and relies on block core's late bio-splitting to ensure that dm-crypt's encryption bios are split accordingly if they exceed the underlying device's limits (e.g. max_segment_size). Commit 586b286 was applied as a 4.3 fix for the benefit of stable@ kernels 4.0+ just after block core's late bio-splitting was introduced in 4.3 with commit 54efd50 ("block: make generic_make_request handle arbitrarily sized bios"). Given block core's late bio-splitting it is past time that dm-crypt make use of it. Also, given the recent need to revert meaningful progress that was attempted during the 6.9 merge window (see commit bff4b74 Revert "dm: use queue_limits_set") this change allows DM core to safely make use of queue_limits_set() without risk of breaking dm-crypt on NVMe. Though it should be noted this commit isn't a prereq for reinstating DM core's use of queue_limits_set() because blk_validate_limits() was made less strict with commit b561ea5 ("block: allow device to have both virt_boundary_mask and max segment size"). Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Mikulas Patocka <mpatocka@redhat.com> Reviewed-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Mike Snitzer <snitzer@kernel.org>
1 parent 2285e14 commit 7560680

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

drivers/md/dm-crypt.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,8 +1656,8 @@ static void crypt_free_buffer_pages(struct crypt_config *cc, struct bio *clone);
16561656

16571657
/*
16581658
* Generate a new unfragmented bio with the given size
1659-
* This should never violate the device limitations (but only because
1660-
* max_segment_size is being constrained to PAGE_SIZE).
1659+
* This should never violate the device limitations (but if it did then block
1660+
* core should split the bio as needed).
16611661
*
16621662
* This function may be called concurrently. If we allocate from the mempool
16631663
* concurrently, there is a possibility of deadlock. For example, if we have
@@ -3717,14 +3717,6 @@ static void crypt_io_hints(struct dm_target *ti, struct queue_limits *limits)
37173717
{
37183718
struct crypt_config *cc = ti->private;
37193719

3720-
/*
3721-
* Unfortunate constraint that is required to avoid the potential
3722-
* for exceeding underlying device's max_segments limits -- due to
3723-
* crypt_alloc_buffer() possibly allocating pages for the encryption
3724-
* bio that are not as physically contiguous as the original bio.
3725-
*/
3726-
limits->max_segment_size = PAGE_SIZE;
3727-
37283720
limits->logical_block_size =
37293721
max_t(unsigned int, limits->logical_block_size, cc->sector_size);
37303722
limits->physical_block_size =

0 commit comments

Comments
 (0)