On Wed, 2 Nov 2022 14:09:54 -0600 Keith Busch <kbusch@xxxxxxxxxx> wrote: > On Wed, Nov 02, 2022 at 08:03:45PM +0300, Dmitrii Tcvetkov wrote: > > > > Applied on top 6.1-rc3, the issue still reproduces. > > Yeah, I see that now. I needed to run a dm-crypt setup to figure out > how they're actually doing this, so now I have that up and running. > > I think this type of usage will require the dma_alignment to move from > the request_queue to the queue_limits. Here's that, and I've > successfully tested this with cryptsetup. I still need more work to > get mdraid atop that working on my dev machine, but I'll post this > now since it's looking better: > > --- > diff --git a/block/blk-settings.c b/block/blk-settings.c > index 8bb9eef5310e..e84304959318 100644 > --- a/block/blk-settings.c > +++ b/block/blk-settings.c > @@ -81,6 +81,7 @@ void blk_set_stacking_limits(struct queue_limits > *lim) lim->max_dev_sectors = UINT_MAX; > lim->max_write_zeroes_sectors = UINT_MAX; > lim->max_zone_append_sectors = UINT_MAX; > + lim->dma_alignment = 511; > } > EXPORT_SYMBOL(blk_set_stacking_limits); > > @@ -600,6 +601,7 @@ int blk_stack_limits(struct queue_limits *t, > struct queue_limits *b, > t->io_min = max(t->io_min, b->io_min); > t->io_opt = lcm_not_zero(t->io_opt, b->io_opt); > + t->dma_alignment = max(t->dma_alignment, b->dma_alignment); > > /* Set non-power-of-2 compatible chunk_sectors boundary */ > if (b->chunk_sectors) > @@ -773,7 +775,7 @@ EXPORT_SYMBOL(blk_queue_virt_boundary); > **/ > void blk_queue_dma_alignment(struct request_queue *q, int mask) > { > - q->dma_alignment = mask; > + q->limits.dma_alignment = mask; > } > EXPORT_SYMBOL(blk_queue_dma_alignment); > > @@ -795,8 +797,8 @@ void blk_queue_update_dma_alignment(struct > request_queue *q, int mask) { > BUG_ON(mask > PAGE_SIZE); > > - if (mask > q->dma_alignment) > - q->dma_alignment = mask; > + if (mask > q->limits.dma_alignment) > + q->limits.dma_alignment = mask; > } > EXPORT_SYMBOL(blk_queue_update_dma_alignment); > > diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c > index 159c6806c19b..2653516bcdef 100644 > --- a/drivers/md/dm-crypt.c > +++ b/drivers/md/dm-crypt.c > @@ -3630,6 +3630,7 @@ static void crypt_io_hints(struct dm_target > *ti, struct queue_limits *limits) limits->physical_block_size = > max_t(unsigned, limits->physical_block_size, > cc->sector_size); limits->io_min = max_t(unsigned, limits->io_min, > cc->sector_size); > + limits->dma_alignment = limits->logical_block_size - 1; > } > > static struct target_type crypt_target = { > diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h > index 854b4745cdd1..69ee5ea29e2f 100644 > --- a/include/linux/blkdev.h > +++ b/include/linux/blkdev.h > @@ -310,6 +310,13 @@ struct queue_limits { > unsigned char discard_misaligned; > unsigned char raid_partial_stripes_expensive; > enum blk_zoned_model zoned; > + > + /* > + * Drivers that set dma_alignment to less than 511 must be > prepared to > + * handle individual bvec's that are not a multiple of a > SECTOR_SIZE > + * due to possible offsets. > + */ > + unsigned int dma_alignment; > }; > > typedef int (*report_zones_cb)(struct blk_zone *zone, unsigned int > idx, @@ -455,12 +462,6 @@ struct request_queue { > unsigned long nr_requests; /* Max # of > requests */ > unsigned int dma_pad_mask; > - /* > - * Drivers that set dma_alignment to less than 511 must be > prepared to > - * handle individual bvec's that are not a multiple of a > SECTOR_SIZE > - * due to possible offsets. > - */ > - unsigned int dma_alignment; > > #ifdef CONFIG_BLK_INLINE_ENCRYPTION > struct blk_crypto_profile *crypto_profile; > @@ -1318,7 +1319,7 @@ static inline sector_t bdev_zone_sectors(struct > block_device *bdev) > static inline int queue_dma_alignment(const struct request_queue *q) > { > - return q ? q->dma_alignment : 511; > + return q ? q->limits.dma_alignment : 511; > } > > static inline unsigned int bdev_dma_alignment(struct block_device > *bdev) -- With this patch the issue doesn't reproduce. -- dm-devel mailing list dm-devel@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/dm-devel