Loading...
Searching...
No Matches
XrdFfsFsinfo.cc File Reference
`#include <cstdio>`
`#include <cstring>`
`#include <cstdlib>`
`#include <ctime>`
`#include <pthread.h>`
`#include <sys/statvfs.h>`
`#include "XrdOuc/XrdOucHash.hh"`
Include dependency graph for XrdFfsFsinfo.cc:

Go to the source code of this file.

## Classes

struct | XrdFfsFsInfo

## Macros

#define | _GNU_SOURCE

## Functions

int | XrdFfsFsinfo_cache_search (int(*func)(const char *, const char *, struct statvfs *, uid_t), const char *rdrurl, const char *path, struct statvfs *stbuf, uid_t user_uid)

## Variables

pthread_mutex_t | XrdFfsFsinfo_cache_mutex_rd = PTHREAD_MUTEX_INITIALIZER
pthread_mutex_t | XrdFfsFsinfo_cache_mutex_wr = PTHREAD_MUTEX_INITIALIZER
XrdOucHash< struct XrdFfsFsInfo > | XrdFfsFsinfoHtab

## Class Documentation

## XrdFfsFsInfo

struct XrdFfsFsInfo

Definition at line 46 of file XrdFfsFsinfo.cc.

Collaboration diagram for XrdFfsFsInfo:

Class Members
fsblkcnt_t | f_bavail |
fsblkcnt_t | f_bfree |
fsblkcnt_t | f_blocks |
time_t | t |

## Macro Definition Documentation

## _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 37 of file XrdFfsFsinfo.cc.

## Function Documentation

## XrdFfsFsinfo_cache_search()

int XrdFfsFsinfo_cache_search | ( | int(* | func )(const char *, const char *, struct statvfs *, uid_t),
|  | const char * | rdrurl,
|  | const char * | path,
|  | struct statvfs * | stbuf,
|  | uid_t | user_uid )

Definition at line 57 of file XrdFfsFsinfo.cc.

{
struct XrdFfsFsInfo *s;
int wlock, rc = 0, dofree = 0;
const char *p;
char* sname;
wlock = pthread_mutex_trylock(&XrdFfsFsinfo_cache_mutex_wr);
pthread_mutex_lock(&XrdFfsFsinfo_cache_mutex_rd);
p=strstr(path, "oss.cgroup=");
if (p != NULL && p[11] != '\0')
sname = strdup(p+11);
else
sname = strdup(" ");
s = XrdFfsFsinfoHtab.Find(sname);
if (s != NULL)
{
stbuf->f_blocks = s->f_blocks;
stbuf->f_bavail = s->f_bavail;
stbuf->f_bfree = s->f_bfree;
}
else
{
rc = (*func)(rdrurl, path, stbuf, user_uid);
s = (struct XrdFfsFsInfo*) malloc(sizeof(struct XrdFfsFsInfo));
s->t = 0;
dofree = 1;
}
pthread_mutex_unlock(&XrdFfsFsinfo_cache_mutex_rd);
if (wlock == 0) // did get a lock for update
{
time_t curr_time = time(NULL);
if (curr_time - s->t > 120)
{
if (s->t != 0)
rc = (*func)(rdrurl, path, stbuf, user_uid);
pthread_mutex_lock(&XrdFfsFsinfo_cache_mutex_rd);
s->t = curr_time;
s->f_blocks = stbuf->f_blocks;
s->f_bavail = stbuf->f_bavail;
s->f_bfree = stbuf->f_bfree;
if (s->f_blocks != 0) // if s->f_blocks is zero, then this space token probably does not exist
XrdFfsFsinfoHtab.Rep(sname, s, 0, (XrdOucHash_Options)(Hash_default | Hash_keepdata));
else if (dofree) free(s);
pthread_mutex_unlock(&XrdFfsFsinfo_cache_mutex_rd);
}
pthread_mutex_unlock(&XrdFfsFsinfo_cache_mutex_wr);
}
free(sname);
return rc;
}
XrdFfsFsInfo::f_bavail
fsblkcnt_t f_bavail
Definition XrdFfsFsinfo.cc:49
XrdFfsFsInfo::t
time_t t
Definition XrdFfsFsinfo.cc:47
XrdFfsFsinfo_cache_mutex_rd
pthread_mutex_t XrdFfsFsinfo_cache_mutex_rd
Definition XrdFfsFsinfo.cc:53
XrdFfsFsinfoHtab
XrdOucHash< struct XrdFfsFsInfo > XrdFfsFsinfoHtab
Definition XrdFfsFsinfo.cc:55
XrdFfsFsInfo::f_bfree
fsblkcnt_t f_bfree
Definition XrdFfsFsinfo.cc:49
XrdFfsFsInfo::f_blocks
fsblkcnt_t f_blocks
Definition XrdFfsFsinfo.cc:49
XrdFfsFsinfo_cache_mutex_wr
pthread_mutex_t XrdFfsFsinfo_cache_mutex_wr
Definition XrdFfsFsinfo.cc:52
XrdFfsFsInfo
Definition XrdFfsFsinfo.cc:46
XrdOucHash_Options
XrdOucHash_Options
Definition XrdOucHash.hh:51
Hash_keepdata
@ Hash_keepdata
Definition XrdOucHash.hh:57
Hash_default
@ Hash_default
Definition XrdOucHash.hh:51

References XrdFfsFsInfo::f_bavail, XrdFfsFsInfo::f_bfree, XrdFfsFsInfo::f_blocks, Hash_default, Hash_keepdata, statvfs, XrdFfsFsInfo::t, XrdFfsFsinfo_cache_mutex_rd, XrdFfsFsinfo_cache_mutex_wr, and XrdFfsFsinfoHtab.

Referenced by xrootdfs_statfs().

Here is the caller graph for this function:

## Variable Documentation

## XrdFfsFsinfo_cache_mutex_rd

pthread_mutex_t XrdFfsFsinfo_cache_mutex_rd = PTHREAD_MUTEX_INITIALIZER

Definition at line 53 of file XrdFfsFsinfo.cc.

Referenced by XrdFfsFsinfo_cache_search().

## XrdFfsFsinfo_cache_mutex_wr

pthread_mutex_t XrdFfsFsinfo_cache_mutex_wr = PTHREAD_MUTEX_INITIALIZER

Definition at line 52 of file XrdFfsFsinfo.cc.

Referenced by XrdFfsFsinfo_cache_search().

## XrdFfsFsinfoHtab

XrdOucHash<struct XrdFfsFsInfo> XrdFfsFsinfoHtab

Definition at line 55 of file XrdFfsFsinfo.cc.

Referenced by XrdFfsFsinfo_cache_search().