Skip to content

Commit

Permalink
fix: Support building rafs without the dedup feature
Browse files Browse the repository at this point in the history
Signed-off-by: Yang Kaiyong <[email protected]>
  • Loading branch information
Yang Kaiyong committed Jan 23, 2025
1 parent e255261 commit ed03daf
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
1 change: 0 additions & 1 deletion rafs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ thiserror = "1"
nydus-api = { version = "0.3", path = "../api" }
nydus-storage = { version = "0.6", path = "../storage", features = [
"backend-localfs",
"dedup",
] }
nydus-utils = { version = "0.4", path = "../utils" }

Expand Down
4 changes: 4 additions & 0 deletions storage/src/cache/cachedfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ impl FileCacheEntry {
};
let res = Self::persist_cached_data(&file, offset, buf);
Self::_update_chunk_pending_status(&delayed_chunk_map, chunk.as_ref(), res.is_ok());
#[cfg(feature = "dedup")]
if let Some(mgr) = cas_mgr {
if let Err(e) = mgr.record_chunk(&blob_info, chunk.deref(), file_path.as_ref()) {
warn!(
Expand All @@ -312,6 +313,7 @@ impl FileCacheEntry {
let offset = chunk.uncompressed_offset();
let res = Self::persist_cached_data(&self.file, offset, buf);
self.update_chunk_pending_status(chunk, res.is_ok());
#[cfg(feature = "dedup")]
if let Some(mgr) = &self.cas_mgr {
if let Err(e) = mgr.record_chunk(&self.blob_info, chunk, self.file_path.as_ref()) {
warn!(
Expand Down Expand Up @@ -1079,6 +1081,7 @@ impl FileCacheEntry {
Err(e) => return Err(einval!(e)),
};

#[cfg(feature = "dedup")]
if !is_ready {
if let Some(mgr) = self.cas_mgr.as_ref() {
is_ready = mgr.dedup_chunk(&self.blob_info, chunk.deref(), &self.file);
Expand Down Expand Up @@ -1481,6 +1484,7 @@ impl FileCacheEntry {
}
}

#[cfg(feature = "dedup")]
impl Drop for FileCacheEntry {
fn drop(&mut self) {
if let Some(cas_mgr) = &self.cas_mgr {
Expand Down
7 changes: 6 additions & 1 deletion storage/src/cache/filecache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,12 @@ impl FileCacheEntry {
warn!("chunk deduplication trun off");
None
} else {
CasMgr::get_singleton()
#[cfg(feature = "dedup")]
{
CasMgr::get_singleton()
}
#[cfg(not(feature = "dedup"))]
None
};

let blob_compressed_size = Self::get_blob_size(&reader, &blob_info)?;
Expand Down
7 changes: 6 additions & 1 deletion storage/src/cache/fscache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,12 @@ impl FileCacheEntry {
warn!("chunk deduplication trun off");
None
} else {
CasMgr::get_singleton()
#[cfg(feature = "dedup")]
{
CasMgr::get_singleton()
}
#[cfg(not(feature = "dedup"))]
None
};

let need_validation = mgr.need_validation
Expand Down

0 comments on commit ed03daf

Please sign in to comment.