Loading...
Searching...
No Matches
XrdFfsMisc.hh File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Macros

#define | XrdFfs_MAX_NUM_NODES 4096 /* 64*64 max number of data nodes in a cluster */

## Functions

int | XrdFfsMisc_get_all_urls (const char *oldurl, char **newurls, const int nnodes)
char | XrdFfsMisc_get_current_url (const char *oldurl, char *newurl)
int | XrdFfsMisc_get_list_of_data_servers (char *list)
int | XrdFfsMisc_get_number_of_data_servers ()
void | XrdFfsMisc_logging_url_cache (const char *url)
void | XrdFfsMisc_refresh_url_cache (const char *url)
void | XrdFfsMisc_xrd_init (const char *rdrurl, const char *urlcachelife, int startQueue)
void | XrdFfsMisc_xrd_secsss_editurl (char *url, uid_t user_uid, int *id)
void | XrdFfsMisc_xrd_secsss_init ()
void | XrdFfsMisc_xrd_secsss_register (uid_t user_uid, gid_t user_gid, int *id)

## Macro Definition Documentation

## XrdFfs_MAX_NUM_NODES

#define XrdFfs_MAX_NUM_NODES 4096 /* 64*64 max number of data nodes in a cluster */

Definition at line 34 of file XrdFfsMisc.hh.

Referenced by XrdFfsMisc_get_all_urls(), XrdFfsMisc_get_list_of_data_servers(), XrdFfsMisc_logging_url_cache(), XrdFfsMisc_refresh_url_cache(), XrdFfsPosix_deleteall(), XrdFfsPosix_readdirall(), XrdFfsPosix_renameall(), XrdFfsPosix_statall(), XrdFfsPosix_statvfsall(), XrdFfsPosix_truncateall(), and xrootdfs_getxattr().

## Function Documentation

## XrdFfsMisc_get_all_urls()

int XrdFfsMisc_get_all_urls | ( | const char * | oldurl,
|  | char ** | newurls,
|  | const int | nnodes )

Definition at line 172 of file XrdFfsMisc.cc.

{
time_t currtime;
int i, nurls;
pthread_mutex_lock(&XrdFfsMiscUrlcache_mutex);
currtime = time(NULL);
/* setting the cache to effectively not expire will let us know if a host is down */
if (XrdFfsMiscCururl[0] == '\0' ||
(currtime - XrdFfsMiscUrlcachetime) > XrdFfsMiscUrlcachelife ||
strcmp(XrdFfsMiscCururl, oldurl) != 0)
{
for (i = 0; i < XrdFfsMiscNcachedurls; i++)
if (XrdFfsMiscUrlcache[i] != NULL) free(XrdFfsMiscUrlcache[i]);
for (i = 0; i < XrdFfs_MAX_NUM_NODES; i++)
XrdFfsMiscUrlcache[i] = (char*) malloc(MAXROOTURLLEN);
XrdFfsMiscUrlcachetime = currtime;
strcpy(XrdFfsMiscCururl, oldurl);
XrdFfsMiscNcachedurls = XrdFfsMisc_get_all_urls_real(oldurl, XrdFfsMiscUrlcache, nnodes);
for (i = XrdFfsMiscNcachedurls; i < XrdFfs_MAX_NUM_NODES; i++)
if (XrdFfsMiscUrlcache[i] != NULL) free(XrdFfsMiscUrlcache[i]);
}
nurls = XrdFfsMiscNcachedurls;
for (i = 0; i < nurls; i++)
{
newurls[i] = (char*) malloc(MAXROOTURLLEN);
strncpy(newurls[i], XrdFfsMiscUrlcache[i], MAXROOTURLLEN -1);
newurls[i][MAXROOTURLLEN-1] = '\0';
}
pthread_mutex_unlock(&XrdFfsMiscUrlcache_mutex);
return nurls;
}
XrdFfsMiscUrlcache
char * XrdFfsMiscUrlcache[XrdFfs_MAX_NUM_NODES]
Definition XrdFfsMisc.cc:126
XrdFfsMiscUrlcache_mutex
pthread_mutex_t XrdFfsMiscUrlcache_mutex
Definition XrdFfsMisc.cc:129
XrdFfsMiscNcachedurls
int XrdFfsMiscNcachedurls
Definition XrdFfsMisc.cc:127
XrdFfsMiscUrlcachetime
time_t XrdFfsMiscUrlcachetime
Definition XrdFfsMisc.cc:128
XrdFfsMisc_get_all_urls_real
int XrdFfsMisc_get_all_urls_real(const char *oldurl, char **newurls, const int nnodes)
Definition XrdFfsMisc.cc:103
XrdFfsMiscCururl
char XrdFfsMiscCururl[MAXROOTURLLEN]
Definition XrdFfsMisc.cc:125
MAXROOTURLLEN
#define MAXROOTURLLEN
Definition XrdFfsMisc.cc:62
XrdFfsMiscUrlcachelife
time_t XrdFfsMiscUrlcachelife
Definition XrdFfsMisc.cc:130
XrdFfs_MAX_NUM_NODES
#define XrdFfs_MAX_NUM_NODES
Definition XrdFfsMisc.hh:34

