Skip to content

Commit 74cc150

Browse files
Christoph Hellwigaxboe
authored andcommitted
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>
1 parent 85253ba commit 74cc150

File tree

3 files changed

+14
-23
lines changed

3 files changed

+14
-23
lines changed

block/bio-integrity.c

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -131,34 +131,25 @@ static void bio_integrity_uncopy_user(struct bio_integrity_payload *bip)
131131
bio_integrity_unpin_bvec(copy, nr_vecs, true);
132132
}
133133

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)
135141
{
136-
bool dirty = bio_data_dir(bip->bip_bio) == READ;
142+
struct bio_integrity_payload *bip = bio_integrity(bio);
137143

138144
if (bip->bip_flags & BIP_COPY_USER) {
139-
if (dirty)
145+
if (bio_data_dir(bio) == READ)
140146
bio_integrity_uncopy_user(bip);
141147
kfree(bvec_virt(bip->bip_vec));
142148
return;
143149
}
144150

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);
162153
}
163154

164155
/**

block/blk-map.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ int blk_rq_unmap_user(struct bio *bio)
758758
}
759759

760760
if (bio_integrity(bio))
761-
bio_integrity_unmap_free_user(bio);
761+
bio_integrity_unmap_user(bio);
762762

763763
next_bio = bio;
764764
bio = bio->bi_next;

include/linux/bio-integrity.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio, gfp_t gfp,
7373
int bio_integrity_add_page(struct bio *bio, struct page *page, unsigned int len,
7474
unsigned int offset);
7575
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);
7777
bool bio_integrity_prep(struct bio *bio);
7878
void bio_integrity_advance(struct bio *bio, unsigned int bytes_done);
7979
void bio_integrity_trim(struct bio *bio);
@@ -104,7 +104,7 @@ static inline int bio_integrity_map_user(struct bio *bio, void __user *ubuf,
104104
return -EINVAL;
105105
}
106106

107-
static inline void bio_integrity_unmap_free_user(struct bio *bio)
107+
static inline void bio_integrity_unmap_user(struct bio *bio)
108108
{
109109
}
110110

0 commit comments

Comments
 (0)