Skip to content

Commit

Permalink
nydusd: feed all bootstrap cachefile at once
Browse files Browse the repository at this point in the history
whan handle read requests for bootstrap, feed all data at once.For
supporting daemonless we need fill all cache files before nydusd exit.
but bootstrap does not support prefetch. Also it may improve
performance.

Signed-off-by: Xin Yin <[email protected]>
  • Loading branch information
Xin Yin committed Jun 30, 2022
1 parent 13220ce commit 565dca3
Showing 1 changed file with 37 additions and 31 deletions.
68 changes: 37 additions & 31 deletions src/bin/nydusd/fs_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,38 +604,44 @@ impl FsCacheHandler {
}
}
Some((FsCacheObject::Bootstrap(bs), u)) => {
// TODO: should we feed the bootstrap at together to improve performance?
fd = u;
let base = unsafe {
libc::mmap(
std::ptr::null_mut(),
msg.len as usize,
libc::PROT_READ,
libc::MAP_SHARED,
bs.bootstrap_file.as_raw_fd(),
msg.off as libc::off_t,
)
};
if base == libc::MAP_FAILED {
warn!(
"fscache: failed to mmap bootstrap file, {}",
std::io::Error::last_os_error()
);
} else {
let ret = unsafe {
libc::pwrite(
bs.cache_file.as_raw_fd(),
base,
msg.len as usize,
msg.off as libc::off_t,
)
};
let _ = unsafe { libc::munmap(base, msg.len as usize) };
if ret < 0 {
warn!(
"fscache: failed to write bootstrap blob data to cached file, {}",
std::io::Error::last_os_error()
);
match bs.bootstrap_file.metadata() {
Err(e) => {
warn!("fscache: get bootstrap file metadata err {}", e);
}
Ok(md) => {
let base = unsafe {
libc::mmap(
std::ptr::null_mut(),
md.len() as usize,
libc::PROT_READ,
libc::MAP_SHARED,
bs.bootstrap_file.as_raw_fd(),
0 as libc::off_t,
)
};
if base == libc::MAP_FAILED {
warn!(
"fscache: failed to mmap bootstrap file, {}",
std::io::Error::last_os_error()
);
} else {
let ret = unsafe {
libc::pwrite(
bs.cache_file.as_raw_fd(),
base,
md.len() as usize,
0 as libc::off_t,
)
};
let _ = unsafe { libc::munmap(base, md.len() as usize) };
if ret < 0 {
warn!(
"fscache: failed to write bootstrap blob data to cached file, {}",
std::io::Error::last_os_error()
);
}
}
}
}
}
Expand Down

0 comments on commit 565dca3

Please sign in to comment.