@@ -272,6 +272,12 @@ impl LiveRepairData {
272
272
}
273
273
}
274
274
275
+ #[ derive( Debug ) ]
276
+ pub ( crate ) struct CollateData {
277
+ max_flush : u64 ,
278
+ max_gen : u64 ,
279
+ }
280
+
275
281
#[ derive( Debug ) ]
276
282
pub ( crate ) struct ReconcileData {
277
283
/// An ID uniquely identifying this reconciliation
@@ -862,27 +868,15 @@ impl Downstairs {
862
868
///
863
869
/// Returns `true` if repair is needed, `false` otherwise
864
870
pub ( crate ) fn collate ( & mut self ) -> Result < bool , NegotiationError > {
865
- let r = self . collate_inner ( ) ;
866
- if r. is_err ( ) {
867
- // If we failed to begin the repair, then assert that nothing has
868
- // changed and everything is empty.
869
- assert ! ( self . ds_active. is_empty( ) ) ;
870
- assert ! ( self . reconcile. is_none( ) ) ;
871
-
872
- for c in self . clients . iter ( ) {
873
- assert_eq ! (
874
- c. state( ) ,
875
- DsState :: Connecting {
876
- state: NegotiationState :: WaitQuorum ,
877
- mode: ConnectionMode :: New
878
- }
879
- ) ;
880
- }
881
- }
882
- r
871
+ let r = self . check_region_metadata ( ) ?;
872
+ Ok ( self . start_reconciliation ( r) )
883
873
}
884
874
885
- fn collate_inner ( & mut self ) -> Result < bool , NegotiationError > {
875
+ /// Checks that region metadata is valid
876
+ ///
877
+ /// # Panics
878
+ /// If no regions are in `NegotiationState::WaitQuorum`
879
+ fn check_region_metadata ( & self ) -> Result < CollateData , NegotiationError > {
886
880
/*
887
881
* Show some (or all if small) of the info from each region.
888
882
*
@@ -961,6 +955,14 @@ impl Downstairs {
961
955
) ;
962
956
}
963
957
958
+ Ok ( CollateData { max_flush, max_gen } )
959
+ }
960
+
961
+ /// Begins reconciliation, using the given collation data
962
+ #[ must_use]
963
+ fn start_reconciliation ( & mut self , data : CollateData ) -> bool {
964
+ let CollateData { max_flush, max_gen } = data;
965
+
964
966
/*
965
967
* Set the next flush ID so we have if we need to repair.
966
968
*/
@@ -995,10 +997,10 @@ impl Downstairs {
995
997
self . reconcile = Some ( reconcile) ;
996
998
self . reconcile_repaired = 0 ;
997
999
998
- Ok ( true )
1000
+ true
999
1001
} else {
1000
1002
info ! ( self . log, "All extents match" ) ;
1001
- Ok ( false )
1003
+ false
1002
1004
}
1003
1005
}
1004
1006
0 commit comments