Loading...
Searching...
No Matches
XrdRmcReal Class Reference

`#include <XrdRmcReal.hh>`

Inheritance diagram for XrdRmcReal:
Collaboration diagram for XrdRmcReal:

## Public Member Functions

| XrdRmcReal (int &rc, XrdRmc::Parms &Parms, XrdOucCacheIO::aprParms *aprP=0)
| ~XrdRmcReal ()
XrdOucCacheIO * | Attach (XrdOucCacheIO *ioP, int Options=0)
void | PreRead ()
Public Member Functions inherited from XrdOucCache
| XrdOucCache (const char *ctype)
virtual | ~XrdOucCache ()
| Destructor.
virtual int | LocalFilePath (const char *url, char *buff=0, int blen=0, LFP_Reason why=ForAccess, bool forall=false)
virtual int | Prepare (const char *url, int oflags, mode_t mode)
virtual int | Rename (const char *oldp, const char *newp)
virtual int | Rmdir (const char *dirp)
virtual int | Stat (const char *url, struct stat &sbuff)
virtual int | Truncate (const char *path, off_t size)
virtual int | Unlink (const char *path)
virtual int | Xeq (XeqCmd cmd, char *arg, int arglen)

## Friends

class | XrdRmcData

## Additional Inherited Members

Public Types inherited from XrdOucCache
enum | LFP_Reason { ForAccess =0 , ForInfo , ForPath }
enum | XeqCmd { xeqNoop = 0 }
Public Attributes inherited from XrdOucCache
const char | CacheType [8]
| A 1-to-7 character cache type identifier (usually pfc or rmc).
XrdOucCacheStats | Statistics
Static Public Attributes inherited from XrdOucCache
static const int | optFIS = 0x0001
| File is structured (e.g. root file).
static const int | optNEW = 0x0014
| File is new -> optRW (o/w read or write).
static const int | optRW = 0x0004
| File is read/write (o/w read/only).
static const int | optWIN = 0x0024
| File is new -> optRW use write-in cache.

## Detailed Description

Definition at line 39 of file XrdRmcReal.hh.

## Constructor & Destructor Documentation

## XrdRmcReal()

XrdRmcReal::XrdRmcReal | ( | int & | rc,
|  | XrdRmc::Parms & | Parms,
|  | XrdOucCacheIO::aprParms * | aprP = 0 )

Definition at line 58 of file XrdRmcReal.cc.

