mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-10-23 07:23:12 +02:00
bcachefs: Move various init code to _init_early()
_init_early() is for initialization that cannot fail, and often must happen for teardown partway through initialization to work. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
31813dcf37
commit
a17e985be9
|
@ -1266,16 +1266,11 @@ void bch2_gc_gens_async(struct bch_fs *c)
|
||||||
bch2_write_ref_put(c, BCH_WRITE_REF_gc_gens);
|
bch2_write_ref_put(c, BCH_WRITE_REF_gc_gens);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bch2_fs_btree_gc_exit(struct bch_fs *c)
|
void bch2_fs_btree_gc_init_early(struct bch_fs *c)
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int bch2_fs_btree_gc_init(struct bch_fs *c)
|
|
||||||
{
|
{
|
||||||
seqcount_init(&c->gc_pos_lock);
|
seqcount_init(&c->gc_pos_lock);
|
||||||
INIT_WORK(&c->gc_gens_work, bch2_gc_gens_work);
|
INIT_WORK(&c->gc_gens_work, bch2_gc_gens_work);
|
||||||
|
|
||||||
init_rwsem(&c->gc_lock);
|
init_rwsem(&c->gc_lock);
|
||||||
mutex_init(&c->gc_gens_lock);
|
mutex_init(&c->gc_gens_lock);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,6 @@ void bch2_gc_pos_to_text(struct printbuf *, struct gc_pos *);
|
||||||
int bch2_gc_gens(struct bch_fs *);
|
int bch2_gc_gens(struct bch_fs *);
|
||||||
void bch2_gc_gens_async(struct bch_fs *);
|
void bch2_gc_gens_async(struct bch_fs *);
|
||||||
|
|
||||||
void bch2_fs_btree_gc_exit(struct bch_fs *);
|
void bch2_fs_btree_gc_init_early(struct bch_fs *);
|
||||||
int bch2_fs_btree_gc_init(struct bch_fs *);
|
|
||||||
|
|
||||||
#endif /* _BCACHEFS_BTREE_GC_H */
|
#endif /* _BCACHEFS_BTREE_GC_H */
|
||||||
|
|
|
@ -866,13 +866,18 @@ void bch2_fs_btree_write_buffer_exit(struct bch_fs *c)
|
||||||
darray_exit(&wb->inc.keys);
|
darray_exit(&wb->inc.keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
int bch2_fs_btree_write_buffer_init(struct bch_fs *c)
|
void bch2_fs_btree_write_buffer_init_early(struct bch_fs *c)
|
||||||
{
|
{
|
||||||
struct btree_write_buffer *wb = &c->btree_write_buffer;
|
struct btree_write_buffer *wb = &c->btree_write_buffer;
|
||||||
|
|
||||||
mutex_init(&wb->inc.lock);
|
mutex_init(&wb->inc.lock);
|
||||||
mutex_init(&wb->flushing.lock);
|
mutex_init(&wb->flushing.lock);
|
||||||
INIT_WORK(&wb->flush_work, bch2_btree_write_buffer_flush_work);
|
INIT_WORK(&wb->flush_work, bch2_btree_write_buffer_flush_work);
|
||||||
|
}
|
||||||
|
|
||||||
|
int bch2_fs_btree_write_buffer_init(struct bch_fs *c)
|
||||||
|
{
|
||||||
|
struct btree_write_buffer *wb = &c->btree_write_buffer;
|
||||||
|
|
||||||
/* Will be resized by journal as needed: */
|
/* Will be resized by journal as needed: */
|
||||||
unsigned initial_size = 1 << 16;
|
unsigned initial_size = 1 << 16;
|
||||||
|
|
|
@ -101,6 +101,7 @@ int bch2_journal_keys_to_write_buffer_end(struct bch_fs *, struct journal_keys_t
|
||||||
|
|
||||||
int bch2_btree_write_buffer_resize(struct bch_fs *, size_t);
|
int bch2_btree_write_buffer_resize(struct bch_fs *, size_t);
|
||||||
void bch2_fs_btree_write_buffer_exit(struct bch_fs *);
|
void bch2_fs_btree_write_buffer_exit(struct bch_fs *);
|
||||||
|
void bch2_fs_btree_write_buffer_init_early(struct bch_fs *);
|
||||||
int bch2_fs_btree_write_buffer_init(struct bch_fs *);
|
int bch2_fs_btree_write_buffer_init(struct bch_fs *);
|
||||||
|
|
||||||
#endif /* _BCACHEFS_BTREE_WRITE_BUFFER_H */
|
#endif /* _BCACHEFS_BTREE_WRITE_BUFFER_H */
|
||||||
|
|
|
@ -1588,7 +1588,7 @@ void bch2_fs_journal_exit(struct journal *j)
|
||||||
free_fifo(&j->pin);
|
free_fifo(&j->pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
int bch2_fs_journal_init(struct journal *j)
|
void bch2_fs_journal_init_early(struct journal *j)
|
||||||
{
|
{
|
||||||
static struct lock_class_key res_key;
|
static struct lock_class_key res_key;
|
||||||
|
|
||||||
|
@ -1607,7 +1607,10 @@ int bch2_fs_journal_init(struct journal *j)
|
||||||
atomic64_set(&j->reservations.counter,
|
atomic64_set(&j->reservations.counter,
|
||||||
((union journal_res_state)
|
((union journal_res_state)
|
||||||
{ .cur_entry_offset = JOURNAL_ENTRY_CLOSED_VAL }).v);
|
{ .cur_entry_offset = JOURNAL_ENTRY_CLOSED_VAL }).v);
|
||||||
|
}
|
||||||
|
|
||||||
|
int bch2_fs_journal_init(struct journal *j)
|
||||||
|
{
|
||||||
j->free_buf_size = j->buf_size_want = JOURNAL_ENTRY_SIZE_MIN;
|
j->free_buf_size = j->buf_size_want = JOURNAL_ENTRY_SIZE_MIN;
|
||||||
j->free_buf = kvmalloc(j->free_buf_size, GFP_KERNEL);
|
j->free_buf = kvmalloc(j->free_buf_size, GFP_KERNEL);
|
||||||
if (!j->free_buf)
|
if (!j->free_buf)
|
||||||
|
|
|
@ -458,6 +458,7 @@ void bch2_journal_set_replay_done(struct journal *);
|
||||||
void bch2_dev_journal_exit(struct bch_dev *);
|
void bch2_dev_journal_exit(struct bch_dev *);
|
||||||
int bch2_dev_journal_init(struct bch_dev *, struct bch_sb *);
|
int bch2_dev_journal_init(struct bch_dev *, struct bch_sb *);
|
||||||
void bch2_fs_journal_exit(struct journal *);
|
void bch2_fs_journal_exit(struct journal *);
|
||||||
|
void bch2_fs_journal_init_early(struct journal *);
|
||||||
int bch2_fs_journal_init(struct journal *);
|
int bch2_fs_journal_init(struct journal *);
|
||||||
|
|
||||||
#endif /* _BCACHEFS_JOURNAL_H */
|
#endif /* _BCACHEFS_JOURNAL_H */
|
||||||
|
|
|
@ -133,12 +133,10 @@ void bch2_fs_nocow_locking_exit(struct bch_fs *c)
|
||||||
BUG_ON(atomic_read(&l->l[j]));
|
BUG_ON(atomic_read(&l->l[j]));
|
||||||
}
|
}
|
||||||
|
|
||||||
int bch2_fs_nocow_locking_init(struct bch_fs *c)
|
void bch2_fs_nocow_locking_init_early(struct bch_fs *c)
|
||||||
{
|
{
|
||||||
struct bucket_nocow_lock_table *t = &c->nocow_locks;
|
struct bucket_nocow_lock_table *t = &c->nocow_locks;
|
||||||
|
|
||||||
for (struct nocow_lock_bucket *l = t->l; l < t->l + ARRAY_SIZE(t->l); l++)
|
for (struct nocow_lock_bucket *l = t->l; l < t->l + ARRAY_SIZE(t->l); l++)
|
||||||
spin_lock_init(&l->lock);
|
spin_lock_init(&l->lock);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,6 @@ static inline bool bch2_bucket_nocow_trylock(struct bucket_nocow_lock_table *t,
|
||||||
void bch2_nocow_locks_to_text(struct printbuf *, struct bucket_nocow_lock_table *);
|
void bch2_nocow_locks_to_text(struct printbuf *, struct bucket_nocow_lock_table *);
|
||||||
|
|
||||||
void bch2_fs_nocow_locking_exit(struct bch_fs *);
|
void bch2_fs_nocow_locking_exit(struct bch_fs *);
|
||||||
int bch2_fs_nocow_locking_init(struct bch_fs *);
|
void bch2_fs_nocow_locking_init_early(struct bch_fs *);
|
||||||
|
|
||||||
#endif /* _BCACHEFS_NOCOW_LOCKING_H */
|
#endif /* _BCACHEFS_NOCOW_LOCKING_H */
|
||||||
|
|
|
@ -714,11 +714,10 @@ int bch2_fs_upgrade_for_subvolumes(struct bch_fs *c)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bch2_fs_subvolumes_init(struct bch_fs *c)
|
void bch2_fs_subvolumes_init_early(struct bch_fs *c)
|
||||||
{
|
{
|
||||||
INIT_WORK(&c->snapshot_delete_work, bch2_delete_dead_snapshots_work);
|
INIT_WORK(&c->snapshot_delete_work, bch2_delete_dead_snapshots_work);
|
||||||
INIT_WORK(&c->snapshot_wait_for_pagecache_and_delete_work,
|
INIT_WORK(&c->snapshot_wait_for_pagecache_and_delete_work,
|
||||||
bch2_subvolume_wait_for_pagecache_and_delete);
|
bch2_subvolume_wait_for_pagecache_and_delete);
|
||||||
mutex_init(&c->snapshots_unlinked_lock);
|
mutex_init(&c->snapshots_unlinked_lock);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,6 @@ int bch2_subvolume_create(struct btree_trans *, u64, u32, u32, u32 *, u32 *, boo
|
||||||
int bch2_initialize_subvolumes(struct bch_fs *);
|
int bch2_initialize_subvolumes(struct bch_fs *);
|
||||||
int bch2_fs_upgrade_for_subvolumes(struct bch_fs *);
|
int bch2_fs_upgrade_for_subvolumes(struct bch_fs *);
|
||||||
|
|
||||||
int bch2_fs_subvolumes_init(struct bch_fs *);
|
void bch2_fs_subvolumes_init_early(struct bch_fs *);
|
||||||
|
|
||||||
#endif /* _BCACHEFS_SUBVOLUME_H */
|
#endif /* _BCACHEFS_SUBVOLUME_H */
|
||||||
|
|
|
@ -567,7 +567,6 @@ static void __bch2_fs_free(struct bch_fs *c)
|
||||||
bch2_io_clock_exit(&c->io_clock[WRITE]);
|
bch2_io_clock_exit(&c->io_clock[WRITE]);
|
||||||
bch2_io_clock_exit(&c->io_clock[READ]);
|
bch2_io_clock_exit(&c->io_clock[READ]);
|
||||||
bch2_fs_compress_exit(c);
|
bch2_fs_compress_exit(c);
|
||||||
bch2_fs_btree_gc_exit(c);
|
|
||||||
bch2_journal_keys_put_initial(c);
|
bch2_journal_keys_put_initial(c);
|
||||||
bch2_find_btree_nodes_exit(&c->found_btree_nodes);
|
bch2_find_btree_nodes_exit(&c->found_btree_nodes);
|
||||||
BUG_ON(atomic_read(&c->journal_keys.ref));
|
BUG_ON(atomic_read(&c->journal_keys.ref));
|
||||||
|
@ -783,16 +782,21 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
|
||||||
bch2_fs_allocator_background_init(c);
|
bch2_fs_allocator_background_init(c);
|
||||||
bch2_fs_allocator_foreground_init(c);
|
bch2_fs_allocator_foreground_init(c);
|
||||||
bch2_fs_btree_cache_init_early(&c->btree_cache);
|
bch2_fs_btree_cache_init_early(&c->btree_cache);
|
||||||
|
bch2_fs_btree_gc_init_early(c);
|
||||||
bch2_fs_btree_interior_update_init_early(c);
|
bch2_fs_btree_interior_update_init_early(c);
|
||||||
bch2_fs_btree_iter_init_early(c);
|
bch2_fs_btree_iter_init_early(c);
|
||||||
bch2_fs_btree_key_cache_init_early(&c->btree_key_cache);
|
bch2_fs_btree_key_cache_init_early(&c->btree_key_cache);
|
||||||
|
bch2_fs_btree_write_buffer_init_early(c);
|
||||||
bch2_fs_copygc_init(c);
|
bch2_fs_copygc_init(c);
|
||||||
bch2_fs_ec_init_early(c);
|
bch2_fs_ec_init_early(c);
|
||||||
|
bch2_fs_journal_init_early(&c->journal);
|
||||||
bch2_fs_journal_keys_init(c);
|
bch2_fs_journal_keys_init(c);
|
||||||
bch2_fs_move_init(c);
|
bch2_fs_move_init(c);
|
||||||
|
bch2_fs_nocow_locking_init_early(c);
|
||||||
bch2_fs_quota_init(c);
|
bch2_fs_quota_init(c);
|
||||||
bch2_fs_rebalance_init(c);
|
bch2_fs_rebalance_init(c);
|
||||||
bch2_fs_sb_errors_init_early(c);
|
bch2_fs_sb_errors_init_early(c);
|
||||||
|
bch2_fs_subvolumes_init_early(c);
|
||||||
|
|
||||||
INIT_LIST_HEAD(&c->list);
|
INIT_LIST_HEAD(&c->list);
|
||||||
|
|
||||||
|
@ -906,7 +910,6 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
|
||||||
|
|
||||||
ret =
|
ret =
|
||||||
bch2_fs_btree_cache_init(c) ?:
|
bch2_fs_btree_cache_init(c) ?:
|
||||||
bch2_fs_btree_gc_init(c) ?:
|
|
||||||
bch2_fs_btree_iter_init(c) ?:
|
bch2_fs_btree_iter_init(c) ?:
|
||||||
bch2_fs_btree_interior_update_init(c) ?:
|
bch2_fs_btree_interior_update_init(c) ?:
|
||||||
bch2_fs_btree_key_cache_init(&c->btree_key_cache) ?:
|
bch2_fs_btree_key_cache_init(&c->btree_key_cache) ?:
|
||||||
|
@ -924,9 +927,7 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
|
||||||
bch2_fs_io_read_init(c) ?:
|
bch2_fs_io_read_init(c) ?:
|
||||||
bch2_fs_io_write_init(c) ?:
|
bch2_fs_io_write_init(c) ?:
|
||||||
bch2_fs_journal_init(&c->journal) ?:
|
bch2_fs_journal_init(&c->journal) ?:
|
||||||
bch2_fs_nocow_locking_init(c) ?:
|
|
||||||
bch2_fs_sb_errors_init(c) ?:
|
bch2_fs_sb_errors_init(c) ?:
|
||||||
bch2_fs_subvolumes_init(c) ?:
|
|
||||||
bch2_fs_vfs_init(c);
|
bch2_fs_vfs_init(c);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user