-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathznsmaxappendtest.rs
More file actions
49 lines (41 loc) · 1.26 KB
/
znsmaxappendtest.rs
File metadata and controls
49 lines (41 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use clap::Parser;
use nvme::types::PerformOn;
use std::io::ErrorKind;
#[derive(Parser, Debug)]
#[command(author, version, about)]
struct Cli {
#[arg(long)]
device: String,
}
/// Tests size where appends begin to fail
fn main() -> std::io::Result<()> {
let args = Cli::parse();
let nvme_config = match nvme::info::nvme_get_info(args.device.as_str()) {
Ok(config) => config,
Err(err) => return Err(err.try_into().unwrap()),
};
let zc = match nvme::info::zns_get_info(&nvme_config) {
Ok(config) => config,
Err(err) => return Err(std::io::Error::new(ErrorKind::Other, err)),
};
let stop = 1024 * 1024 * 1024;
let mut start = 64 * 1024;
loop {
nvme::ops::reset_zone(&nvme_config, &zc, PerformOn::AllZones).unwrap();
let data: Vec<u8> = vec![0; start];
match nvme::ops::zns_append(&nvme_config, &zc, 0, data.as_slice()) {
Ok(_res) => {
println!("Wrote {} bytes", start);
}
Err(err) => {
println!("Failed to write {} bytes", start);
return Err(std::io::Error::new(ErrorKind::Other, err));
}
}
start *= 2;
if start >= stop {
break;
}
}
Ok(())
}