summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2019-08-13 03:16:52 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:25 -0400
commitb3fce09cd33271d8dcdd3b18527d106558e30728 (patch)
tree96e886ba7367a5747776a959549a309e7021f5b7
parent1904a65a315d78e6357aed36d3e7e9a5c2563370 (diff)
downloadlwn-b3fce09cd33271d8dcdd3b18527d106558e30728.tar.gz
lwn-b3fce09cd33271d8dcdd3b18527d106558e30728.zip
bcachefs: Mark space as unallocated on write failure
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/fs-io.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c
index 913e26487efb..91a34ca5e4e1 100644
--- a/fs/bcachefs/fs-io.c
+++ b/fs/bcachefs/fs-io.c
@@ -1219,11 +1219,20 @@ static void bch2_writepage_io_done(struct closure *cl)
struct bio *bio = &io->op.op.wbio.bio;
struct bvec_iter_all iter;
struct bio_vec *bvec;
+ unsigned i;
if (io->op.op.error) {
bio_for_each_segment_all(bvec, bio, iter) {
+ struct bch_page_state *s;
+
SetPageError(bvec->bv_page);
mapping_set_error(bvec->bv_page->mapping, -EIO);
+
+ lock_page(bvec->bv_page);
+ s = bch2_page_state(bvec->bv_page);
+ for (i = 0; i < PAGE_SECTORS; i++)
+ s->s[i].nr_replicas = 0;
+ unlock_page(bvec->bv_page);
}
}