diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-08-14 22:29:41 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:10:11 -0400 |
commit | 62898dd12ba017c56c39a74ef891845118b0c190 (patch) | |
tree | d93799799e1528e4e1d8a4b102cc40babadea42f /fs/bcachefs/fs-io-buffered.c | |
parent | 8c9b0f7bdc4183573d57f0442693d99cc9758617 (diff) | |
download | lwn-62898dd12ba017c56c39a74ef891845118b0c190.tar.gz lwn-62898dd12ba017c56c39a74ef891845118b0c190.zip |
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>
Diffstat (limited to 'fs/bcachefs/fs-io-buffered.c')
-rw-r--r-- | fs/bcachefs/fs-io-buffered.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/bcachefs/fs-io-buffered.c b/fs/bcachefs/fs-io-buffered.c index 102c70887f76..dc22182d532f 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; |