Skip to content

Commit 42e4c3b

Browse files
author
Andreas Gruenbacher
committed
gfs2: Variable rename
Instead of counting the number of bytes read from the filesystem, functions gfs2_file_direct_read and gfs2_file_read_iter count the number of bytes written into the user buffer. Conversely, functions gfs2_file_direct_write and gfs2_file_buffered_write count the number of bytes read from the user buffer. This is nothing but confusing, so change the read functions to count how many bytes they have read, and the write functions to count how many bytes they have written. Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent d031a88 commit 42e4c3b

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

fs/gfs2/file.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ static ssize_t gfs2_file_direct_read(struct kiocb *iocb, struct iov_iter *to,
807807
struct file *file = iocb->ki_filp;
808808
struct gfs2_inode *ip = GFS2_I(file->f_mapping->host);
809809
size_t prev_count = 0, window_size = 0;
810-
size_t written = 0;
810+
size_t read = 0;
811811
ssize_t ret;
812812

813813
/*
@@ -839,11 +839,11 @@ static ssize_t gfs2_file_direct_read(struct kiocb *iocb, struct iov_iter *to,
839839
pagefault_disable();
840840
to->nofault = true;
841841
ret = iomap_dio_rw(iocb, to, &gfs2_iomap_ops, NULL,
842-
IOMAP_DIO_PARTIAL, written);
842+
IOMAP_DIO_PARTIAL, read);
843843
to->nofault = false;
844844
pagefault_enable();
845845
if (ret > 0)
846-
written = ret;
846+
read = ret;
847847

848848
if (should_fault_in_pages(ret, to, &prev_count, &window_size)) {
849849
size_t leftover;
@@ -863,7 +863,7 @@ static ssize_t gfs2_file_direct_read(struct kiocb *iocb, struct iov_iter *to,
863863
gfs2_holder_uninit(gh);
864864
if (ret < 0)
865865
return ret;
866-
return written;
866+
return read;
867867
}
868868

869869
static ssize_t gfs2_file_direct_write(struct kiocb *iocb, struct iov_iter *from,
@@ -873,7 +873,7 @@ static ssize_t gfs2_file_direct_write(struct kiocb *iocb, struct iov_iter *from,
873873
struct inode *inode = file->f_mapping->host;
874874
struct gfs2_inode *ip = GFS2_I(inode);
875875
size_t prev_count = 0, window_size = 0;
876-
size_t read = 0;
876+
size_t written = 0;
877877
ssize_t ret;
878878

879879
/*
@@ -906,13 +906,13 @@ static ssize_t gfs2_file_direct_write(struct kiocb *iocb, struct iov_iter *from,
906906

907907
from->nofault = true;
908908
ret = iomap_dio_rw(iocb, from, &gfs2_iomap_ops, NULL,
909-
IOMAP_DIO_PARTIAL, read);
909+
IOMAP_DIO_PARTIAL, written);
910910
from->nofault = false;
911911

912912
if (ret == -ENOTBLK)
913913
ret = 0;
914914
if (ret > 0)
915-
read = ret;
915+
written = ret;
916916

917917
if (should_fault_in_pages(ret, from, &prev_count, &window_size)) {
918918
size_t leftover;
@@ -933,15 +933,15 @@ static ssize_t gfs2_file_direct_write(struct kiocb *iocb, struct iov_iter *from,
933933
gfs2_holder_uninit(gh);
934934
if (ret < 0)
935935
return ret;
936-
return read;
936+
return written;
937937
}
938938

939939
static ssize_t gfs2_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
940940
{
941941
struct gfs2_inode *ip;
942942
struct gfs2_holder gh;
943943
size_t prev_count = 0, window_size = 0;
944-
size_t written = 0;
944+
size_t read = 0;
945945
ssize_t ret;
946946

947947
/*
@@ -962,7 +962,7 @@ static ssize_t gfs2_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
962962
if (ret >= 0) {
963963
if (!iov_iter_count(to))
964964
return ret;
965-
written = ret;
965+
read = ret;
966966
} else if (ret != -EFAULT) {
967967
if (ret != -EAGAIN)
968968
return ret;
@@ -980,7 +980,7 @@ static ssize_t gfs2_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
980980
ret = generic_file_read_iter(iocb, to);
981981
pagefault_enable();
982982
if (ret > 0)
983-
written += ret;
983+
read += ret;
984984

985985
if (should_fault_in_pages(ret, to, &prev_count, &window_size)) {
986986
size_t leftover;
@@ -998,7 +998,7 @@ static ssize_t gfs2_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
998998
gfs2_glock_dq(&gh);
999999
out_uninit:
10001000
gfs2_holder_uninit(&gh);
1001-
return written ? written : ret;
1001+
return read ? read : ret;
10021002
}
10031003

10041004
static ssize_t gfs2_file_buffered_write(struct kiocb *iocb,
@@ -1012,7 +1012,7 @@ static ssize_t gfs2_file_buffered_write(struct kiocb *iocb,
10121012
struct gfs2_holder *statfs_gh = NULL;
10131013
size_t prev_count = 0, window_size = 0;
10141014
size_t orig_count = iov_iter_count(from);
1015-
size_t read = 0;
1015+
size_t written = 0;
10161016
ssize_t ret;
10171017

10181018
/*
@@ -1050,13 +1050,13 @@ static ssize_t gfs2_file_buffered_write(struct kiocb *iocb,
10501050
current->backing_dev_info = NULL;
10511051
if (ret > 0) {
10521052
iocb->ki_pos += ret;
1053-
read += ret;
1053+
written += ret;
10541054
}
10551055

10561056
if (inode == sdp->sd_rindex)
10571057
gfs2_glock_dq_uninit(statfs_gh);
10581058

1059-
from->count = orig_count - read;
1059+
from->count = orig_count - written;
10601060
if (should_fault_in_pages(ret, from, &prev_count, &window_size)) {
10611061
size_t leftover;
10621062

@@ -1077,8 +1077,8 @@ static ssize_t gfs2_file_buffered_write(struct kiocb *iocb,
10771077
gfs2_holder_uninit(gh);
10781078
if (statfs_gh)
10791079
kfree(statfs_gh);
1080-
from->count = orig_count - read;
1081-
return read ? read : ret;
1080+
from->count = orig_count - written;
1081+
return written ? written : ret;
10821082
}
10831083

10841084
/**

0 commit comments

Comments
 (0)