Re: [git pull] iov_iter fixes

From: Al Viro
Date: Fri Sep 10 2021 - 11:34:54 EST


On Fri, Sep 10, 2021 at 09:08:02AM -0600, Jens Axboe wrote:

> > You actually can cut it down even more - nr_segs + iov remains constant
> > all along, so you could get away with just 3 words here... I would be
>
> Mmm, the iov pointer remains constant? Maybe I'm missing your point, but
> the various advance functions are quite happy to increment iter->iov or
> iter->bvec, so we need to restore them. From a quick look, looks like
> iter->nr_segs is modified for advancing too.
>
> What am I missing?

i->iov + i->nr_segs does not change - the places incrementing the former
will decrement the latter by the same amount. So it's enough to store
either of those - the other one can be recovered by subtracting the
saved value from the current i->iov + i->nr_segs.