On 7/1/2024 10:39 AM, Christoph Hellwig wrote: > +/* > + * Integrity payloads can either be owned by the submitter, in which case > + * bio_uninit will free them, or owned and generated by the block layer, > + * in which case we'll verify them here (for reads) and free them before > + * the bio is handed back to the submitted. > + */ > +bool __bio_integrity_endio(struct bio *bio); > static inline bool bio_integrity_endio(struct bio *bio) > { > - if (bio_integrity(bio)) > + struct bio_integrity_payload *bip = bio_integrity(bio); > + > + if (bip && (bip->bip_flags & BIP_BLOCK_INTEGRITY)) > return __bio_integrity_endio(bio); The patch will cause regression for nvme-passthrough. For that completion order is: (a) bio_endio() (b) req->end_io (c) blk_rq_unmap_user. And current code ensures that integrity is freed explicitly only after (a) and (b). With the patch, integrity will get freed during (a) itself. There are two places in bio_endio() that can free the integrity. It first calls bio_integrity_endio() - which is handled fine above. But it also calls bio_uninit() - which will free the integrity. We don't want that to happen before passthrough gets the chance to unpin/copy-back.