Commit 114eea75 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Fix dev accounting after device add

This is a hacky but effective fix to device usage stats for superblock
and journal being wrong on a newly added device (following the comment
that already told us how it needed to be done!)
Reported-by: default avatarChris Webb <chris@arachsys.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent ab44d7bd
......@@ -1591,6 +1591,8 @@ int bch2_dev_add(struct bch_fs *c, const char *path)
struct bch_dev *ca = NULL;
struct bch_sb_field_members *mi;
struct bch_member dev_mi;
struct bucket_array *buckets;
struct bucket *g;
unsigned dev_idx, nr_devices, u64s;
int ret;
......@@ -1694,6 +1696,16 @@ int bch2_dev_add(struct bch_fs *c, const char *path)
bch2_dev_usage_journal_reserve(c);
/*
* Clear marks before marking transactionally in the btree, so that
* per-device accounting gets done correctly:
*/
down_read(&ca->bucket_lock);
buckets = bucket_array(ca);
for_each_bucket(g, buckets)
atomic64_set(&g->_mark.v, 0);
up_read(&ca->bucket_lock);
err = "error marking superblock";
ret = bch2_trans_mark_dev_sb(c, ca);
if (ret)
......
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