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

Gripe when using non-raw block device #594

Merged
merged 1 commit into from
Jan 6, 2024
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
11 changes: 11 additions & 0 deletions bin/propolis-server/src/lib/initializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::convert::TryInto;
use std::fs::File;
use std::io::{Error, ErrorKind};
use std::num::NonZeroUsize;
use std::os::unix::fs::FileTypeExt;
use std::sync::Arc;
use std::time::{SystemTime, UNIX_EPOCH};

Expand Down Expand Up @@ -327,6 +328,16 @@ impl<'a> MachineInitializer<'a> {
info!(self.log, "Creating file disk backend";
"path" => &spec.path);

// Check if raw device is being used and gripe if it isn't
let meta = std::fs::metadata(&spec.path)?;
if meta.file_type().is_block_device() {
slog::warn!(
self.log,
"Block backend using standard device rather than raw";
"path" => &spec.path
);
}

let nworkers = NonZeroUsize::new(8).unwrap();
let be = propolis::block::FileBackend::create(
&spec.path,
Expand Down
9 changes: 9 additions & 0 deletions bin/propolis-standalone/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use std::collections::BTreeMap;
use std::num::NonZeroUsize;
use std::os::unix::fs::FileTypeExt;
use std::str::FromStr;
use std::sync::Arc;

Expand Down Expand Up @@ -58,6 +59,14 @@ pub fn block_backend(
"file" => {
let parsed: FileConfig = opt_deser(&be.options).unwrap();

// Check if raw device is being used and gripe if it isn't
let meta = std::fs::metadata(&parsed.path)
.expect("file device path is valid");
if meta.file_type().is_block_device() {
slog::warn!(log, "Block backend using standard device rather than raw";
"path" => &parsed.path);
}

let be = block::FileBackend::create(
&parsed.path,
opts,
Expand Down
Loading