Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a series of fixups for nydusd #1587

Merged
merged 3 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions service/src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,13 +422,16 @@ impl DaemonController {
self.fs_service.lock().unwrap().clone()
}

/// Shutdown all services managed by the controller.
pub fn shutdown(&self) {
/// Notify controller shutdown
pub fn notify_shutdown(&self) {
// Marking exiting state.
self.active.store(false, Ordering::Release);
// Signal the `run_loop()` working thread to exit.
let _ = self.waker.wake();
}

/// Shutdown all services managed by the controller.
pub fn shutdown(&self) {
let daemon = self.daemon.lock().unwrap().take();
if let Some(d) = daemon {
if let Err(e) = d.trigger_stop() {
Expand Down
2 changes: 1 addition & 1 deletion src/bin/nydusd/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ mod nbd {
}

extern "C" fn sig_exit(_sig: std::os::raw::c_int) {
DAEMON_CONTROLLER.shutdown();
DAEMON_CONTROLLER.notify_shutdown();
}

fn main() -> Result<()> {
Expand Down
20 changes: 17 additions & 3 deletions storage/src/cache/cachedfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1662,6 +1662,20 @@ impl FileIoMergeState {
tag: BlobIoTag,
chunk: Option<Arc<dyn BlobChunkInfo>>,
) -> Result<()> {
// Make sure user io of same region continuous
if !self.regions.is_empty() && self.joinable(region_type) {
let region = &self.regions[self.regions.len() - 1];
if !region.seg.is_empty() && tag.is_user_io() {
if let BlobIoTag::User(ref seg) = tag {
if seg.offset as u64 + start
!= region.blob_address + region.seg.offset as u64 + region.seg.len as u64
{
self.commit();
}
}
}
}

if self.regions.is_empty() || !self.joinable(region_type) {
self.regions.push(Region::new(region_type));
self.last_region_joinable = true;
Expand Down Expand Up @@ -1793,7 +1807,7 @@ mod tests {

let tag = BlobIoTag::User(BlobIoSegment {
offset: 0x1800,
len: 0x1800,
len: 0x800,
});
state
.push(RegionType::CacheFast, 0x1000, 0x2000, tag, None)
Expand All @@ -1810,8 +1824,8 @@ mod tests {
assert_eq!(state.regions.len(), 1);

let tag = BlobIoTag::User(BlobIoSegment {
offset: 0x0000,
len: 0x2000,
offset: 0x0001,
len: 0x1fff,
});
state
.push(RegionType::CacheSlow, 0x5000, 0x2000, tag, None)
Expand Down
2 changes: 1 addition & 1 deletion storage/src/cache/filecache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl FileCacheEntry {
} else {
blob_info.uncompressed_size()
};
if file_size == 0 {
if file_size == 0 || file_size < cached_file_size {
file.set_len(cached_file_size)?;
} else if cached_file_size != 0 && file_size != cached_file_size {
let msg = format!(
Expand Down
Loading