@@ -832,7 +832,6 @@ static ssize_t gfs2_file_direct_read(struct kiocb *iocb, struct iov_iter *to,
832
832
ret = gfs2_glock_nq (gh );
833
833
if (ret )
834
834
goto out_uninit ;
835
- retry_under_glock :
836
835
pagefault_disable ();
837
836
to -> nofault = true;
838
837
ret = iomap_dio_rw (iocb , to , & gfs2_iomap_ops , NULL ,
@@ -845,14 +844,10 @@ static ssize_t gfs2_file_direct_read(struct kiocb *iocb, struct iov_iter *to,
845
844
read = ret ;
846
845
847
846
if (should_fault_in_pages (to , iocb , & prev_count , & window_size )) {
848
- gfs2_holder_allow_demote (gh );
847
+ gfs2_glock_dq (gh );
849
848
window_size -= fault_in_iov_iter_writeable (to , window_size );
850
- gfs2_holder_disallow_demote (gh );
851
- if (window_size ) {
852
- if (gfs2_holder_queued (gh ))
853
- goto retry_under_glock ;
849
+ if (window_size )
854
850
goto retry ;
855
- }
856
851
}
857
852
out_unlock :
858
853
if (gfs2_holder_queued (gh ))
@@ -900,7 +895,6 @@ static ssize_t gfs2_file_direct_write(struct kiocb *iocb, struct iov_iter *from,
900
895
/* Silently fall back to buffered I/O when writing beyond EOF */
901
896
if (iocb -> ki_pos + iov_iter_count (from ) > i_size_read (& ip -> i_inode ))
902
897
goto out_unlock ;
903
- retry_under_glock :
904
898
905
899
from -> nofault = true;
906
900
ret = iomap_dio_rw (iocb , from , & gfs2_iomap_ops , NULL ,
@@ -916,14 +910,10 @@ static ssize_t gfs2_file_direct_write(struct kiocb *iocb, struct iov_iter *from,
916
910
written = ret ;
917
911
918
912
if (should_fault_in_pages (from , iocb , & prev_count , & window_size )) {
919
- gfs2_holder_allow_demote (gh );
913
+ gfs2_glock_dq (gh );
920
914
window_size -= fault_in_iov_iter_readable (from , window_size );
921
- gfs2_holder_disallow_demote (gh );
922
- if (window_size ) {
923
- if (gfs2_holder_queued (gh ))
924
- goto retry_under_glock ;
915
+ if (window_size )
925
916
goto retry ;
926
- }
927
917
}
928
918
out_unlock :
929
919
if (gfs2_holder_queued (gh ))
@@ -974,7 +964,6 @@ static ssize_t gfs2_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
974
964
ret = gfs2_glock_nq (& gh );
975
965
if (ret )
976
966
goto out_uninit ;
977
- retry_under_glock :
978
967
pagefault_disable ();
979
968
ret = generic_file_read_iter (iocb , to );
980
969
pagefault_enable ();
@@ -984,14 +973,10 @@ static ssize_t gfs2_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
984
973
read += ret ;
985
974
986
975
if (should_fault_in_pages (to , iocb , & prev_count , & window_size )) {
987
- gfs2_holder_allow_demote (& gh );
976
+ gfs2_glock_dq (& gh );
988
977
window_size -= fault_in_iov_iter_writeable (to , window_size );
989
- gfs2_holder_disallow_demote (& gh );
990
- if (window_size ) {
991
- if (gfs2_holder_queued (& gh ))
992
- goto retry_under_glock ;
978
+ if (window_size )
993
979
goto retry ;
994
- }
995
980
}
996
981
out_unlock :
997
982
if (gfs2_holder_queued (& gh ))
@@ -1030,22 +1015,17 @@ static ssize_t gfs2_file_buffered_write(struct kiocb *iocb,
1030
1015
1031
1016
gfs2_holder_init (ip -> i_gl , LM_ST_EXCLUSIVE , 0 , gh );
1032
1017
retry :
1033
- ret = gfs2_glock_nq (gh );
1034
- if (ret )
1035
- goto out_uninit ;
1036
1018
if (should_fault_in_pages (from , iocb , & prev_count , & window_size )) {
1037
- retry_under_glock :
1038
- gfs2_holder_allow_demote (gh );
1039
1019
window_size -= fault_in_iov_iter_readable (from , window_size );
1040
- gfs2_holder_disallow_demote (gh );
1041
1020
if (!window_size ) {
1042
1021
ret = - EFAULT ;
1043
- goto out_unlock ;
1022
+ goto out_uninit ;
1044
1023
}
1045
- if (!gfs2_holder_queued (gh ))
1046
- goto retry ;
1047
1024
from -> count = min (from -> count , window_size );
1048
1025
}
1026
+ ret = gfs2_glock_nq (gh );
1027
+ if (ret )
1028
+ goto out_uninit ;
1049
1029
1050
1030
if (inode == sdp -> sd_rindex ) {
1051
1031
struct gfs2_inode * m_ip = GFS2_I (sdp -> sd_statfs_inode );
@@ -1073,8 +1053,10 @@ static ssize_t gfs2_file_buffered_write(struct kiocb *iocb,
1073
1053
goto out_unlock ;
1074
1054
1075
1055
from -> count = orig_count - written ;
1076
- if (should_fault_in_pages (from , iocb , & prev_count , & window_size ))
1077
- goto retry_under_glock ;
1056
+ if (should_fault_in_pages (from , iocb , & prev_count , & window_size )) {
1057
+ gfs2_glock_dq (gh );
1058
+ goto retry ;
1059
+ }
1078
1060
out_unlock :
1079
1061
if (gfs2_holder_queued (gh ))
1080
1062
gfs2_glock_dq (gh );
0 commit comments