forked from openzfs/zfs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openzfs#455 from delphix/projects/merge-upstream/m…
…aster Merge remote-tracking branch '6.0/stage' into 'master'
- Loading branch information
Showing
10 changed files
with
259 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//! `zcache expand` subcommand | ||
use std::path::PathBuf; | ||
|
||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
use clap::Parser; | ||
use util::message::ExpandDiskRequest; | ||
use util::message::ExpandDiskResponse; | ||
use util::message::TYPE_EXPAND_DISK; | ||
use util::nice_p2size; | ||
use util::writeln_stdout; | ||
|
||
use crate::remote_channel::RemoteChannel; | ||
use crate::subcommand::ZcacheSubCommand; | ||
|
||
#[derive(Parser)] | ||
#[clap(about = "Expand a disk in the ZettaCache.")] | ||
pub struct Expand { | ||
path: PathBuf, | ||
} | ||
|
||
#[async_trait] | ||
impl ZcacheSubCommand for Expand { | ||
async fn invoke(&self) -> Result<()> { | ||
let mut remote = RemoteChannel::new(true).await?; | ||
|
||
let request = ExpandDiskRequest { | ||
path: self.path.clone(), | ||
}; | ||
|
||
let nvlist = remote | ||
.call(TYPE_EXPAND_DISK, Some(nvpair::to_nvlist(&request).unwrap())) | ||
.await?; | ||
let response: ExpandDiskResponse = nvpair::from_nvlist(&nvlist)?; | ||
if response.additional_bytes > 0 { | ||
writeln_stdout!( | ||
"Disk {:?} expanded, new size {} (added {})", | ||
self.path, | ||
nice_p2size(response.new_size), | ||
nice_p2size(response.additional_bytes) | ||
); | ||
} else { | ||
writeln_stdout!( | ||
"Disk {:?} expansion not needed, size {}", | ||
self.path, | ||
nice_p2size(response.new_size) | ||
); | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.