Skip to content

Commit

Permalink
Try #1526:
Browse files Browse the repository at this point in the history
  • Loading branch information
mayastor-bors committed Oct 13, 2023
2 parents 821bbb1 + 432308d commit c89271c
Show file tree
Hide file tree
Showing 39 changed files with 1,344 additions and 1,676 deletions.
248 changes: 79 additions & 169 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions io-engine-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,15 @@ edition = "2018"

[dependencies]
ansi_term = "0.12.1"
assert_matches = "1.5.0"
async-channel = "1.9.0"
async-task = "4.4.1"
async-trait = "0.1.73"
bincode = "1.3.3"
byte-unit = "4.0.19"
bytes = "1.5.0"
chrono = "0.4.31"
clap = "2.33.3"
colored_json = "3.3.0"
crc = "3.0.1"
crossbeam = "0.8.2"
crossbeam-sync = "0.0.0"
dns-lookup = "2.0.3"
env_logger = "0.10.0"
etcd-client = "0.12.1"
function_name = "0.3.0"
futures = "0.3.28"
Expand All @@ -41,7 +35,6 @@ pin-utils = "0.1.0"
proc-mounts = "0.3.0"
prost = "0.11.9"
prost-derive = "0.11.9"
prost-types = "0.11.9"
rand = "0.8.5"
rand_chacha = "0.3.1"
regex = "1.10.0"
Expand All @@ -51,12 +44,10 @@ serde_yaml = "0.9.25"
sha2 = "0.10.8"
signal-hook = "0.3.17"
snafu = "0.7.5"
structopt = "0.3.26"
tonic = "0.9.2"
tower = "0.4.13"
tracing = "0.1.37"
tracing-core = "0.1.31"
tracing-futures = "0.2.5"
tracing-log = "0.1.3"
tracing-subscriber = "0.3.17"
udev = "0.8.0"
Expand Down
9 changes: 1 addition & 8 deletions io-engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,9 @@ bincode = "1.3.3"
byte-unit = "4.0.19"
bytes = "1.5.0"
chrono = "0.4.31"
clap = "2.33.3"
clap = { version = "4.4.6", features = ["color", "derive", "string", "env"] }
colored_json = "3.3.0"
crc = "3.0.1"
crossbeam = "0.8.2"
crossbeam-sync = "0.0.0"
dns-lookup = "2.0.3"
env_logger = "0.10.0"
etcd-client = "0.12.1"
function_name = "0.3.0"
Expand All @@ -69,7 +66,6 @@ ioctl-gen = "0.1.1"
lazy_static = "1.4.0"
libc = "0.2.149"
log = "0.4.20"
md5 = "0.7.0"
merge = "0.1.0"
nix = { version = "0.27.1", default-features = false, features = [ "hostname", "net", "socket", "ioctl" ] }
once_cell = "1.18.0"
Expand All @@ -78,22 +74,19 @@ pin-utils = "0.1.0"
proc-mounts = "0.3.0"
prost = "0.11.9"
prost-derive = "0.11.9"
prost-types = "0.11.9"
rand = "0.8.5"
regex = "1.10.0"
serde_json = "1.0.107"
serde_yaml = "0.9.25"
sha2 = "0.10.8"
signal-hook = "0.3.17"
snafu = "0.7.5"
structopt = "0.3.26"
strum = "0.25"
strum_macros = "0.25"
tonic = "0.9.2"
tower = "0.4.13"
tracing = "0.1.37"
tracing-core = "0.1.31"
tracing-futures = "0.2.5"
tracing-log = "0.1.3"
tracing-subscriber = "0.3.17"
udev = "0.8.0"
Expand Down
51 changes: 26 additions & 25 deletions io-engine/src/bin/casperf.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{cell::RefCell, os::raw::c_void, ptr::NonNull};

use clap::{value_t, App, AppSettings, Arg};
use clap::{Arg, Command};
use rand::Rng;

use io_engine::{
Expand Down Expand Up @@ -338,61 +338,62 @@ fn main() {
cfg
});

