On Thu, Jan 22, 2026 at 04:05:37PM -0800, Darrick J. Wong wrote:
> On Wed, Jan 21, 2026 at 07:43:10AM +0100, Christoph Hellwig wrote:
> > Add a helper to set the seed and check flag based on useful defaults
> > from the profile.
> >
> > Note that this includes a small behavior change, as we ow only sets the
>
> "...as we only set the seed if..." ?
Yes.
> > +void bio_integrity_setup_default(struct bio *bio)
> > +{
> > + struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk);
> > + struct bio_integrity_payload *bip = bio_integrity(bio);
> > +
> > + bip_set_seed(bip, bio->bi_iter.bi_sector);
> > +
> > + if (bi->csum_type) {
> > + bip->bip_flags |= BIP_CHECK_GUARD;
> > + if (bi->csum_type == BLK_INTEGRITY_CSUM_IP)
>
> /me wonders if this should be a switch, but it'd be a pretty lame one.
>
> switch (bi->csum_type) {
> case BLK_INTEGRITY_CSUM_NONE:
> break;
> case BLK_INTEGRITY_CSUM_IP:
> bip->bip_flags |= BIP_IP_CHECKSUM;
> fallthrough;
> case BLK_INTEGRITY_CSUM_CRC:
> case BLK_INTEGRITY_CSUM_CRC64:
> bip->bip_flags |= BIP_CHECK_GUARD;
> break;
> }
I don't really think that's a good idea here. BIP_IP_CHECKSUM is a
really a special snowflake for SCSI HBA (and not even actual device)
usage, so it should be treated like a special snowflake with the if.
I sincerely hope no new special snowflakes will show up for the checksums
in the future.