@@ -34,10 +34,10 @@ pub fn subcommands() -> Command {
3434 . help ( "SPDK cluster size" ) ,
3535 )
3636 . arg (
37- Arg :: new ( "md-resv-ratio " )
38- . long ( "md-resv-ratio " )
37+ Arg :: new ( "max-expansion " )
38+ . long ( "max-expansion " )
3939 . required ( false )
40- . help ( "Metadata reservation ratio " ) ,
40+ . help ( "Max expected expansion in factor or absolute size " ) ,
4141 )
4242 . arg (
4343 Arg :: new ( "disk" )
@@ -184,8 +184,8 @@ pub fn subcommands() -> Command {
184184 . default_value ( PoolType :: Lvs . as_ref ( ) ) ,
185185 ) ;
186186
187- let grow = Command :: new ( "grow " )
188- . about ( "Grow a storage pool to fill the entire underlying device" )
187+ let expand = Command :: new ( "expand " )
188+ . about ( "Expand a storage pool to span the entire underlying device" )
189189 . arg (
190190 Arg :: new ( "name" )
191191 . required ( true )
@@ -230,7 +230,7 @@ pub fn subcommands() -> Command {
230230 . subcommand ( import)
231231 . subcommand ( destroy)
232232 . subcommand ( export)
233- . subcommand ( grow )
233+ . subcommand ( expand )
234234 . subcommand ( list)
235235}
236236
@@ -240,7 +240,7 @@ pub async fn handler(ctx: Context, matches: &ArgMatches) -> crate::Result<()> {
240240 ( "import" , args) => import ( ctx, args) . await ,
241241 ( "destroy" , args) => destroy ( ctx, args) . await ,
242242 ( "export" , args) => export ( ctx, args) . await ,
243- ( "grow " , args) => grow ( ctx, args) . await ,
243+ ( "expand " , args) => expand ( ctx, args) . await ,
244244 ( "list" , args) => list ( ctx, args) . await ,
245245 ( cmd, _) => {
246246 Err ( Status :: not_found ( format ! ( "command {cmd} does not exist" ) ) ) . context ( GrpcStatus )
@@ -297,8 +297,8 @@ async fn create(mut ctx: Context, matches: &ArgMatches) -> crate::Result<()> {
297297 None => None ,
298298 } ;
299299
300- let md_resv_ratio = match matches. get_one :: < String > ( "md-resv-ratio " ) {
301- Some ( s) => match s. parse :: < f32 > ( ) {
300+ let max_expansion = match matches. get_one :: < String > ( "max-expansion " ) {
301+ Some ( s) => match s. parse :: < String > ( ) {
302302 Ok ( v) => Some ( v) ,
303303 Err ( err) => {
304304 return Err ( Status :: invalid_argument ( format ! (
@@ -336,7 +336,10 @@ async fn create(mut ctx: Context, matches: &ArgMatches) -> crate::Result<()> {
336336 disks : disks_list,
337337 pooltype : v1rpc:: pool:: PoolType :: from ( pooltype) as i32 ,
338338 cluster_size,
339- md_args : Some ( v1rpc:: pool:: PoolMetadataArgs { md_resv_ratio } ) ,
339+ md_args : Some ( v1rpc:: pool:: PoolMetadataArgs {
340+ md_resv_ratio : None ,
341+ max_expansion,
342+ } ) ,
340343 encryption : enc_msg,
341344 } )
342345 . await
@@ -537,7 +540,7 @@ async fn export(mut ctx: Context, matches: &ArgMatches) -> crate::Result<()> {
537540 Ok ( ( ) )
538541}
539542
540- async fn grow ( mut ctx : Context , matches : & ArgMatches ) -> crate :: Result < ( ) > {
543+ async fn expand ( mut ctx : Context , matches : & ArgMatches ) -> crate :: Result < ( ) > {
541544 let name = matches
542545 . get_one :: < String > ( "name" )
543546 . ok_or_else ( || ClientError :: MissingValue {
@@ -546,24 +549,55 @@ async fn grow(mut ctx: Context, matches: &ArgMatches) -> crate::Result<()> {
546549 . to_owned ( ) ;
547550 let uuid = matches. get_one :: < String > ( "uuid" ) . cloned ( ) ;
548551
549- let response = ctx
552+ let pooltype = matches
553+ . get_one :: < String > ( "type" )
554+ . map ( |s| PoolType :: from_str ( s. as_str ( ) ) )
555+ . transpose ( )
556+ . map_err ( |e| Status :: invalid_argument ( e. to_string ( ) ) )
557+ . context ( GrpcStatus ) ?;
558+
559+ let list_response = ctx
560+ . v1
561+ . pool
562+ . list_pools ( v1rpc:: pool:: ListPoolOptions {
563+ name : Some ( name. clone ( ) ) ,
564+ pooltype : pooltype. map ( |pooltype| v1rpc:: pool:: PoolTypeValue {
565+ value : v1rpc:: pool:: PoolType :: from ( pooltype) as i32 ,
566+ } ) ,
567+ uuid : None ,
568+ } )
569+ . await
570+ . context ( GrpcStatus ) ?;
571+
572+ if list_response. get_ref ( ) . pools . is_empty ( ) {
573+ return Err ( ClientError :: GrpcStatus {
574+ source : Status :: not_found ( format ! ( "Pool {name} not found" ) ) ,
575+ backtrace : None ,
576+ } ) ;
577+ }
578+
579+ let pool = & list_response. get_ref ( ) . pools [ 0 ] ;
580+ let previous_capacity = pool. capacity ;
581+
582+ let grow_response = ctx
550583 . v1
551584 . pool
552- . grow_pool ( v1rpc:: pool:: GrowPoolRequest {
585+ . grow_pool_v2 ( v1rpc:: pool:: GrowPoolRequest {
553586 name : name. clone ( ) ,
554587 uuid,
555588 } )
556589 . await
557590 . context ( GrpcStatus ) ?;
558591
559- let old_cap = response . get_ref ( ) . previous_pool . as_ref ( ) . unwrap ( ) . capacity ;
560- let new_cap = response . get_ref ( ) . current_pool . as_ref ( ) . unwrap ( ) . capacity ;
592+ let pool = & grow_response . get_ref ( ) ;
593+ let current_capacity = pool . capacity ;
561594
562- if old_cap == new_cap {
563- println ! ( "Pool capacity did not change: {new_cap} bytes" ) ;
564- } else {
565- println ! ( "Pool capacity was {old_cap}, now {new_cap} bytes" ) ;
566- }
595+ match ctx. output {
596+ OutputFormat :: Json => { }
597+ OutputFormat :: Default => {
598+ println ! ( "pool expanded from {previous_capacity} to {current_capacity}" ) ;
599+ }
600+ } ;
567601
568602 Ok ( ( ) )
569603}
0 commit comments