Commit 00839add authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Convert bch2_replicas_gc2() to new accounting

bch2_replicas_gc2() is used for garbage collection superblock replicas
entries that are empty - this converts it to the new accounting scheme.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent fb23d57a
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include "bcachefs.h" #include "bcachefs.h"
#include "buckets.h" #include "buckets.h"
#include "disk_accounting.h"
#include "journal.h" #include "journal.h"
#include "replicas.h" #include "replicas.h"
#include "super-io.h" #include "super-io.h"
...@@ -418,8 +419,6 @@ int bch2_replicas_gc_start(struct bch_fs *c, unsigned typemask) ...@@ -418,8 +419,6 @@ int bch2_replicas_gc_start(struct bch_fs *c, unsigned typemask)
*/ */
int bch2_replicas_gc2(struct bch_fs *c) int bch2_replicas_gc2(struct bch_fs *c)
{ {
return 0;
#if 0
struct bch_replicas_cpu new = { 0 }; struct bch_replicas_cpu new = { 0 };
unsigned i, nr; unsigned i, nr;
int ret = 0; int ret = 0;
...@@ -449,20 +448,26 @@ int bch2_replicas_gc2(struct bch_fs *c) ...@@ -449,20 +448,26 @@ int bch2_replicas_gc2(struct bch_fs *c)
struct bch_replicas_entry_v1 *e = struct bch_replicas_entry_v1 *e =
cpu_replicas_entry(&c->replicas, i); cpu_replicas_entry(&c->replicas, i);
if (e->data_type == BCH_DATA_journal || struct disk_accounting_pos k = {
c->usage_base->replicas[i] || .type = BCH_DISK_ACCOUNTING_replicas,
percpu_u64_get(&c->usage[0]->replicas[i]) || };
percpu_u64_get(&c->usage[1]->replicas[i]) ||
percpu_u64_get(&c->usage[2]->replicas[i]) || memcpy(&k.replicas, e, replicas_entry_bytes(e));
percpu_u64_get(&c->usage[3]->replicas[i]))
u64 v = 0;
bch2_accounting_mem_read(c, disk_accounting_pos_to_bpos(&k), &v, 1);
if (e->data_type == BCH_DATA_journal || v)
memcpy(cpu_replicas_entry(&new, new.nr++), memcpy(cpu_replicas_entry(&new, new.nr++),
e, new.entry_size); e, new.entry_size);
} }
bch2_cpu_replicas_sort(&new); bch2_cpu_replicas_sort(&new);
ret = bch2_cpu_replicas_to_sb_replicas(c, &new) ?: ret = bch2_cpu_replicas_to_sb_replicas(c, &new);
replicas_table_update(c, &new);
if (!ret)
swap(c->replicas, new);
kfree(new.entries); kfree(new.entries);
...@@ -474,7 +479,6 @@ int bch2_replicas_gc2(struct bch_fs *c) ...@@ -474,7 +479,6 @@ int bch2_replicas_gc2(struct bch_fs *c)
mutex_unlock(&c->sb_lock); mutex_unlock(&c->sb_lock);
return ret; return ret;
#endif
} }
/* Replicas tracking - superblock: */ /* Replicas tracking - superblock: */
......
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