diff options
| author | Christoph Hellwig <hch@lst.de> | 2026-02-23 05:20:02 -0800 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2026-03-09 07:47:02 -0600 |
| commit | a936655697cd8d1bab2fd5189e2c33dd6356a266 (patch) | |
| tree | 9191bdfc6495893544b07ec3fecf91c2ad73b1f3 /block/bio-integrity.c | |
| parent | 7ea25eaad5ae3a6c837a3df9bdb822194f002565 (diff) | |
block: factor out a bio_integrity_setup_default helper
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 now only set the
seed if any action is set, which is fine as nothing will look at it
otherwise.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Anuj Gupta <anuj20.g@samsung.com>
Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Tested-by: Anuj Gupta <anuj20.g@samsung.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/bio-integrity.c')
| -rw-r--r-- | block/bio-integrity.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 0955be90038b..e79eaf047794 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -101,6 +101,22 @@ void bio_integrity_free_buf(struct bio_integrity_payload *bip) kfree(bvec_virt(bv)); } +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) + bip->bip_flags |= BIP_IP_CHECKSUM; + } + if (bi->flags & BLK_INTEGRITY_REF_TAG) + bip->bip_flags |= BIP_CHECK_REFTAG; +} + /** * bio_integrity_free - Free bio integrity payload * @bio: bio containing bip to be freed |
