mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-17 16:15:18 +00:00
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: Chris Webb <chris@arachsys.com> Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
parent
ab44d7bdee
commit
114eea75c7
1 changed files with 12 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue