From 28e00d1371aaee5925dd3d2dd2ab1257650aa51a Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Thu, 1 Apr 2021 14:40:19 -0700 Subject: [PATCH] [Pfc] Fix error handling in File::ReadV(). --- src/XrdPfc/XrdPfcFile.cc | 11 ++--------- src/XrdPfc/XrdPfcFile.hh | 4 +--- src/XrdPfc/XrdPfcVRead.cc | 22 ++++++++++++++-------- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/XrdPfc/XrdPfcFile.cc b/src/XrdPfc/XrdPfcFile.cc index f0f5c45a801..ade5a9f5f10 100644 --- a/src/XrdPfc/XrdPfcFile.cc +++ b/src/XrdPfc/XrdPfcFile.cc @@ -209,7 +209,6 @@ bool File::ioActive(IO *io) TRACE(Info, "ioActive for io " << io << ", active_prefetches " << mi->second.m_active_prefetches << ", allow_prefetching " << mi->second.m_allow_prefetching << - ", ioactive_false_reported " << mi->second.m_ioactive_false_reported << ", ios_in_detach " << m_ios_in_detach); TRACEF(Info, "\tio_map.size() " << m_io_map.size() << @@ -217,10 +216,6 @@ bool File::ioActive(IO *io) insert_remote_location(loc); - // XXX Intermediate check for 4.11 - 5.0 transition. - // Can be removed for 5.1, including member IODetals::m_ioactive_false_reported. - assert( ! mi->second.m_ioactive_false_reported && "ioActive already returned false"); - mi->second.m_allow_prefetching = false; // Check if any IO is still available for prfetching. If not, stop it. @@ -249,7 +244,6 @@ bool File::ioActive(IO *io) if ( ! io_active_result) { ++m_ios_in_detach; - mi->second.m_ioactive_false_reported = true; } TRACEF(Info, "ioActive for io " << io << " returning " << io_active_result << ", file"); @@ -1093,12 +1087,11 @@ void File::inc_ref_count(Block* b) void File::dec_ref_count(Block* b) { // Method always called under lock. + assert(b->is_finished()); b->m_refcnt--; assert(b->m_refcnt >= 0); - // File::Read() can decrease ref count before waiting for the block in case - // of an error. Prefetch starts with refcnt 0. - if (b->m_refcnt == 0 && b->is_finished()) + if (b->m_refcnt == 0) { free_block(b); } diff --git a/src/XrdPfc/XrdPfcFile.hh b/src/XrdPfc/XrdPfcFile.hh index fd803a38f7e..7c9158b77ea 100644 --- a/src/XrdPfc/XrdPfcFile.hh +++ b/src/XrdPfc/XrdPfcFile.hh @@ -264,13 +264,11 @@ private: time_t m_attach_time; int m_active_prefetches; bool m_allow_prefetching; - bool m_ioactive_false_reported; IODetails(time_t at) : m_attach_time (at), m_active_prefetches (0), - m_allow_prefetching (true), - m_ioactive_false_reported (false) + m_allow_prefetching (true) {} }; diff --git a/src/XrdPfc/XrdPfcVRead.cc b/src/XrdPfc/XrdPfcVRead.cc index 2ffddbe58ab..d1227ebfbe3 100644 --- a/src/XrdPfc/XrdPfcVRead.cc +++ b/src/XrdPfc/XrdPfcVRead.cc @@ -348,8 +348,10 @@ int File::VReadProcessBlocks(IO *io, const XrdOucIOVec *readV, int n, long long& bytes_hit, long long& bytes_missed) { - int bytes_read = 0; - while ( ! blocks_to_process.empty() && bytes_read >= 0) + long long bytes_read = 0; + int error_cond = 0; // to be set to -errno + + while ( ! blocks_to_process.empty()) { std::vector finished; BlockList_t to_reissue; @@ -418,10 +420,14 @@ int File::VReadProcessBlocks(IO *io, const XrdOucIOVec *readV, int n, } else { - bytes_read = bi->block->m_errno; - TRACEF(Error, "VReadProcessBlocks() io " << io << ", block "<< bi->block << - " finished with error " << -bytes_read << " " << XrdSysE2T(-bytes_read)); - break; + // It has failed ... report only the first error. + if ( ! error_cond) + { + error_cond = bi->block->m_errno; + TRACEF(Error, "VReadProcessBlocks() io " << io << ", block "<< bi->block << + " finished with error " << -error_cond << " " << XrdSysE2T(-error_cond)); + break; + } } ++bi; @@ -432,7 +438,7 @@ int File::VReadProcessBlocks(IO *io, const XrdOucIOVec *readV, int n, finished.clear(); } - TRACEF(Dump, "VReadProcessBlocks total read " << bytes_read); + TRACEF(Dump, "VReadProcessBlocks status " << error_cond << ", total read " << bytes_read); - return bytes_read; + return error_cond ? error_cond : bytes_read; }