bcachefs: improve behaviour of btree_cache_scan()
authorDaniel Hill <daniel@gluo.nz>
Thu, 6 Oct 2022 02:53:36 +0000 (15:53 +1300)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:44 +0000 (17:09 -0400)
Appending new nodes to the end of the list means we're more likely to
evict old entries when btree_cache_scan() is started.

Signed-off-by: Daniel Hill <daniel@gluo.nz>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_cache.c

index db786df193180f360d28c3ff848bcb9b2db9de4b..75bc18466e756787859ab816bf541031016b83da 100644 (file)
@@ -173,7 +173,7 @@ int bch2_btree_node_hash_insert(struct btree_cache *bc, struct btree *b,
        mutex_lock(&bc->lock);
        ret = __bch2_btree_node_hash_insert(bc, b);
        if (!ret)
-               list_add(&b->list, &bc->live);
+               list_add_tail(&b->list, &bc->live);
        mutex_unlock(&bc->lock);
 
        return ret;