XRootD
Loading...
Searching...
No Matches
XrdRmcReal.hh
Go to the documentation of this file.
1#ifndef __XRDRMCREAL_HH__
2#define __XRDRMCREAL_HH__
3/******************************************************************************/
4/* */
5/* X r d R m c R e a l . h h */
6/* */
7/* (c) 2019 by the Board of Trustees of the Leland Stanford, Jr., University */
8/* All Rights Reserved */
9/* Produced by Andrew Hanushevsky for Stanford University under contract */
10/* DE-AC02-76-SFO0515 with the Department of Energy */
11/* */
12/* This file is part of the XRootD software suite. */
13/* */
14/* XRootD is free software: you can redistribute it and/or modify it under */
15/* the terms of the GNU Lesser General Public License as published by the */
16/* Free Software Foundation, either version 3 of the License, or (at your */
17/* option) any later version. */
18/* */
19/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22/* License for more details. */
23/* */
24/* You should have received a copy of the GNU Lesser General Public License */
25/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27/* */
28/* The copyright holder's institutional names and contributor's names may not */
29/* be used to endorse or promote products derived from this software without */
30/* specific prior written permission of the institution or contributor. */
31/******************************************************************************/
32
33#include "XrdRmc/XrdRmc.hh"
34#include "XrdRmc/XrdRmcSlot.hh"
36
37/* This class defines an actual implementation of an XrdOucCache object. */
38
39class XrdRmcReal : public XrdOucCache
40{
41friend class XrdRmcData;
42public:
43
44XrdOucCacheIO *Attach(XrdOucCacheIO *ioP, int Options=0);
45
46 XrdRmcReal(int &rc,
47 XrdRmc::Parms &Parms,
49
51
52void PreRead();
53
54private:
55
56void eMsg(const char *Path, const char *What, long long xOff,
57 int xLen, int ec);
58int Detach(XrdOucCacheIO *ioP);
59char *Get(XrdOucCacheIO *ioP, long long lAddr, int &rGot, int &bIO);
60
61int ioAdd(XrdOucCacheIO *KeyVal, int &iNum);
62int ioDel(XrdOucCacheIO *KeyVal, int &iNum);
63
64inline
65int ioEnt(XrdOucCacheIO *kVal)
66 {union {short sV[4]; XrdOucCacheIO *pV;} Key = {{0,0,0,0}};
67 Key.pV = kVal;
68 return ((Key.sV[0]^Key.sV[1]^Key.sV[2]^Key.sV[3])&0x7fff)%hMax;
69 }
70inline
71int ioLookup(int &pip, int hip, void *kval)
72 {pip = 0;
73 while(hip && kval != Slots[hip].Key)
74 {pip = hip; hip = Slots[hip].HLink;}
75 return hip;
76 }
77
78int Ref(char *Addr, int rAmt, int sFlags=0);
79void Trunc(XrdOucCacheIO *ioP, long long lAddr);
80void Upd(char *Addr, int wAmt, int wOff);
81
82static const long long Shift = 48;
83static const long long Strip = 0x00000000ffffffffLL; //
84static const long long MaxFO = 0x000007ffffffffffLL; // Min 4K page -> 8TB-1
85
86XrdOucCacheIO::aprParms aprDefault; // Default automatic preread
87
88XrdSysMutex CMutex;
89XrdRmcSlot *Slots; // 1-to-1 slot to memory map
90int *Slash; // Slot hash table
91char *Base; // Base of memory cache
92long long HNum;
93long long SegCnt;
94long long SegSize;
95long long OffMask; // SegSize - 1
96long long SegShft; // log2(SegSize)
97int SegFull; // SegSize to mark
98int maxCache; // Maximum read to cache
99int maxFiles; // Maximum number of files to support
100int Options;
101
102// The following supports CacheIO object tracking
103//
104int *hTab; // -> Hash Table
105int hMax; // Number of entries in table
106int sFree; // Index of free file slot
107int sBeg; // Index of file slot array in slot table
108int sEnd; // Last index + 1
109
110// Various options
111//
112char Dbg; // Debug setting
113char Lgs; // Log statistics
114
115// This is the attach/detach control area
116//
117XrdSysSemaphore *AZero;
118int Attached;
119
120// This is the pre-read control area
121//
122struct prTask
123 {prTask *Next;
124 XrdRmcData *Data;
125 };
126void PreRead(XrdRmcReal::prTask *prReq);
127prTask *prFirst;
128prTask *prLast;
129XrdSysMutex prMutex;
130XrdSysSemaphore prReady;
131XrdSysSemaphore *prStop;
132int prNum;
133};
134#endif
XrdOucString Path
#define eMsg(x)
XrdOucCacheIO * Attach(XrdOucCacheIO *ioP, int Options=0)
void PreRead()
Parameters for a newly created memory cache.
Definition XrdRmc.hh:101