On 4/16/25 1:57 PM, Nitesh Shetty wrote:...
/*This might not be needed for is_kbuf , as they already update nr_seg
@@ -1073,7 +1075,6 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
* since we can just skip the first segment, which may not
* be folio_size aligned.
*/
- const struct bio_vec *bvec = imu->bvec;
/*
* Kernel buffer bvecs, on the other hand, don't necessarily
@@ -1099,6 +1100,27 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
}
}
+ /*
+ * Offset trimmed front segments too, if any, now trim the tail.
+ * For is_kbuf we'll iterate them as they may be different sizes,
+ * otherwise we can just do straight up math.
+ */
+ if (len + offset < imu->len) {
+ bvec = iter->bvec;
+ if (imu->is_kbuf) {
+ while (len > bvec->bv_len) {
+ len -= bvec->bv_len;
+ bvec++;
+ }
+ iter->nr_segs = bvec - iter->bvec;
+ } else {
+ size_t vec_len;
+
+ vec_len = bvec->bv_offset + iter->iov_offset +
+ iter->count + ((1UL << folio_shift) - 1);
+ iter->nr_segs = vec_len >> folio_shift;
+ }
+ }
return 0;
}
inside iov_iter_advance.
How so? If 'offset' is true, then yes it'd skip the front, but it
doesn't skip the end part. And if 'offset' is 0, then no advancing is
done in the first place - which does make sense, as it's just advancing
from the front.
How about changing something like this ?
You can't hide this in the if (offset) section...