Module page_cache

Module page_cache 

Source
Expand description

Global Page Cache Manager

Provides a unified page cache for all filesystem operations (read/write/mmap). This cache is shared across all file objects pointing to the same file, ensuring consistency and memory efficiency.

§Phase 0 Implementation

Current implementation includes:

  • Page allocation and caching with CacheId-based indexing
  • Pin-based protection against eviction during active use
  • Dirty page tracking for write operations
  • Object-level locking for mmap support
  • Flush operations for writeback

Not yet implemented:

  • Page eviction (LRU or similar policy)
  • LOADING state coordination for concurrent access
  • Integration with filesystem read/write operations (Phase 1)
  • Demand paging for mmap (Phase 2)

§Usage

use crate::mem::page_cache::PageCacheManager;

let paddr = PageCacheManager::global().get_or_create_pinned(cache_id, page_index, |paddr| {
    // Load page content from disk to paddr
    Ok(())
})?;
// Use the page...
PageCacheManager::global().unpin(cache_id, page_index);

Structs§

PageCacheEntry
Entry in the page cache representing a single cached page
PageCacheManager
Global page cache manager
PinnedPage
RAII guard for a pinned page.

Statics§

GLOBAL_PAGE_CACHE
Global page cache instance

Type Aliases§

PageIndex
Page index within a file (0, 1, 2, …)
PhysicalAddress
Physical address of a page