@@ -978,6 +978,8 @@ static int pfn_reader_fill_span(struct pfn_reader *pfns)
978
978
{
979
979
struct interval_tree_double_span_iter * span = & pfns -> span ;
980
980
unsigned long start_index = pfns -> batch_end_index ;
981
+ struct pfn_reader_user * user = & pfns -> user ;
982
+ unsigned long npages ;
981
983
struct iopt_area * area ;
982
984
int rc ;
983
985
@@ -1015,10 +1017,9 @@ static int pfn_reader_fill_span(struct pfn_reader *pfns)
1015
1017
return rc ;
1016
1018
}
1017
1019
1018
- batch_from_pages (& pfns -> batch ,
1019
- pfns -> user .upages +
1020
- (start_index - pfns -> user .upages_start ),
1021
- pfns -> user .upages_end - start_index );
1020
+ npages = user -> upages_end - start_index ;
1021
+ start_index -= user -> upages_start ;
1022
+ batch_from_pages (& pfns -> batch , user -> upages + start_index , npages );
1022
1023
return 0 ;
1023
1024
}
1024
1025
@@ -1092,16 +1093,18 @@ static int pfn_reader_init(struct pfn_reader *pfns, struct iopt_pages *pages,
1092
1093
static void pfn_reader_release_pins (struct pfn_reader * pfns )
1093
1094
{
1094
1095
struct iopt_pages * pages = pfns -> pages ;
1096
+ struct pfn_reader_user * user = & pfns -> user ;
1095
1097
1096
- if (pfns -> user .upages_end > pfns -> batch_end_index ) {
1097
- size_t npages = pfns -> user .upages_end - pfns -> batch_end_index ;
1098
-
1098
+ if (user -> upages_end > pfns -> batch_end_index ) {
1099
1099
/* Any pages not transferred to the batch are just unpinned */
1100
- unpin_user_pages (pfns -> user .upages + (pfns -> batch_end_index -
1101
- pfns -> user .upages_start ),
1102
- npages );
1100
+
1101
+ unsigned long npages = user -> upages_end - pfns -> batch_end_index ;
1102
+ unsigned long start_index = pfns -> batch_end_index -
1103
+ user -> upages_start ;
1104
+
1105
+ unpin_user_pages (user -> upages + start_index , npages );
1103
1106
iopt_pages_sub_npinned (pages , npages );
1104
- pfns -> user . upages_end = pfns -> batch_end_index ;
1107
+ user -> upages_end = pfns -> batch_end_index ;
1105
1108
}
1106
1109
if (pfns -> batch_start_index != pfns -> batch_end_index ) {
1107
1110
pfn_reader_unpin (pfns );
0 commit comments