Skip to content

Commit

Permalink
Allow specifying a different timeout for null cached entries; fixes #413
Browse files Browse the repository at this point in the history
  • Loading branch information
abh3 committed Oct 22, 2016
1 parent 810e3b5 commit 28f0477
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 11 deletions.
28 changes: 23 additions & 5 deletions src/XrdCms/XrdCmsCache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ int XrdCmsCache::AddFile(XrdCmsSelect &Sel, SMask_t mask)
if (iP)
{if (!mask)
{iP->Loc.deadline = QDelay + time(0);
iP->Loc.lifeline = nilTMO + iP->Loc.deadline;
iP->Loc.hfvec = 0; iP->Loc.pfvec = 0; iP->Loc.qfvec = 0;
iP->Loc.TOD_B = BClock;
iP->Key.TOD = Tock;
Expand All @@ -161,6 +162,7 @@ int XrdCmsCache::AddFile(XrdCmsSelect &Sel, SMask_t mask)
iP->Loc.TOD_B = BClock;
iP->Loc.qfvec = 0;
iP->Loc.deadline = QDelay + time(0);
iP->Loc.lifeline = nilTMO + iP->Loc.deadline;
Sel.Path.Ref = iP->Key.Ref;
Sel.Path.TODRef = iP; isnew = 1;
}
Expand Down Expand Up @@ -200,10 +202,12 @@ int XrdCmsCache::DelFile(XrdCmsSelect &Sel, SMask_t mask)
if ((iP = CTable.Find(Sel.Path)))
{iP->Loc.hfvec &= ~mask;
iP->Loc.pfvec &= ~mask;
if ((gone4good = (iP->Loc.hfvec == 0))
&& (!(Sel.Opts & XrdCmsSelect::Advisory))
&& (XrdCmsKeyItem::Unload(iP) && !CTable.Recycle(iP)))
Say.Emsg("DelFile", "Delete failed for", iP->Key.Val);
if ((gone4good = (iP->Loc.hfvec == 0)))
{if (nilTMO) iP->Loc.lifeline = nilTMO + time(0);
if (!(Sel.Opts & XrdCmsSelect::Advisory)
&& XrdCmsKeyItem::Unload(iP) && !CTable.Recycle(iP))
Say.Emsg("DelFile", "Delete failed for", iP->Key.Val);
}
} else gone4good = 0;

// All done
Expand Down Expand Up @@ -244,11 +248,16 @@ int XrdCmsCache::GetFile(XrdCmsSelect &Sel, SMask_t mask)
iP->Loc.pfvec &= ~bVec;
iP->Loc.qfvec &= ~mask;
iP->Loc.deadline = QDelay + time(0);
iP->Loc.lifeline = nilTMO + iP->Loc.deadline;
retc = -1;
} else if (iP->Loc.deadline)
if (iP->Loc.deadline > time(0)) retc = -1;
else {iP->Loc.deadline = 0; retc = 1;}
else retc = 1;

if (nilTMO && retc == 1 && iP->Loc.hfvec == 0
&& iP->Loc.lifeline <= time(0)) retc = 0;

Sel.Vec.hf = okVec & iP->Loc.hfvec;
Sel.Vec.pf = okVec & iP->Loc.pfvec;
Sel.Vec.bf = okVec & (bVec | iP->Loc.qfvec); iP->Loc.qfvec = 0;
Expand Down Expand Up @@ -368,7 +377,7 @@ void XrdCmsCache::Drop(SMask_t smask, int SNum, int xHi)
/* public I n i t */
/******************************************************************************/

