Skip to content

Commit 0410f36

Browse files
committed
Add initial block TRIM/UNMAP/discard support
1 parent 9ee2e1f commit 0410f36

File tree

9 files changed

+362
-41
lines changed

9 files changed

+362
-41
lines changed

bin/propolis-server/src/lib/stats/virtual_disk.rs

+4
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ impl VirtualDiskStats {
8181
self.on_write_completion(result, len, duration)
8282
}
8383
Operation::Flush => self.on_flush_completion(result, duration),
84+
Operation::Discard(..) => {
85+
// Discard is not wired up in backends we care about for now, so
86+
// it can safely be ignored.
87+
}
8488
}
8589
}
8690

lib/propolis/src/block/crucible.rs

+9
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ impl CrucibleBackend {
149149
block_size: block_size as u32,
150150
total_size: sectors,
151151
read_only: opts.read_only.unwrap_or(false),
152+
supports_discard: false,
152153
},
153154
skip_flush: opts.skip_flush.unwrap_or(false),
154155
}),
@@ -198,6 +199,7 @@ impl CrucibleBackend {
198199
block_size: block_size as u32,
199200
total_size: size / block_size,
200201
read_only: opts.read_only.unwrap_or(false),
202+
supports_discard: false,
201203
},
202204
skip_flush: opts.skip_flush.unwrap_or(false),
203205
}),
@@ -312,6 +314,8 @@ pub enum Error {
312314
BadGuestRegion,
313315
#[error("backend is read-only")]
314316
ReadOnly,
317+
#[error("operation not supported")]
318+
Unsupported,
315319

316320
#[error("offset or length not multiple of blocksize")]
317321
BlocksizeMismatch,
@@ -329,6 +333,7 @@ impl From<Error> for block::Result {
329333
fn from(value: Error) -> Self {
330334
match value {
331335
Error::ReadOnly => block::Result::ReadOnly,
336+
Error::Unsupported => block::Result::Unsupported,
332337
_ => block::Result::Failure,
333338
}
334339
}
@@ -421,6 +426,10 @@ async fn process_request(
421426
let _ = block.flush(None).await?;
422427
}
423428
}
429+
block::Operation::Discard(..) => {
430+
// Crucible does not support discard operations for now
431+
return Err(Error::Unsupported);
432+
}
424433
}
425434
Ok(())
426435
}

0 commit comments

Comments
 (0)