let matches = App::new("Mayastor performance tool")
let matches = Command::new("Mayastor performance tool")
.version(version_info_str!())
.settings(&[AppSettings::ColoredHelp, AppSettings::ColorAlways])
.about("Perform IO to storage URIs")
.arg(
Arg::with_name("io_size")
.value_name("io_size")
.short("b")
.help("block size in bytes")
.takes_value(true),
Arg::new("io-size")
.value_name("io-size")
.short('b')
.help("block size in bytes"),
)
.arg(
Arg::with_name("io_type")
.value_name("io_type")
.short("t")
Arg::new("io-type")
.value_name("io-type")
.short('t')
.help("type of IOs")
.possible_values(&["randread", "randwrite"])
.takes_value(true),
.value_parser(["randread", "randwrite"]),
)
.arg(
Arg::with_name("queue_depth")
.value_name("queue_depth")
.short("q")
.help("queue depth")
.takes_value(true),
Arg::new("queue-depth")
.value_name("queue-depth")
.short('q')
.value_parser(clap::value_parser!(u64))
.help("queue depth"),
)
.arg(
Arg::with_name("URI")
Arg::new("URI")
.value_name("URI")
.help("storage URI's")
.index(1)
.multiple(true)
.takes_value(true),
.action(clap::ArgAction::Append),
)
.subcommand_required(true)
.get_matches();

let mut uris = matches
.values_of("URI")
.get_many::<String>("URI")
.unwrap()
.map(|u| u.to_string())
.collect::<Vec<_>>();

