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
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);
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
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
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
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//
119
120// This is the pre-read control area
121//
133};
134#endif
Definition XrdOucCache.hh:105
Definition XrdOucCache.hh:495
Definition XrdRmcData.hh:43
Definition XrdRmcReal.hh:40
char Lgs
Definition XrdRmcReal.hh:113
XrdSysSemaphore * AZero
Definition XrdRmcReal.hh:117
XrdOucCacheIO * Attach(XrdOucCacheIO *ioP, int Options=0)
prTask * prFirst
Definition XrdRmcReal.hh:127
XrdRmcReal(int &rc, XrdRmc::Parms &Parms, XrdOucCacheIO::aprParms *aprP=0)
long long SegSize
Definition XrdRmcReal.hh:94
long long SegCnt
Definition XrdRmcReal.hh:93
prTask * prLast
Definition XrdRmcReal.hh:128
long long SegShft
Definition XrdRmcReal.hh:96
int Detach(XrdOucCacheIO *ioP)
void Upd(char *Addr, int wAmt, int wOff)
char * Get(XrdOucCacheIO *ioP, long long lAddr, int &rGot, int &bIO)
XrdOucCacheIO::aprParms aprDefault
Definition XrdRmcReal.hh:86
static const long long Shift
Definition XrdRmcReal.hh:82
int ioLookup(int &pip, int hip, void *kval)
Definition XrdRmcReal.hh:71
int hMax
Definition XrdRmcReal.hh:105
char Dbg
Definition XrdRmcReal.hh:112
long long OffMask
Definition XrdRmcReal.hh:95
void Trunc(XrdOucCacheIO *ioP, long long lAddr)
XrdRmcSlot * Slots
Definition XrdRmcReal.hh:89
int ioAdd(XrdOucCacheIO *KeyVal, int &iNum)
int maxFiles
Definition XrdRmcReal.hh:99
int prNum
Definition XrdRmcReal.hh:132
int SegFull
Definition XrdRmcReal.hh:97
int Options
Definition XrdRmcReal.hh:100
char * Base
Definition XrdRmcReal.hh:91
int ioEnt(XrdOucCacheIO *kVal)
Definition XrdRmcReal.hh:65
int sFree
Definition XrdRmcReal.hh:106
int * Slash
Definition XrdRmcReal.hh:90
long long HNum
Definition XrdRmcReal.hh:92
void PreRead(XrdRmcReal::prTask *prReq)
int Attached
Definition XrdRmcReal.hh:118
static const long long Strip
Definition XrdRmcReal.hh:83
XrdSysSemaphore * prStop
Definition XrdRmcReal.hh:131
int ioDel(XrdOucCacheIO *KeyVal, int &iNum)
XrdSysMutex prMutex
Definition XrdRmcReal.hh:129
XrdSysSemaphore prReady
Definition XrdRmcReal.hh:130
int * hTab
Definition XrdRmcReal.hh:104
int sEnd
Definition XrdRmcReal.hh:108
void eMsg(const char *Path, const char *What, long long xOff, int xLen, int ec)
void PreRead()
int maxCache
Definition XrdRmcReal.hh:98
static const long long MaxFO
Definition XrdRmcReal.hh:84
XrdSysMutex CMutex
Definition XrdRmcReal.hh:88
int sBeg
Definition XrdRmcReal.hh:107
int Ref(char *Addr, int rAmt, int sFlags=0)
Definition XrdRmcSlot.hh:42
int HLink
Definition XrdRmcSlot.hh:141
Definition XrdSysPthread.hh:165
Definition XrdSysPthread.hh:494
Definition XrdOucCache.hh:291
Definition XrdRmcReal.hh:123
prTask * Next
Definition XrdRmcReal.hh:123
XrdRmcData * Data
Definition XrdRmcReal.hh:124
Parameters for a newly created memory cache.
Definition XrdRmc.hh:101