: XrdOucCache("rmc"),
Slots(0), Slash(0), Base((char *)MAP_FAILED), Dbg(0), Lgs(0),
AZero(0), Attached(0), prFirst(0), prLast(0),
prReady(0), prStop(0), prNum(0)
{
size_t Bytes;
int n, minPag, isServ = ParmV.Options & XrdRmc::isServer;
// Copy over options
//
rc = ENOMEM;
Options = ParmV.Options;
if (Options & XrdRmc::Debug) Lgs = Dbg = (Options & XrdRmc::Debug);
if (Options & XrdRmc::logStats) Lgs = 1;
minPag = (ParmV.minPages <= 0 ? 256 : ParmV.minPages);
// Establish maximum number of attached files
//
if (ParmV.MaxFiles <= 0) maxFiles = (isServ ? 16384 : 256);
else {maxFiles = (ParmV.MaxFiles > 32764 ? 32764 : ParmV.MaxFiles);
maxFiles = maxFiles/sizeof(int)*sizeof(int);
if (!maxFiles) maxFiles = 256;
}
// Adjust segment size to be a power of two and atleast 4k.
//
if (ParmV.PageSize <= 0) SegSize = 32768;
else if (!(SegSize = ParmV.PageSize & ~0xfff)) SegSize = 4096;
// else if (SegSize > 16*1024*1024) SegSize = 16*1024*1024;
SegShft = 0; n = SegSize-1;
while(n) {SegShft++; n = n >> 1;}
SegSize = 1<<SegShft;
// The max to cache is also adjusted accrodingly based on segment size.
//
OffMask = SegSize-1;
SegCnt = (ParmV.CacheSize > 0 ? ParmV.CacheSize : 104857600)/SegSize;
if (SegCnt < minPag) SegCnt = minPag;
if (ParmV.Max2Cache < SegSize) maxCache = SegSize;
else maxCache = ParmV.Max2Cache/SegSize*SegSize;
SegFull = (Options & XrdRmc::isServer ? XrdRmcSlot::lenMask : SegSize);
// Allocate the cache plus the cache hash table
//
Bytes = static_cast<size_t>(SegSize)*SegCnt;
Base = (char *)mmap(0, Bytes + SegCnt*sizeof(int), PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
if (Base == MAP_FAILED) {rc = errno; return;}
Slash = (int *)(Base + Bytes); HNum = SegCnt/2*2-1;
// Now allocate the actual slots. We add additional slots to map files. These
// do not have any memory backing but serve as anchors for memory mappings.
//
if (!(Slots = new XrdRmcSlot[SegCnt+maxFiles])) return;
XrdRmcSlot::Init(Slots, SegCnt);
// Set pointers to be able to keep track of CacheIO objects and map them to
// CacheData objects. The hash table will be the first page of slot memory.
//
hTab = (int *)Base;
hMax = SegSize/sizeof(int);
sBeg = sFree = SegCnt;
sEnd = SegCnt + maxFiles;
// Now iniialize the slots to be used for the CacheIO objects
//
for (n = sBeg; n < sEnd; n++)
{Slots[n].Own.Next = Slots[n].Own.Prev = n;
Slots[n].HLink = n+1;
}
Slots[sEnd-1].HLink = 0;
// Setup the pre-readers if pre-read is enabled
//
if (Options & XrdRmc::canPreRead)
{pthread_t tid;
n = (Options & XrdRmc::isServer ? 9 : 3);
while(n--)
{if (XrdSysThread::Run(&tid, XrdRmcRealPRXeq, (void *)this,
0, "Prereader")) break;
prNum++;
}
if (aprP && prNum) XrdRmcData::setAPR(aprDefault, *aprP, SegSize);
}
// All done
//
rc = 0;
}
XrdRmcRealPRXeq
void * XrdRmcRealPRXeq(void *parg)
Definition XrdRmcReal.cc:52
Dbg
int Dbg
Definition XrdSecgsitest.cc:75
XrdOucCache::XrdOucCache
XrdOucCache(const char *ctype)
Definition XrdOucCache.hh:700
XrdRmcData::setAPR
static int setAPR(aprParms &Dest, aprParms &Src, int pSize)
Definition XrdRmcData.cc:489
XrdRmcSlot::lenMask
static const int lenMask
Definition XrdRmcSlot.hh:144
XrdRmcSlot::Init
static void Init(XrdRmcSlot *Base, int Num)
Definition XrdRmcSlot.hh:63
XrdRmc::Debug
static const int Debug
Produce some debug messages (levels 0, 1, 2, or 3).
Definition XrdRmc.hh:136
XrdRmc::logStats
static const int logStats
Display statistics upon detach.
Definition XrdRmc.hh:127
XrdRmc::isServer
static const int isServer
This is server application; not a user application.
Definition XrdRmc.hh:118
XrdRmc::canPreRead
static const int canPreRead
Enable pre-read operations (o/w ignored).
Definition XrdRmc.hh:124
XrdSysThread::Run
static int Run(pthread_t *, void *(*proc)(void *), void *arg, int opts=0, const char *desc=0)
Definition XrdSysPthread.cc:307

References XrdOucCache::XrdOucCache(), XrdRmc::Parms::CacheSize, XrdRmc::canPreRead, XrdRmc::Debug, if(), XrdRmcSlot::Init(), XrdRmc::isServer, XrdRmcSlot::lenMask, XrdRmc::logStats, XrdRmc::Parms::Max2Cache, XrdRmc::Parms::MaxFiles, XrdRmc::Parms::minPages, XrdRmc::Parms::Options, XrdRmc::Parms::PageSize, XrdSysThread::Run(), XrdRmcData::setAPR(), and XrdRmcRealPRXeq().

Here is the call graph for this function:

## ~XrdRmcReal()

XrdRmcReal::~XrdRmcReal | ( |  | ) |

Definition at line 154 of file XrdRmcReal.cc.

{
// Wait for all attachers to go away
//
CMutex.Lock();
if (Attached)
{XrdSysSemaphore aZero(0);
AZero = &aZero;
CMutex.UnLock();
aZero.Wait();
CMutex.Lock();
}
// If any preread threads exist, then stop them now
//
prMutex.Lock();
if (prNum)
{XrdSysSemaphore prDone(0);
prStop = &prDone;
prReady.Post();
prMutex.UnLock();
prDone.Wait();
prMutex.Lock();
}
// Delete the slots
//
delete Slots; Slots = 0;
// Unmap cache memory and associated hash table
//
if (Base != MAP_FAILED)
{munmap(Base, static_cast<size_t>(SegSize)*SegCnt);
Base = (char *)(MAP_FAILED);
}
// Release all locks, we are done
//
prMutex.UnLock();
CMutex.UnLock();
}

References XrdSysSemaphore::Post(), and XrdSysSemaphore::Wait().

Here is the call graph for this function:

## Member Function Documentation

## Attach()

XrdOucCacheIO * XrdRmcReal::Attach | ( | XrdOucCacheIO * | ioP,
|  | int | Options = 0 )

virtual

Implements XrdOucCache.

Definition at line 200 of file XrdRmcReal.cc.

{
static int Inst = 0;
XrdSysMutexHelper Monitor(CMutex);
XrdRmcData *dP;
int Cnt, Fnum = 0, theOpts = Opts & optRW;
// Check if we are being deleted
//
if (AZero) {errno = ECANCELED; return ioP;}
// Setup structured/unstructured option
//
if ((Opts & optFIS) || (Options & XrdRmc::isStructured)) theOpts |= optFIS;
// Get an entry in the filename table.
//
if (!(Cnt = ioAdd(ioP, Fnum)))
{errno = EMFILE;
return ioP;
}
// If this is the first addition then we need to get a new CacheData object.
// Otherwise, simply reuse the previous cache data object.
//
if (Cnt != 1) dP = Slots[Fnum].Status.Data;
else {long long vNum = static_cast<long long>(Fnum-SegCnt) << Shift
| (static_cast<long long>(Inst) << (Shift - 16));
Inst = (Inst+1) & 0xffff;
if ((dP = new XrdRmcData(this, ioP, vNum, theOpts)))
{Attached++; Slots[Fnum].Status.Data = dP;}
}
// Some debugging
//
if (Dbg) std::cerr <<"Cache: Attached " <<Cnt <<'/' <<Attached <<' '
<<std::hex << Fnum <<std::dec <<' ' <<ioP->Path() <<std::endl;
// All done
//
if (!dP) {errno = ENOMEM; return ioP;}
return (XrdOucCacheIO *)dP;
}
XrdOucCacheIO::Path
virtual const char * Path()=0
XrdOucCache::optRW
static const int optRW
File is read/write (o/w read/only).
Definition XrdOucCache.hh:517
XrdOucCache::optFIS
static const int optFIS
File is structured (e.g. root file).
Definition XrdOucCache.hh:516
XrdRmcReal::XrdRmcData
friend class XrdRmcData
Definition XrdRmcReal.hh:41
XrdRmc::isStructured
static const int isStructured
Definition XrdRmc.hh:121
XrdMpx::Opts
int Opts
Definition XrdMpxStats.cc:58

References XrdRmc::isStructured, XrdOucCache::optFIS, XrdOucCache::optRW, XrdOucCacheIO::Path(), and XrdRmcData.

Here is the call graph for this function:

## PreRead()

void XrdRmcReal::PreRead | ( |  | ) |

Definition at line 456 of file XrdRmcReal.cc.

{
prTask *prP;
// Simply wait and dispatch elements
//
if (Dbg) std::cerr <<"Cache: preread thread started; now " <<prNum <<std::endl;
while(1)
{prReady.Wait();
prMutex.Lock();
if (prStop) break;
if ((prP = prFirst))
{if (!(prFirst = prP->Next)) prLast = 0;
prMutex.UnLock();
prP->Data->Preread();
} else prMutex.UnLock();
}
// The cache is being deleted, wind down the prereads
//
prNum--;
if (prNum > 0) prReady.Post();
else prStop->Post();
if (Dbg) std::cerr <<"Cache: preread thread exited; left " <<prNum <<std::endl;
prMutex.UnLock();
}

References XrdRmcData::Preread().

Referenced by XrdRmcRealPRXeq().

Here is the call graph for this function:
Here is the caller graph for this function:

## Friends And Related Symbol Documentation

## XrdRmcData

friend class XrdRmcData

friend

Definition at line 41 of file XrdRmcReal.hh.

References ec, Path, and XrdRmcData.

Referenced by Attach(), and XrdRmcData.

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

- XrdRmcReal.hh
- XrdRmcReal.cc