All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Marzinski <bmarzins@redhat.com>
To: Keith Busch <kbusch@kernel.org>
Cc: Keith Busch <kbusch@meta.com>,
	dm-devel@lists.linux.dev, mpatocka@redhat.com,
	snitzer@kernel.org
Subject: Re: [PATCH 1/3] dm-integrity: fix mismatched queue limits
Date: Mon, 30 Mar 2026 13:41:34 -0400	[thread overview]
Message-ID: <acq1zq78j-aS39KV@redhat.com> (raw)
In-Reply-To: <acbqQ5YaFPMQ23UI@kbusch-mbp>

On Fri, Mar 27, 2026 at 02:36:19PM -0600, Keith Busch wrote:
> On Fri, Mar 27, 2026 at 03:41:50PM -0400, Benjamin Marzinski wrote:
> > > @@ -4047,9 +4047,15 @@ static void dm_integrity_io_hints(struct dm_target *ti, struct queue_limits *lim
> > >  	struct dm_integrity_c *ic = ti->private;
> > >  
> > >  	if (ic->sectors_per_block > 1) {
> > > -		limits->logical_block_size = ic->sectors_per_block << SECTOR_SHIFT;
> > > -		limits->physical_block_size = ic->sectors_per_block << SECTOR_SHIFT;
> > > -		limits->io_min = ic->sectors_per_block << SECTOR_SHIFT;
> > > +		limits->logical_block_size =
> > > +				max(limits->logical_block_size,
> > > +				    ic->sectors_per_block << SECTOR_SHIFT);
> > > +		limits->physical_block_size =
> > > +				max(limits->physical_block_size,
> > > +				    ic->sectors_per_block << SECTOR_SHIFT);
> > > +		limits->io_min =
> > > +				max(limits->io_min,
> > > +				    ic->sectors_per_block << SECTOR_SHIFT);
> > >  		limits->dma_alignment = limits->logical_block_size - 1;
> > >  		limits->discard_granularity = ic->sectors_per_block << SECTOR_SHIFT;
> > 
> > Shouldn't this also respect the underlying device's discard_granularity?
> 
> It doesn't appear to. I left it unchanged as I'm not very familiar with
> this device mapper, so that seemed safer. But I thought it was fine as
> is: this dm doesn't appear to forward discards, so the underlying
> device's constraints aren't brought into the operation. It looks like it
> just sets a "DISCARD_FILLER" pattern into metadata.

If you set allow discards, dm-intergrity should pass them down.

For example:

VALID:
# modprobe scsi_debug dev_size_mb=1024 lbpu=1
# integritysetup format -s 1024 /dev/sda
# integritysetup open --allow-discards /dev/sda integrity-test
# cat /sys/block/sda/queue/discard_granularity                  
512
# cat /sys/block/dm-1/queue/discard_granularity
1024
# blkdiscard -o 1024 -l 16384 /dev/mapper/integrity-test
# echo $?
0

perf trace:
      blkdiscard   11852 [000] 256486.743981:    block:block_bio_queue: 253,1 DS 0 + 2 [blkdiscard]
 kworker/0:1-eve   11763 [000] 256486.744063:    block:block_bio_queue: 8,0 DS 16504 + 2 [kworker/0:1]
 kworker/0:1-eve   11763 [000] 256486.744076:     block:block_rq_issue: 8,0 DS 1024 () 16504 + 2 0x2,0,4 [kworker/0:1]
         swapper       0 [000] 256486.745099:  block:block_rq_complete: 8,0 DS () 16504 + 2 0x2,0,4 [0]
         swapper       0 [000] 256486.745104: block:block_bio_complete: 253,1 DS 0 + 2 [0]


INVALID:
# modprobe scsi_debug dev_size_mb=1024 lbpu=1 sector_size=4096
# integritysetup format -s 1024 /dev/sda
# integritysetup open --allow-discards /dev/sda integrity-test
# cat /sys/block/sda/queue/discard_granularity
2048
# cat /sys/block/dm-1/queue/discard_granularity
1024
# blkdiscard -o 1024 -l 16384 /dev/mapper/integrity-test
blkdiscard: BLKDISCARD: /dev/mapper/integrity-test ioctl failed: Input/output error
# echo $?
1

perf trace:
      blkdiscard   12191 [000] 257234.995337:    block:block_bio_queue: 253,1 DS 0 + 2 [blkdiscard]
 kworker/0:1-eve   11763 [000] 257235.046620:    block:block_bio_queue: 8,0 DS 16504 + 2 [kworker/0:1]
 kworker/0:1-eve   11763 [000] 257235.046623: block:block_bio_complete: 8,0 DS 16504 + 2 [-5]
 kworker/0:1-eve   11763 [000] 257235.046629: block:block_bio_complete: 253,1 DS 0 + 2 [-5]

-Ben


  reply	other threads:[~2026-03-30 17:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-25 19:36 [PATCH 1/3] dm-integrity: fix mismatched queue limits Keith Busch
2026-03-25 19:36 ` [PATCH 2/3] dm-integrity: always set the io hints Keith Busch
2026-03-25 19:36 ` [PATCH 3/3] dm: provide helper to set stacked limits Keith Busch
2026-03-27 19:41 ` [PATCH 1/3] dm-integrity: fix mismatched queue limits Benjamin Marzinski
2026-03-27 20:36   ` Keith Busch
2026-03-30 17:41     ` Benjamin Marzinski [this message]
2026-03-30 18:16       ` Keith Busch
2026-03-27 21:25 ` Mikulas Patocka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=acq1zq78j-aS39KV@redhat.com \
    --to=bmarzins@redhat.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=kbusch@kernel.org \
    --cc=kbusch@meta.com \
    --cc=mpatocka@redhat.com \
    --cc=snitzer@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.