Commit 1df42b57 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: don't do initial gc if have alloc info feature

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 3577df5f
...@@ -568,6 +568,7 @@ struct bch_fs { ...@@ -568,6 +568,7 @@ struct bch_fs {
u32 time_base_hi; u32 time_base_hi;
u32 time_precision; u32 time_precision;
u64 features; u64 features;
u64 compat;
} sb; } sb;
struct bch_sb_handle disk_sb; struct bch_sb_handle disk_sb;
......
...@@ -1279,6 +1279,10 @@ enum bch_sb_features { ...@@ -1279,6 +1279,10 @@ enum bch_sb_features {
BCH_FEATURE_NR, BCH_FEATURE_NR,
}; };
enum bch_sb_compat {
BCH_COMPAT_FEAT_ALLOC_INFO = 0,
};
/* options: */ /* options: */
#define BCH_REPLICAS_MAX 4U #define BCH_REPLICAS_MAX 4U
......
...@@ -577,7 +577,8 @@ static void bch2_gc_done(struct bch_fs *c, bool initial) ...@@ -577,7 +577,8 @@ static void bch2_gc_done(struct bch_fs *c, bool initial)
percpu_down_write(&c->mark_lock); percpu_down_write(&c->mark_lock);
if (initial) { if (initial &&
!(c->sb.compat & (1ULL << BCH_COMPAT_FEAT_ALLOC_INFO))) {
bch2_gc_done_nocheck(c); bch2_gc_done_nocheck(c);
goto out; goto out;
} }
...@@ -819,9 +820,6 @@ int bch2_gc(struct bch_fs *c, struct list_head *journal, bool initial) ...@@ -819,9 +820,6 @@ int bch2_gc(struct bch_fs *c, struct list_head *journal, bool initial)
bch2_gc_free(c); bch2_gc_free(c);
up_write(&c->gc_lock); up_write(&c->gc_lock);
if (!ret && initial)
set_bit(BCH_FS_INITIAL_GC_DONE, &c->flags);
trace_gc_end(c); trace_gc_end(c);
bch2_time_stats_update(&c->times[BCH_TIME_btree_gc], start_time); bch2_time_stats_update(&c->times[BCH_TIME_btree_gc], start_time);
......
...@@ -300,14 +300,18 @@ int bch2_fs_recovery(struct bch_fs *c) ...@@ -300,14 +300,18 @@ int bch2_fs_recovery(struct bch_fs *c)
set_bit(BCH_FS_ALLOC_READ_DONE, &c->flags); set_bit(BCH_FS_ALLOC_READ_DONE, &c->flags);
bch_verbose(c, "starting mark and sweep:"); if (!(c->sb.compat & (1ULL << BCH_COMPAT_FEAT_ALLOC_INFO)) ||
err = "error in recovery"; c->opts.fsck) {
ret = bch2_gc(c, &journal, true); bch_verbose(c, "starting mark and sweep:");
if (ret) err = "error in recovery";
goto err; ret = bch2_gc(c, &journal, true);
bch_verbose(c, "mark and sweep done"); if (ret)
goto err;
bch_verbose(c, "mark and sweep done");
}
clear_bit(BCH_FS_REBUILD_REPLICAS, &c->flags); clear_bit(BCH_FS_REBUILD_REPLICAS, &c->flags);
set_bit(BCH_FS_INITIAL_GC_DONE, &c->flags);
/* /*
* Skip past versions that might have possibly been used (as nonces), * Skip past versions that might have possibly been used (as nonces),
...@@ -411,6 +415,8 @@ int bch2_fs_initialize(struct bch_fs *c) ...@@ -411,6 +415,8 @@ int bch2_fs_initialize(struct bch_fs *c)
if (ret) if (ret)
goto err; goto err;
set_bit(BCH_FS_INITIAL_GC_DONE, &c->flags);
err = "unable to allocate journal buckets"; err = "unable to allocate journal buckets";
for_each_online_member(ca, c, i) for_each_online_member(ca, c, i)
if (bch2_dev_journal_alloc(ca)) { if (bch2_dev_journal_alloc(ca)) {
......
...@@ -371,6 +371,7 @@ static void bch2_sb_update(struct bch_fs *c) ...@@ -371,6 +371,7 @@ static void bch2_sb_update(struct bch_fs *c)
c->sb.time_base_hi = le32_to_cpu(src->time_base_hi); c->sb.time_base_hi = le32_to_cpu(src->time_base_hi);
c->sb.time_precision = le32_to_cpu(src->time_precision); c->sb.time_precision = le32_to_cpu(src->time_precision);
c->sb.features = le64_to_cpu(src->features[0]); c->sb.features = le64_to_cpu(src->features[0]);
c->sb.compat = le64_to_cpu(src->compat[0]);
for_each_member_device(ca, c, i) for_each_member_device(ca, c, i)
ca->mi = bch2_mi_to_cpu(mi->members + i); ca->mi = bch2_mi_to_cpu(mi->members + i);
...@@ -888,8 +889,10 @@ void bch2_sb_clean_renumber(struct bch_sb_field_clean *clean, int write) ...@@ -888,8 +889,10 @@ void bch2_sb_clean_renumber(struct bch_sb_field_clean *clean, int write)
static void bch2_fs_mark_dirty(struct bch_fs *c) static void bch2_fs_mark_dirty(struct bch_fs *c)
{ {
mutex_lock(&c->sb_lock); mutex_lock(&c->sb_lock);
if (BCH_SB_CLEAN(c->disk_sb.sb)) { if (BCH_SB_CLEAN(c->disk_sb.sb) ||
(c->disk_sb.sb->compat[0] & (1ULL << BCH_COMPAT_FEAT_ALLOC_INFO))) {
SET_BCH_SB_CLEAN(c->disk_sb.sb, false); SET_BCH_SB_CLEAN(c->disk_sb.sb, false);
c->disk_sb.sb->compat[0] &= ~(1ULL << BCH_COMPAT_FEAT_ALLOC_INFO);
bch2_write_super(c); bch2_write_super(c);
} }
mutex_unlock(&c->sb_lock); mutex_unlock(&c->sb_lock);
...@@ -1011,6 +1014,8 @@ void bch2_fs_mark_clean(struct bch_fs *c, bool clean) ...@@ -1011,6 +1014,8 @@ void bch2_fs_mark_clean(struct bch_fs *c, bool clean)
SET_BCH_SB_CLEAN(c->disk_sb.sb, true); SET_BCH_SB_CLEAN(c->disk_sb.sb, true);
c->disk_sb.sb->compat[0] |= 1ULL << BCH_COMPAT_FEAT_ALLOC_INFO;
u64s = sizeof(*sb_clean) / sizeof(u64) + c->journal.entry_u64s_reserved; u64s = sizeof(*sb_clean) / sizeof(u64) + c->journal.entry_u64s_reserved;
sb_clean = bch2_sb_resize_clean(&c->disk_sb, u64s); sb_clean = bch2_sb_resize_clean(&c->disk_sb, u64s);
......
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