Skip to content

Commit

Permalink
XrdApps::JCache: don't create cache directories if neither journal nor
Browse files Browse the repository at this point in the history
vector caching is enabled - fix address handling if buffer is 0 in
VectorRead function
  • Loading branch information
Andreas Joachim Peters committed Jun 10, 2024
1 parent fb8e01f commit c9094f4
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions src/XrdApps/XrdClJCachePlugin/file/XrdClJCacheFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,16 @@ JCacheFile::Open(const std::string& url,

if (st.IsOK()) {
mIsOpen = true;
if ((flags & OpenFlags::Flags::Read) == OpenFlags::Flags::Read) {
std::string JournalDir = sCachePath + "/" + VectorCache::computeSHA256(pUrl);
pJournalPath = JournalDir + "/journal";
// it can be that we cannot write the journal directory
if (!VectorCache::ensureLastSubdirectoryExists(JournalDir)) {
st = XRootDStatus(stError, errOSError);
std::cerr << "error: unable to create cache directory: " << JournalDir << std::endl;
if (sEnableVectorCache || sEnableJournalCache) {
if ((flags & OpenFlags::Flags::Read) == OpenFlags::Flags::Read) {
std::string JournalDir = sCachePath + "/" + VectorCache::computeSHA256(pUrl);
pJournalPath = JournalDir + "/journal";
// it can be that we cannot write the journal directory
if (!VectorCache::ensureLastSubdirectoryExists(JournalDir)) {
st = XRootDStatus(stError, errOSError);
std::cerr << "error: unable to create cache directory: " << JournalDir << std::endl;
return st;
}
}
}
}
Expand Down Expand Up @@ -327,28 +329,29 @@ JCacheFile::VectorRead(const ChunkList& chunks,
XRootDStatus st;

if (pFile) {
VectorCache cache(chunks, pUrl, (const char*)buffer, sCachePath);
if (sEnableVectorCache) {
if (cache.retrieve()) {
// Compute total length of readv request
uint32_t len = 0;
for (auto it = chunks.begin(); it != chunks.end(); ++it) {
len += it->length;
}
uint32_t len = 0;
for (auto it = chunks.begin(); it != chunks.end(); ++it) {
len += it->length;
}

VectorCache cache(chunks, pUrl, buffer?(char*)buffer:(char*)(chunks.begin()->buffer), sCachePath);

if (cache.retrieve()) {
XRootDStatus* ret_st = new XRootDStatus(st);
*ret_st = XRootDStatus(stOK, 0);
AnyObject* obj = new AnyObject();
VectorReadInfo* vReadInfo = new VectorReadInfo();
vReadInfo->SetSize(len);
ChunkList vResp = vReadInfo->GetChunks();
ChunkList& vResp = vReadInfo->GetChunks();
vResp = chunks;
obj->Set(vReadInfo);
handler->HandleResponse(ret_st, obj);
return st;
}
}

auto jhandler = new JCacheReadVHandler(handler, &pStats.bytesReadV,sEnableJournalCache?&pJournal:nullptr, buffer, sEnableVectorCache?sCachePath:"", pUrl);
auto jhandler = new JCacheReadVHandler(handler, &pStats.bytesReadV,sEnableJournalCache?&pJournal:nullptr, buffer?(char*)buffer:(char*)(chunks.begin()->buffer), sEnableVectorCache?sCachePath:"", pUrl);
pStats.readVOps++;
pStats.readVreadOps += chunks.size();

Expand Down

0 comments on commit c9094f4

Please sign in to comment.