XRootD
Loading...
Searching...
No Matches
XrdOssCache_FS Class Reference

#include <XrdOssCache.hh>

+ Collaboration diagram for XrdOssCache_FS:

Public Types

enum  FSOpts {
  None = 0 ,
  isXA = 1
}
 

Public Member Functions

 XrdOssCache_FS (int &retc, const char *fsg, const char *fsp, FSOpts opt)
 
 ~XrdOssCache_FS ()
 

Static Public Member Functions

static int Add (const char *Path)
 
static long long freeSpace (long long &Size, const char *path=0)
 
static long long freeSpace (XrdOssCache_Space &Space, const char *path)
 
static int getSpace (XrdOssCache_Space &Space, const char *sname, XrdOssVSPart **vsPart=0)
 
static int getSpace (XrdOssCache_Space &Space, XrdOssCache_Group *fsg, XrdOssVSPart **vsPart=0)
 

Public Attributes

XrdOssCache_FSDatafsdata
 
XrdOssCache_Groupfsgroup
 
const char * group
 
XrdOssCache_FSnext
 
FSOpts opts
 
const char * path
 
int plen
 
char suffix [4]
 

Detailed Description

Definition at line 132 of file XrdOssCache.hh.

Member Enumeration Documentation

◆ FSOpts

Enumerator
None 
isXA 

Definition at line 136 of file XrdOssCache.hh.

Constructor & Destructor Documentation

◆ XrdOssCache_FS()

XrdOssCache_FS::XrdOssCache_FS ( int & retc,
const char * fsg,
const char * fsp,
FSOpts opt )

Definition at line 146 of file XrdOssCache.cc.

150{
151 static const mode_t theMode = S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH;
152 STATFS_t fsbuff;
153 struct stat sfbuff;
155 XrdOssCache_FS *fsp;
156 int n;
157
158// Prefill in case of failure
159//
160 path = group = 0;
161
162// Verify that this is not a duplicate
163//
165 while(fsp && (strcmp(fsp->path,fsPath)||strcmp(fsp->fsgroup->group,fsGrp)))
166 if ((fsp = fsp->next) == XrdOssCache::fsfirst) {fsp = 0; break;}
167 if (fsp) {retc = EEXIST; return;}
168
169// Set the groupname and the path which is the supplied path/group name
170//
171 if (!(fsOpts & isXA)) path = strdup(fsPath);
172 else {path = XrdOssPath::genPath(fsPath, fsGrp, suffix);
173 if (mkdir(path, theMode) && errno != EEXIST) {retc=errno; return;}
174 }
175 plen = strlen(path);
176 group = strdup(fsGrp);
177 fsgroup= 0;
178 opts = fsOpts;
179 retc = ENOMEM;
180
181// Find the filesystem for this object
182//
183 if (FS_Stat(fsPath, &fsbuff) || stat(fsPath, &sfbuff)) {retc=errno; return;}
184
185// Find the matching filesystem data
186//
188 while(fdp) {if (fdp->fsid == sfbuff.st_dev) break; fdp = fdp->next;}
189
190// If we didn't find the filesystem, then create one
191//
192 if (!fdp)
193 {if (!(fdp = new XrdOssCache_FSData(fsPath,fsbuff,sfbuff.st_dev))) return;
194 else {fdp->next = XrdOssCache::fsdata; XrdOssCache::fsdata = fdp;}
195 }
196
197// Complete the filesystem block (failure now is not an option)
198//
199 fsdata = fdp;
200 retc = 0;
201
202// Link this filesystem into the filesystem chain
203//
204 if (!XrdOssCache::fsfirst) {next = this;
206 XrdOssCache::fslast = this;
207 }
210 XrdOssCache::fslast = this;
211 }
212
213// Check if this is the first group allocation
214//
216 while(fsgroup && strcmp(group, fsgroup->group)) fsgroup = fsgroup->next;
217 if (!fsgroup && (fsgroup = new XrdOssCache_Group(group, this)))
220 }
221
222// Add a filesystem to this group but only if it is a new one
223//
224 XrdOssCache_FSAP *fsAP;
225 for (n = 0; n < fsgroup->fsNum && fdp != fsgroup->fsVec[n].fsP; n++);
226 if (n >= fsgroup->fsNum)
227 {n= (fsgroup->fsNum + 1) * sizeof(XrdOssCache_FSAP);
228 fsgroup->fsVec = (XrdOssCache_FSAP *)realloc((void *)fsgroup->fsVec,n);
229 fsAP = &(fsgroup->fsVec[fsgroup->fsNum++]);
230 fsAP->fsP = fdp;
231 fsAP->apVec = 0;
232 fsAP->apNum = 0;
233 } else fsAP = &(fsgroup->fsVec[n]);
234
235// Add the allocation path to this partition
236//
237 n = (fsAP->apNum + 2) * sizeof(char *);
238 fsAP->apVec = (const char **)realloc((void *)fsAP->apVec, n);
239 fsAP->apVec[fsAP->apNum++] = path;
240 fsAP->apVec[fsAP->apNum] = 0;
241}
const char ** apVec
XrdOssCache_FSData * fsP
#define mkdir(a, b)
Definition XrdPosix.hh:69
#define stat(a, b)
Definition XrdPosix.hh:96
XrdOssCache_FSData * next
const char * group
XrdOssCache_Group * fsgroup
const char * path
XrdOssCache_FS * next
XrdOssCache_FSData * fsdata
static XrdOssCache_Group * fsgroups
XrdOssCache_FSAP * fsVec
XrdOssCache_Group * next
static XrdOssCache_FSData * fsdata
static XrdOssCache_FS * fsfirst
static XrdOssCache_FS * fslast
static char * genPath(const char *inPath, const char *cgrp, char *sfx)

