xrootd
XrdOucCacheReal.hh
Go to the documentation of this file.
1#ifndef __XRDOUCCACHEREAL_HH__
2#define __XRDOUCCACHEREAL_HH__
3/******************************************************************************/
4/* */
5/* X r d O u c C a c h e R e a l . h h */
6/* */
7/* (c) 2011 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
36
37/* This class defines an actual implementation of an XrdOucCache object. */
38
40{
41friend class XrdOucCacheData;
42public:
43
45
46int isAttached() {int n;
48 return n;
49 }
50
51 XrdOucCacheReal(int &rc, // Success = 0; o/w !0
52 Parms &Parms, // Parameters
54
56
57void PreRead();
58
59private:
60
61void eMsg(const char *Path, const char *What, long long xOff,
62 int xLen, int ec);
64char *Get(XrdOucCacheIO *ioP, long long lAddr, int &rGot, int &bIO);
65
66int ioAdd(XrdOucCacheIO *KeyVal, int &iNum);
67int ioDel(XrdOucCacheIO *KeyVal, int &iNum);
68
69inline
71 {union {short sV[4]; XrdOucCacheIO *pV;} Key = {{0,0,0,0}};
72 Key.pV = kVal;
73 return ((Key.sV[0]^Key.sV[1]^Key.sV[2]^Key.sV[3])&0x7fff)%hMax;
74 }
75inline
76int ioLookup(int &pip, int hip, void *kval)
77 {pip = 0;
78 while(hip && kval != Slots[hip].Key)
79 {pip = hip; hip = Slots[hip].HLink;}
80 return hip;
81 }
82
83int Ref(char *Addr, int rAmt, int sFlags=0);
84void Trunc(XrdOucCacheIO *ioP, long long lAddr);
85void Upd(char *Addr, int wAmt, int wOff);
86
87static const long long Shift = 48;
88static const long long Strip = 0x00000000ffffffffLL; //
89static const long long MaxFO = 0x000007ffffffffffLL; // Min 4K page -> 8TB-1
90
91XrdOucCacheIO::aprParms aprDefault; // Default automatic preread
92
94XrdOucCacheSlot *Slots; // 1-to-1 slot to memory map
95int *Slash; // Slot hash table
96char *Base; // Base of memory cache
97long long HNum;
98long long SegCnt;
99long long SegSize;
100long long OffMask; // SegSize - 1
101long long SegShft; // log2(SegSize)
102int SegFull; // SegSize to mark
103int maxCache; // Maximum read to cache
104int maxFiles; // Maximum number of files to support
106
107// The following supports CacheIO object tracking
108//
109int *hTab; // -> Hash Table
110int hMax; // Number of entries in table
111int sFree; // Index of free file slot
112int sBeg; // Index of file slot array in slot table
113int sEnd; // Last index + 1
114
115// Various options
116//
117char Dbg; // Debug setting
118char Lgs; // Log statistics
119
120// This is the attach/detach control area
121//
124
125// This is the pre-read control area
126//
127struct prTask
130 };
138};
139#endif
Definition: XrdOucCacheData.hh:47
const char * Path()
Definition: XrdOucCacheData.hh:56
Definition: XrdOucCacheDram.hh:94
Definition: XrdOucCache.hh:128
Definition: XrdOucCacheReal.hh:40
int Options
Definition: XrdOucCacheReal.hh:105
prTask * prLast
Definition: XrdOucCacheReal.hh:133
XrdSysMutex prMutex
Definition: XrdOucCacheReal.hh:134
int SegFull
Definition: XrdOucCacheReal.hh:102
long long SegShft
Definition: XrdOucCacheReal.hh:101
int hMax
Definition: XrdOucCacheReal.hh:110
long long OffMask
Definition: XrdOucCacheReal.hh:100
int maxCache
Definition: XrdOucCacheReal.hh:103
long long SegCnt
Definition: XrdOucCacheReal.hh:98
long long SegSize
Definition: XrdOucCacheReal.hh:99
void Trunc(XrdOucCacheIO *ioP, long long lAddr)
XrdOucCacheIO::aprParms aprDefault
Definition: XrdOucCacheReal.hh:91
int maxFiles
Definition: XrdOucCacheReal.hh:104
int ioDel(XrdOucCacheIO *KeyVal, int &iNum)
void Upd(char *Addr, int wAmt, int wOff)
int sBeg
Definition: XrdOucCacheReal.hh:112
int prNum
Definition: XrdOucCacheReal.hh:137
int Attached
Definition: XrdOucCacheReal.hh:123
int * hTab
Definition: XrdOucCacheReal.hh:109
static const long long MaxFO
Definition: XrdOucCacheReal.hh:89
int ioEnt(XrdOucCacheIO *kVal)
Definition: XrdOucCacheReal.hh:70
XrdOucCacheIO * Attach(XrdOucCacheIO *ioP, int Options=0)
int Detach(XrdOucCacheIO *ioP)
prTask * prFirst
Definition: XrdOucCacheReal.hh:132
long long HNum
Definition: XrdOucCacheReal.hh:97
XrdSysSemaphore prReady
Definition: XrdOucCacheReal.hh:135
char * Base
Definition: XrdOucCacheReal.hh:96
XrdSysSemaphore * prStop
Definition: XrdOucCacheReal.hh:136
int Ref(char *Addr, int rAmt, int sFlags=0)
static const long long Strip
Definition: XrdOucCacheReal.hh:88
char Dbg
Definition: XrdOucCacheReal.hh:117
int sEnd
Definition: XrdOucCacheReal.hh:113
int * Slash
Definition: XrdOucCacheReal.hh:95
int sFree
Definition: XrdOucCacheReal.hh:111
int ioLookup(int &pip, int hip, void *kval)
Definition: XrdOucCacheReal.hh:76
int isAttached()
Definition: XrdOucCacheReal.hh:46
void eMsg(const char *Path, const char *What, long long xOff, int xLen, int ec)
XrdOucCacheReal(int &rc, Parms &Parms, XrdOucCacheIO::aprParms *aprP=0)
XrdOucCacheSlot * Slots
Definition: XrdOucCacheReal.hh:94
XrdSysMutex CMutex
Definition: XrdOucCacheReal.hh:93
char Lgs
Definition: XrdOucCacheReal.hh:118
int ioAdd(XrdOucCacheIO *KeyVal, int &iNum)
void PreRead(XrdOucCacheReal::prTask *prReq)
XrdSysSemaphore * AZero
Definition: XrdOucCacheReal.hh:122
static const long long Shift
Definition: XrdOucCacheReal.hh:87
char * Get(XrdOucCacheIO *ioP, long long lAddr, int &rGot, int &bIO)
Definition: XrdOucCacheSlot.hh:42
int HLink
Definition: XrdOucCacheSlot.hh:141
Definition: XrdSysPthread.hh:166
void Lock()
Definition: XrdSysPthread.hh:220
void UnLock()
Definition: XrdSysPthread.hh:222
Definition: XrdSysPthread.hh:404
Definition: XrdOucCache.hh:248
Definition: XrdOucCacheReal.hh:128
prTask * Next
Definition: XrdOucCacheReal.hh:128
XrdOucCacheData * Data
Definition: XrdOucCacheReal.hh:129
Definition: XrdOucCache.hh:321