History

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.

Andreas Gruenbacher committed 4 years ago

Commit 42e4c3b1 parent d031a881 file · +17 −17Browse files

Unified · Split

fs/gfs2/file.c+17−17
@@ -807,7 +807,7 @@ static ssize_t gfs2_file_direct_read(struct kiocb *iocb, struct iov_iter *to, · 806 unmodified lines
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 @@ retry_under_glock: · 25 unmodified lines
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 @@ out_uninit: · 13 unmodified lines
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, · 3 unmodified lines
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 @@ retry_under_glock: · 26 unmodified lines
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,7 +933,7 @@ out_uninit: · 14 unmodified lines
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)
@@ -941,7 +941,7 @@ static ssize_t gfs2_file_read_iter(struct kiocb *iocb, struct iov_iter *to) · 1 unmodified line
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) · 14 unmodified lines
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 @@ retry_under_glock: · 11 unmodified lines
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 @@ retry_under_glock: · 11 unmodified lines
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, · 7 unmodified lines
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 @@ retry_under_glock: · 31 unmodified lines
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 @@ out_uninit: · 14 unmodified lines
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 /**