[PR #217] [MERGED] fix(overlaybd): preallocate cache blocks to avoid SIGBUS when disk is… #258

Closed
opened 2026-10-29 14:21:34 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/kvcache-ai/AgentENV/pull/217
Author: @huang-jl
Created: 8/25/2026
Status: ✅ Merged
Merged: 8/26/2026
Merged by: @yingdi-shan

Base: main ← Head: hjl/fix-cache-sigbus


📝 Commits (1)

  • 80e6470 fix(overlaybd): preallocate cache blocks to avoid SIGBUS when disk is full

📊 Changes

3 files changed (+254 additions, -7 deletions)

View changed files

📝 storage/overlaybd/src/backend/cache/full_file_cache/cache_entry.rs (+135 -0)
📝 storage/overlaybd/src/backend/cache/full_file_cache/cache_store.rs (+22 -7)
📝 storage/overlaybd/src/backend/cache/tests.rs (+97 -0)

📄 Description

What

Reserve the block's byte range with fallocate(FALLOC_FL_KEEP_SIZE) before handing out mmap write access (write_block and mmap_mut_for_block). Disk exhaustion now surfaces as a plain ENOSPC refill error, and reads fall back to the source exactly like the existing cache-capacity-full path. Filesystems without fallocate support (EOPNOTSUPP/ENOSYS) keep the previous behavior.

Why

The full-file cache writes refilled blocks through a shared mmap over a sparse data file. Writing into an unallocated hole makes the kernel allocate filesystem blocks at page-fault time; when the local disk is full that allocation fails and the process is killed with SIGBUS, taking down the whole ublk-daemon.

Design and behavior changes

Before write into mmap region of cache files, an extra fallocate syscall will be invoked.

Validation

  • make fmt
  • make clippy
  • make test-unit
  • Relevant Rust integration tests
  • make -C services test (required when services/ changes)
  • Generated clients/server regenerated with the documented make target
  • Documentation updated
  • Benchmarks or performance comparison completed

Checklist

  • The PR contains one coherent change and no unrelated formatting or refactoring.
  • New behavior is covered by tests, or I explained why testing is impractical.
  • Logs and examples contain no credentials, tokens, or private registry information.
  • I did not manually edit generated code without updating its source and regenerating it.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/kvcache-ai/AgentENV/pull/217 **Author:** [@huang-jl](https://github.com/huang-jl) **Created:** 8/25/2026 **Status:** ✅ Merged **Merged:** 8/26/2026 **Merged by:** [@yingdi-shan](https://github.com/yingdi-shan) **Base:** `main` ← **Head:** `hjl/fix-cache-sigbus` --- ### 📝 Commits (1) - [`80e6470`](https://github.com/kvcache-ai/AgentENV/commit/80e647095fd3cb2d19583d824e5aaa4172cd305b) fix(overlaybd): preallocate cache blocks to avoid SIGBUS when disk is full ### 📊 Changes **3 files changed** (+254 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `storage/overlaybd/src/backend/cache/full_file_cache/cache_entry.rs` (+135 -0) 📝 `storage/overlaybd/src/backend/cache/full_file_cache/cache_store.rs` (+22 -7) 📝 `storage/overlaybd/src/backend/cache/tests.rs` (+97 -0) </details> ### 📄 Description ## What Reserve the block's byte range with fallocate(FALLOC_FL_KEEP_SIZE) before handing out mmap write access (write_block and mmap_mut_for_block). Disk exhaustion now surfaces as a plain ENOSPC refill error, and reads fall back to the source exactly like the existing cache-capacity-full path. Filesystems without fallocate support (EOPNOTSUPP/ENOSYS) keep the previous behavior. ## Why The full-file cache writes refilled blocks through a shared mmap over a sparse data file. Writing into an unallocated hole makes the kernel allocate filesystem blocks at page-fault time; when the local disk is full that allocation fails and the process is killed with SIGBUS, taking down the whole ublk-daemon. ## Design and behavior changes Before write into mmap region of cache files, an extra `fallocate` syscall will be invoked. ## Validation <!-- Check only commands you actually ran. Add focused tests and exact commands below. --> - [x] `make fmt` - [x] `make clippy` - [x] `make test-unit` - [ ] Relevant Rust integration tests - [ ] `make -C services test` (required when `services/` changes) - [ ] Generated clients/server regenerated with the documented `make` target - [ ] Documentation updated - [ ] Benchmarks or performance comparison completed ## Checklist - [ ] The PR contains one coherent change and no unrelated formatting or refactoring. - [ ] New behavior is covered by tests, or I explained why testing is impractical. - [ ] Logs and examples contain no credentials, tokens, or private registry information. - [ ] I did not manually edit generated code without updating its source and regenerating it. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 14:21:34 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kvcache-ai/AgentENV#258
No description provided.