References XrdOssCache_FSAP::apNum, XrdOssCache_FSAP::apVec, fsdata, XrdOssCache::fsdata, XrdOssCache::fsfirst, fsgroup, XrdOssCache_Group::fsgroups, XrdOssCache::fslast, XrdOssCache_Group::fsNum, XrdOssCache_FSAP::fsP, XrdOssCache_Group::fsVec, XrdOssPath::genPath(), group, XrdOssCache_Group::group, isXA, mkdir, XrdOssCache_FSData::next, next, XrdOssCache_Group::next, opts, path, plen, stat, and suffix.

+ Here is the call graph for this function:

◆ ~XrdOssCache_FS()

XrdOssCache_FS::~XrdOssCache_FS ( )
inline

Definition at line 160 of file XrdOssCache.hh.

160 {if (group) free((void *)group);
161 if (path) free((void *)path);
162 }

References group, and path.

Member Function Documentation

◆ Add()

int XrdOssCache_FS::Add ( const char * Path)
static

Definition at line 250 of file XrdOssCache.cc.

251{
252 STATFS_t fsbuff;
253 struct stat sfbuff;
255
256// Find the filesystem for this object
257//
258 if (FS_Stat(fsPath, &fsbuff) || stat(fsPath, &sfbuff)) return -errno;
259
260// Find the matching filesystem data
261//
263 while(fdp) {if (fdp->fsid == sfbuff.st_dev) break; fdp = fdp->next;}
264 if (fdp) return 0;
265
266// Create new filesystem data that will not be linked to any filesystem
267//
268 if (!(fdp = new XrdOssCache_FSData(fsPath,fsbuff,sfbuff.st_dev)))
269 return -ENOMEM;
272 return 0;
273}

References XrdOssCache::fsdata, XrdOssCache_FSData::next, and stat.

Referenced by XrdOssSys::ConfigSpace().

+ Here is the caller graph for this function:

◆ freeSpace() [1/2]

long long XrdOssCache_FS::freeSpace ( long long & Size,
const char * path = 0 )
static

Definition at line 279 of file XrdOssCache.cc.

280{
281 STATFS_t fsbuff;
282 long long fSpace;
283
284// Free space for a specific path
285//
286 if (path)
287 {if (FS_Stat(path, &fsbuff)) return -1;
288 Size = static_cast<long long>(fsbuff.f_blocks)
289 * static_cast<long long>(fsbuff.FS_BLKSZ);
290 return static_cast<long long>(fsbuff.f_bavail)
291 * static_cast<long long>(fsbuff.FS_BLKSZ);
292 }
293
294// Free space for the whole system
295//
297 fSpace = XrdOssCache::fsFree;
298 Size = XrdOssCache::fsSize;
300 return fSpace;
301}
static long long fsSize
static long long fsFree
static XrdSysMutex Mutex

References XrdOssCache::fsFree, XrdOssCache::fsSize, XrdSysMutex::Lock(), XrdOssCache::Mutex, path, and XrdSysMutex::UnLock().

Referenced by XrdOssSys::getStats(), XrdOssCache::Scan(), and XrdOssSys::StatFS().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ freeSpace() [2/2]

long long XrdOssCache_FS::freeSpace ( XrdOssCache_Space & Space,
const char * path )
static

Definition at line 305 of file XrdOssCache.cc.

306{
307 STATFS_t fsbuff;
308
309// Free space for a specific path
310//
311 if (!path || FS_Stat(path, &fsbuff)) return -1;
312
313 Space.Total = static_cast<long long>(fsbuff.f_blocks)
314 * static_cast<long long>(fsbuff.FS_BLKSZ);
315 Space.Free = static_cast<long long>(fsbuff.f_bavail)
316 * static_cast<long long>(fsbuff.FS_BLKSZ);
317 Space.Inodes= static_cast<long long>(fsbuff.f_files);
318 Space.Inleft= static_cast<long long>(fsbuff.FS_FFREE);
319
320 return Space.Free;
321}

References XrdOssCache_Space::Free, XrdOssCache_Space::Inleft, XrdOssCache_Space::Inodes, path, and XrdOssCache_Space::Total.

◆ getSpace() [1/2]

