Skip to content

Commit 6d22ff4

Browse files
author
Andreas Gruenbacher
committed
gfs2: Clean up use of fault_in_iov_iter_{read,write}able
No need to store the return value of the fault_in functions in separate variables. Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent 42e4c3b commit 6d22ff4

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

fs/gfs2/file.c

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -846,12 +846,10 @@ static ssize_t gfs2_file_direct_read(struct kiocb *iocb, struct iov_iter *to,
846846
read = ret;
847847

848848
if (should_fault_in_pages(ret, to, &prev_count, &window_size)) {
849-
size_t leftover;
850-
851849
gfs2_holder_allow_demote(gh);
852-
leftover = fault_in_iov_iter_writeable(to, window_size);
850+
window_size -= fault_in_iov_iter_writeable(to, window_size);
853851
gfs2_holder_disallow_demote(gh);
854-
if (leftover != window_size) {
852+
if (window_size) {
855853
if (gfs2_holder_queued(gh))
856854
goto retry_under_glock;
857855
goto retry;
@@ -915,12 +913,10 @@ static ssize_t gfs2_file_direct_write(struct kiocb *iocb, struct iov_iter *from,
915913
written = ret;
916914

917915
if (should_fault_in_pages(ret, from, &prev_count, &window_size)) {
918-
size_t leftover;
919-
920916
gfs2_holder_allow_demote(gh);
921-
leftover = fault_in_iov_iter_readable(from, window_size);
917+
window_size -= fault_in_iov_iter_readable(from, window_size);
922918
gfs2_holder_disallow_demote(gh);
923-
if (leftover != window_size) {
919+
if (window_size) {
924920
if (gfs2_holder_queued(gh))
925921
goto retry_under_glock;
926922
goto retry;
@@ -983,12 +979,10 @@ static ssize_t gfs2_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
983979
read += ret;
984980

985981
if (should_fault_in_pages(ret, to, &prev_count, &window_size)) {
986-
size_t leftover;
987-
988982
gfs2_holder_allow_demote(&gh);
989-
leftover = fault_in_iov_iter_writeable(to, window_size);
983+
window_size -= fault_in_iov_iter_writeable(to, window_size);
990984
gfs2_holder_disallow_demote(&gh);
991-
if (leftover != window_size) {
985+
if (window_size) {
992986
if (gfs2_holder_queued(&gh))
993987
goto retry_under_glock;
994988
goto retry;
@@ -1058,13 +1052,11 @@ static ssize_t gfs2_file_buffered_write(struct kiocb *iocb,
10581052

10591053
from->count = orig_count - written;
10601054
if (should_fault_in_pages(ret, from, &prev_count, &window_size)) {
1061-
size_t leftover;
1062-
10631055
gfs2_holder_allow_demote(gh);
1064-
leftover = fault_in_iov_iter_readable(from, window_size);
1056+
window_size -= fault_in_iov_iter_readable(from, window_size);
10651057
gfs2_holder_disallow_demote(gh);
1066-
if (leftover != window_size) {
1067-
from->count = min(from->count, window_size - leftover);
1058+
if (window_size) {
1059+
from->count = min(from->count, window_size);
10681060
if (gfs2_holder_queued(gh))
10691061
goto retry_under_glock;
10701062
goto retry;

0 commit comments

Comments
 (0)