summaryrefslogtreecommitdiffstats
path: root/fs/iomap
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruenba@redhat.com>2021-11-09 12:56:06 +0100
committerAndreas Gruenbacher <agruenba@redhat.com>2022-03-25 15:14:03 +0100
commit631f871f071746789e9242e514ab0f49067fa97a (patch)
tree4d35c6076638ba43441cebfecdc96a08c6dee343 /fs/iomap
parent42eb8fdac2fc5d62392dcfcf0253753e821a97b0 (diff)
downloadlinux-stable-631f871f071746789e9242e514ab0f49067fa97a.tar.gz
linux-stable-631f871f071746789e9242e514ab0f49067fa97a.tar.bz2
linux-stable-631f871f071746789e9242e514ab0f49067fa97a.zip
fs/iomap: Fix buffered write page prefaulting
When part of the user buffer passed to generic_perform_write() or iomap_file_buffered_write() cannot be faulted in for reading, the entire write currently fails. The correct behavior would be to write all the data that can be written, up to the point of failure. Commit a6294593e8a1 ("iov_iter: Turn iov_iter_fault_in_readable into fault_in_iov_iter_readable") gave us the information needed, so fix the page prefaulting in generic_perform_write() and iomap_write_iter() to only bail out when no pages could be faulted in. We already factor in that pages that are faulted in may no longer be resident by the time they are accessed. Paging out pages has the same effect as not faulting in those pages in the first place, so the code can already deal with that. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs/iomap')
-rw-r--r--fs/iomap/buffered-io.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 1753c26c8e76..54516ab464cd 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -750,7 +750,7 @@ again:
* same page as we're writing to, without it being marked
* up-to-date.
*/
- if (unlikely(fault_in_iov_iter_readable(i, bytes))) {
+ if (unlikely(fault_in_iov_iter_readable(i, bytes) == bytes)) {
status = -EFAULT;
break;
}