Skip to content

Commit

Permalink
Include filename in traces on most frequent paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
osschar committed Jun 29, 2016
1 parent 399b79d commit 0d6e9c8
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/XrdFileCache/XrdFileCache.cc
Expand Up @@ -425,7 +425,7 @@ int Cache::Stat(const char *curl, struct stat &sbuff)
int res = infoFile->Open(name.c_str(), O_RDONLY, 0600, myEnv);
if (res >= 0) {
Info info(m_trace, 0);
if (info.Read(infoFile))
if (info.Read(infoFile, name))
{
sbuff.st_size = info.GetFileSize();
success = true;
Expand Down
12 changes: 8 additions & 4 deletions src/XrdFileCache/XrdFileCacheFile.cc
Expand Up @@ -224,14 +224,16 @@ bool File::Open()
// Create the data file itself.
if (myOss.Create(myUser, m_temp_filename.c_str(), 0600, myEnv, XRDOSS_mkpath) != XrdOssOK)
{
TRACEF(Error, "File::Open() Create failed for data file, " << strerror(errno));
TRACEF(Error, "File::Open() Create failed for data file " << m_temp_filename
<< ", err=" << strerror(errno));
return false;
}

m_output = myOss.newFile(myUser);
if (m_output->Open(m_temp_filename.c_str(), O_RDWR, 0600, myEnv) != XrdOssOK)
{
TRACEF(Error, "File::Open() Open failed for data file, " << strerror(errno));
TRACEF(Error, "File::Open() Open failed for data file " << m_temp_filename
<< ", err=" << strerror(errno));
delete m_output; m_output = 0;
return false;
}
Expand All @@ -244,15 +246,17 @@ bool File::Open()

if (myOss.Create(myUser, ifn.c_str(), 0600, myEnv, XRDOSS_mkpath) != XrdOssOK)
{
TRACEF(Error, "File::Open() Create failed for info file, " << strerror(errno));
TRACEF(Error, "File::Open() Create failed for info file " << ifn
<< ", err=" << strerror(errno));
delete m_output; m_output = 0;
return false;
}

m_infoFile = myOss.newFile(myUser);
if (m_infoFile->Open(ifn.c_str(), O_RDWR, 0600, myEnv) != XrdOssOK)
{
TRACEF(Error, "File::Open() Open failed for info file, " << strerror(errno));
TRACEF(Error, "File::Open() Open failed for info file " << ifn
<< ", err=" << strerror(errno));
delete m_infoFile; m_infoFile = 0;
delete m_output; m_output = 0;
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/XrdFileCache/XrdFileCacheIOEntireFile.cc
Expand Up @@ -110,7 +110,7 @@ int IOEntireFile::initCachedStat(const char* path)
if (infoFile->Open(path, O_RDONLY, 0600, myEnv) == XrdOssOK)
{
Info info(m_cache.GetTrace());
if (info.Read(infoFile))
if (info.Read(infoFile, path))
{
tmpStat.st_size = info.GetFileSize();
TRACEIO(Info, "IOEntireFile::initCachedStat successfuly read size from info file = " << tmpStat.st_size);
Expand Down
2 changes: 1 addition & 1 deletion src/XrdFileCache/XrdFileCacheIOFileBlock.cc
Expand Up @@ -150,7 +150,7 @@ int IOFileBlock::initLocalStat()
XrdOssDF* infoFile = m_cache.GetOss()->newFile(m_cache.RefConfiguration().m_username.c_str());
if (infoFile->Open(path.c_str(), O_RDONLY, 0600, myEnv) == XrdOssOK) {
Info info(m_cache.GetTrace());
if (info.Read(infoFile))
if (info.Read(infoFile, path))
{
tmpStat.st_size = info.GetFileSize();
TRACEIO(Info, "IOFileBlock::initCachedStat successfuly read size from existing info file = " << tmpStat.st_size);
Expand Down
39 changes: 24 additions & 15 deletions src/XrdFileCache/XrdFileCacheInfo.cc
Expand Up @@ -41,12 +41,12 @@ namespace
off_t f_off;
XrdOucTrace *f_trace;
const char *m_traceID;
const char *f_ttext;
std::string f_ttext;

XrdOucTrace* GetTrace() const {return f_trace;}

FpHelper(XrdOssDF* fp, off_t off,
XrdOucTrace *trace, const char *tid, const char *ttext) :
XrdOucTrace *trace, const char *tid, const std::string &ttext) :
f_fp(fp), f_off(off),
f_trace(trace), m_traceID(tid), f_ttext(ttext)
{}
Expand Down Expand Up @@ -151,18 +151,21 @@ void Info::ResizeBits(int s)

//------------------------------------------------------------------------------

bool Info::Read(XrdOssDF* fp)
bool Info::Read(XrdOssDF* fp, const std::string &fname)
{
// does not need lock, called only in File::Open
// before File::Run() starts

FpHelper r(fp, 0, m_trace, m_traceID, "Info:::Read() failed");
std::string trace_pfx("Info:::Read() ");
trace_pfx += fname + " ";

FpHelper r(fp, 0, m_trace, m_traceID, trace_pfx + "oss read failed");

int version;
if (r.Read(version)) return false;
if (version != m_version)
{
TRACE(Warning, "Info:::Read() incompatible file version " << version);
TRACE(Warning, trace_pfx << " incompatible file version " << version);
return false;
}

Expand All @@ -179,7 +182,7 @@ bool Info::Read(XrdOssDF* fp)
m_complete = ! IsAnythingEmptyInRng(0, m_sizeInBits);

if (r.Read(m_accessCnt)) return false;
TRACE(Dump, "Info:::Read() complete "<< m_complete << " access_cnt " << m_accessCnt);
TRACE(Dump, trace_pfx << " complete "<< m_complete << " access_cnt " << m_accessCnt);

return true;
}
Expand All @@ -194,15 +197,18 @@ int Info::GetHeaderSize() const

//------------------------------------------------------------------------------

bool Info::WriteHeader(XrdOssDF* fp)
bool Info::WriteHeader(XrdOssDF* fp, const std::string &fname)
{
std::string trace_pfx("Info:::WriteHeader() ");
trace_pfx += fname + " ";

if (XrdOucSxeq::Serialize(fp->getFD(), XrdOucSxeq::noWait))
{
TRACE(Error, "Info::WriteHeader() lock failed " << strerror(errno));
TRACE(Error, trace_pfx << " lock failed " << strerror(errno));
return false;
}

FpHelper w(fp, 0, m_trace, m_traceID, "Info:::WriteHeader() failed");
FpHelper w(fp, 0, m_trace, m_traceID, trace_pfx + "oss write failed");

if (w.Write(m_version)) return false;
if (w.Write(m_bufferSize)) return false;
Expand All @@ -213,27 +219,30 @@ bool Info::WriteHeader(XrdOssDF* fp)
// Can this really fail?
if (XrdOucSxeq::Release(fp->getFD()))
{
TRACE(Error, "Info::WriteHeader() un-lock failed");
TRACE(Error, trace_pfx << "un-lock failed");
}

return true;
}

//------------------------------------------------------------------------------

bool Info::AppendIOStat(AStat& as, XrdOssDF* fp)
bool Info::AppendIOStat(AStat& as, XrdOssDF* fp, const std::string &fname)
{
TRACE(Dump, "Info:::AppendIOStat()");
std::string trace_pfx("Info:::AppendIOStat() ");
trace_pfx += fname + " ";

TRACE(Dump, trace_pfx);

if (XrdOucSxeq::Serialize(fp->getFD(), 0))
{
TRACE(Error, "Info::AppendIOStat() lock failed");
TRACE(Error, trace_pfx << "lock failed");
return false;
}

m_accessCnt++;

FpHelper w(fp, GetHeaderSize(), m_trace, m_traceID, "Info::AppendIOStat() write failed");
FpHelper w(fp, GetHeaderSize(), m_trace, m_traceID, trace_pfx + "oss write failed");

if (w.Write(m_accessCnt)) return false;

Expand All @@ -243,7 +252,7 @@ bool Info::AppendIOStat(AStat& as, XrdOssDF* fp)

if (XrdOucSxeq::Release(fp->getFD()))
{
TRACE(Error, "Info::AppenIOStat() un-lock failed");
TRACE(Error, trace_pfx << "un-lock failed");
}

return true;
Expand Down
9 changes: 5 additions & 4 deletions src/XrdFileCache/XrdFileCacheInfo.hh
Expand Up @@ -96,23 +96,24 @@ namespace XrdFileCache
//---------------------------------------------------------------------
//! \brief Rea load content from cinfo file into this object
//!
//! @param fp file handle
//! @param fp file handle
//! @param fname optional file name for trace output
//!
//! @return true on success
//---------------------------------------------------------------------
bool Read(XrdOssDF* fp);
bool Read(XrdOssDF* fp, const std::string &fname="<unknown>");

//---------------------------------------------------------------------
//! Write number of blocks and read buffer size
//! @return true on success
//---------------------------------------------------------------------
bool WriteHeader(XrdOssDF* fp);
bool WriteHeader(XrdOssDF* fp, const std::string &fname="<unknown>");

//---------------------------------------------------------------------
//! Append access time, and cache statistics
//! @return true on success
//---------------------------------------------------------------------
bool AppendIOStat(AStat& stat, XrdOssDF* fp);
bool AppendIOStat(AStat& stat, XrdOssDF* fp, const std::string &fname="<unknown>");

//---------------------------------------------------------------------
//! Check download status in given block range
Expand Down
2 changes: 1 addition & 1 deletion src/XrdFileCache/XrdFileCachePrint.cc
Expand Up @@ -64,7 +64,7 @@ void Print::printFile(const std::string& path)
XrdOucTrace tr(&err); tr.What = 1;
Info cfi(&tr);

if ( ! cfi.Read(fh))
if ( ! cfi.Read(fh, path))
{
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/XrdFileCache/XrdFileCachePurge.cc
Expand Up @@ -82,12 +82,12 @@ void FillFileMapRecurse( XrdOssDF* iOssDF, const std::string& path, FPurgeState&
XrdOssDF* dh = factory.GetOss()->newDir(factory.RefConfiguration().m_username.c_str());
XrdOssDF* fh = factory.GetOss()->newFile(factory.RefConfiguration().m_username.c_str());

if (fname_len > InfoExtLen && strncmp(&buff[fname_len - InfoExtLen ], XrdFileCache::Info::m_infoExtension, InfoExtLen) == 0)
if (fname_len > InfoExtLen && strncmp(&buff[fname_len - InfoExtLen], XrdFileCache::Info::m_infoExtension, InfoExtLen) == 0)
{
// XXXX MT - shouldn't we also check if it is currently opened?

Info cinfo(Cache::GetInstance().GetTrace());
if (fh->Open(np.c_str(), O_RDONLY, 0600, env) == XrdOssOK && cinfo.Read(fh))
if (fh->Open(np.c_str(), O_RDONLY, 0600, env) == XrdOssOK && cinfo.Read(fh, np))
{
time_t accessTime;
if (cinfo.GetLatestDetachTime(accessTime, fh))
Expand Down

0 comments on commit 0d6e9c8

Please sign in to comment.