Skip to content

Commit

Permalink
feat(lvs): adding support for pool grow and related tests
Browse files Browse the repository at this point in the history
* Pool grow API support added to LVS.
* Additional pool stats added.
* Added support for MD reservation hint.
* Related CLI subcommand added. 'pool list' subcommand extended to
  print additional pool info.
* Related tests added.
* For testing purposes, a non-safe support for resizing malloc bdev added.
* To simplify adding new pool and replica parameters, LVS inner create-related
  APIs refactored to accept parameters via PoolArgs and ReplicaArgs instead
  of function arguments.
* Added a example tool (lvs-eval) that creates an LVS with the given
  parameters and prints it internal configuration (allocated clusters,
  extent pages, etc.)

Signed-off-by: Dmitry Savitskiy <[email protected]>
  • Loading branch information
dsavitskiy committed Aug 30, 2024
1 parent c661e1b commit cde38b5
Show file tree
Hide file tree
Showing 33 changed files with 1,379 additions and 151 deletions.
101 changes: 101 additions & 0 deletions Cargo.lock

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

31 changes: 29 additions & 2 deletions io-engine-tests/src/bdev.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
use super::compose::rpc::v1::{
bdev::{Bdev, ListBdevOptions},
bdev::{Bdev, CreateBdevRequest, ListBdevOptions},
SharedRpcHandle,
Status,
};

pub async fn list_bdevs(rpc: &SharedRpcHandle) -> Result<Vec<Bdev>, Status> {
/// Creates a bdev.
pub async fn create_bdev(
rpc: SharedRpcHandle,
uri: &str,
) -> Result<Bdev, Status> {
rpc.lock()
.await
.bdev
.create(CreateBdevRequest {
uri: uri.to_string(),
})
.await
.map(|r| r.into_inner().bdev.unwrap())
}

/// Lists bdevs.
pub async fn list_bdevs(rpc: SharedRpcHandle) -> Result<Vec<Bdev>, Status> {
rpc.lock()
.await
.bdev
Expand All @@ -14,3 +30,14 @@ pub async fn list_bdevs(rpc: &SharedRpcHandle) -> Result<Vec<Bdev>, Status> {
.await
.map(|r| r.into_inner().bdevs)
}

/// Finds a bdev by its name.
pub async fn find_bdev_by_name(
rpc: SharedRpcHandle,
name: &str,
) -> Option<Bdev> {
match list_bdevs(rpc).await {
Err(_) => None,
Ok(nn) => nn.into_iter().find(|p| p.name == name),
}
}
9 changes: 8 additions & 1 deletion io-engine-tests/src/compose/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,15 @@ impl<'a> MayastorTest<'a> {
}

pub fn new(args: MayastorCliArgs) -> MayastorTest<'static> {
Self::new_ex(args, None)
}

pub fn new_ex(
args: MayastorCliArgs,
log_level: Option<&str>,
) -> MayastorTest<'static> {
let (tx, rx) = bounded(1);
mayastor_test_init_ex(args.log_format.unwrap_or_default());
mayastor_test_init_ex(args.log_format.unwrap_or_default(), log_level);
let thdl = std::thread::Builder::new()
.name("mayastor_master".into())
.spawn(move || {
Expand Down
10 changes: 7 additions & 3 deletions io-engine-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ macro_rules! test_init {
}

pub fn mayastor_test_init() {
mayastor_test_init_ex(LogFormat::default());
mayastor_test_init_ex(LogFormat::default(), None);
}

pub fn mayastor_test_init_ex(log_format: LogFormat) {
pub fn mayastor_test_init_ex(log_format: LogFormat, log_level: Option<&str>) {
fn binary_present(name: &str) -> Result<bool, std::env::VarError> {
std::env::var("PATH").map(|paths| {
paths
Expand All @@ -151,7 +151,11 @@ pub fn mayastor_test_init_ex(log_format: LogFormat) {
}
});

logger::init_ex("info,io_engine=DEBUG", log_format, None);
logger::init_ex(
log_level.unwrap_or("info,io_engine=DEBUG"),
log_format,
None,
);

io_engine::CPS_INIT!();
}
Expand Down
21 changes: 20 additions & 1 deletion io-engine-tests/src/pool.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub use super::compose::rpc::v1::pool::Pool;
use super::{
compose::rpc::v1::{
pool::{CreatePoolRequest, ListPoolOptions},
pool::{CreatePoolRequest, GrowPoolRequest, ListPoolOptions},
replica::{ListReplicaOptions, Replica},
SharedRpcHandle,
Status,
Expand Down Expand Up @@ -190,6 +190,7 @@ impl PoolBuilderRpc {
.with_malloc_blk_size(bdev_name, size_mb, blk_size);
self
}

pub async fn create(&mut self) -> Result<Pool, Status> {
self.rpc()
.lock()
Expand All @@ -201,11 +202,28 @@ impl PoolBuilderRpc {
pooltype: 0,
disks: vec![self.bdev.as_ref().unwrap().clone()],
cluster_size: None,
md_args: None,
})
.await
.map(|r| r.into_inner())
}

pub async fn grow(&mut self) -> Result<(Pool, Pool), Status> {
self.rpc()
.lock()
.await
.pool
.grow_pool(GrowPoolRequest {
name: self.name(),
uuid: Some(self.uuid()),
})
.await
.map(|r| {
let t = r.into_inner();
(t.previous_pool.unwrap(), t.current_pool.unwrap())
})
}

pub async fn get_pool(&self) -> Result<Pool, Status> {
let uuid = self.uuid();
list_pools(self.rpc())
Expand Down Expand Up @@ -263,6 +281,7 @@ impl PoolBuilderLocal {
uuid: Some(self.uuid()),
disks: vec![self.bdev.as_ref().unwrap().clone()],
cluster_size: None,
md_args: None,
backend: Default::default(),
})
.await?;
Expand Down
5 changes: 5 additions & 0 deletions io-engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ path = "src/bin/jsonrpc.rs"
name = "casperf"
path = "src/bin/casperf.rs"

[[example]]
name = "lvs-eval"
path = "examples/lvs-eval/main.rs"

[dependencies]
ansi_term = "0.12.1"
async-channel = "1.9.0"
Expand Down Expand Up @@ -125,4 +129,5 @@ version = "1.4.1"
assert_matches = "1.5.0"
io-engine-tests = { path = "../io-engine-tests" }
libnvme-rs = { path = "../libnvme-rs", version = "0.1.0" }
prettytable-rs = "0.10.0"
run_script = "0.10.1"
Loading

0 comments on commit cde38b5

Please sign in to comment.