@@ -1037,6 +1037,7 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
1037
1037
u64 buf_addr , size_t len )
1038
1038
{
1039
1039
const struct bio_vec * bvec ;
1040
+ unsigned nr_segs ;
1040
1041
size_t offset ;
1041
1042
int ret ;
1042
1043
@@ -1056,8 +1057,6 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
1056
1057
return 0 ;
1057
1058
}
1058
1059
1059
- iov_iter_bvec (iter , ddir , imu -> bvec , imu -> nr_bvecs , offset + len );
1060
-
1061
1060
/*
1062
1061
* Don't use iov_iter_advance() here, as it's really slow for
1063
1062
* using the latter parts of a big fixed buffer - it iterates
@@ -1067,30 +1066,21 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
1067
1066
* 1) it's a BVEC iter, we set it up
1068
1067
* 2) all bvecs are the same in size, except potentially the
1069
1068
* first and last bvec
1070
- *
1071
- * So just find our index, and adjust the iterator afterwards.
1072
- * If the offset is within the first bvec (or the whole first
1073
- * bvec, just use iov_iter_advance(). This makes it easier
1074
- * since we can just skip the first segment, which may not
1075
- * be folio_size aligned.
1076
1069
*/
1077
1070
bvec = imu -> bvec ;
1078
- if (offset < bvec -> bv_len ) {
1079
- iter -> count -= offset ;
1080
- iter -> iov_offset = offset ;
1081
- } else {
1071
+ if (offset >= bvec -> bv_len ) {
1082
1072
unsigned long seg_skip ;
1083
1073
1084
1074
/* skip first vec */
1085
1075
offset -= bvec -> bv_len ;
1086
1076
seg_skip = 1 + (offset >> imu -> folio_shift );
1087
-
1088
- iter -> bvec += seg_skip ;
1089
- iter -> nr_segs -= seg_skip ;
1090
- iter -> count -= bvec -> bv_len + offset ;
1091
- iter -> iov_offset = offset & ((1UL << imu -> folio_shift ) - 1 );
1077
+ bvec += seg_skip ;
1078
+ offset &= (1UL << imu -> folio_shift ) - 1 ;
1092
1079
}
1093
1080
1081
+ nr_segs = imu -> nr_bvecs - (bvec - imu -> bvec );
1082
+ iov_iter_bvec (iter , ddir , bvec , nr_segs , len );
1083
+ iter -> iov_offset = offset ;
1094
1084
return 0 ;
1095
1085
}
1096
1086
0 commit comments