int XrdCmsCache::Init(int fxHold, int fxDelay, int fxQuery, int seFS)
int XrdCmsCache::Init(int fxHold, int fxDelay, int fxQuery, int seFS, int nxHold)
{
XrdCmsKeyItem *iP;
pthread_t tid;
Expand All @@ -383,6 +392,15 @@ int XrdCmsCache::Init(int fxHold, int fxDelay, int fxQuery, int seFS)
DLTime = fxDelay; QDelay = fxQuery;
if (!(Tick = fxHold/XrdCmsKeyItem::TickRate)) Tick = 1;

// Set the timeout for nil entries if one needs to be set. Since this may cause
// an infinite lookup delay, adjust it to be no less than 10 minutes longer
// than the overall deadline for lookups (QDelay/fxQuery).
//
if (nxHold)
{if (nxHold < fxQuery+min_nxTime) nxHold = fxQuery+min_nxTime;
nilTMO = static_cast<unsigned int>(nxHold);
}

// Start the clock thread
//
if (XrdSysThread::Run(&tid, XrdCmsStartTickTock, (void *)this,
Expand Down
6 changes: 5 additions & 1 deletion src/XrdCms/XrdCmsCache.hh
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,14 @@ void Bounce(SMask_t smask, int SNum);

void Drop(SMask_t mask, int SNum, int xHi);

int Init(int fxHold, int fxDelay, int fxQuery, int seFS);
int Init(int fxHold, int fxDelay, int fxQuery, int seFS, int nxHold);

void *TickTock();

static const int min_nxTime = 60;

XrdCmsCache() : okVec(0), Tick(8*60*60), Tock(0), BClock(0),
nilTMO(0),
DLTime(5), QDelay(5), Bhits(0), Bmiss(0), vecHi(-1),
isDFS(0)
{memset(Bounced, 0, sizeof(Bounced));
Expand Down Expand Up @@ -106,6 +109,7 @@ SMask_t okVec;
unsigned int Tick;
unsigned int Tock;
unsigned int BClock;
int nilTMO;
int DLTime;
int QDelay;
int Bhits;
Expand Down
17 changes: 14 additions & 3 deletions src/XrdCms/XrdCmsConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ int XrdCmsConfig::Configure2()
//
if (QryDelay < 0) QryDelay = LUPDelay;
if (isManager)
NoGo = !Cache.Init(cachelife, LUPDelay, QryDelay, baseFS.isDFS());
NoGo = !Cache.Init(cachelife,LUPDelay,QryDelay,baseFS.isDFS(),emptylife);

// Issue warning if the adminpath resides in /tmp
//
Expand Down Expand Up @@ -709,6 +709,7 @@ void XrdCmsConfig::ConfigDefaults(void)
pidPath = strdup("/tmp");
Police = 0;
cachelife= 8*60*60;
emptylife= 0;
pendplife= 60*60*24*7;
DiskLinger=0;
ProgCH = 0;
Expand Down Expand Up @@ -1791,9 +1792,10 @@ int XrdCmsConfig::xfsxq(XrdSysError *eDest, XrdOucStream &CFile)

/* Function: xfxhld
Purpose: To parse the directive: fxhold <sec>
Purpose: To parse the directive: fxhold [noloc <nls>] <sec>
<sec> number of seconds (or M, H, etc) to cache file existence
<nls> number of seconds (or M, H, etc) to cache file non-existence
<sec> number of seconds (or M, H, etc) to cache file existence
Type: Manager only, dynamic.
Expand All @@ -1810,6 +1812,15 @@ int XrdCmsConfig::xfxhld(XrdSysError *eDest, XrdOucStream &CFile)
if (!(val = CFile.GetWord()))
{eDest->Emsg("Config", "fxhold value not specified."); return 1;}

if (!strcmp(val, "noloc"))
{if (!(val = CFile.GetWord()))
{eDest->Emsg("Config","fxhold noloc value not specified."); return 1;}
if (XrdOuca2x::a2tm(*eDest, "fxhold noloc value", val, &ct,
XrdCmsCache:: min_nxTime)) return 1;
emptylife = ct;
if (!(val = CFile.GetWord())) return 0;
}

if (XrdOuca2x::a2tm(*eDest, "fxhold value", val, &ct, 60)) return 1;

cachelife = ct;
Expand Down
1 change: 1 addition & 0 deletions src/XrdCms/XrdCmsConfig.hh
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ int isSolo;
char *perfpgm;
int perfint;
int cachelife;
int emptylife;
int pendplife;
int FSlim;
};
Expand Down
5 changes: 3 additions & 2 deletions src/XrdCms/XrdCmsKey.hh
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ SMask_t hfvec; // Servers that are staging or have the file
SMask_t pfvec; // Servers that are staging the file
SMask_t qfvec; // Servers that are not yet queried
unsigned int TOD_B; // Server currency clock
unsigned int Reserved;
int lifeline; // TOD when nil entry should expire
union {
unsigned int HashSave; // Where hash goes upon item unload
int deadline;
Expand All @@ -105,11 +105,12 @@ inline
XrdCmsKeyLoc& operator=(const XrdCmsKeyLoc &rhs)
{hfvec=rhs.hfvec; pfvec=rhs.pfvec; TOD_B=rhs.TOD_B;
deadline = rhs.deadline;
lifeline = rhs.lifeline;
roPend = rhs.roPend; rwPend = rhs.rwPend;
return *this;
}

XrdCmsKeyLoc() : roPend(0), rwPend(0) {}
XrdCmsKeyLoc() : lifeline(0), roPend(0), rwPend(0) {}
~XrdCmsKeyLoc() {}
};

Expand Down

0 comments on commit 28f0477

Please sign in to comment.