Skip to content

Commit 5722119

Browse files
committed
Merge tag 'iomap-6.6-fixes-5' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Pull iomap fix from Darrick Wong: - Fix a bug where a writev consisting of a bunch of sub-fsblock writes where the last buffer address is invalid could lead to an infinite loop * tag 'iomap-6.6-fixes-5' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: iomap: fix short copy in iomap_write_iter()
2 parents 9c5d00c + 3ac9747 commit 5722119

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

fs/iomap/buffered-io.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -881,8 +881,10 @@ static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i)
881881
size_t bytes; /* Bytes to write to folio */
882882
size_t copied; /* Bytes copied from user */
883883

884+
bytes = iov_iter_count(i);
885+
retry:
884886
offset = pos & (chunk - 1);
885-
bytes = min(chunk - offset, iov_iter_count(i));
887+
bytes = min(chunk - offset, bytes);
886888
status = balance_dirty_pages_ratelimited_flags(mapping,
887889
bdp_flags);
888890
if (unlikely(status))
@@ -933,10 +935,12 @@ static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i)
933935
* halfway through, might be a race with munmap,
934936
* might be severe memory pressure.
935937
*/
936-
if (copied)
937-
bytes = copied;
938938
if (chunk > PAGE_SIZE)
939939
chunk /= 2;
940+
if (copied) {
941+
bytes = copied;
942+
goto retry;
943+
}
940944
} else {
941945
pos += status;
942946
written += status;

0 commit comments

Comments
 (0)