Skip to content

Commit e0d5bc6

Browse files
author
Kent Overstreet
committed
bcachefs: Fix missing BTREE_TRIGGER_bucket_invalidate flag
This fixes an accounting mismatch for cached data. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 7554a8b commit e0d5bc6

4 files changed

Lines changed: 8 additions & 6 deletions

File tree

fs/bcachefs/alloc_background.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,15 +477,16 @@ bch2_trans_start_alloc_update_noupdate(struct btree_trans *trans, struct btree_i
477477
}
478478

479479
__flatten
480-
struct bkey_i_alloc_v4 *bch2_trans_start_alloc_update(struct btree_trans *trans, struct bpos pos)
480+
struct bkey_i_alloc_v4 *bch2_trans_start_alloc_update(struct btree_trans *trans, struct bpos pos,
481+
enum btree_iter_update_trigger_flags flags)
481482
{
482483
struct btree_iter iter;
483484
struct bkey_i_alloc_v4 *a = bch2_trans_start_alloc_update_noupdate(trans, &iter, pos);
484485
int ret = PTR_ERR_OR_ZERO(a);
485486
if (ret)
486487
return ERR_PTR(ret);
487488

488-
ret = bch2_trans_update(trans, &iter, &a->k_i, 0);
489+
ret = bch2_trans_update(trans, &iter, &a->k_i, flags);
489490
bch2_trans_iter_exit(trans, &iter);
490491
return unlikely(ret) ? ERR_PTR(ret) : a;
491492
}
@@ -2006,7 +2007,7 @@ static int invalidate_one_bucket(struct btree_trans *trans,
20062007
if (bch2_bucket_is_open_safe(c, bucket.inode, bucket.offset))
20072008
return 0;
20082009

2009-
a = bch2_trans_start_alloc_update(trans, bucket);
2010+
a = bch2_trans_start_alloc_update(trans, bucket, BTREE_TRIGGER_bucket_invalidate);
20102011
ret = PTR_ERR_OR_ZERO(a);
20112012
if (ret)
20122013
goto out;

fs/bcachefs/alloc_background.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ static inline void set_alloc_v4_u64s(struct bkey_i_alloc_v4 *a)
206206
struct bkey_i_alloc_v4 *
207207
bch2_trans_start_alloc_update_noupdate(struct btree_trans *, struct btree_iter *, struct bpos);
208208
struct bkey_i_alloc_v4 *
209-
bch2_trans_start_alloc_update(struct btree_trans *, struct bpos);
209+
bch2_trans_start_alloc_update(struct btree_trans *, struct bpos,
210+
enum btree_iter_update_trigger_flags);
210211

211212
void __bch2_alloc_to_v4(struct bkey_s_c, struct bch_alloc_v4 *);
212213

fs/bcachefs/buckets.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ static int bch2_trigger_pointer(struct btree_trans *trans,
569569
*sectors = insert ? bp.bucket_len : -((s64) bp.bucket_len);
570570

571571
if (flags & BTREE_TRIGGER_transactional) {
572-
struct bkey_i_alloc_v4 *a = bch2_trans_start_alloc_update(trans, bucket);
572+
struct bkey_i_alloc_v4 *a = bch2_trans_start_alloc_update(trans, bucket, 0);
573573
ret = PTR_ERR_OR_ZERO(a) ?:
574574
__mark_pointer(trans, ca, k, &p, *sectors, bp.data_type, &a->v);
575575
if (ret)

fs/bcachefs/ec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ static int mark_stripe_bucket(struct btree_trans *trans,
283283

284284
if (flags & BTREE_TRIGGER_transactional) {
285285
struct bkey_i_alloc_v4 *a =
286-
bch2_trans_start_alloc_update(trans, bucket);
286+
bch2_trans_start_alloc_update(trans, bucket, 0);
287287
ret = PTR_ERR_OR_ZERO(a) ?:
288288
__mark_stripe_bucket(trans, ca, s, ptr_idx, deleting, bucket, &a->v, flags);
289289
}

0 commit comments

Comments
 (0)