Loading...
Searching...
No Matches
XrdCmsBaseFS Class Reference

`#include <XrdCmsBaseFS.hh>`

Collaboration diagram for XrdCmsBaseFS:

## Public Member Functions

| XrdCmsBaseFS (void(*theCB)(XrdCmsBaseFR *, int))
| ~XrdCmsBaseFS ()
int | dfsTries ()
int | Exists (char *Path, int fnPos, int UpAT=0)
int | Exists (XrdCmsRRData &Arg, XrdCmsPInfo &Who, int noLim=0)
void | Init (int Opts, int DMlife, int DPLife)
int | isDFS ()
int | Limit ()
void | Limit (int rLim, int qMax)
int | Local ()
void | Pacer ()
void | Runner ()
void | SetTries (bool xdfs, int tcnt)
void | Start ()
int | stgTries ()
int | Traverse ()
int | Trim ()

## Static Public Attributes

static const int | Cntrl = 0x0001
static const int | dfltDfsTries = 2
static const int | dfltStgTries = 3
static const int | DFSys = 0x0002
static const int | Immed = 0x0004
static const int | Servr = 0x0100

## Detailed Description

Definition at line 87 of file XrdCmsBaseFS.hh.

## Constructor & Destructor Documentation

## XrdCmsBaseFS()

XrdCmsBaseFS::XrdCmsBaseFS | ( | void(* | theCB )(XrdCmsBaseFR *, int) | ) |

inline

Definition at line 149 of file XrdCmsBaseFS.hh.

: cBack(theCB), dfsMaxTries(dfltDfsTries),
stgMaxTries(dfltStgTries),
dmLife(0), dpLife(0), lclStat(0), preSel(1),
dfsSys(0), Server(0), Fixed(0), Punt(0) {}
XrdCmsBaseFS::dfltStgTries
static const int dfltStgTries
Definition XrdCmsBaseFS.hh:132
XrdCmsBaseFS::dfltDfsTries
static const int dfltDfsTries
Definition XrdCmsBaseFS.hh:131

References dfltDfsTries, and dfltStgTries.

## ~XrdCmsBaseFS()

XrdCmsBaseFS::~XrdCmsBaseFS | ( |  | ) |

inline

Definition at line 154 of file XrdCmsBaseFS.hh.

{}

## Member Function Documentation

## dfsTries()

int XrdCmsBaseFS::dfsTries | ( |  | ) |

inline

Definition at line 91 of file XrdCmsBaseFS.hh.

{return dfsMaxTries;}

## Exists() [1/2]

int XrdCmsBaseFS::Exists | ( | char * | Path,
|  | int | fnPos,
|  | int | UpAT = 0 )

Definition at line 151 of file XrdCmsBaseFS.cc.

