xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdOss
XrdOssCache.hh
Go to the documentation of this file.
1
#ifndef __XRDOSS_CACHE_H__
2
#define __XRDOSS_CACHE_H__
3
/******************************************************************************/
4
/* */
5
/* X r d O s s C a c h e . h h */
6
/* */
7
/* (c) 2003 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-AC03-76-SFO0515 with the Department of Energy */
11
/******************************************************************************/
12
13
// $Id$
14
15
#include <time.h>
16
#include <sys/stat.h>
17
#include "
XrdOuc/XrdOucDLlist.hh
"
18
#include "
XrdSys/XrdSysError.hh
"
19
#include "
XrdSys/XrdSysPthread.hh
"
20
21
/******************************************************************************/
22
/* O S D e p e n d e n t D e f i n i t i o n s */
23
/******************************************************************************/
24
25
#ifdef __solaris__
26
#include <sys/statvfs.h>
27
#define STATFS_t struct statvfs
28
#define FS_Stat(a,b) statvfs(a,b)
29
#define FS_BLKSZ f_frsize
30
#define FS_FFREE f_favail
31
#endif
32
#ifdef __linux__
33
#include <sys/vfs.h>
34
#define FS_Stat(a,b) statfs(a,b)
35
#define STATFS_t struct statfs
36
#define FS_BLKSZ f_bsize
37
#define FS_FFREE f_ffree
38
#endif
39
#ifdef AIX
40
#include <sys/statfs.h>
41
#define STATFS_t struct statfs
42
#define FS_Stat(a,b) statfs(a,b)
43
#define FS_BLKSZ f_bsize
44
#define FS_FFREE f_ffree
45
#endif
46
#if defined(__macos__) || defined(__FreeBSD__)
47
#include <sys/param.h>
48
#include <sys/mount.h>
49
#define STATFS_t struct statfs
50
#define FS_Stat(a,b) statfs(a,b)
51
#define FS_BLKSZ f_bsize
52
#define FS_FFREE f_ffree
53
#endif
54
55
/******************************************************************************/
56
/* X r d O s s C a c h e _ S p a c e */
57
/******************************************************************************/
58
59
class
XrdOssCache_Space
60
{
61
public
:
62
63
long
long
Total
;
64
long
long
Free
;
65
long
long
Maxfree
;
66
long
long
Largest
;
67
long
long
Inodes
;
68
long
long
Inleft
;
69
long
long
Usage
;
70
long
long
Quota
;
71
72
XrdOssCache_Space
() :
Total
(0),
Free
(0),
Maxfree
(0),
Largest
(0),
73
Inodes
(0),
Inleft
(0),
Usage
(-1),
Quota
(-1) {}
74
~XrdOssCache_Space
() {}
75
};
76
77
/******************************************************************************/
78
/* X r d O s s C a c h e _ F S D a t a */
79
/******************************************************************************/
80
81
// Flags values for FSData
82
//
83
#define XrdOssFSData_OFFLINE 0x0001
84
#define XrdOssFSData_ADJUSTED 0x0002
85
#define XrdOssFSData_REFRESH 0x0004
86
87
class
XrdOssCache_FSData
88
{
89
public
:
90
91
XrdOssCache_FSData
*
next
;
92
long
long
size
;
93
long
long
frsz
;
94
dev_t
fsid
;
95
const
char
*
path
;
96
time_t
updt
;
97
int
stat
;
98
99
XrdOssCache_FSData
(
const
char
*, STATFS_t &, dev_t);
100
~XrdOssCache_FSData
() {
if
(
path
) free((
void
*)
path
);}
101
};
102
103
/******************************************************************************/
104
/* X r d O s s C a c h e _ F S */
105
/******************************************************************************/
106
107
class
XrdOssCache_Group
;
108
109
class
XrdOssCache_FS
110
{
111
public
:
112
113
enum
FSOpts
{
None
= 0,
isXA
= 1};
114
115
XrdOssCache_FS
*
next
;
116
const
char
*
group
;
117
const
char
*
path
;
118
int
plen
;
119
FSOpts
opts
;
120
char
suffix
[4];
// Corresponds to OssPath::sfxLen
121
XrdOssCache_FSData
*
fsdata
;
122
XrdOssCache_Group
*
fsgroup
;
123
124
static
int
Add
(
const
char
*
Path
);
125
static
long
long
freeSpace
(
long
long
&Size,
const
char
*
path
=0);
126
static
long
long
freeSpace
(
XrdOssCache_Space
&Space,
const
char
*
path
);
127
static
int
getSpace
(
XrdOssCache_Space
&Space,
const
char
*sname);
128
static
int
getSpace
(
XrdOssCache_Space
&Space,
XrdOssCache_Group
*fsg);
129
130
XrdOssCache_FS
(
int
&retc,
131
const
char
*fsg,
132
const
char
*fsp,
133
FSOpts
opt);
134
~XrdOssCache_FS
() {
if
(
group
) free((
void
*)
group
);
135
if
(
path
) free((
void
*)
path
);
136
}
137
};
138
139
/******************************************************************************/
140
/* X r d O s s C a c h e _ G r o u p */
141
/******************************************************************************/
142
143
// Eventually we will have management information associated with cache groups
144
//
145
class
XrdOssCache_Group
146
{
147
public
:
148
149
XrdOssCache_Group
*
next
;
150
char
*
group
;
151
XrdOssCache_FS
*
curr
;
152
long
long
Usage
;
153
long
long
Quota
;
154
int
GRPid
;
155
static
long
long
PubQuota
;
156
157
static
XrdOssCache_Group
*
fsgroups
;
158
159
XrdOssCache_Group
(
const
char
*grp,
XrdOssCache_FS
*fsp=0)
160
:
next
(0),
group
(strdup(grp)),
curr
(fsp),
Usage
(0),
161
Quota
(-1),
GRPid
(-1) {}
162
~XrdOssCache_Group
() {
if
(
group
) free((
void
*)
group
);}
163
};
164
165
/******************************************************************************/
166
/* X r d O s s C a c h e */
167
/******************************************************************************/
168
169
class
XrdOssCache
170
{
171
public
:
172
173
static
void
Adjust
(dev_t devid, off_t size);
174
175
static
void
Adjust
(
const
char
*
Path
, off_t size,
struct
stat
*buf=0);
176
177
static
void
Adjust
(
XrdOssCache_FS
*fsp, off_t size);
178
179
struct
allocInfo
180
{
const
char
*
Path
;
// Req: Local file name
181
const
char
*
cgName
;
// Req: Cache group name
182
long
long
cgSize
;
// Opt: Estimated size
183
const
char
*
cgPath
;
// Opt: Specific partition path
184
int
cgPlen
;
// Opt: Length of partition path
185
int
cgPFsz
;
// Req: Size of buffer
186
char
*
cgPFbf
;
// Req: Buffer for cache pfn of size cgPFsz
187
char
*
cgPsfx
;
// Out: -> pfn suffix area. If 0, non-xa cache
188
XrdOssCache_FS
*
cgFSp
;
// Out: -> Cache file system definition
189
mode_t
aMode
;
// Opt: Create mode; if 0, pfn file not created
190
191
allocInfo
(
const
char
*pP,
char
*bP,
int
bL)
192
: Path(pP),
cgName
(0),
cgSize
(0),
cgPath
(0),
cgPlen
(0),
193
cgPFsz
(bL),
cgPFbf
(bP),
cgPsfx
(0),
cgFSp
(0),
aMode
(0) {}
194
~allocInfo
() {}
195
};
196
197
static
int
Alloc
(allocInfo &aInfo);
198
199
static
XrdOssCache_FS
*
Find
(
const
char
*Path,
int
lklen=0);
200
201
static
int
Init
(
const
char
*UDir,
const
char
*Qfile,
int
isSOL);
202
203
static
int
Init
(
long
long
aMin,
int
ovhd,
int
aFuzz);
204
205
static
void
List
(
const
char
*lname,
XrdSysError
&Eroute);
206
207
static
char
*
Parse
(
const
char
*token,
char
*cbuff,
int
cblen);
208
209
static
void
*
Scan
(
int
cscanint);
210
211
XrdOssCache
() {}
212
~XrdOssCache
() {}
213
214
static
XrdSysMutex
Mutex
;
// Cache context lock
215
216
static
long
long
fsTotal
;
// Total number of bytes known
217
static
long
long
fsLarge
;
// Total number of bytes in largest fspart
218
static
long
long
fsTotFr
;
// Total number of bytes free
219
static
long
long
fsFree
;
// Maximum contiguous free space
220
static
long
long
fsSize
;
// Size of partition with fsFree
221
static
XrdOssCache_FS
*
fsfirst
;
// -> First filesystem
222
static
XrdOssCache_FS
*
fslast
;
// -> Last filesystem
223
static
XrdOssCache_FSData
*
fsdata
;
// -> Filesystem data
224
static
int
fsCount
;
// Number of file systems
225
226
private
:
227
228
static
long
long
minAlloc
;
229
static
double
fuzAlloc
;
230
static
int
ovhAlloc
;
231
static
int
Quotas
;
232
static
int
Usage
;
233
};
234
#endif
Generated by
1.8.1.2