let io_size = match matches.value_of("io_size") {
let io_size = match matches.get_one::<String>("io-size") {
Some(io_size) => {
byte_unit::Byte::from_str(io_size).unwrap().get_bytes() as u64
}
None => IO_SIZE,
};
let io_type = match matches.value_of("io_type").unwrap_or("randread") {
let io_type = match matches
.get_one::<String>("io-type")
.map(|s| s.as_str())
.unwrap_or("randread")
{
"randread" => IoType::Read,
"randwrite" => IoType::Write,
io_type => panic!("Invalid io_type: {}", io_type),
};

let qd = value_t!(matches.value_of("queue_depth"), u64).unwrap_or(QD);
let qd = *matches.get_one::<u64>("queue-depth").unwrap_or(&QD);
let args = MayastorCliArgs {
reactor_mask: "0x2".to_string(),
skip_sig_handler: true,
Expand Down
60 changes: 29 additions & 31 deletions io-engine/src/bin/initiator.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
//! Command line test utility to copy bytes to/from a replica which can be any
//! target type understood by the nexus.
extern crate clap;
#[macro_use]
extern crate tracing;

use std::{
fmt,
fs,
io::{self, Write},
};

use clap::{App, Arg, SubCommand};

use chrono::Utc;
use clap::{Arg, Command};
use tracing::{error, info, warn};
use uuid::Uuid;
use version_info::version_info_str;

use io_engine::{
bdev::{device_create, device_open},
bdev_api::{bdev_create, BdevError},
Expand All @@ -32,8 +31,6 @@ use io_engine::{
subsys::Config,
};
use spdk_rs::DmaError;
use uuid::Uuid;
use version_info::version_info_str;

unsafe extern "C" fn run_static_initializers() {
spdk_rs::libspdk::spdk_add_subsystem(subsys::ConfigSubsystem::new().0)
Expand Down Expand Up @@ -167,53 +164,52 @@ async fn connect(uri: &str) -> Result<()> {
}

fn main() {
let matches = App::new("Test initiator for nexus replica")
let matches = Command::new("Test initiator for nexus replica")
.version(version_info_str!())
.about("Connect, read or write a block to a nexus replica using its URI")
.arg(Arg::with_name("URI")
.arg(Arg::new("URI")
.help("URI of the replica to connect to")
.required(true)
.index(1))
.arg(Arg::with_name("offset")
.short("o")
.arg(Arg::new("offset")
.short('o')
.long("offset")
.value_name("NUMBER")
.help("Offset of IO operation on the replica in bytes (default 0)")
.takes_value(true))
.subcommand(SubCommand::with_name("connect")
.help("Offset of IO operation on the replica in bytes (default 0)"))
.subcommand(Command::new("connect")
.about("Connect to and disconnect from the replica"))
.subcommand(SubCommand::with_name("read")
.subcommand(Command::new("read")
.about("Read bytes from the replica")
.arg(Arg::with_name("FILE")
.arg(Arg::new("FILE")
.help("File to write data that were read from the replica")
.required(true)
.index(1)))
.subcommand(SubCommand::with_name("write")
.subcommand(Command::new("write")
.about("Write bytes to the replica")
.arg(Arg::with_name("FILE")
.arg(Arg::new("FILE")
.help("File to read data from that will be written to the replica")
.required(true)
.index(1)))
.subcommand(SubCommand::with_name("nvme-admin")
.subcommand(Command::new("nvme-admin")
.about("Send a custom NVMe Admin command")
.arg(Arg::with_name("opcode")
.arg(Arg::new("opcode")
.help("Admin command opcode to send")
.required(true)
.index(1)))
.subcommand(SubCommand::with_name("id-ctrlr")
.subcommand(Command::new("id-ctrlr")
.about("Send NVMe Admin identify controller command")
.arg(Arg::with_name("FILE")
.arg(Arg::new("FILE")
.help("File to write output of identify controller command")
.required(true)
.index(1)))
.subcommand(SubCommand::with_name("create-snapshot")
.subcommand(Command::new("create-snapshot")
.about("Create a snapshot on the replica"))
.get_matches();
.subcommand_required(true).subcommand_required(true).get_matches();

logger::init("INFO");

let uri = matches.value_of("URI").unwrap().to_owned();
let offset: u64 = match matches.value_of("offset") {
let uri = matches.get_one::<String>("URI").unwrap().to_owned();
let offset: u64 = match matches.get_one::<String>("offset") {
Some(val) => val.parse().expect("Offset must be a number"),
None => 0,
};
Expand All @@ -230,17 +226,19 @@ fn main() {
ms.init();
let fut = async move {
let res = if let Some(matches) = matches.subcommand_matches("read") {
read(&uri, offset, matches.value_of("FILE").unwrap()).await
read(&uri, offset, matches.get_one::<String>("FILE").unwrap()).await
} else if let Some(matches) = matches.subcommand_matches("write") {
write(&uri, offset, matches.value_of("FILE").unwrap()).await
write(&uri, offset, matches.get_one::<String>("FILE").unwrap())
.await
} else if let Some(matches) = matches.subcommand_matches("nvme-admin") {
let opcode: u8 = match matches.value_of("opcode") {
let opcode: u8 = match matches.get_one::<String>("opcode") {
Some(val) => val.parse().expect("Opcode must be a number"),
None => 0,
};
nvme_admin(&uri, opcode).await
} else if let Some(matches) = matches.subcommand_matches("id-ctrlr") {
identify_ctrlr(&uri, matches.value_of("FILE").unwrap()).await
identify_ctrlr(&uri, matches.get_one::<String>("FILE").unwrap())
.await
} else if matches.subcommand_matches("create-snapshot").is_some() {
create_snapshot(&uri).await
} else {
Expand Down
14 changes: 7 additions & 7 deletions io-engine/src/bin/io-engine-client/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,24 +109,24 @@ pub struct Context {
pub(crate) bdev: BdevClient,
pub(crate) json: JsonClient,
pub(crate) v1: v1::Context,
verbosity: u64,
verbosity: u8,
units: char,
pub(crate) output: OutputFormat,
}

impl Context {
pub(crate) async fn new(matches: &ArgMatches<'_>) -> Result<Self, Error> {
let verbosity = if matches.is_present("quiet") {
pub(crate) async fn new(matches: &ArgMatches) -> Result<Self, Error> {
let verbosity = if matches.get_flag("quiet") {
0
} else {
matches.occurrences_of("verbose") + 1
matches.get_count("verbose") + 1
};
let units = matches
.value_of("units")
.get_one::<String>("units")
.and_then(|u| u.chars().next())
.unwrap_or('b');
// Ensure the provided host is defaulted & normalized to what we expect.
let host = if let Some(host) = matches.value_of("bind") {
let host = if let Some(host) = matches.get_one::<String>("bind") {
let uri = host.parse::<Uri>().context(InvalidUri)?;
let mut parts = uri.into_parts();
if parts.scheme.is_none() {
Expand All @@ -153,7 +153,7 @@ impl Context {
println!("Connecting to {:?}", host.uri());
}

let output = matches.value_of("output").ok_or_else(|| {
let output = matches.get_one::<String>("output").ok_or_else(|| {
Error::OutputFormatInvalid {
format: "<none>".to_string(),
}
Expand Down
2 changes: 1 addition & 1 deletion io-engine/src/bin/io-engine-client/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub enum ClientError {
MissingValue { field: String },
}

pub type Result<T, E = ClientError> = std::result::Result<T, E>;
type Result<T, E = ClientError> = std::result::Result<T, E>;

pub(crate) fn parse_size(src: &str) -> Result<Byte, String> {
Byte::from_str(src).map_err(|_| src.to_string())
Expand Down
Loading

0 comments on commit c89271c

Please sign in to comment.