Re: [PATCH RESEND] block: pin user PI pages for writing when ref tags are remapped

From: Keith Busch

Date: Fri Nov 20 2026 - 11:58:40 EST


On Fri, Nov 20, 2026 at 05:22:57PM +0100, Zakaria Belkadi wrote:
> Christoph, Caleb,
>
> Thanks to both of you for the review.
>
> On Fri, Nov 20, 2026 at 07:28:07AM -0800, Christoph Hellwig wrote:
> > I don't think we can just pin memory as writable that wasn't given to
> > us as writable. So this needs to force bounce buffering, at least when
> > remapping might be required.
>
> Agreed. I'll keep the PI iterator as ITER_SOURCE. In v2,
> bio_integrity_map_user() will bounce the user PI buffer for REQ_OP_WRITE
> when the integrity profile has BLK_INTEGRITY_REF_TAG. That way the
> block layer can remap the tags in its own copy.

Can avoid bouncing? I think the remapping flags can be tied to the
user's reftag check request.

If BIP_CHECK_REFTAG is set from the user setting IO_INTEGRITY_CHK_REFTAG
on a write, we can map the PI buffer for writing. The user explicitly
asked to have the ref tags checked by the device, and partitions require
remapping them, so they've told the kernel to write to their buffer.

And if the flag isn't set, blk_integrity_prepare() can skip the remap
for that bio because the request asked to not be checked.