{
EPNAME("Exists");
static struct dMoP dirMiss = {0}, dirPres = {1};
static int badDStat = 0;
static int badFStat = 0;
struct stat buf;
int eCnt, fRC, dRC;
int Opts = (UpAT ? XRDOSS_resonly|XRDOSS_updtatm : XRDOSS_resonly);
// If directory checking is enabled, find where the directory component ends
// if so requested.
//
if (fnPos < 0 && dmLife)
{for (fnPos = -(fnPos+1); fnPos >= 0 && Path[fnPos] != '/'; fnPos--) {}
if (fnPos > 0 && !hasDir(Path, fnPos)) return -1;
}
// Issue stat() via oss plugin. If it succeeds, return result.
//
if (!(fRC = Config.ossFS->Stat(Path, &buf, Opts)))
{if ((buf.st_mode & S_IFMT) == S_IFREG)
return (buf.st_mode & XRDSFS_POSCPEND ? CmsHaveRequest::Pending
: CmsHaveRequest::Online);
return (buf.st_mode & S_IFMT) == S_IFDIR ? CmsHaveRequest::Online : -1;
}
// The entry does not exist but if we are a staging server then it may be in
// the prepare queue in which case we must say that it is pending arrival.
//
if (Config.DiskSS && PrepQ.Exists(Path)) return CmsHaveRequest::Pending;
// The entry does not exist. Check if the directory exists and if not, put it
// in our directory missing table so we don't keep hitting this directory.
// This is disabled by default and enabled by the cms.dfs directive.
//
if (fnPos > 0 && dmLife)
{struct dMoP *xVal = &dirMiss;
int xLife = dmLife;
Path[fnPos] = '\0';
if (!(dRC = Config.ossFS->Stat(Path, &buf, XRDOSS_resonly)))
{xLife = dpLife; xVal = &dirPres;}
if (dRC && dRC != -ENOENT)
{fsMutex.Lock(); eCnt = badDStat++; fsMutex.UnLock();
if (!(eCnt & 0xff))
{char buff[80];
snprintf(buff, sizeof(buff), "to stat dir (events=%d)", eCnt+1);
Say.Emsg("Exists", dRC, buff, Path);
Path[fnPos] = '/';
}
} else {
fsMutex.Lock();
fsDirMP.Rep(Path, xVal, xLife, Hash_keepdata);
fsMutex.UnLock();
DEBUG("add " <<xLife <<(xVal->Present ? " okdir ":" nodir ") <<Path);
Path[fnPos] = '/';
}
} else {
if (fRC && fRC != -ENOENT)
{fsMutex.Lock(); eCnt = badFStat++; fsMutex.UnLock();
if (!(eCnt & 0xff))
{char buff[80];
snprintf(buff, sizeof(buff), "to stat file (events=%d)", eCnt+1);
Say.Emsg("Exists", fRC, buff, Path);
}
}
}
return -1;
}
DEBUG
#define DEBUG(x)
Definition XrdBwmTrace.hh:54
EPNAME
#define EPNAME(x)
Definition XrdBwmTrace.hh:56
XRDOSS_resonly
#define XRDOSS_resonly
Definition XrdOss.hh:486
XRDOSS_updtatm
#define XRDOSS_updtatm
Definition XrdOss.hh:487
Hash_keepdata
@ Hash_keepdata
Definition XrdOucHash.hh:57
stat
#define stat(a, b)
Definition XrdPosix.hh:101
Path
XrdOucString Path
Definition XrdSecpwdSrvAdmin.cc:160
XRDSFS_POSCPEND
#define XRDSFS_POSCPEND
Definition XrdSfsFlags.hh:89
XrdCmsConfig::ossFS
XrdOss * ossFS
Definition XrdCmsConfig.hh:186
XrdCmsConfig::DiskSS
bool DiskSS
Definition XrdCmsConfig.hh:123
XrdCmsPrepare::Exists
int Exists(char *path)
Definition XrdCmsPrepare.cc:216
XrdOss::Stat
virtual int Stat(const char *path, struct stat *buff, int opts=0, XrdOucEnv *envP=0)=0
XrdSysError::Emsg
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition XrdSysError.cc:95
XrdCms::Say
XrdSysError Say
Definition XrdCmsManager.cc:62
XrdCms::PrepQ
XrdCmsPrepare PrepQ
Definition XrdCmsPrepare.cc:54
XrdCms::Config
XrdCmsConfig Config
Definition XrdCmsConfig.cc:108
XrdMpx::Opts
int Opts
Definition XrdMpxStats.cc:58
XrdCms::CmsHaveRequest::Pending
@ Pending
Definition YProtocol.hh:236
XrdCms::CmsHaveRequest::Online
@ Online
Definition YProtocol.hh:236

References XrdCms::Config, DEBUG, EPNAME, Hash_keepdata, XrdCms::CmsHaveRequest::Online, Path, XrdCms::CmsHaveRequest::Pending, XrdCms::PrepQ, XrdCms::Say, stat, XRDOSS_resonly, XRDOSS_updtatm, and XRDSFS_POSCPEND.

## Exists() [2/2]

int XrdCmsBaseFS::Exists | ( | XrdCmsRRData & | Arg,
|  | XrdCmsPInfo & | Who,
|  | int | noLim = 0 )

Definition at line 115 of file XrdCmsBaseFS.cc.

{
int aOK, fnPos;
// If we cannot do this locally, then we need to forward the request but only
// if we have a route. Otherwise, just indicate that queueing is necessary.
//
if (!lclStat)
{aOK = (!theQ.rLimit || noLim || (!Fixed && Bypass()));
if (Who.rovec) Queue(Arg, Who, -(Arg.PathLen-1), !aOK);
return 0;
}
// If directory checking is enabled, find where the directory component ends
// and then check if we even have this directory.
//
if (dmLife)
{for (fnPos=Arg.PathLen-2;fnPos >= 0 && Arg.Path[fnPos] != '/';fnPos--) {}
if (fnPos > 0 && !hasDir(Arg.Path, fnPos)) return -1;
} else fnPos = 0;
// If we are not limiting requests, or not limiting everyone and this is not
// a meta-manager, or we are not timing requests and can skip the queue; then
// issue the fstat() inline and report back the result.
//
if (!theQ.rLimit || noLim || (Fixed && Bypass()))
return Exists(Arg.Path, fnPos);
// We can't do this now, so forcibly queue the request
//
if (Who.rovec) Queue(Arg, Who, fnPos, 1);
return 0;
}
Exists
bool Exists
Definition XrdSecgsiProxy.cc:97
XrdCmsPInfo::rovec
SMask_t rovec
Definition XrdCmsPList.hh:47
XrdCmsRRData::Path
char * Path
Definition XrdCmsRRData.hh:55
XrdCmsRRData::PathLen
int PathLen
Definition XrdCmsRRData.hh:66

