Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Pfc] Fix error handling in File::ReadV(). #1438

Merged
merged 1 commit into from
Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 2 additions & 9 deletions src/XrdPfc/XrdPfcFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,18 +209,13 @@ 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() <<
", block_map.size() " << m_block_map.size() << ", file");

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.
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 1 addition & 3 deletions src/XrdPfc/XrdPfcFile.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{}
};

Expand Down
22 changes: 14 additions & 8 deletions src/XrdPfc/XrdPfcVRead.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<ReadVChunkListRAM> finished;
BlockList_t to_reissue;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}