Skip to content

Commit b5cbb42

Browse files
author
Kent Overstreet
committed
bcachefs: Repair fragmentation_lru in alloc_write_key()
fragmentation_lru derives from dirty_sectors, and wasn't being checked. Co-developed-by: Daniel Hill <[email protected]> Signed-off-by: Kent Overstreet <[email protected]>
1 parent d39881d commit b5cbb42

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

fs/bcachefs/btree_gc.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,8 @@ static int bch2_alloc_write_key(struct btree_trans *trans,
903903
bch2_dev_usage_update(c, ca, &old_gc, &gc, 0, true);
904904
percpu_up_read(&c->mark_lock);
905905

906+
gc.fragmentation_lru = alloc_lru_idx_fragmentation(gc, ca);
907+
906908
if (fsck_err_on(new.data_type != gc.data_type, c,
907909
alloc_key_data_type_wrong,
908910
"bucket %llu:%llu gen %u has wrong data_type"
@@ -916,23 +918,19 @@ static int bch2_alloc_write_key(struct btree_trans *trans,
916918
#define copy_bucket_field(_errtype, _f) \
917919
if (fsck_err_on(new._f != gc._f, c, _errtype, \
918920
"bucket %llu:%llu gen %u data type %s has wrong " #_f \
919-
": got %u, should be %u", \
921+
": got %llu, should be %llu", \
920922
iter->pos.inode, iter->pos.offset, \
921923
gc.gen, \
922924
bch2_data_type_str(gc.data_type), \
923-
new._f, gc._f)) \
925+
(u64) new._f, (u64) gc._f)) \
924926
new._f = gc._f; \
925927

926-
copy_bucket_field(alloc_key_gen_wrong,
927-
gen);
928-
copy_bucket_field(alloc_key_dirty_sectors_wrong,
929-
dirty_sectors);
930-
copy_bucket_field(alloc_key_cached_sectors_wrong,
931-
cached_sectors);
932-
copy_bucket_field(alloc_key_stripe_wrong,
933-
stripe);
934-
copy_bucket_field(alloc_key_stripe_redundancy_wrong,
935-
stripe_redundancy);
928+
copy_bucket_field(alloc_key_gen_wrong, gen);
929+
copy_bucket_field(alloc_key_dirty_sectors_wrong, dirty_sectors);
930+
copy_bucket_field(alloc_key_cached_sectors_wrong, cached_sectors);
931+
copy_bucket_field(alloc_key_stripe_wrong, stripe);
932+
copy_bucket_field(alloc_key_stripe_redundancy_wrong, stripe_redundancy);
933+
copy_bucket_field(alloc_key_fragmentation_lru_wrong, fragmentation_lru);
936934
#undef copy_bucket_field
937935

938936
if (!bch2_alloc_v4_cmp(*old, new))
@@ -946,7 +944,7 @@ static int bch2_alloc_write_key(struct btree_trans *trans,
946944
a->v = new;
947945

948946
/*
949-
* The trigger normally makes sure this is set, but we're not running
947+
* The trigger normally makes sure these are set, but we're not running
950948
* triggers:
951949
*/
952950
if (a->v.data_type == BCH_DATA_cached && !a->v.io_time[READ])

fs/bcachefs/sb-errors_format.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ enum bch_fsck_flags {
286286
x(accounting_mismatch, 272, 0) \
287287
x(accounting_replicas_not_marked, 273, 0) \
288288
x(invalid_btree_id, 274, 0) \
289-
x(alloc_key_io_time_bad, 275, 0)
289+
x(alloc_key_io_time_bad, 275, 0) \
290+
x(alloc_key_fragmentation_lru_wrong, 276, FSCK_AUTOFIX)
290291

291292
enum bch_sb_error_id {
292293
#define x(t, n, ...) BCH_FSCK_ERR_##t = n,

0 commit comments

Comments
 (0)