Re: [PATCH] io_uring/rsrc: send exact nr_segs for fixed buffer

From: Keith Busch
Date: Wed Apr 16 2025 - 16:03:36 EST


On Thu, Apr 17, 2025 at 01:27:55AM +0530, Nitesh Shetty wrote:
> > + /*
> > + * Offset trimmed front segments too, if any, now trim the tail.
> > + * For is_kbuf we'll iterate them as they may be different sizes,
> > + * otherwise we can just do straight up math.
> > + */
> > + if (len + offset < imu->len) {
> > + bvec = iter->bvec;
> > + if (imu->is_kbuf) {
> > + while (len > bvec->bv_len) {
> > + len -= bvec->bv_len;
> > + bvec++;
> > + }
> > + iter->nr_segs = bvec - iter->bvec;
> > + } else {
> > + size_t vec_len;
> > +
> > + vec_len = bvec->bv_offset + iter->iov_offset +
> > + iter->count + ((1UL << folio_shift) - 1);
> > + iter->nr_segs = vec_len >> folio_shift;
> > + }
> > + }
> > return 0;
> > }
> This might not be needed for is_kbuf , as they already update nr_seg
> inside iov_iter_advance.

iov_iter_advance only handles the front segs. We still need something
for any trailing segments that are not part of this mapping request.