On Mon, Jul 01, 2024 at 06:30:34PM +0530, Kanchan Joshi wrote: > 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. It is supposed to be freed from (c), specifically from blk_mq_map_bio_put. > > 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. But yes, that messed it up. I'm kinda curious why it didn't trip up during my testing of the passthrough metadata code. That bio_uninit in bio_endio is quite bogus and I'm a bit suprised it hasn't caught more errors - the reason why bio_uninit exists is specifically to deal with those on-stack or embedded into bigger structure bios.