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

[XCache] Improve cinfo consistency, purge file on read size mismatch. #1349

Merged
merged 1 commit into from
Dec 4, 2020
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
10 changes: 2 additions & 8 deletions src/XrdPfc/XrdPfc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1010,16 +1010,10 @@ int Cache::Unlink(const char *curl)

// printf("Unlink url=%s\n\t fname=%s\n", curl, f_name.c_str());

return UnlinkCommon(f_name, false);
return UnlinkFile(f_name, false);
}


int Cache::UnlinkUnlessOpen(const std::string& f_name)
{
return UnlinkCommon(f_name, true);
}

int Cache::UnlinkCommon(const std::string& f_name, bool fail_if_open)
int Cache::UnlinkFile(const std::string& f_name, bool fail_if_open)
{
ActiveMap_i it;
File *file = 0;
Expand Down
6 changes: 2 additions & 4 deletions src/XrdPfc/XrdPfc.hh
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,9 @@ public:
void Purge();

//---------------------------------------------------------------------
//! Remove file from cache unless it is currently open.
//! Remove cinfo and data files from cache.
//---------------------------------------------------------------------
int UnlinkUnlessOpen(const std::string& f_name);
int UnlinkFile(const std::string& f_name, bool fail_if_open);

//---------------------------------------------------------------------
//! Add downloaded block in write queue.
Expand Down Expand Up @@ -402,8 +402,6 @@ private:

bool cfg2bytes(const std::string &str, long long &store, long long totalSpace, const char *name);

int UnlinkCommon(const std::string& f_name, bool fail_if_open);

static Cache *m_instance; //!< this object

XrdOucEnv *m_env; //!< environment passed in at creation
Expand Down
4 changes: 2 additions & 2 deletions src/XrdPfc/XrdPfcCommand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ void Cache::ExecuteCommandUrl(const std::string& command_url)

Info myInfo(m_trace, false);
myInfo.SetBufferSize(block_size);
myInfo.SetFileSize(file_size);
myInfo.SetFileSizeAndCreationTime(file_size);
myInfo.SetAllBitsSynced();

for (int i = 0; i < at_count; ++i)
Expand Down Expand Up @@ -312,7 +312,7 @@ void Cache::ExecuteCommandUrl(const std::string& command_url)

TRACE(Debug, err_prefix << "file argument '" << f_name << "'.");

int ret = UnlinkCommon(f_name, true);
int ret = UnlinkFile(f_name, true);

TRACE(Info, err_prefix << "returned with status " << ret);
}
Expand Down
9 changes: 4 additions & 5 deletions src/XrdPfc/XrdPfcConfiguration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -785,12 +785,11 @@ bool Cache::ConfigParameters(std::string part, XrdOucStream& config, TmpConfigur
return false;
}
}
else if ( part == "hdfsmode" || part == "filefragmentmode" )
else if ( part == "hdfsmode" )
{
if (part == "filefragmentmode")
{
m_log.Emsg("Config", "pfc.filefragmentmode is deprecated, please use pfc.hdfsmode instead. Replacing the directive internally.");
}
m_log.Emsg("Config", "pfc.hdfsmode is currently unsupported.");
return false;

m_configuration.m_hdfsmode = true;

const char* params = cwg.GetWord();
Expand Down
21 changes: 15 additions & 6 deletions src/XrdPfc/XrdPfcFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ File* File::FileOpen(const std::string &path, long long offset, long long fileSi

void File::initiate_emergency_shutdown()
{
// Called from Cache::UnlinkCommon() when the file is currently open.
// CacheUnlink is also called on FSync error.
// Called from Cache::Unlink() when the file is currently open.
// Cache::Unlink is also called on FSync error and when wrong number of bytes
// is received from a remote read.
//
// From this point onward the file will not be written to, cinfo file will
// not be updated, and all new read requests will return -ENOENT.
Expand Down Expand Up @@ -477,7 +478,7 @@ bool File::Open()
if (initialize_info_file)
{
m_cfi.SetBufferSize(conf.m_bufferSize);
m_cfi.SetFileSize(m_file_size);
m_cfi.SetFileSizeAndCreationTime(m_file_size);
m_cfi.SetCkSumState(conf.get_cs_Chk());
m_cfi.Write(m_info_file, ifn.c_str());
m_info_file->Fsync();
Expand Down Expand Up @@ -1054,7 +1055,7 @@ void File::Sync()
TRACEF(Error, "Sync failed, unlinking local files and initiating shutdown of File object");

// Unlink will also call this->initiate_emergency_shutdown()
Cache::GetInstance().Unlink(m_filename.c_str());
Cache::GetInstance().UnlinkFile(m_filename, false);

XrdSysCondVarHelper _lck(&m_state_cond);

Expand Down Expand Up @@ -1179,12 +1180,20 @@ void File::ProcessBlockResponse(BlockResponseHandler* brh, int res)
{
static const char* tpfx = "ProcessBlockResponse ";

XrdSysCondVarHelper _lck(m_state_cond);

Block *b = brh->m_block;

TRACEF(Dump, tpfx << "block=" << b << ", idx=" << b->m_offset/BufferSize() << ", off=" << b->m_offset << ", res=" << res);

if (res >= 0 && res != b->get_size())
{
// Incorrect number of bytes received, apparently size of the file on the remote
// is different than what the cache expects it to be.
TRACEF(Error, tpfx << "Wrong number of bytes received, assuming remote/local file size mismatch, unlinking local files and initiating shutdown of File object");
Cache::GetInstance().UnlinkFile(m_filename, false);
}

XrdSysCondVarHelper _lck(m_state_cond);

// Deregister block from IO's prefetch count, if needed.
if (b->m_prefetch)
{
Expand Down
4 changes: 2 additions & 2 deletions src/XrdPfc/XrdPfcIOFileBlock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ int IOFileBlock::initLocalStat()
// The info file is used to get file size on defer open
// don't initalize buffer, it does not hold useful information in this case
m_info.SetBufferSize(m_cache.RefConfiguration().m_bufferSize);
m_info.DisableDownloadStatus();
m_info.SetFileSize(tmpStat.st_size);
// m_info.DisableDownloadStatus(); -- this stopped working a while back.
m_info.SetFileSizeAndCreationTime(tmpStat.st_size);
m_info.Write(m_info_file, path.c_str());
m_info_file->Fsync();
}
Expand Down