References MAXROOTURLLEN, XrdFfs_MAX_NUM_NODES, XrdFfsMisc_get_all_urls_real(), XrdFfsMiscCururl, XrdFfsMiscNcachedurls, XrdFfsMiscUrlcache, XrdFfsMiscUrlcache_mutex, XrdFfsMiscUrlcachelife, and XrdFfsMiscUrlcachetime.

Referenced by XrdFfsMisc_refresh_url_cache(), XrdFfsPosix_deleteall(), XrdFfsPosix_readdirall(), XrdFfsPosix_renameall(), XrdFfsPosix_statall(), XrdFfsPosix_statvfsall(), and XrdFfsPosix_truncateall().

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

## XrdFfsMisc_get_current_url()

char XrdFfsMisc_get_current_url | ( | const char * | oldurl,
|  | char * | newurl )

Definition at line 68 of file XrdFfsMisc.cc.

{
struct stat stbuf;
/* if it is a directory, return oldurl */
if (XrdFfsPosix_stat(oldurl, &stbuf) == 0 && S_ISDIR(stbuf.st_mode))
{
strcpy(newurl, oldurl);
return 1;
}
XrdOucECMsg ecMsg;
XrdPosixAdmin adm(oldurl,ecMsg);
if (adm.isOK() && adm.Stat())
{
// We might have been redirected to a destination server. Better
// to remember it and use only this one as output.
// if (stat && adm->GetCurrentUrl().IsValid())
// {
// strcpy(newurl, adm->GetCurrentUrl().GetUrl().c_str());
// delete adm;
strcpy(newurl, oldurl); // This needs to change!!!
return 1;
}
return 0;
}
XrdFfsPosix_stat
int XrdFfsPosix_stat(const char *path, struct stat *buf)
Definition XrdFfsPosix.cc:66
stat
#define stat(a, b)
Definition XrdPosix.hh:101
XrdOucECMsg
Definition XrdOucECMsg.hh:39
XrdPosixAdmin
Definition XrdPosixAdmin.hh:48
XrdPosixGlobals::ecMsg
XrdOucECMsg ecMsg

References XrdPosixAdmin::isOK(), XrdPosixAdmin::Stat(), stat, and XrdFfsPosix_stat().

Here is the call graph for this function:

## XrdFfsMisc_get_list_of_data_servers()

int XrdFfsMisc_get_list_of_data_servers | ( | char * | list | ) |

Definition at line 209 of file XrdFfsMisc.cc.

{
XrdNetAddr uAddr;
int i, n = 0;
const char *netName;
const char *hName, *hNend, *hPort, *hPend;
char *url, *rc, *hostip, hsep;
rc = (char*)malloc(sizeof(char) * XrdFfs_MAX_NUM_NODES * MAXROOTURLLEN);
rc[0] = '\0';
pthread_mutex_lock(&XrdFfsMiscUrlcache_mutex);
for (i = 0; i < XrdFfsMiscNcachedurls; i++)
{
url = strdup(XrdFfsMiscUrlcache[i]);
hostip = &url[7];
if (XrdNetUtils::Parse(hostip, &hName, &hNend, &hPort, &hPend))
{n++;
hsep = *hNend;
hostip[hNend-hostip] = 0;
hostip[hPend-hostip] = 0;
if (uAddr.Set(hName,0) || !(netName = uAddr.Name()))
{hostip[hNend-hostip] = hsep;
hName = hostip;
hPend = hNend;
}
strcat(rc, hName);
if (hPort != hNend)
{strcat(rc, ":");
strcat(rc, hPort);
}
strcat(rc, "\n");
}
free(url);
}
pthread_mutex_unlock(&XrdFfsMiscUrlcache_mutex);
strcpy(list, rc);
free(rc);
return n;
}
XrdNetAddrInfo::Name
const char * Name(const char *eName=0, const char **eText=0)
Definition XrdNetAddrInfo.cc:309
XrdNetAddr
Definition XrdNetAddr.hh:42
XrdNetAddr::Set
const char * Set(const char *hSpec, int pNum=PortInSpec)
Definition XrdNetAddr.cc:216
XrdNetUtils::Parse
static bool Parse(const char *hSpec, const char **hName, const char **hNend, const char **hPort, const char **hPend)
Definition XrdNetUtils.cc:780

