Skip to content

Commit

Permalink
gfs2: Explain some direct I/O oddities
Browse files Browse the repository at this point in the history
Add some comments explaining the oddities of partial direct I/O reads
and writes.

Signed-off-by: Andreas Gruenbacher <[email protected]>
  • Loading branch information
Andreas Gruenbacher committed May 24, 2022
1 parent b846f2d commit 53bb540
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/gfs2/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,7 @@ static ssize_t gfs2_file_direct_read(struct kiocb *iocb, struct iov_iter *to,
pagefault_enable();
if (ret <= 0 && ret != -EFAULT)
goto out_unlock;
/* No increment (+=) because iomap_dio_rw returns a cumulative value. */
if (ret > 0)
read = ret;

Expand All @@ -854,6 +855,7 @@ static ssize_t gfs2_file_direct_read(struct kiocb *iocb, struct iov_iter *to,
gfs2_glock_dq(gh);
out_uninit:
gfs2_holder_uninit(gh);
/* User space doesn't expect partial success. */
if (ret < 0)
return ret;
return read;
Expand Down Expand Up @@ -906,6 +908,7 @@ static ssize_t gfs2_file_direct_write(struct kiocb *iocb, struct iov_iter *from,
if (ret != -EFAULT)
goto out_unlock;
}
/* No increment (+=) because iomap_dio_rw returns a cumulative value. */
if (ret > 0)
written = ret;

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

0 comments on commit 53bb540

Please sign in to comment.