Skip to content

Commit 53bb540

Browse files
author
Andreas Gruenbacher
committed
gfs2: Explain some direct I/O oddities
Add some comments explaining the oddities of partial direct I/O reads and writes. Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent b846f2d commit 53bb540

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fs/gfs2/file.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,7 @@ static ssize_t gfs2_file_direct_read(struct kiocb *iocb, struct iov_iter *to,
840840
pagefault_enable();
841841
if (ret <= 0 && ret != -EFAULT)
842842
goto out_unlock;
843+
/* No increment (+=) because iomap_dio_rw returns a cumulative value. */
843844
if (ret > 0)
844845
read = ret;
845846

@@ -854,6 +855,7 @@ static ssize_t gfs2_file_direct_read(struct kiocb *iocb, struct iov_iter *to,
854855
gfs2_glock_dq(gh);
855856
out_uninit:
856857
gfs2_holder_uninit(gh);
858+
/* User space doesn't expect partial success. */
857859
if (ret < 0)
858860
return ret;
859861
return read;
@@ -906,6 +908,7 @@ static ssize_t gfs2_file_direct_write(struct kiocb *iocb, struct iov_iter *from,
906908
if (ret != -EFAULT)
907909
goto out_unlock;
908910
}
911+
/* No increment (+=) because iomap_dio_rw returns a cumulative value. */
909912
if (ret > 0)
910913
written = ret;
911914

@@ -920,6 +923,7 @@ static ssize_t gfs2_file_direct_write(struct kiocb *iocb, struct iov_iter *from,
920923
gfs2_glock_dq(gh);
921924
out_uninit:
922925
gfs2_holder_uninit(gh);
926+
/* User space doesn't expect partial success. */
923927
if (ret < 0)
924928
return ret;
925929
return written;

0 commit comments

Comments
 (0)