int XrdOssCache_FS::getSpace ( XrdOssCache_Space & Space,
const char * sname,
XrdOssVSPart ** vsPart = 0 )
static

Definition at line 327 of file XrdOssCache.cc.

329{
331
332// Try to find the space group name
333//
334 while(fsg && strcmp(sname, fsg->group)) fsg = fsg->next;
335 if (!fsg) return 0;
336
337// Return the accumulated result
338//
339 return getSpace(Space, fsg, vsPart);
340}
static int getSpace(XrdOssCache_Space &Space, const char *sname, XrdOssVSPart **vsPart=0)

References XrdOssCache_Group::fsgroups, getSpace(), XrdOssCache_Group::group, and XrdOssCache_Group::next.

Referenced by getSpace(), XrdOssSys::getStats(), XrdOssSys::StatLS(), and XrdOssSys::StatVS().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSpace() [2/2]

int XrdOssCache_FS::getSpace ( XrdOssCache_Space & Space,
XrdOssCache_Group * fsg,
XrdOssVSPart ** vsPart = 0 )
static

Definition at line 344 of file XrdOssCache.cc.

346{
347 XrdOssVSPart *pVec;
349
350// If there is no partition table then we really have no space to report
351//
352 if (fsg->fsNum < 1 || !fsg->fsVec) return 0;
353
354// If partion information is wanted, allocate a partition table
355//
356 if (vsPart) *vsPart = pVec = new XrdOssVSPart[fsg->fsNum];
357 else pVec = 0;
358
359// Prevent any changes
360//
362
363// Get overall values
364//
365 Space.Quota = fsg->Quota;
366 Space.Usage = fsg->Usage;
367
368// Accumulate the stats.
369//
370 for (int i = 0; i < fsg->fsNum; i++)
371 {fsd = fsg->fsVec[i].fsP;
372 Space.Total += fsd->size;
373 Space.Free += fsd->frsz;
374 if (fsd->frsz > Space.Maxfree) Space.Maxfree = fsd->frsz;
375 if (fsd->size > Space.Largest) Space.Largest = fsd->size;
376
377 if (pVec)
378 {pVec[i].pPath = fsd->path;
379 pVec[i].aPath = fsg->fsVec[i].apVec;
380 pVec[i].Total = fsd->size;
381 pVec[i].Free = fsd->frsz;
382 pVec[i].bdevID= fsd->bdevID;
383 pVec[i].partID= fsd->partID;
384 }
385 }
387
388// All done
389//
390 return fsg->fsNum;
391}
const char * path
unsigned short partID
unsigned short bdevID
unsigned short partID
Definition XrdOssVS.hh:71
long long Total
Definition XrdOssVS.hh:68
const char * pPath
Definition XrdOssVS.hh:66
const char ** aPath
Definition XrdOssVS.hh:67
long long Free
Definition XrdOssVS.hh:69
unsigned short bdevID
Definition XrdOssVS.hh:70

References XrdOssVSPart::aPath, XrdOssCache_FSAP::apVec, XrdOssCache_FSData::bdevID, XrdOssVSPart::bdevID, XrdOssCache_Space::Free, XrdOssVSPart::Free, XrdOssCache_FSData::frsz, XrdOssCache_Group::fsNum, XrdOssCache_FSAP::fsP, XrdOssCache_Group::fsVec, XrdOssCache_Space::Largest, XrdSysMutex::Lock(), XrdOssCache_Space::Maxfree, XrdOssCache::Mutex, XrdOssCache_FSData::partID, XrdOssVSPart::partID, XrdOssCache_FSData::path, XrdOssVSPart::pPath, XrdOssCache_Space::Quota, XrdOssCache_Group::Quota, XrdOssCache_FSData::size, XrdOssCache_Space::Total, XrdOssVSPart::Total, XrdSysMutex::UnLock(), XrdOssCache_Space::Usage, and XrdOssCache_Group::Usage.

+ Here is the call graph for this function:

Member Data Documentation

◆ fsdata

XrdOssCache_FSData* XrdOssCache_FS::fsdata

◆ fsgroup

XrdOssCache_Group* XrdOssCache_FS::fsgroup

Definition at line 145 of file XrdOssCache.hh.

Referenced by XrdOssCache_FS(), and XrdOssCache::Adjust().

◆ group

const char* XrdOssCache_FS::group

◆ next

◆ opts

FSOpts XrdOssCache_FS::opts

Definition at line 142 of file XrdOssCache.hh.

Referenced by XrdOssCache_FS(), XrdOssCache::Alloc(), and XrdOssCache::List().

◆ path

◆ plen

int XrdOssCache_FS::plen

Definition at line 141 of file XrdOssCache.hh.

Referenced by XrdOssCache_FS(), XrdOssCache::Alloc(), and XrdOssCache::List().

◆ suffix

char XrdOssCache_FS::suffix[4]

Definition at line 143 of file XrdOssCache.hh.

Referenced by XrdOssCache_FS(), and XrdOssCache::Alloc().


The documentation for this class was generated from the following files: