Skip to content

Commit

Permalink
fix: large files broke prefetch
Browse files Browse the repository at this point in the history
backport master commit 7e39a5d
Author: 泰友 <[email protected]>
Date:   Wed Jul 5 14:14:09 2023 +0800

    fix: large files broke prefetch

    Files larger than 4G leads to prefetch panic, because the max blob io
    range is smaller than 4G. This pr changes blob io max size from u32 to
    u64.

Signed-off-by: 泰友 <[email protected]>
Signed-off-by: Peng Tao <[email protected]>
  • Loading branch information
bergwolf authored and imeoer committed Jul 17, 2023
1 parent 74c9edc commit 7041460
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion rafs/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ impl FileSystem for Rafs {
let r = self.device.read_to(w, desc)?;
result += r;
recorder.mark_success(r);
if r as u32 != desc.bi_size {
if r as u64 != desc.bi_size {
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions rafs/src/metadata/direct_v6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,7 @@ impl RafsInode for OndiskInodeWrapper {

let mut descs = BlobIoVec::new();
descs.bi_vec.push(desc);
descs.bi_size += content_len;
descs.bi_size += content_len as u64;
left -= content_len;

if left != 0 {
Expand All @@ -1311,7 +1311,7 @@ impl RafsInode for OndiskInodeWrapper {
}

descs.bi_vec.push(desc);
descs.bi_size += content_len;
descs.bi_size += content_len as u64;
left -= content_len;
if left == 0 {
break;
Expand Down
2 changes: 1 addition & 1 deletion rafs/src/metadata/layout/v5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,7 @@ fn add_chunk_to_bio_desc(
(chunk_end - chunk_start) as u32,
user_io,
);
desc.bi_size += bio.size;
desc.bi_size += bio.size as u64;
desc.bi_vec.push(bio);

true
Expand Down
4 changes: 2 additions & 2 deletions storage/src/cache/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ impl AsyncWorkerMgr {
}

/// Consume network bandwidth budget for prefetching.
pub fn consume_prefetch_budget(&self, size: u32) {
pub fn consume_prefetch_budget(&self, size: u64) {
if self.prefetch_inflight.load(Ordering::Relaxed) > 0 {
if let Some(v) = NonZeroU32::new(size) {
if let Some(v) = NonZeroU32::new(size as u32) {
// Try to consume budget but ignore result.
if let Some(limiter) = self.prefetch_limiter.as_ref() {
let _ = limiter.check_n(v);
Expand Down
4 changes: 2 additions & 2 deletions storage/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ pub struct BlobIoVec {
/// Blob IO flags.
pub bi_flags: u32,
/// Total size of blob IOs to be performed.
pub bi_size: u32,
pub bi_size: u64,
/// Array of blob IOs, these IOs should executed sequentially.
// TODO: As bi_vec must stay within the same blob, move BlobInfo out here?
pub bi_vec: Vec<BlobIoDesc>,
Expand All @@ -560,7 +560,7 @@ impl BlobIoVec {
/// Append another blob io vector to current one.
pub fn append(&mut self, mut desc: BlobIoVec) {
self.bi_vec.append(desc.bi_vec.as_mut());
self.bi_size += desc.bi_size;
self.bi_size += desc.bi_size as u64;
debug_assert!(self.validate());
}

Expand Down

0 comments on commit 7041460

Please sign in to comment.