xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdOuc
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
33
#include "
XrdOuc/XrdOucCacheDram.hh
"
34
#include "
XrdOuc/XrdOucCacheSlot.hh
"
35
#include "
XrdSys/XrdSysPthread.hh
"
36
37
/* This class defines an actual implementation of an XrdOucCache object. */
38
39
class
XrdOucCacheReal
:
public
XrdOucCacheDram
40
{
41
friend
class
XrdOucCacheData
;
42
public
:
43
44
XrdOucCacheIO
*
Attach
(
XrdOucCacheIO
*ioP,
int
Options
=0);
45
46
int
isAttached
() {
int
n;
47
CMutex
.
Lock
(); n =
Attached
;
CMutex
.
UnLock
();
48
return
n;
49
}
50
51
XrdOucCacheReal
(
int
&rc,
// Success = 0; o/w !0
52
Parms &Parms,
// Parameters
53
XrdOucCacheIO::aprParms
*aprP=0);
54
55
~XrdOucCacheReal
();
56
57
void
PreRead
();
58
59
private
:
60
61
void
eMsg
(
const
char
*
Path
,
const
char
*What,
long
long
xOff,
62
int
xLen,
int
ec);
63
int
Detach
(
XrdOucCacheIO
*ioP);
64
char
*
Get
(
XrdOucCacheIO
*ioP,
long
long
lAddr,
int
&rGot,
int
&bIO);
65
66
int
ioAdd
(
XrdOucCacheIO
*KeyVal,
int
&iNum);
67
int
ioDel
(
XrdOucCacheIO
*KeyVal,
int
&iNum);
68
69
inline
70
int
ioEnt
(
XrdOucCacheIO
*kVal)
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
}
75
inline
76
int
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
83
int
Ref
(
char
*Addr,
int
rAmt,
int
sFlags=0);
84
void
Trunc
(
XrdOucCacheIO
*ioP,
long
long
lAddr);
85
void
Upd
(
char
*Addr,
int
wAmt,
int
wOff);
86
87
static
const
long
long
Shift
= 48;
88
static
const
long
long
Strip
= 0x00000000ffffffffLL;
//
89
static
const
long
long
MaxFO
= 0x000007ffffffffffLL;
// Min 4K page -> 8TB-1
90
91
XrdOucCacheIO::aprParms
aprDefault
;
// Default automatic preread
92
93
XrdSysMutex
CMutex
;
94
XrdOucCacheSlot
*
Slots
;
// 1-to-1 slot to memory map
95
int
*
Slash
;
// Slot hash table
96
char
*
Base
;
// Base of memory cache
97
long
long
HNum
;
98
long
long
SegCnt
;
99
long
long
SegSize
;
100
long
long
OffMask
;
// SegSize - 1
101
long
long
SegShft
;
// log2(SegSize)
102
int
SegFull
;
// SegSize to mark
103
int
maxCache
;
// Maximum read to cache
104
int
maxFiles
;
// Maximum number of files to support
105
int
Options
;
106
107
// The following supports CacheIO object tracking
108
//
109
int
*
hTab
;
// -> Hash Table
110
int
hMax
;
// Number of entries in table
111
int
sFree
;
// Index of free file slot
112
int
sBeg
;
// Index of file slot array in slot table
113
int
sEnd
;
// Last index + 1
114
115
// Various options
116
//
117
char
Dbg
;
// Debug setting
118
char
Lgs
;
// Log statistics
119
120
// This is the attach/detach control area
121
//
122
XrdSysSemaphore
*
AZero
;
123
int
Attached
;
124
125
// This is the pre-read control area
126
//
127
struct
prTask
128
{
prTask
*
Next
;
129
XrdOucCacheData
*
Data
;
130
};
131
void
PreRead
(
XrdOucCacheReal::prTask
*prReq);
132
prTask
*
prFirst
;
133
prTask
*
prLast
;
134
XrdSysMutex
prMutex
;
135
XrdSysSemaphore
prReady
;
136
XrdSysSemaphore
*
prStop
;
137
int
prNum
;
138
};
139
#endif
Generated by
1.8.3.1