@@ -595,40 +595,32 @@ impl ExtentInner for RawInner {
595595 } ) ?;
596596 let hash = integrity_hash ( & [ & buf] ) ;
597597
598- // Then, read the slot data and decide if either slot
599- // (1) is present and
600- // (2) has a matching hash
601- let mut matching_slot = None ;
602- let mut empty_slot = None ;
603- for slot in [ ContextSlot :: A , ContextSlot :: B ] {
604- // Read a single context slot, which is by definition contiguous
605- let mut context = self . layout . read_context_slots_contiguous (
606- & self . file , block, 1 , slot,
607- ) ?;
608- assert_eq ! ( context. len( ) , 1 ) ;
609- let context = context. pop ( ) . unwrap ( ) ;
598+ // Read the active context slot, which is by definition contiguous
599+ let slot = self . active_context [ block] ;
600+ let mut context = self
601+ . layout
602+ . read_context_slots_contiguous ( & self . file , block, 1 , slot) ?;
603+ assert_eq ! ( context. len( ) , 1 ) ;
604+ let context = context. pop ( ) . unwrap ( ) ;
610605
611- if let Some ( context) = context {
612- if context. on_disk_hash == hash {
613- matching_slot = Some ( slot) ;
614- }
615- } else if empty_slot. is_none ( ) {
616- empty_slot = Some ( slot) ;
617- }
618- }
619- if matching_slot. is_some ( ) {
620- // great work, everyone
621- } else if empty_slot. is_some ( ) {
622- if !buf. iter ( ) . all ( |v| * v == 0u8 ) {
606+ if let Some ( context) = context {
607+ if context. on_disk_hash == hash {
608+ // great work, everyone
609+ } else {
623610 return Err ( CrucibleError :: GenericError ( format ! (
624- "block {block} has no matching slot, \
625- and has a empty slot but has none-zero data"
611+ "block {block} has an active slot with mismatched hash"
626612 ) ) ) ;
627613 }
628614 } else {
629- return Err ( CrucibleError :: GenericError ( format ! (
630- "block {block} has both slots mismatched"
631- ) ) ) ;
615+ // context slot is empty, hopefully data is as well!
616+ if buf. iter ( ) . all ( |v| * v == 0u8 ) {
617+ // great work, everyone
618+ } else {
619+ return Err ( CrucibleError :: GenericError ( format ! (
620+ "block {block} has an empty active slot, \
621+ but contains none-zero data"
622+ ) ) ) ;
623+ }
632624 }
633625 }
634626 Ok ( ( ) )
0 commit comments