References Exists, XrdCmsRRData::Path, XrdCmsRRData::PathLen, and XrdCmsPInfo::rovec.

## Init()

void XrdCmsBaseFS::Init | ( | int | Opts,
|  | int | DMlife,
|  | int | DPLife )

Definition at line 245 of file XrdCmsBaseFS.cc.

{
// Set values.
//
dmLife = DMLife;
dpLife = DPLife ? DPLife : DMLife * 10;
Server = (Opts & Servr) != 0;
lclStat = (Opts & Cntrl) != 0 || Server;
preSel = (Opts & Immed) == 0;
dfsSys = (Opts & DFSys) != 0;
}
XrdCmsBaseFS::Immed
static const int Immed
Definition XrdCmsBaseFS.hh:114
XrdCmsBaseFS::Servr
static const int Servr
Definition XrdCmsBaseFS.hh:115
XrdCmsBaseFS::Cntrl
static const int Cntrl
Definition XrdCmsBaseFS.hh:112
XrdCmsBaseFS::DFSys
static const int DFSys
Definition XrdCmsBaseFS.hh:113

References Cntrl, DFSys, Immed, and Servr.

## isDFS()

int XrdCmsBaseFS::isDFS | ( |  | ) |

inline

Definition at line 119 of file XrdCmsBaseFS.hh.

{return dfsSys;}

## Limit() [1/2]

int XrdCmsBaseFS::Limit | ( |  | ) |

inline

Definition at line 121 of file XrdCmsBaseFS.hh.

{return theQ.rLimit;}

## Limit() [2/2]

void XrdCmsBaseFS::Limit | ( | int | rLim,
|  | int | qMax )

Definition at line 262 of file XrdCmsBaseFS.cc.

{
// Establish the limits
//
if (rLim < 0) {theQ.rAgain=theQ.rLeft = -1; rLim = -rLim; Fixed = 1;}
else {theQ.rAgain = theQ.rLeft = (rLim > 1 ? rLim/2 : 1); Fixed = 0;}
theQ.rLimit = (rLim <= 1000 ? rLim : 0);
if (Qmax > 0) theQ.qMax = Qmax;
else if (!(theQ.qMax = theQ.rLimit*2 + theQ.rLimit/2)) theQ.qMax = 1;
}

## Local()

int XrdCmsBaseFS::Local | ( |  | ) |

inline

Definition at line 125 of file XrdCmsBaseFS.hh.

{return lclStat;}

## Pacer()

void XrdCmsBaseFS::Pacer | ( |  | ) |

Definition at line 278 of file XrdCmsBaseFS.cc.

{
XrdCmsBaseFR *rP;
int inQ, rqRate = 1000/theQ.rLimit;
// Process requests at the given rate
//
do{theQ.pqAvail.Wait();
theQ.Mutex.Lock(); inQ = 1;
while((rP = theQ.pqFirst))
{if (!(theQ.pqFirst = rP->Next)) {theQ.pqLast = 0; inQ = 0;}
theQ.Mutex.UnLock();
if (rP->PDirLen > 0 && !hasDir(rP->Path, rP->PDirLen))
{delete rP; continue;}
theQ.Mutex.Lock();
if (theQ.rqFirst) {theQ.rqLast->Next = rP; theQ.rqLast = rP;}
else {theQ.rqFirst = theQ.rqLast = rP; theQ.rqAvail.Post();}
theQ.Mutex.UnLock();
XrdSysTimer::Wait(rqRate);
if (!inQ) break;
theQ.Mutex.Lock();
}
if (inQ) theQ.Mutex.UnLock();
} while(1);
}
XrdCmsBaseFR::Path
char * Path
Definition XrdCmsBaseFS.hh:56
XrdCmsBaseFR::PDirLen
short PDirLen
Definition XrdCmsBaseFS.hh:58
XrdCmsBaseFR::Next
XrdCmsBaseFR * Next
Definition XrdCmsBaseFS.hh:54
XrdSysTimer::Wait
static void Wait(int milliseconds)
Definition XrdSysTimer.cc:227

References XrdCmsBaseFR::Next, XrdCmsBaseFR::Path, XrdCmsBaseFR::PDirLen, and XrdSysTimer::Wait().

Here is the call graph for this function:

## Runner()

void XrdCmsBaseFS::Runner | ( |  | ) |

Definition at line 354 of file XrdCmsBaseFS.cc.

