mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 21:21:41 +00:00
bcachefs: Fix data corruption on -ENOSPC in buffered write path
Found by generic/299: When we have to truncate a write due to -ENOSPC, we may have to read in the folio we're writing to if we're now no longer doing a complete write to a !uptodate folio. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
335d318ef5
commit
97535cd84f
@ -856,6 +856,12 @@ static int __bch2_buffered_write(struct bch_inode_info *inode,
|
|||||||
folios_trunc(&fs, fi);
|
folios_trunc(&fs, fi);
|
||||||
end = min(end, folio_end_pos(darray_last(fs)));
|
end = min(end, folio_end_pos(darray_last(fs)));
|
||||||
} else {
|
} else {
|
||||||
|
if (!folio_test_uptodate(f)) {
|
||||||
|
ret = bch2_read_single_folio(f, mapping);
|
||||||
|
if (ret)
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
folios_trunc(&fs, fi + 1);
|
folios_trunc(&fs, fi + 1);
|
||||||
end = f_pos + f_reserved;
|
end = f_pos + f_reserved;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user