From 3d5f5db9d14c5c1814187f8289f822c92b2cda84 Mon Sep 17 00:00:00 2001 From: Michal Simon Date: Tue, 19 Jan 2021 18:47:32 +0100 Subject: [PATCH] [XrdEc] Correctly fail on non-recoverable errors. --- src/XrdEc/XrdEcReader.cc | 45 ++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/src/XrdEc/XrdEcReader.cc b/src/XrdEc/XrdEcReader.cc index 9b4184239a0..3a803cd2ab1 100644 --- a/src/XrdEc/XrdEcReader.cc +++ b/src/XrdEc/XrdEcReader.cc @@ -299,11 +299,16 @@ namespace XrdEc //------------------------------------------------------------ bool recoverable = error_correction( self ); //------------------------------------------------------------ - // Carry out the pending read requests if we got the data or - // if there was an error and we cannot recover + // Carry out the pending read requests if we got the data //------------------------------------------------------------ - if( st.IsOK() || !recoverable ) + if( st.IsOK() ) self->carryout( self->pending[strpid], self->stripes[strpid], st ); + //------------------------------------------------------------ + // Carry out the pending read requests if there was an error + // and we cannot recover + //------------------------------------------------------------ + if( !recoverable ) + self->fail_missing(); }; } @@ -327,26 +332,26 @@ namespace XrdEc return ret; } - //----------------------------------------------------------------------- + //------------------------------------------------------------------------- // Execute the pending read requests - //----------------------------------------------------------------------- + //------------------------------------------------------------------------- inline static void carryout( pending_t &pending, const buffer_t &stripe, const XrdCl::XRootDStatus &st = XrdCl::XRootDStatus() ) { - //--------------------------------------------------------------------- + //----------------------------------------------------------------------- // Iterate over all pending read operations for given stripe - //--------------------------------------------------------------------- + //----------------------------------------------------------------------- auto itr = pending.begin(); for( ; itr != pending.end() ; ++itr ) { auto &args = *itr; callback_t &callback = std::get<3>( args ); uint32_t nbrd = 0; // number of bytes read - //------------------------------------------------------------------- + //--------------------------------------------------------------------- // If the read was successful, copy the data to user buffer - //------------------------------------------------------------------- + //--------------------------------------------------------------------- if( st.IsOK() ) { uint64_t offset = std::get<0>( args ); @@ -361,17 +366,31 @@ namespace XrdEc memcpy( usrbuff, stripe.data() + offset, size ); nbrd = size; } - //------------------------------------------------------------------- + //--------------------------------------------------------------------- // Call the user callback - //------------------------------------------------------------------- + //--------------------------------------------------------------------- callback( st, nbrd ); } - //--------------------------------------------------------------------- + //----------------------------------------------------------------------- // Now we can clear the pending reads - //--------------------------------------------------------------------- + //----------------------------------------------------------------------- pending.clear(); } + //------------------------------------------------------------------------- + // Execute pending read requests for missing stripes + //------------------------------------------------------------------------- + inline static void fail_missing() + { + size_t size = objcfg.nbchunks; + for( size_t i = 0; i < size; ++i ) + { + if( state[i] != Missing ) continue; + carryout( pending[i], stripes[i], + XrdCl::XRootDStatus( XrdCl::stError, XrdCl::errDataError ) ); + } + } + Reader &reader; ObjCfg &objcfg; std::vector stripes; //< data buffer for every stripe