On Fri, Sep 10, 2021 at 12:25:34PM -0600, Jens Axboe wrote: > +void iov_iter_restore(struct iov_iter *i, struct iov_iter_state *state, > + ssize_t did_bytes) > +{ > + if (WARN_ON_ONCE(!iov_iter_is_bvec(i) && !iter_is_iovec(i)) && > + !iov_iter_is_kvec(i)) > + return; > + i->iov_offset = state->iov_offset; > + i->count = state->count; > + /* > + * For the *vec iters, nr_segs + iov is constant - if we increment > + * the vec, then we also decrement the nr_segs count. Hence we don't > + * need to track both of these, just one is enough and we can deduct > + * the other from that. ITER_{BVEC,IOVEC,KVEC} all have their pointers > + * unionized, so we don't need to handle them individually. > + */ > + i->iov -= state->nr_segs - i->nr_segs; > + i->nr_segs = state->nr_segs; > +} No. You can have iovec and kvec handled jointly (struct iovec and struct kvec always have the same size). You can *not* do that to bvec - check sizeof of struct bio_vec and struct iovec on 32bit targets.