Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote: > IDGI. Essentially, you are passing a callback disguised as enum, only to > lose any type safety. Granted, but this is how struct iov_iter works. I'm keeping the enum inside the internal functions where it can't be got at by external code. Now, I could just copy the code three times, once for iter=>bvec, once for iter=>sg and once for iter=>rdma. I can also grant that iter=>bvec is really only needed for UBUF/IOVEC-class iterators; I think I can make the assumption that kernel-supplied buffers are good for the lifetime of the operation. > How is it better than "iov_iter_get_pages2() into a > fixed-sized array and handle the result" done in a loop? Note that iov_iter_get_pages2() doesn't handle KVEC-class iterators, which this code does - for kmalloc'd, vmalloc'd and vmap'd memory and for global and stack variables. What I've written gets the physical addresses but doesn't/can't pin it (which probably means I can't just move my code into iov_iter_get_pages2()). Further, my code also treats multipage folios as single units which iov_iter_get_pages2() also doesn't - at least from XARRAY-class iterators. The UBUF-/IOVEC-extraction code doesn't handle multipage folios because get_user_pages_fast() doesn't - though perhaps it will need to at some point. David