Re: [PATCH 19/22] iomap,xfs: move integrity verification to the file system
"Darrick J. Wong" <[email protected]>
| Newsgroups | org.kernel.vger.linux-xfs,org.kernel.vger.linux-block,org.kernel.vger.linux-fsdevel |
|---|---|
| Message-ID | <20260723210216.GI2901224@frogsfrogsfrogs> |
On Thu, Jul 23, 2026 at 04:49:44PM +0200, Christoph Hellwig wrote: > Integrity support in file systems already requires file system-specific > completion handling because it must be run in process context. > > Move the actual verification to the file system so that it can better > handle errors in file system specific ways, and to support lazy bounce > buffering. > > Signed-off-by: Christoph Hellwig <[email protected]> Sounds good to me. I gather the idea here is that direct reads go straight into the user's buffer, and if they're evil and mess with the buffer contents during the read to make the PI verification fail, we can then retry the read with a bounce buffer out of spite for userspace? If so, then Reviewed-by: "Darrick J. Wong" <[email protected]> --D > --- > fs/iomap/ioend.c | 8 ++------ > fs/xfs/xfs_ioend.c | 3 +++ > include/linux/iomap.h | 1 + > 3 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/fs/iomap/ioend.c b/fs/iomap/ioend.c > index 438be92e131b..b1078f7c08c6 100644 > --- a/fs/iomap/ioend.c > +++ b/fs/iomap/ioend.c > @@ -308,12 +308,13 @@ ssize_t iomap_add_to_ioend(struct iomap_writepage_ctx *wpc, struct folio *folio, > } > EXPORT_SYMBOL_GPL(iomap_add_to_ioend); > > -static int iomap_ioend_integrity_verify(struct iomap_ioend *ioend) > +int iomap_ioend_integrity_verify(struct iomap_ioend *ioend) > { > struct bvec_iter data_iter = BVEC_ITER_IOEND(ioend); > > return fs_bio_integrity_verify(&ioend->io_bio, &data_iter); > } > +EXPORT_SYMBOL_GPL(iomap_ioend_integrity_verify); > > static u32 iomap_finish_ioend(struct iomap_ioend *ioend, int error) > { > @@ -330,11 +331,6 @@ static u32 iomap_finish_ioend(struct iomap_ioend *ioend, int error) > if (!atomic_dec_and_test(&ioend->io_remaining)) > return 0; > > - if (!ioend->io_error && > - bio_integrity(&ioend->io_bio) && > - bio_op(&ioend->io_bio) == REQ_OP_READ) > - ioend->io_error = iomap_ioend_integrity_verify(ioend); > - > if (ioend->io_flags & IOMAP_IOEND_DIRECT) > return iomap_finish_ioend_direct(ioend); > if (bio_op(&ioend->io_bio) == REQ_OP_READ) > diff --git a/fs/xfs/xfs_ioend.c b/fs/xfs/xfs_ioend.c > index 37a3ae8066e9..a095cf217863 100644 > --- a/fs/xfs/xfs_ioend.c > +++ b/fs/xfs/xfs_ioend.c > @@ -25,6 +25,9 @@ xfs_end_io_read( > struct iomap_ioend *ioend = iomap_ioend_from_bio(bio); > int error = blk_status_to_errno(bio->bi_status); > > + if (!error && (ioend->io_flags & IOMAP_IOEND_INTEGRITY)) > + error = iomap_ioend_integrity_verify(ioend); > + > iomap_finish_ioends(ioend, error); > } > > diff --git a/include/linux/iomap.h b/include/linux/iomap.h > index 1916a4f28002..f9e2fce21be0 100644 > --- a/include/linux/iomap.h > +++ b/include/linux/iomap.h > @@ -518,6 +518,7 @@ void iomap_finish_ioends(struct iomap_ioend *ioend, int error); > void iomap_ioend_try_merge(struct iomap_ioend *ioend, > struct list_head *more_ioends); > void iomap_sort_ioends(struct list_head *ioend_list); > +int iomap_ioend_integrity_verify(struct iomap_ioend *ioend); > ssize_t iomap_add_to_ioend(struct iomap_writepage_ctx *wpc, struct folio *folio, > loff_t pos, loff_t end_pos, unsigned int dirty_len); > int iomap_ioend_writeback_submit(struct iomap_writepage_ctx *wpc, int error); > -- > 2.53.0 > >