store: internal locking, remove Arc<Mutex<Store>> wrapper

Store now has internal Mutex for capnp appends and AtomicU64 for
size tracking. All methods take &self. The external Arc<Mutex<Store>>
is replaced with Arc<Store>.

- Store::append_lock protects file appends
- local.rs functions take &Store (not &mut Store)
- access_local() returns Arc<Store>
- All .lock().await calls removed from callers

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-13 21:49:54 -04:00
parent 4696bb8b7d
commit b3d0a3ab25
13 changed files with 86 additions and 70 deletions

View file

@ -351,9 +351,7 @@ impl Mind {
let needs_health = unc.lock().await.needs_health_refresh();
if needs_health {
if let Ok(store_arc) = access_local() {
let store = store_arc.lock().await;
let health = crate::subconscious::daemon::compute_graph_health(&store);
drop(store);
let health = crate::subconscious::daemon::compute_graph_health(&store_arc);
unc.lock().await.set_health(health);
}
}
@ -391,7 +389,7 @@ impl Mind {
let sub = self.subconscious.lock().await;
let store_arc = crate::hippocampus::access_local().ok();
let store_guard = match &store_arc {
Some(s) => Some(s.lock().await),
Some(s) => Some(&**s),
None => None,
};
sub.snapshots(store_guard.as_deref())
@ -405,7 +403,7 @@ impl Mind {
let unc = self.unconscious.lock().await;
let store_arc = crate::hippocampus::access_local().ok();
let store_guard = match &store_arc {
Some(s) => Some(s.lock().await),
Some(s) => Some(&**s),
None => None,
};
unc.snapshots(store_guard.as_deref())