Commit 267039d0 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Pass device to bch2_bucket_do_index()

Eliminating bch2_dev_bkey_exists() uses and replacing them with proper
checks; this one was unnecessary since the caller already has it.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent f5faf43f
...@@ -625,12 +625,12 @@ int bch2_alloc_read(struct bch_fs *c) ...@@ -625,12 +625,12 @@ int bch2_alloc_read(struct bch_fs *c)
/* Free space/discard btree: */ /* Free space/discard btree: */
static int bch2_bucket_do_index(struct btree_trans *trans, static int bch2_bucket_do_index(struct btree_trans *trans,
struct bch_dev *ca,
struct bkey_s_c alloc_k, struct bkey_s_c alloc_k,
const struct bch_alloc_v4 *a, const struct bch_alloc_v4 *a,
bool set) bool set)
{ {
struct bch_fs *c = trans->c; struct bch_fs *c = trans->c;
struct bch_dev *ca = bch2_dev_bkey_exists(c, alloc_k.k->p.inode);
struct btree_iter iter; struct btree_iter iter;
struct bkey_s_c old; struct bkey_s_c old;
struct bkey_i *k; struct bkey_i *k;
...@@ -770,8 +770,8 @@ int bch2_trigger_alloc(struct btree_trans *trans, ...@@ -770,8 +770,8 @@ int bch2_trigger_alloc(struct btree_trans *trans,
if (old_a->data_type != new_a->data_type || if (old_a->data_type != new_a->data_type ||
(new_a->data_type == BCH_DATA_free && (new_a->data_type == BCH_DATA_free &&
alloc_freespace_genbits(*old_a) != alloc_freespace_genbits(*new_a))) { alloc_freespace_genbits(*old_a) != alloc_freespace_genbits(*new_a))) {
ret = bch2_bucket_do_index(trans, old, old_a, false) ?: ret = bch2_bucket_do_index(trans, ca, old, old_a, false) ?:
bch2_bucket_do_index(trans, new.s_c, new_a, true); bch2_bucket_do_index(trans, ca, new.s_c, new_a, true);
if (ret) if (ret)
return ret; return ret;
} }
...@@ -790,8 +790,7 @@ int bch2_trigger_alloc(struct btree_trans *trans, ...@@ -790,8 +790,7 @@ int bch2_trigger_alloc(struct btree_trans *trans,
return ret; return ret;
} }
new_a->fragmentation_lru = alloc_lru_idx_fragmentation(*new_a, new_a->fragmentation_lru = alloc_lru_idx_fragmentation(*new_a, ca);
bch2_dev_bkey_exists(c, new.k->p.inode));
if (old_a->fragmentation_lru != new_a->fragmentation_lru) { if (old_a->fragmentation_lru != new_a->fragmentation_lru) {
ret = bch2_lru_change(trans, ret = bch2_lru_change(trans,
BCH_LRU_FRAGMENTATION_START, BCH_LRU_FRAGMENTATION_START,
...@@ -2078,7 +2077,7 @@ int bch2_dev_freespace_init(struct bch_fs *c, struct bch_dev *ca, ...@@ -2078,7 +2077,7 @@ int bch2_dev_freespace_init(struct bch_fs *c, struct bch_dev *ca,
struct bch_alloc_v4 a_convert; struct bch_alloc_v4 a_convert;
const struct bch_alloc_v4 *a = bch2_alloc_to_v4(k, &a_convert); const struct bch_alloc_v4 *a = bch2_alloc_to_v4(k, &a_convert);
ret = bch2_bucket_do_index(trans, k, a, true) ?: ret = bch2_bucket_do_index(trans, ca, k, a, true) ?:
bch2_trans_commit(trans, NULL, NULL, bch2_trans_commit(trans, NULL, NULL,
BCH_TRANS_COMMIT_no_enospc); BCH_TRANS_COMMIT_no_enospc);
if (ret) if (ret)
......
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