Skip to content

Commit

Permalink
Accidentally inserted error correction twice
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuerstchen committed Aug 25, 2022
1 parent 2827beb commit 30236db
Showing 1 changed file with 0 additions and 138 deletions.
138 changes: 0 additions & 138 deletions src/XrdEc/XrdEcRepairTool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,144 +54,6 @@

namespace XrdEc {


//-----------------------------------------------------------------------
// If neccessary trigger error correction procedure
// @param self : the block_t object
// @return : false if the block is corrupted and cannot be recovered,
// true otherwise
//-----------------------------------------------------------------------
bool RepairTool::error_correction( std::shared_ptr<block_t> &self, RepairTool *writer, uint16_t timeout )
{

//---------------------------------------------------------------------
// Do the accounting for our stripes
//---------------------------------------------------------------------
size_t missingcnt = 0, validcnt = 0, loadingcnt = 0, recoveringcnt = 0, emptycnt = 0;
std::for_each( self->state.begin(), self->state.end(), [&]( block_t::state_t &s )
{
switch( s )
{
case block_t::Missing: ++missingcnt; break;
case block_t::Valid: ++validcnt; break;
case block_t::Loading: ++loadingcnt; break;
case block_t::Recovering: ++recoveringcnt; break;
case block_t::Empty: ++emptycnt; break;
default: ;
}
} );
XrdCl::DefaultEnv::GetLog()->Debug(XrdCl::XRootDMsg, "Error Correct with %d valid, %d missing", validcnt, missingcnt);
if(validcnt == writer->objcfg.nbchunks){
// both check_block and update_callback will skip to the next block by returning false.
return false;
}
//---------------------------------------------------------------------
// Check if we can do the recovery at all (if too many stripes are
// missing it won't be possible)
//---------------------------------------------------------------------
if( missingcnt + recoveringcnt > self->objcfg.nbparity )
{
std::for_each( self->state.begin(), self->state.end(),
[]( block_t::state_t &s ){ if( s == block_t::Recovering ) s = block_t::Missing; } );
writer->repairFailed = true;
return false;
}
//---------------------------------------------------------------------
// Only do the recovery once every chunk was analyzed
// the redundancy results are cached so errors might be overlooked otherwise
//---------------------------------------------------------------------
if( missingcnt > 0 && validcnt + missingcnt == self->objcfg.nbchunks )
{

Config &cfg = Config::Instance();
stripes_t strps( self->get_stripes() );
try
{
cfg.GetRedundancy( self->objcfg ).compute( strps );
}
catch( const IOError &ex )
{
std::for_each( self->state.begin(), self->state.end(),
[]( block_t::state_t &s ){ if( s == block_t::Recovering ) s = block_t::Missing; } );
writer->repairFailed = true;
return false;
}
//-------------------------------------------------------------------
// Now that we triggered the recovery procedure mark every missing
// stripe as recovering.
//-------------------------------------------------------------------
std::for_each( self->state.begin(), self->state.end(),
[]( block_t::state_t &s ){ if( s == block_t::Missing ) s = block_t::Recovering; } );

//-------------------------------------------------------------------
// Now when we recovered the data we need to mark every stripe as
// valid and execute the pending reads
//-------------------------------------------------------------------
for( size_t strpid = 0; strpid < self->objcfg.nbchunks; ++strpid )
{
if( self->state[strpid] != block_t::Recovering ) continue;
// we expect one more repair/write
writer->chunksRepaired.fetch_add(1,std::memory_order_relaxed);
// Write new content to disk
auto st = writer->WriteChunk(self, strpid, timeout);
if(!st.IsOK()){
std::for_each( self->state.begin(), self->state.end(),
[]( block_t::state_t &s ){ if( s == block_t::Recovering ) s = block_t::Missing; } );
writer->repairFailed = true;
return false;
}
self->state[strpid] = block_t::Valid;
validcnt++;
if (validcnt == writer->objcfg.nbchunks)
{
return false;
}

}
return true;
}
//---------------------------------------------------------------------
// Try loading the data and only then attempt recovery
//---------------------------------------------------------------------
size_t i = 0;
while( loadingcnt + validcnt < self->objcfg.nbchunks && i < self->objcfg.nbchunks )
{
size_t strpid = i++;
if( self->state[strpid] != block_t::Empty ) continue;
self->reader.Read( self->blkid, strpid, self->stripes[strpid],
RepairTool::update_callback( self, writer, strpid, timeout ) ,timeout);
self->state[strpid] = block_t::Loading;
++loadingcnt;
}

return true;
}

//-----------------------------------------------------------------------
// Get a callback for read operation
//-----------------------------------------------------------------------
callback_t RepairTool::update_callback(std::shared_ptr<block_t> &self, RepairTool *tool,
size_t strpid, uint16_t timeout) {
return [self, tool, strpid, timeout](const XrdCl::XRootDStatus &st, const uint32_t &length) mutable {
std::unique_lock<std::mutex> lck(tool->blkmtx);
self->state[strpid] = st.IsOK() ? self->Valid : self->Missing;
if(st.IsOK()){
self->stripes[strpid].resize(length);
}
//------------------------------------------------------------
// Check if we need to do any error correction (either for
// the current stripe, or any other stripe)
//------------------------------------------------------------
if(!error_correction(self, tool, timeout)){
tool->currentBlockChecked.fetch_add(1, std::memory_order_relaxed);
BlockPool::Instance().Recycle(std::move(self));
tool->repairVar.notify_all();
lck.unlock();
//tool->CheckBlock();
}
};
}

//-----------------------------------------------------------------------
// If neccessary trigger error correction procedure
// @param self : the block_t object
Expand Down

0 comments on commit 30236db

Please sign in to comment.