aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-12-07 20:43:07 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2024-12-21 01:36:22 -0500
commitbe565740ee84798b5b2d5ab88070d887fd77c1a3 (patch)
tree3ed636d510ac878d4b74b735cbd8d09130efb34a
parentbcachefs: Don't add unknown accounting types to eytzinger tree (diff)
downloadwireguard-linux-be565740ee84798b5b2d5ab88070d887fd77c1a3.tar.xz
wireguard-linux-be565740ee84798b5b2d5ab88070d887fd77c1a3.zip
bcachefs: Set bucket needs discard, inc gen on empty -> nonempty transition
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/alloc_background.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c
index b2d570453351..62069231c63b 100644
--- a/fs/bcachefs/alloc_background.c
+++ b/fs/bcachefs/alloc_background.c
@@ -856,7 +856,10 @@ int bch2_trigger_alloc(struct btree_trans *trans,
if (flags & BTREE_TRIGGER_transactional) {
alloc_data_type_set(new_a, new_a->data_type);
- if (bch2_bucket_sectors_total(*new_a) > bch2_bucket_sectors_total(*old_a)) {
+ int is_empty_delta = (int) data_type_is_empty(new_a->data_type) -
+ (int) data_type_is_empty(old_a->data_type);
+
+ if (is_empty_delta < 0) {
new_a->io_time[READ] = bch2_current_io_time(c, READ);
new_a->io_time[WRITE]= bch2_current_io_time(c, WRITE);
SET_BCH_ALLOC_V4_NEED_INC_GEN(new_a, true);