Skip to content

Commit 8f3aaa5

Browse files
author
Kent Overstreet
committed
bcachefs: bch2_fs_btree_gc_init()
Now returns errors, prep work for check_allocations_done_lock Signed-off-by: Kent Overstreet <[email protected]>
1 parent cb3f349 commit 8f3aaa5

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

fs/bcachefs/btree_gc.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,9 +1238,16 @@ void bch2_gc_gens_async(struct bch_fs *c)
12381238
bch2_write_ref_put(c, BCH_WRITE_REF_gc_gens);
12391239
}
12401240

1241-
void bch2_fs_gc_init(struct bch_fs *c)
1241+
void bch2_fs_btree_gc_exit(struct bch_fs *c)
12421242
{
1243-
seqcount_init(&c->gc_pos_lock);
1243+
}
12441244

1245+
int bch2_fs_btree_gc_init(struct bch_fs *c)
1246+
{
1247+
seqcount_init(&c->gc_pos_lock);
12451248
INIT_WORK(&c->gc_gens_work, bch2_gc_gens_work);
1249+
1250+
init_rwsem(&c->gc_lock);
1251+
mutex_init(&c->gc_gens_lock);
1252+
return 0;
12461253
}

fs/bcachefs/btree_gc.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ void bch2_gc_pos_to_text(struct printbuf *, struct gc_pos *);
8282

8383
int bch2_gc_gens(struct bch_fs *);
8484
void bch2_gc_gens_async(struct bch_fs *);
85-
void bch2_fs_gc_init(struct bch_fs *);
85+
86+
void bch2_fs_btree_gc_exit(struct bch_fs *);
87+
int bch2_fs_btree_gc_init(struct bch_fs *);
8688

8789
#endif /* _BCACHEFS_BTREE_GC_H */

fs/bcachefs/super.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ static void __bch2_fs_free(struct bch_fs *c)
563563
bch2_io_clock_exit(&c->io_clock[WRITE]);
564564
bch2_io_clock_exit(&c->io_clock[READ]);
565565
bch2_fs_compress_exit(c);
566+
bch2_fs_btree_gc_exit(c);
566567
bch2_journal_keys_put_initial(c);
567568
bch2_find_btree_nodes_exit(&c->found_btree_nodes);
568569
BUG_ON(atomic_read(&c->journal_keys.ref));
@@ -770,13 +771,9 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
770771
spin_lock_init(&c->recovery_pass_lock);
771772
sema_init(&c->online_fsck_mutex, 1);
772773

773-
init_rwsem(&c->gc_lock);
774-
mutex_init(&c->gc_gens_lock);
775-
776774
for (i = 0; i < BCH_TIME_STAT_NR; i++)
777775
bch2_time_stats_init(&c->times[i]);
778776

779-
bch2_fs_gc_init(c);
780777
bch2_fs_copygc_init(c);
781778
bch2_fs_btree_key_cache_init_early(&c->btree_key_cache);
782779
bch2_fs_btree_iter_init_early(c);
@@ -911,6 +908,7 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
911908
bch2_fs_btree_cache_init(c) ?:
912909
bch2_fs_btree_key_cache_init(&c->btree_key_cache) ?:
913910
bch2_fs_btree_interior_update_init(c) ?:
911+
bch2_fs_btree_gc_init(c) ?:
914912
bch2_fs_buckets_waiting_for_journal_init(c) ?:
915913
bch2_fs_btree_write_buffer_init(c) ?:
916914
bch2_fs_subvolumes_init(c) ?:

0 commit comments

Comments
 (0)