Skip to content

Commit 19b22d0

Browse files
author
Kent Overstreet
committed
bcachefs: Don't set btree nodes as accessed on fill
Prevent jobs that do lots of scanning (i.e. evacuatee, scrub) from causing OOMs. The shrinker code seems to be having issues when it doesn't do any freeing because it's just flipping off the acccessed bit - and the accessed bit shouldn't be set on first use anyways. Signed-off-by: Kent Overstreet <[email protected]>
1 parent 7b6759b commit 19b22d0

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

fs/bcachefs/btree_cache.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,6 @@ struct btree *bch2_btree_node_mem_alloc(struct btree_trans *trans, bool pcpu_rea
852852
b->sib_u64s[1] = 0;
853853
b->whiteout_u64s = 0;
854854
bch2_btree_keys_init(b);
855-
set_btree_node_accessed(b);
856855

857856
bch2_time_stats_update(&c->times[BCH_TIME_btree_node_mem_alloc],
858857
start_time);
@@ -1286,6 +1285,10 @@ struct btree *bch2_btree_node_get_noiter(struct btree_trans *trans,
12861285
six_unlock_read(&b->c.lock);
12871286
goto retry;
12881287
}
1288+
1289+
/* avoid atomic set bit if it's not needed: */
1290+
if (!btree_node_accessed(b))
1291+
set_btree_node_accessed(b);
12891292
}
12901293

12911294
/* XXX: waiting on IO with btree locks held: */
@@ -1301,10 +1304,6 @@ struct btree *bch2_btree_node_get_noiter(struct btree_trans *trans,
13011304
prefetch(p + L1_CACHE_BYTES * 2);
13021305
}
13031306

1304-
/* avoid atomic set bit if it's not needed: */
1305-
if (!btree_node_accessed(b))
1306-
set_btree_node_accessed(b);
1307-
13081307
if (unlikely(btree_node_read_error(b))) {
13091308
six_unlock_read(&b->c.lock);
13101309
b = ERR_PTR(-BCH_ERR_btree_node_read_err_cached);

0 commit comments

Comments
 (0)