@@ -249,11 +249,23 @@ pub struct MayastorCliArgs {
249
249
/// LVM pools can then be created by specifying the LVM pool type.
250
250
/// If LVM is enabled and LVM_SUPPRESS_FD_WARNINGS is not set then it will
251
251
/// be set to 1.
252
- #[ clap( long = "enable-lvm" , env = "ENABLE_LVM" ) ]
252
+ #[ clap( long = "enable-lvm" , env = "ENABLE_LVM" , value_parser = delay_compat ) ]
253
253
pub lvm : bool ,
254
254
/// Enables experimental Snapshot Rebuild support.
255
- #[ clap( long = "enable-snapshot-rebuild" , env = "ENABLE_SNAPSHOT_REBUILD" ) ]
255
+ #[ clap( long = "enable-snapshot-rebuild" , env = "ENABLE_SNAPSHOT_REBUILD" , value_parser = delay_compat ) ]
256
256
pub snap_rebuild : bool ,
257
+ /// Reactors sleep 1ms before each poll.
258
+ /// # Warning: Don't use this in production.
259
+ #[ clap( long, env = "MAYASTOR_DELAY" , hide = true , value_parser = delay_compat) ]
260
+ pub developer_delay : bool ,
261
+ }
262
+
263
+ fn delay_compat ( s : & str ) -> Result < bool , String > {
264
+ match s {
265
+ "1" | "true" => Ok ( true ) ,
266
+ "" | "0" | "false" => Ok ( false ) ,
267
+ _else => Err ( format ! ( "Must be one of: 1,true,0,false" ) ) ,
268
+ }
257
269
}
258
270
259
271
/// Mayastor features.
@@ -312,6 +324,7 @@ impl Default for MayastorCliArgs {
312
324
enable_nexus_channel_debug : false ,
313
325
lvm : false ,
314
326
snap_rebuild : false ,
327
+ developer_delay : false ,
315
328
}
316
329
}
317
330
}
@@ -411,6 +424,7 @@ pub struct MayastorEnvironment {
411
424
api_versions : Vec < ApiVersion > ,
412
425
skip_sig_handler : bool ,
413
426
enable_io_all_thrd_nexus_channels : bool ,
427
+ developer_delay : bool ,
414
428
}
415
429
416
430
impl Default for MayastorEnvironment {
@@ -458,6 +472,7 @@ impl Default for MayastorEnvironment {
458
472
api_versions : vec ! [ ApiVersion :: V0 , ApiVersion :: V1 ] ,
459
473
skip_sig_handler : false ,
460
474
enable_io_all_thrd_nexus_channels : false ,
475
+ developer_delay : false ,
461
476
}
462
477
}
463
478
}
@@ -562,7 +577,8 @@ struct SubsystemCtx {
562
577
563
578
static MAYASTOR_FEATURES : OnceCell < MayastorFeatures > = OnceCell :: new ( ) ;
564
579
565
- static MAYASTOR_DEFAULT_ENV : OnceCell < MayastorEnvironment > = OnceCell :: new ( ) ;
580
+ static MAYASTOR_DEFAULT_ENV : OnceCell < parking_lot:: Mutex < MayastorEnvironment > > =
581
+ OnceCell :: new ( ) ;
566
582
567
583
impl MayastorEnvironment {
568
584
pub fn new ( args : MayastorCliArgs ) -> Self {
@@ -597,6 +613,7 @@ impl MayastorEnvironment {
597
613
nvmf_tgt_crdt : args. nvmf_tgt_crdt ,
598
614
api_versions : args. api_versions ,
599
615
skip_sig_handler : args. skip_sig_handler ,
616
+ developer_delay : args. developer_delay ,
600
617
enable_io_all_thrd_nexus_channels : args
601
618
. enable_io_all_thrd_nexus_channels ,
602
619
..Default :: default ( )
@@ -610,15 +627,23 @@ impl MayastorEnvironment {
610
627
}
611
628
612
629
fn setup_static ( self ) -> Self {
613
- MAYASTOR_DEFAULT_ENV . get_or_init ( || self . clone ( ) ) ;
630
+ match MAYASTOR_DEFAULT_ENV . get ( ) {
631
+ None => {
632
+ MAYASTOR_DEFAULT_ENV
633
+ . get_or_init ( || parking_lot:: Mutex :: new ( self . clone ( ) ) ) ;
634
+ }
635
+ Some ( some) => {
636
+ * some. lock ( ) = self . clone ( ) ;
637
+ }
638
+ }
614
639
self
615
640
}
616
641
617
642
/// Get the global environment (first created on new)
618
643
/// or otherwise the default one (used by the tests)
619
644
pub fn global_or_default ( ) -> Self {
620
645
match MAYASTOR_DEFAULT_ENV . get ( ) {
621
- Some ( env) => env. clone ( ) ,
646
+ Some ( env) => env. lock ( ) . clone ( ) ,
622
647
None => MayastorEnvironment :: default ( ) ,
623
648
}
624
649
}
@@ -913,9 +938,9 @@ impl MayastorEnvironment {
913
938
}
914
939
}
915
940
916
- /// load the config and apply it before any subsystems have started.
941
+ /// Load the config and apply it before any subsystems have started.
917
942
/// there is currently no run time check that enforces this.
918
- fn load_yaml_config ( & self ) {
943
+ fn load_yaml_config ( & mut self ) {
919
944
let cfg = if let Some ( yaml) = & self . mayastor_config {
920
945
info ! ( "loading mayastor config YAML file {}" , yaml) ;
921
946
Config :: get_or_init ( || {
@@ -930,6 +955,19 @@ impl MayastorEnvironment {
930
955
Config :: get_or_init ( Config :: default)
931
956
} ;
932
957
cfg. apply ( ) ;
958
+ if let Some ( mask) = cfg. eal_opts . reactor_mask . as_ref ( ) {
959
+ self . reactor_mask = mask. clone ( ) ;
960
+ }
961
+ if cfg. eal_opts . core_list . is_some ( ) {
962
+ self . core_list = cfg. eal_opts . core_list . clone ( ) ;
963
+ }
964
+ if let Some ( delay) = cfg. eal_opts . developer_delay {
965
+ self . developer_delay = delay;
966
+ }
967
+ if let Some ( interface) = & cfg. nvmf_tcp_tgt_conf . interface {
968
+ self . nvmf_tgt_interface = Some ( interface. clone ( ) ) ;
969
+ }
970
+ self . clone ( ) . setup_static ( ) ;
933
971
}
934
972
935
973
/// load the pool config file.
@@ -991,7 +1029,7 @@ impl MayastorEnvironment {
991
1029
}
992
1030
993
1031
// allocate a Reactor per core
994
- Reactors :: init ( ) ;
1032
+ Reactors :: init ( self . developer_delay ) ;
995
1033
996
1034
// launch the remote cores if any. note that during init these have to
997
1035
// be running as during setup cross call will take place.
0 commit comments