mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
bcachefs: Fixes/improvements for journal entry reservations
This fixes some arithmetic bugs in "bcachefs: Journal updates to dev usage" - additionally, it cleans things up by switching everything that goes in every journal entry to the journal_entry_res mechanism. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
91f6ad6f94
commit
4b8f89afd4
4 changed files with 16 additions and 14 deletions
|
@ -582,8 +582,9 @@ struct bch_fs {
|
|||
struct bch_replicas_cpu replicas_gc;
|
||||
struct mutex replicas_gc_lock;
|
||||
|
||||
struct journal_entry_res btree_root_journal_res;
|
||||
struct journal_entry_res replicas_journal_res;
|
||||
|
||||
struct journal_entry_res clock_journal_res;
|
||||
struct journal_entry_res dev_usage_journal_res;
|
||||
|
||||
struct bch_disk_groups_cpu __rcu *disk_groups;
|
||||
|
|
|
@ -1119,13 +1119,6 @@ int bch2_fs_journal_init(struct journal *j)
|
|||
j->write_delay_ms = 1000;
|
||||
j->reclaim_delay_ms = 100;
|
||||
|
||||
/* Btree roots: */
|
||||
j->entry_u64s_reserved +=
|
||||
BTREE_ID_NR * (JSET_KEYS_U64s + BKEY_BTREE_PTR_U64s_MAX);
|
||||
|
||||
j->entry_u64s_reserved +=
|
||||
2 * (sizeof(struct jset_entry_clock) / sizeof(u64));
|
||||
|
||||
atomic64_set(&j->reservations.counter,
|
||||
((union journal_res_state)
|
||||
{ .cur_entry_offset = JOURNAL_ENTRY_CLOSED_VAL }).v);
|
||||
|
|
|
@ -1074,8 +1074,9 @@ unsigned bch2_dev_has_data(struct bch_fs *c, struct bch_dev *ca)
|
|||
|
||||
int bch2_fs_replicas_init(struct bch_fs *c)
|
||||
{
|
||||
c->journal.entry_u64s_reserved +=
|
||||
reserve_journal_replicas(c, &c->replicas);
|
||||
bch2_journal_entry_res_resize(&c->journal,
|
||||
&c->replicas_journal_res,
|
||||
reserve_journal_replicas(c, &c->replicas));
|
||||
|
||||
return replicas_table_update(c, &c->replicas);
|
||||
}
|
||||
|
|
|
@ -159,8 +159,9 @@ static void bch2_dev_usage_journal_reserve(struct bch_fs *c)
|
|||
{
|
||||
struct bch_dev *ca;
|
||||
unsigned i, nr = 0, u64s =
|
||||
(sizeof(struct jset_entry_dev_usage) +
|
||||
sizeof(struct jset_entry_dev_usage_type) * BCH_DATA_NR);
|
||||
((sizeof(struct jset_entry_dev_usage) +
|
||||
sizeof(struct jset_entry_dev_usage_type) * BCH_DATA_NR)) /
|
||||
sizeof(u64);
|
||||
|
||||
rcu_read_lock();
|
||||
for_each_member_device_rcu(ca, c, i, NULL)
|
||||
|
@ -796,14 +797,20 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
|
|||
bch2_fs_fsio_init(c))
|
||||
goto err;
|
||||
|
||||
bch2_dev_usage_journal_reserve(c);
|
||||
|
||||
mi = bch2_sb_get_members(c->disk_sb.sb);
|
||||
for (i = 0; i < c->sb.nr_devices; i++)
|
||||
if (bch2_dev_exists(c->disk_sb.sb, mi, i) &&
|
||||
bch2_dev_alloc(c, i))
|
||||
goto err;
|
||||
|
||||
bch2_journal_entry_res_resize(&c->journal,
|
||||
&c->btree_root_journal_res,
|
||||
BTREE_ID_NR * (JSET_KEYS_U64s + BKEY_BTREE_PTR_U64s_MAX));
|
||||
bch2_dev_usage_journal_reserve(c);
|
||||
bch2_journal_entry_res_resize(&c->journal,
|
||||
&c->clock_journal_res,
|
||||
(sizeof(struct jset_entry_clock) / sizeof(u64)) * 2);
|
||||
|
||||
mutex_lock(&bch_fs_list_lock);
|
||||
err = bch2_fs_online(c);
|
||||
mutex_unlock(&bch_fs_list_lock);
|
||||
|
|
Loading…
Add table
Reference in a new issue