Skip to content

Commit e1fa9ea

Browse files
author
Andreas Gruenbacher
committed
gfs2: Stop using glock holder auto-demotion for now
We're having unresolved issues with the glock holder auto-demotion mechanism introduced in commit dc73290. This mechanism was assumed to be essential for avoiding frequent short reads and writes until commit 296abc0 ("gfs2: No short reads or writes upon glock contention"). Since then, when the inode glock is lost, it is simply re-acquired and the operation is resumed. This means that apart from the performance penalty, we might as well drop the inode glock before faulting in pages, and re-acquire it afterwards. Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent fa5dfa6 commit e1fa9ea

File tree

1 file changed

+14
-32
lines changed

1 file changed

+14
-32
lines changed

fs/gfs2/file.c

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,6 @@ static ssize_t gfs2_file_direct_read(struct kiocb *iocb, struct iov_iter *to,
832832
ret = gfs2_glock_nq(gh);
833833
if (ret)
834834
goto out_uninit;
835-
retry_under_glock:
836835
pagefault_disable();
837836
to->nofault = true;
838837
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,
845844
read = ret;
846845

847846
if (should_fault_in_pages(to, iocb, &prev_count, &window_size)) {
848-
gfs2_holder_allow_demote(gh);
847+
gfs2_glock_dq(gh);
849848
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)
854850
goto retry;
855-
}
856851
}
857852
out_unlock:
858853
if (gfs2_holder_queued(gh))
@@ -900,7 +895,6 @@ static ssize_t gfs2_file_direct_write(struct kiocb *iocb, struct iov_iter *from,
900895
/* Silently fall back to buffered I/O when writing beyond EOF */
901896
if (iocb->ki_pos + iov_iter_count(from) > i_size_read(&ip->i_inode))
902897
goto out_unlock;
903-
retry_under_glock:
904898

905899
from->nofault = true;
906900
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,
916910
written = ret;
917911

918912
if (should_fault_in_pages(from, iocb, &prev_count, &window_size)) {
919-
gfs2_holder_allow_demote(gh);
913+
gfs2_glock_dq(gh);
920914
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)
925916
goto retry;
926-
}
927917
}
928918
out_unlock:
929919
if (gfs2_holder_queued(gh))
@@ -974,7 +964,6 @@ static ssize_t gfs2_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
974964
ret = gfs2_glock_nq(&gh);
975965
if (ret)
976966
goto out_uninit;
977-
retry_under_glock:
978967
pagefault_disable();
979968
ret = generic_file_read_iter(iocb, to);
980969
pagefault_enable();
@@ -984,14 +973,10 @@ static ssize_t gfs2_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
984973
read += ret;
985974

986975
if (should_fault_in_pages(to, iocb, &prev_count, &window_size)) {
987-
gfs2_holder_allow_demote(&gh);
976+
gfs2_glock_dq(&gh);
988977
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)
993979
goto retry;
994-
}
995980
}
996981
out_unlock:
997982
if (gfs2_holder_queued(&gh))
@@ -1030,22 +1015,17 @@ static ssize_t gfs2_file_buffered_write(struct kiocb *iocb,
10301015

10311016
gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, gh);
10321017
retry:
1033-
ret = gfs2_glock_nq(gh);
1034-
if (ret)
1035-
goto out_uninit;
10361018
if (should_fault_in_pages(from, iocb, &prev_count, &window_size)) {
1037-
retry_under_glock:
1038-
gfs2_holder_allow_demote(gh);
10391019
window_size -= fault_in_iov_iter_readable(from, window_size);
1040-
gfs2_holder_disallow_demote(gh);
10411020
if (!window_size) {
10421021
ret = -EFAULT;
1043-
goto out_unlock;
1022+
goto out_uninit;
10441023
}
1045-
if (!gfs2_holder_queued(gh))
1046-
goto retry;
10471024
from->count = min(from->count, window_size);
10481025
}
1026+
ret = gfs2_glock_nq(gh);
1027+
if (ret)
1028+
goto out_uninit;
10491029

10501030
if (inode == sdp->sd_rindex) {
10511031
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,
10731053
goto out_unlock;
10741054

10751055
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+
}
10781060
out_unlock:
10791061
if (gfs2_holder_queued(gh))
10801062
gfs2_glock_dq(gh);

0 commit comments

Comments
 (0)