References MAXROOTURLLEN, XrdNetAddrInfo::Name(), XrdNetUtils::Parse(), XrdNetAddr::Set(), XrdFfs_MAX_NUM_NODES, XrdFfsMiscNcachedurls, XrdFfsMiscUrlcache, and XrdFfsMiscUrlcache_mutex.

Referenced by XrdFfsMisc_logging_url_cache(), and xrootdfs_getxattr().

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

## XrdFfsMisc_get_number_of_data_servers()

int XrdFfsMisc_get_number_of_data_servers | ( |  | ) |

Definition at line 132 of file XrdFfsMisc.cc.

{
return XrdFfsMiscNcachedurls;
}

References XrdFfsMiscNcachedurls.

Referenced by XrdFfsPosix_statall().

Here is the caller graph for this function:

## XrdFfsMisc_logging_url_cache()

void XrdFfsMisc_logging_url_cache | ( | const char * | url | ) |

Definition at line 273 of file XrdFfsMisc.cc.

{
int i;
char *hostlist, *p1, *p2;
if (url != NULL) XrdFfsMisc_refresh_url_cache(url);
hostlist = (char*) malloc(sizeof(char) * XrdFfs_MAX_NUM_NODES * 256);
i = XrdFfsMisc_get_list_of_data_servers(hostlist);
syslog(LOG_INFO, "INFO: use the following %d data servers :", i);
p1 = hostlist;
p2 = strchr(p1, '\n');
while (p2 != NULL)
{
p2[0] = '\0';
syslog(LOG_INFO, " %s", p1);
p1 = p2 +1;
p2 = strchr(p1, '\n');
}
free(hostlist);
}
XrdFfsMisc_get_list_of_data_servers
int XrdFfsMisc_get_list_of_data_servers(char *list)
Definition XrdFfsMisc.cc:209
XrdFfsMisc_refresh_url_cache
void XrdFfsMisc_refresh_url_cache(const char *url)
Definition XrdFfsMisc.cc:249

References XrdFfs_MAX_NUM_NODES, XrdFfsMisc_get_list_of_data_servers(), and XrdFfsMisc_refresh_url_cache().

Referenced by XrdFfsMisc_logging_url_cache_pthread_create_cast(), XrdFfsMisc_xrd_init(), and xrootdfs_setxattr().

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

## XrdFfsMisc_refresh_url_cache()

void XrdFfsMisc_refresh_url_cache | ( | const char * | url | ) |

Definition at line 249 of file XrdFfsMisc.cc.

{
int i, nurls;
char *surl, **turls;
turls = (char**) malloc(sizeof(char*) * XrdFfs_MAX_NUM_NODES);
// invalid the cache first
pthread_mutex_lock(&XrdFfsMiscUrlcache_mutex);
XrdFfsMiscUrlcachetime = 0;
pthread_mutex_unlock(&XrdFfsMiscUrlcache_mutex);
if (url != NULL)
surl = strdup(url);
else
surl = strdup(XrdFfsMiscCururl);
nurls = XrdFfsMisc_get_all_urls(surl, turls, XrdFfs_MAX_NUM_NODES);
free(surl);
for (i = 0; i < nurls; i++) free(turls[i]);
free(turls);
}
XrdFfsMisc_get_all_urls
int XrdFfsMisc_get_all_urls(const char *oldurl, char **newurls, const int nnodes)
Definition XrdFfsMisc.cc:172

References XrdFfs_MAX_NUM_NODES, XrdFfsMisc_get_all_urls(), XrdFfsMiscCururl, XrdFfsMiscUrlcache_mutex, and XrdFfsMiscUrlcachetime.

Referenced by XrdFfsMisc_logging_url_cache(), XrdFfsMisc_xrd_init(), and xrootdfs_setxattr().

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

## XrdFfsMisc_xrd_init()

void XrdFfsMisc_xrd_init | ( | const char * | rdrurl,
|  | const char * | urlcachelife,
|  | int | startQueue )

Definition at line 296 of file XrdFfsMisc.cc.

