summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-08-14 22:29:41 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-09-11 01:29:29 -0400
commit8ee86b61183344033fb0fe259f90635657233413 (patch)
tree65e1958ea7ad8a91cf81d10107714978724748d7
parent59c3b0c14933a8813826335095b4604ca6540dc1 (diff)
bcachefs: Fix swallowing of data in buffered write path
In __bch2_buffered_write, if we fail to write to an entire !uptodate folio, we have to back out the write, bail out and retry. But we were missing an iov_iter_revert() call, so the data written to the folio was lost and the rest of the write shifted to the wrong offset. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/fs-io-buffered.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/bcachefs/fs-io-buffered.c b/fs/bcachefs/fs-io-buffered.c
index b6d050197d9d..cbfb5b21ddcb 100644
--- a/fs/bcachefs/fs-io-buffered.c
+++ b/fs/bcachefs/fs-io-buffered.c
@@ -909,6 +909,7 @@ static int __bch2_buffered_write(struct bch_inode_info *inode,
if (!folio_test_uptodate(f) &&
f_copied != folio_size(f) &&
pos + copied + f_copied < inode->v.i_size) {
+ iov_iter_revert(iter, f_copied);
folio_zero_range(f, 0, folio_size(f));
folios_trunc(&folios, fi);
break;