mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-22 00:00:03 +03:00
Update bcachefs sources to e67d924a90 bcachefs: Introduce bch2_journal_keys_peek_(upto|slot)()
This commit is contained in:
parent
74b88aa9be
commit
7923c2ee06
@ -1 +1 @@
|
||||
2d5e6ec1447dcd1d56683914140750cef8811eb8
|
||||
e67d924a9002e05dbe593a4eee659b107b712f12
|
||||
|
@ -1081,6 +1081,7 @@ static int invalidate_one_bucket(struct btree_trans *trans, struct bch_dev *ca)
|
||||
struct bkey_s_c k;
|
||||
struct bkey_i_alloc_v4 *a;
|
||||
u64 bucket, idx;
|
||||
struct printbuf buf = PRINTBUF;
|
||||
int ret;
|
||||
|
||||
bch2_trans_iter_init(trans, &lru_iter, BTREE_ID_lru,
|
||||
@ -1106,10 +1107,16 @@ static int invalidate_one_bucket(struct btree_trans *trans, struct bch_dev *ca)
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
if (bch2_trans_inconsistent_on(idx != alloc_lru_idx(a->v), trans,
|
||||
"invalidating bucket with wrong lru idx (got %llu should be %llu",
|
||||
idx, alloc_lru_idx(a->v)))
|
||||
if (idx != alloc_lru_idx(a->v)) {
|
||||
pr_buf(&buf, "alloc key does not point back to lru entry when invalidating bucket:\n ");
|
||||
|
||||
bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(&a->k_i));
|
||||
pr_buf(&buf, "\n ");
|
||||
bch2_bkey_val_to_text(&buf, c, k);
|
||||
bch2_trans_inconsistent(trans, "%s", buf.buf);
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
SET_BCH_ALLOC_V4_NEED_INC_GEN(&a->v, false);
|
||||
a->v.gen++;
|
||||
@ -1124,6 +1131,7 @@ static int invalidate_one_bucket(struct btree_trans *trans, struct bch_dev *ca)
|
||||
out:
|
||||
bch2_trans_iter_exit(trans, &alloc_iter);
|
||||
bch2_trans_iter_exit(trans, &lru_iter);
|
||||
printbuf_exit(&buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -2233,12 +2233,11 @@ struct bkey_s_c btree_trans_peek_journal(struct btree_trans *trans,
|
||||
struct bkey_s_c k)
|
||||
{
|
||||
struct bkey_i *next_journal =
|
||||
bch2_journal_keys_peek(trans->c, iter->btree_id, 0,
|
||||
iter->path->pos);
|
||||
bch2_journal_keys_peek_upto(trans->c, iter->btree_id, 0,
|
||||
iter->path->pos,
|
||||
k.k ? k.k->p : iter->path->l[0].b->key.k.p);
|
||||
|
||||
if (next_journal &&
|
||||
bpos_cmp(next_journal->k.p,
|
||||
k.k ? k.k->p : iter->path->l[0].b->key.k.p) <= 0) {
|
||||
if (next_journal) {
|
||||
iter->k = next_journal->k;
|
||||
k = bkey_i_to_s_c(next_journal);
|
||||
}
|
||||
@ -2687,9 +2686,8 @@ struct bkey_s_c bch2_btree_iter_peek_slot(struct btree_iter *iter)
|
||||
}
|
||||
|
||||
if (unlikely(iter->flags & BTREE_ITER_WITH_JOURNAL) &&
|
||||
(next_update = bch2_journal_keys_peek(trans->c, iter->btree_id,
|
||||
0, iter->pos)) &&
|
||||
!bpos_cmp(next_update->k.p, iter->pos)) {
|
||||
(next_update = bch2_journal_keys_peek_slot(trans->c,
|
||||
iter->btree_id, 0, iter->pos))) {
|
||||
iter->k = next_update->k;
|
||||
k = bkey_i_to_s_c(next_update);
|
||||
goto out;
|
||||
|
@ -664,9 +664,10 @@ bch2_trans_commit_write_locked(struct btree_trans *trans,
|
||||
|
||||
if (unlikely(!test_bit(JOURNAL_REPLAY_DONE, &c->journal.flags))) {
|
||||
struct bkey_i *j_k =
|
||||
bch2_journal_keys_peek(c, i->btree_id, i->level, i->k->k.p);
|
||||
bch2_journal_keys_peek_slot(c, i->btree_id, i->level,
|
||||
i->k->k.p);
|
||||
|
||||
if (j_k && !bpos_cmp(j_k->k.p, i->k->k.p)) {
|
||||
if (j_k) {
|
||||
i->old_k = j_k->k;
|
||||
i->old_v = &j_k->v;
|
||||
}
|
||||
@ -1531,9 +1532,9 @@ bch2_trans_update_by_path(struct btree_trans *trans, struct btree_path *path,
|
||||
|
||||
if (unlikely(!test_bit(JOURNAL_REPLAY_DONE, &c->journal.flags))) {
|
||||
struct bkey_i *j_k =
|
||||
bch2_journal_keys_peek(c, n.btree_id, n.level, k->k.p);
|
||||
bch2_journal_keys_peek_slot(c, n.btree_id, n.level, k->k.p);
|
||||
|
||||
if (j_k && !bpos_cmp(j_k->k.p, i->k->k.p)) {
|
||||
if (j_k) {
|
||||
i->old_k = j_k->k;
|
||||
i->old_v = &j_k->v;
|
||||
}
|
||||
|
@ -109,26 +109,34 @@ size_t bch2_journal_key_search(struct journal_keys *keys,
|
||||
return idx_to_pos(keys, l);
|
||||
}
|
||||
|
||||
struct bkey_i *bch2_journal_keys_peek(struct bch_fs *c, enum btree_id btree_id,
|
||||
unsigned level, struct bpos pos)
|
||||
struct bkey_i *bch2_journal_keys_peek_upto(struct bch_fs *c, enum btree_id btree_id,
|
||||
unsigned level, struct bpos pos,
|
||||
struct bpos end_pos)
|
||||
{
|
||||
struct journal_keys *keys = &c->journal_keys;
|
||||
size_t idx = bch2_journal_key_search(keys, btree_id, level, pos);
|
||||
|
||||
while (idx < keys->size &&
|
||||
keys->d[idx].overwritten) {
|
||||
keys->d[idx].btree_id == btree_id &&
|
||||
keys->d[idx].level == level &&
|
||||
bpos_cmp(keys->d[idx].k->k.p, end_pos) <= 0) {
|
||||
if (!keys->d[idx].overwritten)
|
||||
return keys->d[idx].k;
|
||||
|
||||
idx++;
|
||||
if (idx == keys->gap)
|
||||
idx += keys->size - keys->nr;
|
||||
}
|
||||
|
||||
if (idx < keys->size &&
|
||||
keys->d[idx].btree_id == btree_id &&
|
||||
keys->d[idx].level == level)
|
||||
return keys->d[idx].k;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct bkey_i *bch2_journal_keys_peek_slot(struct bch_fs *c, enum btree_id btree_id,
|
||||
unsigned level, struct bpos pos)
|
||||
{
|
||||
return bch2_journal_keys_peek_upto(c, btree_id, level, pos, pos);
|
||||
}
|
||||
|
||||
static void journal_iters_fix(struct bch_fs *c)
|
||||
{
|
||||
struct journal_keys *keys = &c->journal_keys;
|
||||
|
@ -30,8 +30,10 @@ struct btree_and_journal_iter {
|
||||
|
||||
size_t bch2_journal_key_search(struct journal_keys *, enum btree_id,
|
||||
unsigned, struct bpos);
|
||||
struct bkey_i *bch2_journal_keys_peek(struct bch_fs *, enum btree_id,
|
||||
unsigned, struct bpos pos);
|
||||
struct bkey_i *bch2_journal_keys_peek_upto(struct bch_fs *, enum btree_id,
|
||||
unsigned, struct bpos, struct bpos);
|
||||
struct bkey_i *bch2_journal_keys_peek_slot(struct bch_fs *, enum btree_id,
|
||||
unsigned, struct bpos);
|
||||
|
||||
int bch2_journal_key_insert_take(struct bch_fs *, enum btree_id,
|
||||
unsigned, struct bkey_i *);
|
||||
|
Loading…
Reference in New Issue
Block a user