{
static int OneTimeInitDone = 0;
// Do not execute this more than once
//
if (OneTimeInitDone) return;
OneTimeInitDone = 1;
// EnvPutInt(NAME_FIRSTCONNECTMAXCNT,2);
// EnvPutInt(NAME_DATASERVERCONN_TTL, 99999999);
// EnvPutInt(NAME_LBSERVERCONN_TTL, 99999999);
// EnvPutInt(NAME_READAHEADSIZE,0);
// EnvPutInt(NAME_READCACHESIZE,0);
// EnvPutInt(NAME_REQUESTTIMEOUT, 30);
XrdPosixConfig::SetEnv("WorkerThreads", 50);
if (getenv("XROOTDFS_SECMOD") != NULL && !strcmp(getenv("XROOTDFS_SECMOD"), "sss"))
XrdFfsMisc_xrd_secsss_init();
openlog("XrootdFS", LOG_ODELAY | LOG_PID, LOG_DAEMON);
XrdFfsMisc_set_Urlcachelife(urlcachelife);
XrdFfsMisc_refresh_url_cache(rdrurl);
XrdFfsMisc_logging_url_cache(NULL);
#ifndef NOUSE_QUEUE
if (startQueue)
{
if (getenv("XROOTDFS_NWORKERS") != NULL)
XrdFfsQueue_create_workers(atoi(getenv("XROOTDFS_NWORKERS")));
else
XrdFfsQueue_create_workers(4);
syslog(LOG_INFO, "INFO: Starting %d workers", XrdFfsQueue_count_workers());
}
#endif
pthread_mutex_init(&url_mlock, NULL);
XrdFfsDent_cache_init();
}
XrdFfsDent_cache_init
void XrdFfsDent_cache_init()
Definition XrdFfsDent.cc:207
XrdFfsMisc_set_Urlcachelife
void XrdFfsMisc_set_Urlcachelife(const char *urlcachelife)
Definition XrdFfsMisc.cc:137
XrdFfsMisc_logging_url_cache
void XrdFfsMisc_logging_url_cache(const char *url)
Definition XrdFfsMisc.cc:273
XrdFfsMisc_xrd_secsss_init
void XrdFfsMisc_xrd_secsss_init()
Definition XrdFfsMisc.cc:371
url_mlock
pthread_mutex_t url_mlock
Definition XrdFfsMisc.cc:66
XrdFfsQueue_count_workers
int XrdFfsQueue_count_workers()
Definition XrdFfsQueue.cc:254
XrdFfsQueue_create_workers
int XrdFfsQueue_create_workers(int n)
Definition XrdFfsQueue.cc:192
XrdPosixConfig::SetEnv
static void SetEnv(const char *kword, int kval)
Definition XrdPosixConfig.cc:509

References XrdPosixConfig::SetEnv(), url_mlock, XrdFfsDent_cache_init(), XrdFfsMisc_logging_url_cache(), XrdFfsMisc_refresh_url_cache(), XrdFfsMisc_set_Urlcachelife(), XrdFfsMisc_xrd_secsss_init(), XrdFfsQueue_count_workers(), and XrdFfsQueue_create_workers().

Referenced by xrootdfs_init().

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

## XrdFfsMisc_xrd_secsss_editurl()

void XrdFfsMisc_xrd_secsss_editurl | ( | char * | url,
|  | uid_t | user_uid,
|  | int * | id )

Definition at line 424 of file XrdFfsMisc.cc.

{
char user_num[9], nurl[MAXROOTURLLEN], *tmp;
// Xrootd proxy also use some of the stat()/unlink(), etc funcitons here, without user "sss". It use the default
// connection login name. Don't change this behavior. (so for proxy, use no "sss", and always have *id = 0
if (id != NULL || XrdFfsMiscSecsss)
{
tmp = ntoa24(user_uid);
memcpy(user_num, tmp, 9);
free(tmp);
if (id == NULL) user_num[strlen(user_num)] = 48;
else user_num[strlen(user_num)] = *id + 48;
nurl[0] = '\0';
strncat(nurl, "root://", 8);
strncat(nurl, user_num, 9);
strncat(nurl, "@", 2);
strncat(nurl, &(url[7]), MAXROOTURLLEN-17);
strncpy(url, nurl, MAXROOTURLLEN);
}
}
XrdFfsMiscSecsss
bool XrdFfsMiscSecsss
Definition XrdFfsMisc.cc:369
ntoa24
char * ntoa24(unsigned int d)
Definition XrdFfsMisc.cc:359

