Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions nexus/db-queries/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ pem.workspace = true
petgraph.workspace = true
predicates.workspace = true
pretty_assertions.workspace = true
proptest.workspace = true
rcgen.workspace = true
regex.workspace = true
rustls.workspace = true
Expand Down
15 changes: 4 additions & 11 deletions nexus/db-queries/src/db/datastore/disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,17 +306,10 @@ impl LocalStorageDisk {

/// Size required for the disk's data plus overhead
pub fn required_dataset_size(&self) -> i64 {
// The value in ByteCount is capped at i64::MAX, but a disk backed by
// local storage cannot be created that does not fit in a zpool at the
// time of the disk creation request (note this is different from the
// time of instance reservation where Nexus actually assigns the disk an
// allocation). This means that the size is well below that MAX, meaning
// this won't overflow.
//
// Additionally, there's a checked_add in DiskTypeLocalStorage::New that
// checks this won't happen. Note this won't protect against cases of
// database modification, but not much will!

// Both values are ByteCounts, so each fits in i64. The overhead is
// roughly 7% of the disk size (see DiskTypeLocalStorage::new), so the
// sum only approaches i64::MAX for disks of several EiB, far beyond
// what any zpool can hold.
self.size().to_bytes() as i64
+ self.required_dataset_overhead().to_bytes() as i64
}
Expand Down
Loading
Loading