Theoretically it is, but it always makes me a bit nervous as there are
some _really_ odd iov_iter use cases out there. And passing down known
wrong segment counts is pretty wonky.
Btw, where exactly does it stumble in there? I'd assume we don't
Because segments != 1, and then that hits the slower path.
need to do the segment correction for kbuf as the bio splitting
can do it (and probably does) in exactly the same way?
It doesn't strictly need to, but we should handle that case too. That'd
basically just be the loop addition I already did, something ala the
below on top for both of them:
diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index d8fa7158e598..767ac89c8426 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -1032,6 +1032,25 @@ static int validate_fixed_range(u64 buf_addr, size_t len,
return 0;
}
+static int io_import_kbuf(int ddir, struct iov_iter *iter,
+ struct io_mapped_ubuf *imu, size_t len, size_t offset)
+{
+ iov_iter_bvec(iter, ddir, iter->bvec, imu->nr_bvecs, len + offset);
+ iov_iter_advance(iter, offset);
+
+ if (len + offset < imu->len) {
+ const struct bio_vec *bvec = iter->bvec;
+
+ while (len > bvec->bv_len) {
+ len -= bvec->bv_len;
+ bvec++;
+ }
+ iter->nr_segs = bvec - iter->bvec;
+ }
+
+ return 0;
+}
+