References MAXROOTURLLEN, ntoa24(), and XrdFfsMiscSecsss.

Referenced by XrdFfsPosix_deleteall(), XrdFfsPosix_readdirall(), XrdFfsPosix_renameall(), XrdFfsPosix_statall(), XrdFfsPosix_truncateall(), xrootdfs_do_create(), xrootdfs_getattr(), xrootdfs_getxattr(), xrootdfs_mkdir(), xrootdfs_open(), xrootdfs_readdir(), xrootdfs_release(), xrootdfs_rename(), xrootdfs_rmdir(), xrootdfs_truncate(), and xrootdfs_unlink().

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

## XrdFfsMisc_xrd_secsss_init()

void XrdFfsMisc_xrd_secsss_init | ( |  | ) |

Definition at line 371 of file XrdFfsMisc.cc.

{
XrdFfsMiscSecsss = true;
XrdFfsMiscSssid = new XrdSecsssID(XrdSecsssID::idDynamic);
/* Enforce "sss" security */
setenv("XrdSecPROTOCOL", "sss", 1);
}
XrdFfsMiscSssid
XrdSecsssID * XrdFfsMiscSssid
Definition XrdFfsMisc.cc:368
XrdSecsssID
Definition XrdSecsssID.hh:54
XrdSecsssID::idDynamic
@ idDynamic
Definition XrdSecsssID.hh:80

References XrdSecsssID::idDynamic, XrdFfsMiscSecsss, and XrdFfsMiscSssid.

Referenced by XrdFfsMisc_xrd_init().

Here is the caller graph for this function:

## XrdFfsMisc_xrd_secsss_register()

void XrdFfsMisc_xrd_secsss_register | ( | uid_t | user_uid,
|  | gid_t | user_gid,
|  | int * | id )

Definition at line 380 of file XrdFfsMisc.cc.

{
struct passwd pw, *pwp;
struct group gr, *grp;
char user_num[9], *pwbuf, *grbuf, *tmp;
static size_t pwbuflen = 0;
static size_t grbuflen = 0;
if (pwbuflen == 0) pwbuflen = sysconf(_SC_GETPW_R_SIZE_MAX);
if (grbuflen == 0) grbuflen = sysconf(_SC_GETGR_R_SIZE_MAX);
XrdSecEntity XrdFfsMiscUent("");
tmp = ntoa24((unsigned int)user_uid);
memcpy(user_num, tmp, 9);
free(tmp);
if (id != NULL) {
pthread_mutex_lock(&url_mlock);
*id = iXrdConnPerUsr +1; // id = 1 to nXrdConnPerUsr+1 (8)
iXrdConnPerUsr = (iXrdConnPerUsr +1) % nXrdConnPerUsr;
pthread_mutex_unlock(&url_mlock);
user_num[strlen(user_num)] = *id + 48; // this require that *id stay as single digit.
}
else
user_num[strlen(user_num)] = 48; // id = NULL
if (XrdFfsMiscSecsss)
{
pwbuf = (char*) malloc(pwbuflen);
getpwuid_r(user_uid, &pw, pwbuf, pwbuflen, &pwp);
grbuf = (char*) malloc(grbuflen);
getgrgid_r(user_gid, &gr, grbuf, grbuflen, &grp);
XrdFfsMiscUent.name = pw.pw_name;
XrdFfsMiscUent.grps = gr.gr_name;
XrdFfsMiscUent.uid = user_uid;
XrdFfsMiscUent.gid = user_gid;
XrdFfsMiscSssid->Register(user_num, &XrdFfsMiscUent, 0);
free(pwbuf);
free(grbuf);
}
}
nXrdConnPerUsr
#define nXrdConnPerUsr
Definition XrdFfsMisc.cc:64
iXrdConnPerUsr
short iXrdConnPerUsr
Definition XrdFfsMisc.cc:65
XrdSecEntity
Definition XrdSecEntity.hh:65

References XrdSecEntity::gid, XrdSecEntity::grps, iXrdConnPerUsr, XrdSecEntity::name, ntoa24(), nXrdConnPerUsr, XrdSecEntity::uid, url_mlock, XrdFfsMiscSecsss, and XrdFfsMiscSssid.

Referenced by xrootdfs_do_create(), xrootdfs_getattr(), xrootdfs_getxattr(), xrootdfs_mkdir(), xrootdfs_open(), xrootdfs_readdir(), xrootdfs_release(), xrootdfs_rename(), xrootdfs_rmdir(), xrootdfs_truncate(), and xrootdfs_unlink().

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