XRootD
Loading...
Searching...
No Matches
XrdFfsFsinfo.hh File Reference
#include <sys/statvfs.h>
+ Include dependency graph for XrdFfsFsinfo.hh:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

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)
 

Function Documentation

◆ XrdFfsFsinfo_cache_search()

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

Definition at line 57 of file XrdFfsFsinfo.cc.

58{
59 struct XrdFfsFsInfo *s;
60 int wlock, rc = 0, dofree = 0;
61 const char *p;
62 char* sname;
63
64 wlock = pthread_mutex_trylock(&XrdFfsFsinfo_cache_mutex_wr);
65 pthread_mutex_lock(&XrdFfsFsinfo_cache_mutex_rd);
66
67 p=strstr(path, "oss.cgroup=");
68 if (p != NULL && p[11] != '\0')
69 sname = strdup(p+11);
70 else
71 sname = strdup(" ");
72 s = XrdFfsFsinfoHtab.Find(sname);
73 if (s != NULL)
74 {
75 stbuf->f_blocks = s->f_blocks;
76 stbuf->f_bavail = s->f_bavail;
77 stbuf->f_bfree = s->f_bfree;
78 }
79 else
80 {
81 rc = (*func)(rdrurl, path, stbuf, user_uid);
82 s = (struct XrdFfsFsInfo*) malloc(sizeof(struct XrdFfsFsInfo));
83 s->t = 0;
84 dofree = 1;
85 }
86
87 pthread_mutex_unlock(&XrdFfsFsinfo_cache_mutex_rd);
88 if (wlock == 0) // did get a lock for update
89 {
90 time_t curr_time = time(NULL);
91 if (curr_time - s->t > 120)
92 {
93 if (s->t != 0)
94 rc = (*func)(rdrurl, path, stbuf, user_uid);
95
96 pthread_mutex_lock(&XrdFfsFsinfo_cache_mutex_rd);
97 s->t = curr_time;
98 s->f_blocks = stbuf->f_blocks;
99 s->f_bavail = stbuf->f_bavail;
100 s->f_bfree = stbuf->f_bfree;
101
102 if (s->f_blocks != 0) // if s->f_blocks is zero, then this space token probably does not exist
104 else if (dofree) free(s);
105 pthread_mutex_unlock(&XrdFfsFsinfo_cache_mutex_rd);
106 }
107 pthread_mutex_unlock(&XrdFfsFsinfo_cache_mutex_wr);
108 }
109 free(sname);
110 return rc;
111}
fsblkcnt_t f_bavail
pthread_mutex_t XrdFfsFsinfo_cache_mutex_rd
XrdOucHash< struct XrdFfsFsInfo > XrdFfsFsinfoHtab
fsblkcnt_t f_bfree
fsblkcnt_t f_blocks
pthread_mutex_t XrdFfsFsinfo_cache_mutex_wr
XrdOucHash_Options
Definition XrdOucHash.hh:51
@ Hash_keepdata
Definition XrdOucHash.hh:57
@ Hash_default
Definition XrdOucHash.hh:51

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

Referenced by xrootdfs_statfs().

+ Here is the caller graph for this function: