summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fs/bcachefs/io.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c
index 79003dffa9e9..9f092cc8f55a 100644
--- a/fs/bcachefs/io.c
+++ b/fs/bcachefs/io.c
@@ -999,6 +999,8 @@ do_write:
bkey_start_pos(&key_to_write->k),
total_input >> 9);
+ bch2_alloc_sectors_done(c, wp);
+
dst->bi_end_io = bch2_write_endio;
dst->bi_private = &op->cl;
bio_set_op_attrs(dst, REQ_OP_WRITE, 0);
@@ -1013,6 +1015,8 @@ csum_err:
"rewriting existing data (memory corruption?)");
ret = -EIO;
err:
+ bch2_alloc_sectors_done(c, wp);
+
if (to_wbio(dst)->bounce)
bch2_bio_free_pages_pool(c, dst);
if (to_wbio(dst)->put_bio)
@@ -1063,10 +1067,9 @@ again:
goto flush_io;
}
- ret = bch2_write_extent(op, wp);
-
bch2_open_bucket_get(c, wp, &op->open_buckets);
- bch2_alloc_sectors_done(c, wp);
+
+ ret = bch2_write_extent(op, wp);
if (ret < 0)
goto err;