@@ -771,6 +771,7 @@ static int gfs2_fsync(struct file *file, loff_t start, loff_t end,
771
771
}
772
772
773
773
static inline bool should_fault_in_pages (struct iov_iter * i ,
774
+ struct kiocb * iocb ,
774
775
size_t * prev_count ,
775
776
size_t * window_size )
776
777
{
@@ -783,15 +784,13 @@ static inline bool should_fault_in_pages(struct iov_iter *i,
783
784
return false;
784
785
785
786
size = PAGE_SIZE ;
786
- offs = offset_in_page (i -> iov [ 0 ]. iov_base + i -> iov_offset );
787
+ offs = offset_in_page (iocb -> ki_pos );
787
788
if (* prev_count != count || !* window_size ) {
788
789
size_t nr_dirtied ;
789
790
790
- size = ALIGN (offs + count , PAGE_SIZE );
791
- size = min_t (size_t , size , SZ_1M );
792
791
nr_dirtied = max (current -> nr_dirtied_pause -
793
792
current -> nr_dirtied , 8 );
794
- size = min ( size , nr_dirtied << PAGE_SHIFT );
793
+ size = min_t ( size_t , SZ_1M , nr_dirtied << PAGE_SHIFT );
795
794
}
796
795
797
796
* prev_count = count ;
@@ -845,7 +844,7 @@ static ssize_t gfs2_file_direct_read(struct kiocb *iocb, struct iov_iter *to,
845
844
if (ret > 0 )
846
845
read = ret ;
847
846
848
- if (should_fault_in_pages (to , & prev_count , & window_size )) {
847
+ if (should_fault_in_pages (to , iocb , & prev_count , & window_size )) {
849
848
gfs2_holder_allow_demote (gh );
850
849
window_size -= fault_in_iov_iter_writeable (to , window_size );
851
850
gfs2_holder_disallow_demote (gh );
@@ -916,7 +915,7 @@ static ssize_t gfs2_file_direct_write(struct kiocb *iocb, struct iov_iter *from,
916
915
if (ret > 0 )
917
916
written = ret ;
918
917
919
- if (should_fault_in_pages (from , & prev_count , & window_size )) {
918
+ if (should_fault_in_pages (from , iocb , & prev_count , & window_size )) {
920
919
gfs2_holder_allow_demote (gh );
921
920
window_size -= fault_in_iov_iter_readable (from , window_size );
922
921
gfs2_holder_disallow_demote (gh );
@@ -984,7 +983,7 @@ static ssize_t gfs2_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
984
983
if (ret > 0 )
985
984
read += ret ;
986
985
987
- if (should_fault_in_pages (to , & prev_count , & window_size )) {
986
+ if (should_fault_in_pages (to , iocb , & prev_count , & window_size )) {
988
987
gfs2_holder_allow_demote (& gh );
989
988
window_size -= fault_in_iov_iter_writeable (to , window_size );
990
989
gfs2_holder_disallow_demote (& gh );
@@ -1061,7 +1060,7 @@ static ssize_t gfs2_file_buffered_write(struct kiocb *iocb,
1061
1060
goto out_unlock ;
1062
1061
1063
1062
from -> count = orig_count - written ;
1064
- if (should_fault_in_pages (from , & prev_count , & window_size )) {
1063
+ if (should_fault_in_pages (from , iocb , & prev_count , & window_size )) {
1065
1064
gfs2_holder_allow_demote (gh );
1066
1065
window_size -= fault_in_iov_iter_readable (from , window_size );
1067
1066
gfs2_holder_disallow_demote (gh );
0 commit comments