]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/btree_key_cache.c
Update bcachefs sources to 841a95c29f4c bcachefs: fix userspace build errors
[bcachefs-tools-debian] / libbcachefs / btree_key_cache.c
index b39b28b4ae73772a72778069d9c572b69375d129..39fd4d8a8e903e4c642af5cff394529fe2a01872 100644 (file)
@@ -630,7 +630,7 @@ static int btree_key_cache_flush_pos(struct btree_trans *trans,
        if (ret)
                goto out;
 
-       ck = (void *) c_iter.path->l[0].b;
+       ck = (void *) btree_iter_path(trans, &c_iter)->l[0].b;
        if (!ck)
                goto out;
 
@@ -678,7 +678,8 @@ static int btree_key_cache_flush_pos(struct btree_trans *trans,
 
        bch2_journal_pin_drop(j, &ck->journal);
 
-       BUG_ON(!btree_node_locked(c_iter.path, 0));
+       struct btree_path *path = btree_iter_path(trans, &c_iter);
+       BUG_ON(!btree_node_locked(path, 0));
 
        if (!evict) {
                if (test_bit(BKEY_CACHED_DIRTY, &ck->flags)) {
@@ -687,19 +688,20 @@ static int btree_key_cache_flush_pos(struct btree_trans *trans,
                }
        } else {
                struct btree_path *path2;
+               unsigned i;
 evict:
-               trans_for_each_path(trans, path2)
-                       if (path2 != c_iter.path)
+               trans_for_each_path(trans, path2, i)
+                       if (path2 != path)
                                __bch2_btree_path_unlock(trans, path2);
 
-               bch2_btree_node_lock_write_nofail(trans, c_iter.path, &ck->c);
+               bch2_btree_node_lock_write_nofail(trans, path, &ck->c);
 
                if (test_bit(BKEY_CACHED_DIRTY, &ck->flags)) {
                        clear_bit(BKEY_CACHED_DIRTY, &ck->flags);
                        atomic_long_dec(&c->btree_key_cache.nr_dirty);
                }
 
-               mark_btree_node_locked_noreset(c_iter.path, 0, BTREE_NODE_UNLOCKED);
+               mark_btree_node_locked_noreset(path, 0, BTREE_NODE_UNLOCKED);
                bkey_cached_evict(&c->btree_key_cache, ck);
                bkey_cached_free_fast(&c->btree_key_cache, ck);
        }
@@ -747,28 +749,12 @@ unlock:
        return ret;
 }
 
-/*
- * Flush and evict a key from the key cache:
- */
-int bch2_btree_key_cache_flush(struct btree_trans *trans,
-                              enum btree_id id, struct bpos pos)
-{
-       struct bch_fs *c = trans->c;
-       struct bkey_cached_key key = { id, pos };
-
-       /* Fastpath - assume it won't be found: */
-       if (!bch2_btree_key_cache_find(c, id, pos))
-               return 0;
-
-       return btree_key_cache_flush_pos(trans, key, 0, 0, true);
-}
-
 bool bch2_btree_insert_key_cached(struct btree_trans *trans,
                                  unsigned flags,
                                  struct btree_insert_entry *insert_entry)
 {
        struct bch_fs *c = trans->c;
-       struct bkey_cached *ck = (void *) insert_entry->path->l[0].b;
+       struct bkey_cached *ck = (void *) (trans->paths + insert_entry->path)->l[0].b;
        struct bkey_i *insert = insert_entry->k;
        bool kick_reclaim = false;