cmd_fsck: use access_local(), remove dead AnyView::load()

Convert cmd_fsck to async and use access_local() for the cached store.
Still uses Store::load_from_logs() for fresh comparison.

Remove unused AnyView::load() method - was never called.

Remaining Store::load() calls are all internal caching infrastructure:
- persist.rs cached() for CACHED_STORE
- mod.rs access() fallback for STORE_ACCESS

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-13 18:09:02 -04:00
parent f6f330b07b
commit 09b30d64f2
3 changed files with 5 additions and 16 deletions

View file

@ -59,8 +59,9 @@ pub async fn cmd_init() -> Result<()> {
Ok(())
}
pub fn cmd_fsck() -> Result<()> {
let mut store = store::Store::load()?;
pub async fn cmd_fsck() -> Result<()> {
let arc = memory::access_local()?;
let mut store = arc.lock().await;
// Check cache vs log consistency
let log_store = store::Store::load_from_logs()?;
@ -92,7 +93,7 @@ pub fn cmd_fsck() -> Result<()> {
if cache_issues > 0 {
eprintln!("{} cache inconsistencies found — rebuilding from logs", cache_issues);
store = log_store;
*store = log_store;
store.save().context("rebuild save")?;
}

View file

@ -6,7 +6,6 @@
use super::types::*;
use anyhow::Result;
use std::fs;
// ---------------------------------------------------------------------------
@ -185,17 +184,6 @@ pub enum AnyView {
Owned(Store),
}
impl AnyView {
/// Load the fastest available view: mmap snapshot or owned store.
pub fn load() -> Result<Self> {
if let Some(mv) = MmapView::open() {
Ok(AnyView::Mmap(mv))
} else {
Ok(AnyView::Owned(Store::load()?))
}
}
}
impl StoreView for AnyView {
fn for_each_node<F: FnMut(&str, &str, f32)>(&self, f: F) {
match self { AnyView::Mmap(v) => v.for_each_node(f), AnyView::Owned(s) => s.for_each_node(f) }

View file

@ -460,7 +460,7 @@ impl Run for AdminCmd {
Self::Init => cli::admin::cmd_init().await,
Self::Health => cli::admin::cmd_health().await,
Self::Topology => cli::admin::cmd_topology().await,
Self::Fsck => cli::admin::cmd_fsck(),
Self::Fsck => cli::admin::cmd_fsck().await,
Self::Dedup { apply } => cli::admin::cmd_dedup(apply).await,
Self::DailyCheck => cli::admin::cmd_daily_check().await,
Self::Import { files } => cli::admin::cmd_import(&files).await,