@@ -1036,6 +1036,7 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
1036
1036
struct io_mapped_ubuf * imu ,
1037
1037
u64 buf_addr , size_t len )
1038
1038
{
1039
+ const struct bio_vec * bvec ;
1039
1040
size_t offset ;
1040
1041
int ret ;
1041
1042
@@ -1054,47 +1055,45 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
1054
1055
offset = buf_addr - imu -> ubuf ;
1055
1056
iov_iter_bvec (iter , ddir , imu -> bvec , imu -> nr_bvecs , offset + len );
1056
1057
1057
- if (offset ) {
1058
- /*
1059
- * Don't use iov_iter_advance() here, as it's really slow for
1060
- * using the latter parts of a big fixed buffer - it iterates
1061
- * over each segment manually. We can cheat a bit here for user
1062
- * registered nodes, because we know that:
1063
- *
1064
- * 1) it's a BVEC iter, we set it up
1065
- * 2) all bvecs are the same in size, except potentially the
1066
- * first and last bvec
1067
- *
1068
- * So just find our index, and adjust the iterator afterwards.
1069
- * If the offset is within the first bvec (or the whole first
1070
- * bvec, just use iov_iter_advance(). This makes it easier
1071
- * since we can just skip the first segment, which may not
1072
- * be folio_size aligned.
1073
- */
1074
- const struct bio_vec * bvec = imu -> bvec ;
1058
+ /*
1059
+ * Don't use iov_iter_advance() here, as it's really slow for
1060
+ * using the latter parts of a big fixed buffer - it iterates
1061
+ * over each segment manually. We can cheat a bit here for user
1062
+ * registered nodes, because we know that:
1063
+ *
1064
+ * 1) it's a BVEC iter, we set it up
1065
+ * 2) all bvecs are the same in size, except potentially the
1066
+ * first and last bvec
1067
+ *
1068
+ * So just find our index, and adjust the iterator afterwards.
1069
+ * If the offset is within the first bvec (or the whole first
1070
+ * bvec, just use iov_iter_advance(). This makes it easier
1071
+ * since we can just skip the first segment, which may not
1072
+ * be folio_size aligned.
1073
+ */
1074
+ bvec = imu -> bvec ;
1075
1075
1076
- /*
1077
- * Kernel buffer bvecs, on the other hand, don't necessarily
1078
- * have the size property of user registered ones, so we have
1079
- * to use the slow iter advance.
1080
- */
1081
- if (offset < bvec -> bv_len ) {
1082
- iter -> count -= offset ;
1083
- iter -> iov_offset = offset ;
1084
- } else if (imu -> is_kbuf ) {
1085
- iov_iter_advance (iter , offset );
1086
- } else {
1087
- unsigned long seg_skip ;
1076
+ /*
1077
+ * Kernel buffer bvecs, on the other hand, don't necessarily
1078
+ * have the size property of user registered ones, so we have
1079
+ * to use the slow iter advance.
1080
+ */
1081
+ if (offset < bvec -> bv_len ) {
1082
+ iter -> count -= offset ;
1083
+ iter -> iov_offset = offset ;
1084
+ } else if (imu -> is_kbuf ) {
1085
+ iov_iter_advance (iter , offset );
1086
+ } else {
1087
+ unsigned long seg_skip ;
1088
1088
1089
- /* skip first vec */
1090
- offset -= bvec -> bv_len ;
1091
- seg_skip = 1 + (offset >> imu -> folio_shift );
1089
+ /* skip first vec */
1090
+ offset -= bvec -> bv_len ;
1091
+ seg_skip = 1 + (offset >> imu -> folio_shift );
1092
1092
1093
- iter -> bvec += seg_skip ;
1094
- iter -> nr_segs -= seg_skip ;
1095
- iter -> count -= bvec -> bv_len + offset ;
1096
- iter -> iov_offset = offset & ((1UL << imu -> folio_shift ) - 1 );
1097
- }
1093
+ iter -> bvec += seg_skip ;
1094
+ iter -> nr_segs -= seg_skip ;
1095
+ iter -> count -= bvec -> bv_len + offset ;
1096
+ iter -> iov_offset = offset & ((1UL << imu -> folio_shift ) - 1 );
1098
1097
}
1099
1098
1100
1099
return 0 ;
0 commit comments