Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Christoph Hellwig and committed by
Jens Axboe
a9366556 7ea25eaa

+19 -12
+2 -12
block/bio-integrity-auto.c
··· 88 88 */ 89 89 void bio_integrity_prep(struct bio *bio, unsigned int action) 90 90 { 91 - struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk); 92 91 struct bio_integrity_data *bid; 93 92 94 93 bid = mempool_alloc(&bid_pool, GFP_NOIO); ··· 95 96 bid->bio = bio; 96 97 bid->bip.bip_flags |= BIP_BLOCK_INTEGRITY; 97 98 bio_integrity_alloc_buf(bio, action & BI_ACT_ZERO); 98 - 99 - bip_set_seed(&bid->bip, bio->bi_iter.bi_sector); 100 - 101 - if (action & BI_ACT_CHECK) { 102 - if (bi->csum_type == BLK_INTEGRITY_CSUM_IP) 103 - bid->bip.bip_flags |= BIP_IP_CHECKSUM; 104 - if (bi->csum_type) 105 - bid->bip.bip_flags |= BIP_CHECK_GUARD; 106 - if (bi->flags & BLK_INTEGRITY_REF_TAG) 107 - bid->bip.bip_flags |= BIP_CHECK_REFTAG; 108 - } 99 + if (action & BI_ACT_CHECK) 100 + bio_integrity_setup_default(bio); 109 101 110 102 /* Auto-generate integrity metadata if this is a write */ 111 103 if (bio_data_dir(bio) == WRITE && bip_should_check(&bid->bip))
+16
block/bio-integrity.c
··· 101 101 kfree(bvec_virt(bv)); 102 102 } 103 103 104 + void bio_integrity_setup_default(struct bio *bio) 105 + { 106 + struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk); 107 + struct bio_integrity_payload *bip = bio_integrity(bio); 108 + 109 + bip_set_seed(bip, bio->bi_iter.bi_sector); 110 + 111 + if (bi->csum_type) { 112 + bip->bip_flags |= BIP_CHECK_GUARD; 113 + if (bi->csum_type == BLK_INTEGRITY_CSUM_IP) 114 + bip->bip_flags |= BIP_IP_CHECKSUM; 115 + } 116 + if (bi->flags & BLK_INTEGRITY_REF_TAG) 117 + bip->bip_flags |= BIP_CHECK_REFTAG; 118 + } 119 + 104 120 /** 105 121 * bio_integrity_free - Free bio integrity payload 106 122 * @bio: bio containing bip to be freed
+1
include/linux/bio-integrity.h
··· 143 143 144 144 void bio_integrity_alloc_buf(struct bio *bio, bool zero_buffer); 145 145 void bio_integrity_free_buf(struct bio_integrity_payload *bip); 146 + void bio_integrity_setup_default(struct bio *bio); 146 147 147 148 #endif /* _LINUX_BIO_INTEGRITY_H */