bcachefs: Fix missing BTREE_TRIGGER_bucket_invalidate flag
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 23 Jun 2024 22:48:22 +0000 (18:48 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 14 Jul 2024 23:00:16 +0000 (19:00 -0400)
This fixes an accounting mismatch for cached data.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/alloc_background.c
fs/bcachefs/alloc_background.h
fs/bcachefs/buckets.c
fs/bcachefs/ec.c

index 54e066ee8dcac78a6bcfe7321d2a4aecf8d4cb0b..d9c5a92fa708fb32f00f312c1f4f7301eb9810a2 100644 (file)
@@ -477,7 +477,8 @@ err:
 }
 
 __flatten
-struct bkey_i_alloc_v4 *bch2_trans_start_alloc_update(struct btree_trans *trans, struct bpos pos)
+struct bkey_i_alloc_v4 *bch2_trans_start_alloc_update(struct btree_trans *trans, struct bpos pos,
+                                                     enum btree_iter_update_trigger_flags flags)
 {
        struct btree_iter iter;
        struct bkey_i_alloc_v4 *a = bch2_trans_start_alloc_update_noupdate(trans, &iter, pos);
@@ -485,7 +486,7 @@ struct bkey_i_alloc_v4 *bch2_trans_start_alloc_update(struct btree_trans *trans,
        if (ret)
                return ERR_PTR(ret);
 
-       ret = bch2_trans_update(trans, &iter, &a->k_i, 0);
+       ret = bch2_trans_update(trans, &iter, &a->k_i, flags);
        bch2_trans_iter_exit(trans, &iter);
        return unlikely(ret) ? ERR_PTR(ret) : a;
 }
@@ -2006,7 +2007,7 @@ static int invalidate_one_bucket(struct btree_trans *trans,
        if (bch2_bucket_is_open_safe(c, bucket.inode, bucket.offset))
                return 0;
 
-       a = bch2_trans_start_alloc_update(trans, bucket);
+       a = bch2_trans_start_alloc_update(trans, bucket, BTREE_TRIGGER_bucket_invalidate);
        ret = PTR_ERR_OR_ZERO(a);
        if (ret)
                goto out;
index dd7d14363a689b45b16cc08cd3f88990c0564c74..8d2b62c9588e738364da6aab03000f271604fd5a 100644 (file)
@@ -206,7 +206,8 @@ static inline void set_alloc_v4_u64s(struct bkey_i_alloc_v4 *a)
 struct bkey_i_alloc_v4 *
 bch2_trans_start_alloc_update_noupdate(struct btree_trans *, struct btree_iter *, struct bpos);
 struct bkey_i_alloc_v4 *
-bch2_trans_start_alloc_update(struct btree_trans *, struct bpos);
+bch2_trans_start_alloc_update(struct btree_trans *, struct bpos,
+                             enum btree_iter_update_trigger_flags);
 
 void __bch2_alloc_to_v4(struct bkey_s_c, struct bch_alloc_v4 *);
 
index 95e27995875af4c5401505902a73ceba9ced1ba7..2650a0d246636959caf83b2f27445d47aec8094c 100644 (file)
@@ -569,7 +569,7 @@ static int bch2_trigger_pointer(struct btree_trans *trans,
        *sectors = insert ? bp.bucket_len : -((s64) bp.bucket_len);
 
        if (flags & BTREE_TRIGGER_transactional) {
-               struct bkey_i_alloc_v4 *a = bch2_trans_start_alloc_update(trans, bucket);
+               struct bkey_i_alloc_v4 *a = bch2_trans_start_alloc_update(trans, bucket, 0);
                ret = PTR_ERR_OR_ZERO(a) ?:
                        __mark_pointer(trans, ca, k, &p, *sectors, bp.data_type, &a->v);
                if (ret)
index 3c3a2a7e8389780e9a1b25a5cbd9667bc0e792ff..86948d110f6bf85ccbe3c84998d634cebbc58ed4 100644 (file)
@@ -283,7 +283,7 @@ static int mark_stripe_bucket(struct btree_trans *trans,
 
        if (flags & BTREE_TRIGGER_transactional) {
                struct bkey_i_alloc_v4 *a =
-                       bch2_trans_start_alloc_update(trans, bucket);
+                       bch2_trans_start_alloc_update(trans, bucket, 0);
                ret = PTR_ERR_OR_ZERO(a) ?:
                        __mark_stripe_bucket(trans, ca, s, ptr_idx, deleting, bucket, &a->v, flags);
        }