{
XrdCmsBaseFR *rP;
int inQ;
// Process requests at the given rate
//
do{theQ.rqAvail.Wait();
theQ.Mutex.Lock(); inQ = 1;
while((rP = theQ.rqFirst))
{if (!(theQ.rqFirst = rP->Next)) {theQ.rqLast = 0; inQ = 0;}
theQ.qNum--;
theQ.Mutex.UnLock();
Xeq(rP); delete rP;
if (!inQ) break;
theQ.Mutex.Lock();
}
if (inQ) theQ.Mutex.UnLock();
} while(1);
}

References XrdCmsBaseFR::Next.

## SetTries()

void XrdCmsBaseFS::SetTries | ( | bool | xdfs,
|  | int | tcnt )

inline

Definition at line 134 of file XrdCmsBaseFS.hh.

{if (xdfs) dfsMaxTries =
(tcnt < 0 ? dfltDfsTries : tcnt);
else stgMaxTries =
(tcnt < 1 ? dfltStgTries : tcnt);
}

References dfltDfsTries, and dfltStgTries.

## Start()

void XrdCmsBaseFS::Start | ( |  | ) |

Definition at line 379 of file XrdCmsBaseFS.cc.

{
EPNAME("Start");
void *Me = (void *)this;
pthread_t tid;
// Issue some debugging here so we know how we are starting up
//
DEBUG("Srv=" <<int(Server) <<" dfs=" <<int(dfsSys) <<" lcl=" <<int(lclStat)
<<" Pre=" <<int(preSel) <<" dmLife=" <<dmLife <<' ' <<dpLife);
DEBUG("Lim=" <<theQ.rLimit <<' ' <<theQ.rAgain <<" fix=" <<int(Fixed)
<<" Qmax=" <<theQ.qMax);
// Set the passthru option if we can't do this locally and have no limit
//
Punt = (!theQ.rLimit && !lclStat);
// If we need to throttle we will need two threads for the queue. The first is
// the pacer thread that feeds the runner thread at a fixed rate.
//
if (theQ.rLimit)
{if (XrdSysThread::Run(&tid, XrdCmsBasePacer, Me, 0, "fsQ pacer")
|| XrdSysThread::Run(&tid, XrdCmsBaseRunner, Me, 0, "fsQ runner"))
{Say.Emsg("cmsd", errno, "start baseFS queue handler");
theQ.rLimit = 0;
}
}
}
XrdCmsBaseRunner
void * XrdCmsBaseRunner(void *carg)
Definition XrdCmsBaseFS.cc:63
XrdCmsBasePacer
void * XrdCmsBasePacer(void *carg)
Definition XrdCmsBaseFS.cc:58
XrdSysThread::Run
static int Run(pthread_t *, void *(*proc)(void *), void *arg, int opts=0, const char *desc=0)
Definition XrdSysPthread.cc:307

References DEBUG, EPNAME, XrdSysThread::Run(), XrdCms::Say, XrdCmsBasePacer(), and XrdCmsBaseRunner().

Here is the call graph for this function:

## stgTries()

int XrdCmsBaseFS::stgTries | ( |  | ) |

inline

Definition at line 143 of file XrdCmsBaseFS.hh.

{return stgMaxTries;}

## Traverse()

int XrdCmsBaseFS::Traverse | ( |  | ) |

inline

Definition at line 147 of file XrdCmsBaseFS.hh.

{return Punt;}

## Trim()

int XrdCmsBaseFS::Trim | ( |  | ) |

inline

Definition at line 145 of file XrdCmsBaseFS.hh.

{return preSel;}

## Member Data Documentation

## Cntrl

const int XrdCmsBaseFS::Cntrl = 0x0001

static

Definition at line 112 of file XrdCmsBaseFS.hh.

Referenced by XrdCmsConfig::Configure1(), and Init().

## dfltDfsTries

const int XrdCmsBaseFS::dfltDfsTries = 2

static

Definition at line 131 of file XrdCmsBaseFS.hh.

Referenced by XrdCmsBaseFS(), and SetTries().

## dfltStgTries

const int XrdCmsBaseFS::dfltStgTries = 3

static

Definition at line 132 of file XrdCmsBaseFS.hh.

Referenced by XrdCmsBaseFS(), and SetTries().

## DFSys

const int XrdCmsBaseFS::DFSys = 0x0002

static

Definition at line 113 of file XrdCmsBaseFS.hh.

Referenced by XrdCmsConfig::Configure1(), and Init().

## Immed

const int XrdCmsBaseFS::Immed = 0x0004

static

Definition at line 114 of file XrdCmsBaseFS.hh.

Referenced by XrdCmsConfig::Configure1(), and Init().

## Servr

const int XrdCmsBaseFS::Servr = 0x0100

static

Definition at line 115 of file XrdCmsBaseFS.hh.

Referenced by Init().

The documentation for this class was generated from the following files:

- XrdCmsBaseFS.hh
- XrdCmsBaseFS.cc