[PATCHv2 1/2] block: accumulate segment page gaps per bio
Christoph Hellwig
hch at lst.de
Sun Aug 10 07:55:09 PDT 2025
On Wed, Aug 06, 2025 at 07:51:35AM -0700, Keith Busch wrote:
> +static inline unsigned int bvec_seg_gap(struct bio_vec bv, struct bio_vec bp)
> +{
> + return bv.bv_offset | ((bp.bv_offset + bp.bv_len) & (PAGE_SIZE - 1));
> +}
Can you just pass a pointer to the bio_vec even if the compiler
is probably optimizing away the function either way?
Also bp is a bit of an odd name for a bio_vec. Note that bvprv flows
well, but it is what the caller uses, so mahybe stick to it?
> /* the following two fields are internal, NEVER access directly */
> unsigned int __data_len; /* total data len */
> + unsigned int __page_gaps; /* a mask of all the segment gaps */
> sector_t __sector; /* sector cursor */
>
> struct bio *bio;
> @@ -1080,6 +1081,11 @@ static inline sector_t blk_rq_pos(const struct request *rq)
> return rq->__sector;
> }
>
> +static inline unsigned int blk_rq_page_gaps(const struct request *rq)
> +{
> + return rq->__page_gaps;
> +}
I don't think we really need the __ and the access helper here. This was
mostly done for fields where historically drivers accessed the field
directly, but it subtly changed semantics making these direct accesses
unsafe.
More information about the Linux-nvme
mailing list