Commit b5cbb42d authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Repair fragmentation_lru in alloc_write_key()

fragmentation_lru derives from dirty_sectors, and wasn't being checked.
Co-developed-by: default avatarDaniel Hill <daniel@gluo.nz>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent d39881d2
...@@ -903,6 +903,8 @@ static int bch2_alloc_write_key(struct btree_trans *trans, ...@@ -903,6 +903,8 @@ static int bch2_alloc_write_key(struct btree_trans *trans,
bch2_dev_usage_update(c, ca, &old_gc, &gc, 0, true); bch2_dev_usage_update(c, ca, &old_gc, &gc, 0, true);
percpu_up_read(&c->mark_lock); percpu_up_read(&c->mark_lock);
gc.fragmentation_lru = alloc_lru_idx_fragmentation(gc, ca);
if (fsck_err_on(new.data_type != gc.data_type, c, if (fsck_err_on(new.data_type != gc.data_type, c,
alloc_key_data_type_wrong, alloc_key_data_type_wrong,
"bucket %llu:%llu gen %u has wrong data_type" "bucket %llu:%llu gen %u has wrong data_type"
...@@ -916,23 +918,19 @@ static int bch2_alloc_write_key(struct btree_trans *trans, ...@@ -916,23 +918,19 @@ static int bch2_alloc_write_key(struct btree_trans *trans,
#define copy_bucket_field(_errtype, _f) \ #define copy_bucket_field(_errtype, _f) \
if (fsck_err_on(new._f != gc._f, c, _errtype, \ if (fsck_err_on(new._f != gc._f, c, _errtype, \
"bucket %llu:%llu gen %u data type %s has wrong " #_f \ "bucket %llu:%llu gen %u data type %s has wrong " #_f \
": got %u, should be %u", \ ": got %llu, should be %llu", \
iter->pos.inode, iter->pos.offset, \ iter->pos.inode, iter->pos.offset, \
gc.gen, \ gc.gen, \
bch2_data_type_str(gc.data_type), \ bch2_data_type_str(gc.data_type), \
new._f, gc._f)) \ (u64) new._f, (u64) gc._f)) \
new._f = gc._f; \ new._f = gc._f; \
copy_bucket_field(alloc_key_gen_wrong, copy_bucket_field(alloc_key_gen_wrong, gen);
gen); copy_bucket_field(alloc_key_dirty_sectors_wrong, dirty_sectors);
copy_bucket_field(alloc_key_dirty_sectors_wrong, copy_bucket_field(alloc_key_cached_sectors_wrong, cached_sectors);
dirty_sectors); copy_bucket_field(alloc_key_stripe_wrong, stripe);
copy_bucket_field(alloc_key_cached_sectors_wrong, copy_bucket_field(alloc_key_stripe_redundancy_wrong, stripe_redundancy);
cached_sectors); copy_bucket_field(alloc_key_fragmentation_lru_wrong, fragmentation_lru);
copy_bucket_field(alloc_key_stripe_wrong,
stripe);
copy_bucket_field(alloc_key_stripe_redundancy_wrong,
stripe_redundancy);
#undef copy_bucket_field #undef copy_bucket_field
if (!bch2_alloc_v4_cmp(*old, new)) if (!bch2_alloc_v4_cmp(*old, new))
...@@ -946,7 +944,7 @@ static int bch2_alloc_write_key(struct btree_trans *trans, ...@@ -946,7 +944,7 @@ static int bch2_alloc_write_key(struct btree_trans *trans,
a->v = new; a->v = new;
/* /*
* The trigger normally makes sure this is set, but we're not running * The trigger normally makes sure these are set, but we're not running
* triggers: * triggers:
*/ */
if (a->v.data_type == BCH_DATA_cached && !a->v.io_time[READ]) if (a->v.data_type == BCH_DATA_cached && !a->v.io_time[READ])
......
...@@ -286,7 +286,8 @@ enum bch_fsck_flags { ...@@ -286,7 +286,8 @@ enum bch_fsck_flags {
x(accounting_mismatch, 272, 0) \ x(accounting_mismatch, 272, 0) \
x(accounting_replicas_not_marked, 273, 0) \ x(accounting_replicas_not_marked, 273, 0) \
x(invalid_btree_id, 274, 0) \ x(invalid_btree_id, 274, 0) \
x(alloc_key_io_time_bad, 275, 0) x(alloc_key_io_time_bad, 275, 0) \
x(alloc_key_fragmentation_lru_wrong, 276, FSCK_AUTOFIX)
enum bch_sb_error_id { enum bch_sb_error_id {
#define x(t, n, ...) BCH_FSCK_ERR_##t = n, #define x(t, n, ...) BCH_FSCK_ERR_##t = n,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment