[PATCH AUTOSEL 6.10 13/16] block: change rq_integrity_vec to respect the iterator
Greg KH
gregkh at linuxfoundation.org
Mon Aug 12 07:03:31 PDT 2024
On Mon, Aug 12, 2024 at 03:51:12PM +0200, Matthieu Baerts wrote:
> Hi Sasha, Greg,
>
> On 28/07/2024 02:47, Sasha Levin wrote:
> > From: Mikulas Patocka <mpatocka at redhat.com>
> >
> > [ Upstream commit cf546dd289e0f6d2594c25e2fb4e19ee67c6d988 ]
> >
> > If we allocate a bio that is larger than NVMe maximum request size,
> > attach integrity metadata to it and send it to the NVMe subsystem, the
> > integrity metadata will be corrupted.
>
> (...)
>
> > diff --git a/include/linux/blk-integrity.h b/include/linux/blk-integrity.h
> > index 7428cb43952da..d16dd24719841 100644
> > --- a/include/linux/blk-integrity.h
> > +++ b/include/linux/blk-integrity.h
> > @@ -100,14 +100,13 @@ static inline bool blk_integrity_rq(struct request *rq)
> > }
> >
> > /*
> > - * Return the first bvec that contains integrity data. Only drivers that are
> > - * limited to a single integrity segment should use this helper.
> > + * Return the current bvec that contains the integrity data. bip_iter may be
> > + * advanced to iterate over the integrity data.
> > */
> > -static inline struct bio_vec *rq_integrity_vec(struct request *rq)
> > +static inline struct bio_vec rq_integrity_vec(struct request *rq)
> > {
> > - if (WARN_ON_ONCE(queue_max_integrity_segments(rq->q) > 1))
> > - return NULL;
> > - return rq->bio->bi_integrity->bip_vec;
> > + return mp_bvec_iter_bvec(rq->bio->bi_integrity->bip_vec,
> > + rq->bio->bi_integrity->bip_iter);
> > }
> > #else /* CONFIG_BLK_DEV_INTEGRITY */
> > static inline int blk_rq_count_integrity_sg(struct request_queue *q,
> > @@ -169,7 +168,8 @@ static inline int blk_integrity_rq(struct request *rq)
> >
> > static inline struct bio_vec *rq_integrity_vec(struct request *rq)
> > {
> > - return NULL;
> > + /* the optimizer will remove all calls to this function */
> > + return (struct bio_vec){ };
>
> If CONFIG_BLK_DEV_INTEGRITY is not defined, there is a compilation error
> here in v6.10 with the recently queued patches because the signature has
> not been updated:
>
> > In file included from block/bdev.c:15:
> > include/linux/blk-integrity.h: In function 'rq_integrity_vec':
> > include/linux/blk-integrity.h:172:16: error: incompatible types when returning type 'struct bio_vec' but 'struct bio_vec *' was expected
> > 172 | return (struct bio_vec){ };
> > | ^
>
> Could it be possible to backport the following fix to v6.10 as well please?
>
> 69b6517687a4 ("block: use the right type for stub rq_integrity_vec()")
>
> It is also needed for v6.6 and v6.1.
Now queued up, thanks!
greg k-h
More information about the Linux-nvme
mailing list