-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support direct use blob cache to run image
In localfs mode, we can directly generate blob cache through -blob-cache-dir, in this case, Nydusd can directly use blob cache to start, but it manages the state of chunk through ChunkMap by default, and by default all chunks are not ready, and will go to babckend to download, for which I introduced disable_chunk_map config, to turn off the ability of ChunkMap, by default make all chunks are ready, although Nydusd will still visit the backend to verify the validity of the blob when initializing the backend. it requires that the original nydus blob must exist, I introduced use_cache_only config to disable Nydusd access backend 1. add disable_chunk_map to disable ChunkMap func 2. add use_cache_only to disable nydusd access backend Signed-off-by: zyfjeff <[email protected]>
- Loading branch information
Showing
8 changed files
with
255 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// Copyright (C) 2021-2023 Alibaba Cloud. All rights reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//! Storage backend driver to reject all blob operations. | ||
use std::io::Result; | ||
use std::sync::Arc; | ||
|
||
use fuse_backend_rs::file_buf::FileVolatileSlice; | ||
use nydus_utils::metrics::BackendMetrics; | ||
|
||
use crate::backend::{BackendError, BackendResult, BlobBackend, BlobReader}; | ||
|
||
#[derive(Debug)] | ||
pub enum NoopError { | ||
Noop, | ||
} | ||
|
||
/// a Noop backend, do nothing | ||
#[derive(Default)] | ||
pub struct Noop { | ||
metrics: Arc<BackendMetrics>, | ||
} | ||
|
||
impl Noop { | ||
pub fn new(id: Option<&str>) -> Result<Self> { | ||
let id = id.ok_or_else(|| einval!("noop requires blob_id"))?; | ||
Ok(Noop { | ||
metrics: BackendMetrics::new(id, "noop"), | ||
}) | ||
} | ||
} | ||
|
||
struct NoopEntry { | ||
blob_id: String, | ||
metrics: Arc<BackendMetrics>, | ||
} | ||
|
||
impl BlobReader for NoopEntry { | ||
fn blob_size(&self) -> BackendResult<u64> { | ||
Err(BackendError::Unsupported(format!( | ||
"unsupport blob_size operation for {}", | ||
self.blob_id, | ||
))) | ||
} | ||
|
||
fn try_read(&self, _buf: &mut [u8], _offset: u64) -> BackendResult<usize> { | ||
Err(BackendError::Unsupported(format!( | ||
"unsupport try_read operation for {}", | ||
self.blob_id, | ||
))) | ||
} | ||
|
||
fn readv( | ||
&self, | ||
_bufs: &[FileVolatileSlice], | ||
_offset: u64, | ||
_max_size: usize, | ||
) -> BackendResult<usize> { | ||
Err(BackendError::Unsupported(format!( | ||
"unsupport readv operation for {}", | ||
self.blob_id, | ||
))) | ||
} | ||
|
||
fn metrics(&self) -> &BackendMetrics { | ||
&self.metrics | ||
} | ||
} | ||
|
||
impl BlobBackend for Noop { | ||
fn shutdown(&self) {} | ||
|
||
fn metrics(&self) -> &BackendMetrics { | ||
&self.metrics | ||
} | ||
|
||
fn get_reader(&self, blob_id: &str) -> BackendResult<Arc<dyn BlobReader>> { | ||
Ok(Arc::new(NoopEntry { | ||
blob_id: blob_id.to_owned(), | ||
metrics: self.metrics.clone(), | ||
})) | ||
} | ||
} | ||
|
||
impl Drop for Noop { | ||
fn drop(&mut self) { | ||
self.metrics.release().unwrap_or_else(|e| error!("{:?}", e)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.