Patch error with hole punching LFC

This commit is contained in:
quantumish
2025-08-12 01:48:54 -07:00
parent 02e6c051b7
commit f576dc50e8
3 changed files with 7 additions and 8 deletions

View File

@@ -9,7 +9,6 @@
//! process. The backend processes *also* read the file (and sometimes also
//! write it? ), but the backends use direct C library calls for that.
use std::fs::File;
use std::os::linux::fs::MetadataExt;
use std::os::unix::fs::FileExt;
use std::path::{Path, PathBuf};
use std::sync::Arc;
@@ -179,7 +178,7 @@ impl FileCache {
nix::FallocateFlags::FALLOC_FL_ZERO_RANGE
.union(nix::FallocateFlags::FALLOC_FL_KEEP_SIZE),
(block as usize * BLCKSZ) as libc::off_t,
1
BLCKSZ as libc::off_t
) {
tracing::error!("failed to un-punch hole in LFC at {block}: {e}");
return;
@@ -238,7 +237,7 @@ impl FileCache {
/// of holes within a file. Whether we need this function at all is unclear,
/// as seemingly this part of the codebase only targets a system with ext4?
#[cfg(target_os = "macos")]
pub fn undelete_blocks(&self, num_blocks: u64) -> u64 {
pub fn unpunch_blocks(&self, num_blocks: u64) -> u64 {
use nix::unistd as nix;
let mut free_list = self.free_list.lock().unwrap();
let num_bytes = (free_list.next_free_block * BLOCKSZ) as i64;

View File

@@ -798,7 +798,7 @@ impl<'t> IntegratedCacheWriteAccess<'t> {
err
);
}
let remaining = file_cache.undelete_blocks(difference as u64);
let remaining = file_cache.unpunch_blocks(difference as u64);
file_cache.grow(remaining as u64);
debug_assert!(file_cache.free_space() > remaining);
} else if old_num_blocks > num_blocks {
@@ -832,7 +832,7 @@ impl<'t> IntegratedCacheWriteAccess<'t> {
.fetch_max(old_val.lw_lsn.into_inner().0, Ordering::Relaxed);
let cache_block = old_val.cache_block.into_inner();
if cache_block != INVALID_CACHE_BLOCK {
file_cache.delete_block(cache_block);
file_cache.punch_block(cache_block);
file_evictions += 1;
self.metrics.cache_page_evictions_counter.inc();
}
@@ -850,7 +850,7 @@ impl<'t> IntegratedCacheWriteAccess<'t> {
while remaining > 0 as u64 {
if let Some(i) = self.try_evict_cache_block() {
if i != INVALID_CACHE_BLOCK {
file_cache.delete_block(i);
file_cache.punch_block(i);
remaining -= 1;
}
}

View File

@@ -80,9 +80,9 @@ where
break;
}
};
// tracing::info!("waiting for conflicting IO {request_id} to complete");
tracing::info!("waiting for conflicting IO {request_id} to complete");
let _ = lock.lock().await;
// tracing::info!("conflicting IO {request_id} completed");
tracing::info!("conflicting IO {request_id} completed");
}
MutexHashMapGuard {