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

block: don't free the integrity payload in bio_integrity_unmap_free_user

Now that the integrity payload is always freed in bio_uninit, don't
bother freeing it a little earlier in bio_integrity_unmap_free_user.
With that the separate bio_integrity_unmap_free_user can go away by
just passing the bio to bio_integrity_unmap_user.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20240702151047.1746127-7-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
74cc1502 85253bac

+14 -23
+11 -20
block/bio-integrity.c
··· 131 131 bio_integrity_unpin_bvec(copy, nr_vecs, true); 132 132 } 133 133 134 - static void bio_integrity_unmap_user(struct bio_integrity_payload *bip) 134 + /** 135 + * bio_integrity_unmap_user - Unmap user integrity payload 136 + * @bio: bio containing bip to be unmapped 137 + * 138 + * Unmap the user mapped integrity portion of a bio. 139 + */ 140 + void bio_integrity_unmap_user(struct bio *bio) 135 141 { 136 - bool dirty = bio_data_dir(bip->bip_bio) == READ; 142 + struct bio_integrity_payload *bip = bio_integrity(bio); 137 143 138 144 if (bip->bip_flags & BIP_COPY_USER) { 139 - if (dirty) 145 + if (bio_data_dir(bio) == READ) 140 146 bio_integrity_uncopy_user(bip); 141 147 kfree(bvec_virt(bip->bip_vec)); 142 148 return; 143 149 } 144 150 145 - bio_integrity_unpin_bvec(bip->bip_vec, bip->bip_max_vcnt, dirty); 146 - } 147 - 148 - /** 149 - * bio_integrity_unmap_free_user - Unmap and free bio user integrity payload 150 - * @bio: bio containing bip to be unmapped and freed 151 - * 152 - * Description: Used to unmap and free the user mapped integrity portion of a 153 - * bio. Submitter attaching the user integrity buffer is responsible for 154 - * unmapping and freeing it during completion. 155 - */ 156 - void bio_integrity_unmap_free_user(struct bio *bio) 157 - { 158 - struct bio_integrity_payload *bip = bio_integrity(bio); 159 - 160 - bio_integrity_unmap_user(bip); 161 - bio_integrity_free(bio); 151 + bio_integrity_unpin_bvec(bip->bip_vec, bip->bip_max_vcnt, 152 + bio_data_dir(bio) == READ); 162 153 } 163 154 164 155 /**
+1 -1
block/blk-map.c
··· 758 758 } 759 759 760 760 if (bio_integrity(bio)) 761 - bio_integrity_unmap_free_user(bio); 761 + bio_integrity_unmap_user(bio); 762 762 763 763 next_bio = bio; 764 764 bio = bio->bi_next;
+2 -2
include/linux/bio-integrity.h
··· 73 73 int bio_integrity_add_page(struct bio *bio, struct page *page, unsigned int len, 74 74 unsigned int offset); 75 75 int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t len, u32 seed); 76 - void bio_integrity_unmap_free_user(struct bio *bio); 76 + void bio_integrity_unmap_user(struct bio *bio); 77 77 bool bio_integrity_prep(struct bio *bio); 78 78 void bio_integrity_advance(struct bio *bio, unsigned int bytes_done); 79 79 void bio_integrity_trim(struct bio *bio); ··· 104 104 return -EINVAL; 105 105 } 106 106 107 - static inline void bio_integrity_unmap_free_user(struct bio *bio) 107 + static inline void bio_integrity_unmap_user(struct bio *bio) 108 108 { 109 109 } 110 110