On 9/10/21 12:48 PM, Al Viro wrote: > On Fri, Sep 10, 2021 at 10:31:00AM -0700, Linus Torvalds wrote: >> On Fri, Sep 10, 2021 at 10:26 AM Jens Axboe <axboe@xxxxxxxxx> wrote: >>> >>> On 9/10/21 10:58 AM, Linus Torvalds wrote: >>>> On Fri, Sep 10, 2021 at 9:56 AM Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote: >>>>> >>>>> What's the point of all those contortions, anyway? You only need it for >>>>> iovec case; don't mix doing that and turning it into flavour-independent >>>>> primitive. >>>> >>>> Good point, making it specific to iovec only gets rid of a lot of >>>> special cases and worries. >>>> >>>> This is fairly specialized, no need to always cater to every possible case. >>> >>> Alright, split into three patches: >>> >>> https://git.kernel.dk/cgit/linux-block/log/?h=iov_iter >> >> That looks sane to me. >> >> Please add some comment about how that >> >> i->iov -= state->nr_segs - i->nr_segs; >> >> actually is the right thing for all the three cases (iow how 'iov', >> 'kvec' and 'bvec' all end up having a union member that acts the same >> way). >> >> But yeah, I like how the io_uring.c code looks better this way too. >> >> Al, what do you think? > > I think that sizeof(struct bio_vec) != sizeof(struct iovec): > struct bio_vec { > struct page *bv_page; > unsigned int bv_len; > unsigned int bv_offset; > }; > takes 3 words on 32bit boxen. > struct iovec > { > void __user *iov_base; /* BSD uses caddr_t (1003.1g requires void *) */ > __kernel_size_t iov_len; /* Must be size_t (1003.1g) */ > }; > takes 2 words on 32bit boxen. Ouch yes. I guess we do have to special case BVEC for now, as I do actually need that one internally. I'll add a BUILD_BUG_ON() for the other one while at it. -- Jens Axboe