summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-03-21 00:03:34 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:56 -0400
commitcb16bfaa86f09fae33a712510aa51a03ca370d63 (patch)
tree05934cfc205d47a6a1297812b5241672f7a6576a
parent4cfb722ca16d89ada724c142201fc86872283a90 (diff)
downloadlwn-cb16bfaa86f09fae33a712510aa51a03ca370d63.tar.gz
lwn-cb16bfaa86f09fae33a712510aa51a03ca370d63.zip
bcachefs: Get disk reservation when overwriting data in old snapshot
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/io.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c
index b841b3da2510..5ee9a6c2f4fd 100644
--- a/fs/bcachefs/io.c
+++ b/fs/bcachefs/io.c
@@ -224,9 +224,10 @@ int bch2_sum_sector_overwrites(struct btree_trans *trans,
(bkey_extent_is_allocation(&new->k) -
bkey_extent_is_allocation(old.k));
- *disk_sectors_delta += sectors *
- (int) (bch2_bkey_nr_ptrs_allocated(bkey_i_to_s_c(new)) -
- bch2_bkey_nr_ptrs_fully_allocated(old));
+ *disk_sectors_delta += sectors * bch2_bkey_nr_ptrs_allocated(bkey_i_to_s_c(new));
+ *disk_sectors_delta -= new->k.p.snapshot == old.k->p.snapshot
+ ? sectors * bch2_bkey_nr_ptrs_fully_allocated(old)
+ : 0;
if (!*should_check_enospc &&
(new_replicas > bch2_bkey_replicas(c, old) ||