bcachefs: Fix for long running btree transactions & key cache
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 16 Dec 2022 02:44:32 +0000 (21:44 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:48 +0000 (17:09 -0400)
commite242b92af5ef74cdf40b237c9e904034c081b144
treeba951dcacf44a1d42b309c72d536dca9b0846e3a
parent67ace2724603378fec0c5321736e2772d459fd8c
bcachefs: Fix for long running btree transactions & key cache

While a btree transaction is running, we hold a SRCU read lock on the
btree key cache that prevents btree key cache keys from being freed -
this is so that relock() operations won't access freed memory.

The downside of this is that long running btree transactions prevent
memory from being freed from the key cache. This adds a check in
bch2_trans_begin() - if the transaction has been running longer than 1
second, drop and retake the SRCU read lock and zero out pointers to
unlock key cache paths.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_iter.c
fs/bcachefs/btree_types.h
fs/bcachefs/errcode.h