Skip to content
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 lib/propolis/src/block/crucible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ impl CrucibleBackend {
.map_err(|e| io::Error::from(CrucibleError::from(e)))?;

// Decide if we need to scrub this volume or not.
if volume.has_read_only_parent() {
//
// We should not scrub read-only volumes, as we cannot write back to
// them, due to...you know, being read-only. So just don't do that.
if !opts.is_read_only() && volume.has_read_only_parent() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced Nexus can construct a read only volume with a read_only_parent, but I suppose nothing stops you from sending propolis a toml directly that contains such a beast. So, it's probably best to just prevent it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmpesp told me it was possible, though I'm not sure if it will currently happen for the way we construct ro disks or not?

let vclone = volume.clone();
tokio::spawn(async move {
let volume_id = vclone.get_uuid().await.unwrap();
Expand Down Expand Up @@ -217,7 +220,7 @@ impl CrucibleBackend {
let info = block::DeviceInfo {
block_size: block_size as u32,
total_size: sectors,
read_only: opts.read_only.unwrap_or(false),
read_only: opts.is_read_only(),
supports_discard: false,
};

Expand Down
7 changes: 7 additions & 0 deletions lib/propolis/src/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,13 @@ pub struct BackendOpts {
pub skip_flush: Option<bool>,
}

impl BackendOpts {
/// Return `true` if and only if this backend is configured to be read-only.
pub fn is_read_only(&self) -> bool {
self.read_only.unwrap_or(false)
}
}

/// Top-level trait for block devices (frontends) to translate guest block IO
/// requests into [Request]s for the attached [Backend]
pub trait Device: Send + Sync + 'static {
Expand Down
Loading