Skip to content

fix: report fscache blob cull completion status - #1993

Open
Park-Jiyeonn wants to merge 1 commit into
dragonflyoss:masterfrom
Park-Jiyeonn:fix/fscache-cull
Open

fix: report fscache blob cull completion status#1993
Park-Jiyeonn wants to merge 1 commit into
dragonflyoss:masterfrom
Park-Jiyeonn:fix/fscache-cull

Conversation

@Park-Jiyeonn

@Park-Jiyeonn Park-Jiyeonn commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Overview

Run cachefiles cull requests on a dedicated worker and expose whether reclamation finished or needs another attempt.

Keep configured and open blobs out of cull, and track CLOSE events by fscache volume until cachefiles commits the cookie. A missing cookie after CLOSE is therefore reported as pending instead of done.

Wake asynchronous culls when references close, while leaving retry ownership with synchronous callers. Treat already-removed cache entries as idempotent and keep the cull worker's filesystem state isolated from the daemon.

Add API and fscache tests for done and pending responses, cull ordering, close and cachefiles commit handling, and retry ownership.

Related: Nydus-Snapshotter: fix: retry fscache blob cull until cachefiles completes#787

Change Type

Please select the type of change your pull request relates to:

  • Bug Fix
  • Feature Addition
  • Documentation Update
  • Code Refactoring
  • Performance Improvement
  • Other (please describe)

Copilot AI review requested due to automatic review settings July 22, 2026 14:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves FSCACHE blob reclamation (“cull”) reporting and scheduling by moving cull execution into a dedicated worker, tracking whether reclamation is done vs pending, and exposing that status through a new API v2 endpoint so callers can retry when needed.

Changes:

  • Add a BlobCullResult (Done/Pending) result type and plumb it through the daemon trait and nydusd API glue.
  • Implement a dedicated FSCACHE cull worker with queueing, close-event tracking, and synchronous “attempt status” reporting.
  • Extend HTTP API v2 with /api/v2/blobs/cull and a Pending response payload for retryable results.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/bin/nydusd/api_server_glue.rs Wire new CullBlobFile API request into nydusd and map Done/Pending to response payloads.
service/src/singleton.rs Implement NydusDaemon::cull_blob() by delegating to FSCACHE handler status API.
service/src/fs_cache.rs Add cull worker/state machine, track close/commit settle windows, and provide cull_cache_status() returning Done/Pending.
service/src/daemon.rs Introduce BlobCullResult and a new cull_blob() daemon trait method.
service/src/blob_cache.rs Make removal idempotent for missing entries and add contains_blob_id() used by cull logic.
api/src/http.rs Add CullBlobFile request, Pending payload, and HTTP error variant for cull.
api/src/http_handler.rs Register new v2 route for /api/v2/blobs/cull.
api/src/http_endpoint_v2.rs Implement the v2 cull endpoint and map Pending to a structured HTTP 200 response.

Comment thread service/src/fs_cache.rs
Comment on lines +673 to +684
let mut volume_hash_key: Vec<u8> =
Vec::with_capacity(Self::round_up_u32(volume_key.len() + 2));
volume_hash_key.push(volume_key.len() as u8);
volume_hash_key.append(&mut volume_key.as_bytes().to_vec());
volume_hash_key.resize(volume_hash_key.capacity(), 0);
let volume_hash = Self::fscache_hash(0, volume_hash_key.as_slice());

// Calculate cookie hash.
let mut cookie_hash_key: Vec<u8> = Vec::with_capacity(Self::round_up_u32(cookie_key.len()));
cookie_hash_key.append(&mut cookie_key.as_bytes().to_vec());
cookie_hash_key.resize(cookie_hash_key.capacity(), 0);
let dir_hash = Self::fscache_hash(volume_hash, cookie_hash_key.as_slice());
Comment thread service/src/fs_cache.rs
Comment on lines +1264 to +1268
let guard = fsblob.read().unwrap();
match guard.get_blob_cache() {
Some(blob) => {
if let Ok(cache_cfg) = factory_config.get_cache_config() {
if cache_cfg.prefetch.enable {
Comment thread service/src/blob_cache.rs
Comment on lines 216 to 218
match self.id_to_config_map.get(&scoped_blob_prefix) {
None => return Err(enoent!("blob_cache: cache entry not found")),
None => return Ok(()),
Some(BlobConfig::MetaBlob(o)) => {
Run cachefiles cull requests on a dedicated worker and expose whether
reclamation finished or needs another attempt.

Keep configured and open blobs out of cull, and track CLOSE events by
fscache volume until cachefiles commits the cookie. A missing cookie
after CLOSE is therefore reported as pending instead of done.

Wake asynchronous culls when references close, while leaving retry
ownership with synchronous callers. Treat already-removed cache entries
as idempotent and keep the cull worker's filesystem state isolated from
the daemon.

Add API and fscache tests for done and pending responses, cull ordering,
close and cachefiles commit handling, and retry ownership.

Signed-off-by: Park.Jiyeon <jiyeonnn2@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants