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

Add initial block TRIM/UNMAP/discard support #883

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions bin/propolis-server/src/lib/stats/virtual_disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ impl VirtualDiskStats {
self.on_write_completion(result, len, duration)
}
Operation::Flush => self.on_flush_completion(result, duration),
Operation::Discard(..) => {
// Discard is not wired up in backends we care about for now, so
// it can safely be ignored.
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions lib/propolis/src/block/crucible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ impl CrucibleBackend {
block_size: block_size as u32,
total_size: sectors,
read_only: opts.read_only.unwrap_or(false),
supports_discard: false,
},
skip_flush: opts.skip_flush.unwrap_or(false),
}),
Expand Down Expand Up @@ -198,6 +199,7 @@ impl CrucibleBackend {
block_size: block_size as u32,
total_size: size / block_size,
read_only: opts.read_only.unwrap_or(false),
supports_discard: false,
},
skip_flush: opts.skip_flush.unwrap_or(false),
}),
Expand Down Expand Up @@ -312,6 +314,8 @@ pub enum Error {
BadGuestRegion,
#[error("backend is read-only")]
ReadOnly,
#[error("operation not supported")]
Unsupported,

#[error("offset or length not multiple of blocksize")]
BlocksizeMismatch,
Expand All @@ -329,6 +333,7 @@ impl From<Error> for block::Result {
fn from(value: Error) -> Self {
match value {
Error::ReadOnly => block::Result::ReadOnly,
Error::Unsupported => block::Result::Unsupported,
_ => block::Result::Failure,
}
}
Expand Down Expand Up @@ -421,6 +426,10 @@ async fn process_request(
let _ = block.flush(None).await?;
}
}
block::Operation::Discard(..) => {
// Crucible does not support discard operations for now
return Err(Error::Unsupported);
}
}
Ok(())
}
Expand Down
Loading
Loading