From cd48f00191cc2a6d168c1255037b598499f73a3a Mon Sep 17 00:00:00 2001 From: Ming-Hung Tsai Date: Wed, 23 Jun 2021 11:40:12 +0800 Subject: [PATCH] [all (rust)] Make sync-io the default Multithreaded sync-io has performance similar to async-io. Also, sync-io saves the hassle of setting ulimits to get io_uring working on some systems (commit ba7fd7b). Now we default to sync-io, and leave async-io as a hidden option for testing and benchmarking. --- src/bin/cache_check.rs | 8 +++++++- src/bin/cache_dump.rs | 8 +++++++- src/bin/cache_restore.rs | 13 +++++++------ src/bin/thin_check.rs | 21 ++++++--------------- src/bin/thin_dump.rs | 13 +++++++------ src/bin/thin_restore.rs | 13 +++++++------ 6 files changed, 41 insertions(+), 35 deletions(-) diff --git a/src/bin/cache_check.rs b/src/bin/cache_check.rs index 4db7e9b..f266161 100644 --- a/src/bin/cache_check.rs +++ b/src/bin/cache_check.rs @@ -14,6 +14,12 @@ use thinp::report::*; fn main() { let parser = App::new("cache_check") .version(thinp::version::tools_version()) + .arg( + Arg::with_name("ASYNC_IO") + .help("Force use of io_uring for synchronous io") + .long("async-io") + .hidden(true), + ) .arg( Arg::with_name("INPUT") .help("Specify the input device to check") @@ -75,7 +81,7 @@ fn main() { let opts = CacheCheckOptions { dev: &input_file, - async_io: false, + async_io: matches.is_present("ASYNC_IO"), sb_only: matches.is_present("SB_ONLY"), skip_mappings: matches.is_present("SKIP_MAPPINGS"), skip_hints: matches.is_present("SKIP_HINTS"), diff --git a/src/bin/cache_dump.rs b/src/bin/cache_dump.rs index e706f0b..be6ceca 100644 --- a/src/bin/cache_dump.rs +++ b/src/bin/cache_dump.rs @@ -11,6 +11,12 @@ fn main() { let parser = App::new("cache_dump") .version(thinp::version::tools_version()) .about("Dump the cache metadata to stdout in XML format") + .arg( + Arg::with_name("ASYNC_IO") + .help("Force use of io_uring for synchronous io") + .long("async-io") + .hidden(true), + ) .arg( Arg::with_name("REPAIR") .help("Repair the metadata whilst dumping it") @@ -42,7 +48,7 @@ fn main() { let opts = CacheDumpOptions { input: input_file, output: output_file, - async_io: false, + async_io: matches.is_present("ASYNC_IO"), repair: matches.is_present("REPAIR"), }; diff --git a/src/bin/cache_restore.rs b/src/bin/cache_restore.rs index 9375c91..d5eda5e 100644 --- a/src/bin/cache_restore.rs +++ b/src/bin/cache_restore.rs @@ -15,6 +15,12 @@ fn main() { let parser = App::new("cache_restore") .version(thinp::version::tools_version()) .about("Convert XML format metadata to binary.") + .arg( + Arg::with_name("ASYNC_IO") + .help("Force use of io_uring for synchronous io") + .long("async-io") + .hidden(true), + ) .arg( Arg::with_name("OVERRIDE_MAPPING_ROOT") .help("Specify a mapping root to use") @@ -37,11 +43,6 @@ fn main() { .long("output") .value_name("OUTPUT") .required(true), - ) - .arg( - Arg::with_name("SYNC_IO") - .help("Force use of synchronous io") - .long("sync-io"), ); let matches = parser.get_matches(); @@ -66,7 +67,7 @@ fn main() { let opts = CacheRestoreOptions { input: &input_file, output: &output_file, - async_io: !matches.is_present("SYNC_IO"), + async_io: matches.is_present("ASYNC_IO"), report, }; diff --git a/src/bin/thin_check.rs b/src/bin/thin_check.rs index 2298ce9..c3ab573 100644 --- a/src/bin/thin_check.rs +++ b/src/bin/thin_check.rs @@ -16,6 +16,12 @@ fn main() { let parser = App::new("thin_check") .version(thinp::version::tools_version()) .about("Validates thin provisioning metadata on a device or file.") + .arg( + Arg::with_name("ASYNC_IO") + .help("Force use of io_uring for synchronous io") + .long("async-io") + .hidden(true), + ) .arg( Arg::with_name("QUIET") .help("Suppress output messages, return only exit code.") @@ -66,16 +72,6 @@ fn main() { .help("Specify the input device to check") .required(true) .index(1), - ) - .arg( - Arg::with_name("ASYNC_IO") - .help("Force use of io_uring for asynchronous IO") - .long("async-io"), - ) - .arg( - Arg::with_name("SYNC_IO") - .help("Force use of synchronous IO (currently the default)") - .long("sync-io"), ); let matches = parser.get_matches(); @@ -96,11 +92,6 @@ fn main() { report = Arc::new(mk_simple_report()); } - if matches.is_present("SYNC_IO") && matches.is_present("ASYNC_IO") { - eprintln!("--sync-io and --async-io may not be used at the same time."); - process::exit(1); - } - let engine: Arc; if matches.is_present("ASYNC_IO") { diff --git a/src/bin/thin_dump.rs b/src/bin/thin_dump.rs index b9f08d0..af238dd 100644 --- a/src/bin/thin_dump.rs +++ b/src/bin/thin_dump.rs @@ -15,6 +15,12 @@ fn main() { let parser = App::new("thin_dump") .version(thinp::version::tools_version()) .about("Dump thin-provisioning metadata to stdout in XML format") + .arg( + Arg::with_name("ASYNC_IO") + .help("Force use of io_uring for synchronous io") + .long("async-io") + .hidden(true), + ) .arg( Arg::with_name("QUIET") .help("Suppress output messages, return only exit code.") @@ -32,11 +38,6 @@ fn main() { .help("Do not dump the mappings") .long("skip-mappings"), ) - .arg( - Arg::with_name("SYNC_IO") - .help("Force use of synchronous io") - .long("sync-io"), - ) .arg( Arg::with_name("METADATA_SNAPSHOT") .help("Access the metadata snapshot on a live pool") @@ -84,7 +85,7 @@ fn main() { let opts = ThinDumpOptions { input: input_file, output: output_file, - async_io: !matches.is_present("SYNC_IO"), + async_io: matches.is_present("ASYNC_IO"), report, }; diff --git a/src/bin/thin_restore.rs b/src/bin/thin_restore.rs index 243f3a4..8654613 100644 --- a/src/bin/thin_restore.rs +++ b/src/bin/thin_restore.rs @@ -15,6 +15,12 @@ fn main() { let parser = App::new("thin_restore") .version(thinp::version::tools_version()) .about("Convert XML format metadata to binary.") + .arg( + Arg::with_name("ASYNC_IO") + .help("Force use of io_uring for synchronous io") + .long("async-io") + .hidden(true), + ) .arg( Arg::with_name("OVERRIDE_MAPPING_ROOT") .help("Specify a mapping root to use") @@ -37,11 +43,6 @@ fn main() { .long("output") .value_name("OUTPUT") .required(true), - ) - .arg( - Arg::with_name("SYNC_IO") - .help("Force use of synchronous io") - .long("sync-io"), ); let matches = parser.get_matches(); @@ -66,7 +67,7 @@ fn main() { let opts = ThinRestoreOptions { input: &input_file, output: &output_file, - async_io: !matches.is_present("SYNC_IO"), + async_io: matches.is_present("ASYNC_IO"), report, };