XRootD
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.

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.

173{
174 time_t currtime;
175 int i, nurls;
176
177 pthread_mutex_lock(&XrdFfsMiscUrlcache_mutex);
178
179 currtime = time(NULL);
180/* setting the cache to effectively not expire will let us know if a host is down */
181 if (XrdFfsMiscCururl[0] == '\0' ||
183 strcmp(XrdFfsMiscCururl, oldurl) != 0)
184 {
185 for (i = 0; i < XrdFfsMiscNcachedurls; i++)
186 if (XrdFfsMiscUrlcache[i] != NULL) free(XrdFfsMiscUrlcache[i]);
187 for (i = 0; i < XrdFfs_MAX_NUM_NODES; i++)
188 XrdFfsMiscUrlcache[i] = (char*) malloc(MAXROOTURLLEN);
189
190 XrdFfsMiscUrlcachetime = currtime;
191 strcpy(XrdFfsMiscCururl, oldurl);
194 if (XrdFfsMiscUrlcache[i] != NULL) free(XrdFfsMiscUrlcache[i]);
195 }
196
197 nurls = XrdFfsMiscNcachedurls;
198 for (i = 0; i < nurls; i++)
199 {
200 newurls[i] = (char*) malloc(MAXROOTURLLEN);
201 strncpy(newurls[i], XrdFfsMiscUrlcache[i], MAXROOTURLLEN -1);
202 newurls[i][MAXROOTURLLEN-1] = '\0';
203 }
204
205 pthread_mutex_unlock(&XrdFfsMiscUrlcache_mutex);
206 return nurls;
207}
char * XrdFfsMiscUrlcache[XrdFfs_MAX_NUM_NODES]
pthread_mutex_t XrdFfsMiscUrlcache_mutex
int XrdFfsMiscNcachedurls
time_t XrdFfsMiscUrlcachetime
int XrdFfsMisc_get_all_urls_real(const char *oldurl, char **newurls, const int nnodes)
char XrdFfsMiscCururl[MAXROOTURLLEN]
#define MAXROOTURLLEN
Definition XrdFfsMisc.cc:62
time_t XrdFfsMiscUrlcachelife
#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.

69{
70 struct stat stbuf;
71
72/* if it is a directory, return oldurl */
73 if (XrdFfsPosix_stat(oldurl, &stbuf) == 0 && S_ISDIR(stbuf.st_mode))
74 {
75 strcpy(newurl, oldurl);
76 return 1;
77 }
78
80 XrdPosixAdmin adm(oldurl,ecMsg);
81 if (adm.isOK() && adm.Stat())
82 {
83// We might have been redirected to a destination server. Better
84// to remember it and use only this one as output.
85// if (stat && adm->GetCurrentUrl().IsValid())
86// {
87// strcpy(newurl, adm->GetCurrentUrl().GetUrl().c_str());
88// delete adm;
89 strcpy(newurl, oldurl); // This needs to change!!!
90 return 1;
91 }
92 return 0;
93}
int XrdFfsPosix_stat(const char *path, struct stat *buf)
#define stat(a, b)
Definition XrdPosix.hh:101
thread_local XrdOucECMsg ecMsg

References XrdPosixAdmin::isOK(), stat, XrdPosixAdmin::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.

210{
211 XrdNetAddr uAddr;
212 int i, n = 0;
213 const char *netName;
214 const char *hName, *hNend, *hPort, *hPend;
215 char *url, *rc, *hostip, hsep;
216
217 rc = (char*)malloc(sizeof(char) * XrdFfs_MAX_NUM_NODES * MAXROOTURLLEN);
218 rc[0] = '\0';
219 pthread_mutex_lock(&XrdFfsMiscUrlcache_mutex);
220 for (i = 0; i < XrdFfsMiscNcachedurls; i++)
221 {
222 url = strdup(XrdFfsMiscUrlcache[i]);
223 hostip = &url[7];
224 if (XrdNetUtils::Parse(hostip, &hName, &hNend, &hPort, &hPend))
225 {n++;
226 hsep = *hNend;
227 hostip[hNend-hostip] = 0;
228 hostip[hPend-hostip] = 0;
229 if (uAddr.Set(hName,0) || !(netName = uAddr.Name()))
230 {hostip[hNend-hostip] = hsep;
231 hName = hostip;
232 hPend = hNend;
233 }
234 strcat(rc, hName);
235 if (hPort != hNend)
236 {strcat(rc, ":");
237 strcat(rc, hPort);
238 }
239 strcat(rc, "\n");
240 }
241 free(url);
242 }
243 pthread_mutex_unlock(&XrdFfsMiscUrlcache_mutex);
244 strcpy(list, rc);
245 free(rc);
246 return n;
247}
const char * Name(const char *eName=0, const char **eText=0)
const char * Set(const char *hSpec, int pNum=PortInSpec)
static bool Parse(const char *hSpec, const char **hName, const char **hNend, const char **hPort, const char **hPend)

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

Referenced by XrdFfsMisc_logging_url_cache().

+ 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.

133{
135}

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.

274{
275 int i;
276 char *hostlist, *p1, *p2;
277
278 if (url != NULL) XrdFfsMisc_refresh_url_cache(url);
279
280 hostlist = (char*) malloc(sizeof(char) * XrdFfs_MAX_NUM_NODES * 256);
282
283 syslog(LOG_INFO, "INFO: use the following %d data servers :", i);
284 p1 = hostlist;
285 p2 = strchr(p1, '\n');
286 while (p2 != NULL)
287 {
288 p2[0] = '\0';
289 syslog(LOG_INFO, " %s", p1);
290 p1 = p2 +1;
291 p2 = strchr(p1, '\n');
292 }
293 free(hostlist);
294}
int XrdFfsMisc_get_list_of_data_servers(char *list)
void XrdFfsMisc_refresh_url_cache(const char *url)

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

Referenced by XrdFfsMisc_xrd_init().

+ 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.

250{
251 int i, nurls;
252 char *surl, **turls;
253
254 turls = (char**) malloc(sizeof(char*) * XrdFfs_MAX_NUM_NODES);
255
256// invalid the cache first
257 pthread_mutex_lock(&XrdFfsMiscUrlcache_mutex);
259 pthread_mutex_unlock(&XrdFfsMiscUrlcache_mutex);
260
261 if (url != NULL)
262 surl = strdup(url);
263 else
264 surl = strdup(XrdFfsMiscCururl);
265
266 nurls = XrdFfsMisc_get_all_urls(surl, turls, XrdFfs_MAX_NUM_NODES);
267
268 free(surl);
269 for (i = 0; i < nurls; i++) free(turls[i]);
270 free(turls);
271}
int XrdFfsMisc_get_all_urls(const char *oldurl, char **newurls, const int nnodes)

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

Referenced by XrdFfsMisc_logging_url_cache(), and XrdFfsMisc_xrd_init().

+ 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.

297{
298 static int OneTimeInitDone = 0;
299
300// Do not execute this more than once
301//
302 if (OneTimeInitDone) return;
303 OneTimeInitDone = 1;
304
305// EnvPutInt(NAME_FIRSTCONNECTMAXCNT,2);
306// EnvPutInt(NAME_DATASERVERCONN_TTL, 99999999);
307// EnvPutInt(NAME_LBSERVERCONN_TTL, 99999999);
308// EnvPutInt(NAME_READAHEADSIZE,0);
309// EnvPutInt(NAME_READCACHESIZE,0);
310// EnvPutInt(NAME_REQUESTTIMEOUT, 30);
311 XrdPosixConfig::SetEnv("WorkerThreads", 50);
312
313 if (getenv("XROOTDFS_SECMOD") != NULL && !strcmp(getenv("XROOTDFS_SECMOD"), "sss"))
315
316 openlog("XrootdFS", LOG_ODELAY | LOG_PID, LOG_DAEMON);
317
318 XrdFfsMisc_set_Urlcachelife(urlcachelife);
321
322#ifndef NOUSE_QUEUE
323 if (startQueue)
324 {
325 if (getenv("XROOTDFS_NWORKERS") != NULL)
326 XrdFfsQueue_create_workers(atoi(getenv("XROOTDFS_NWORKERS")));
327 else
329
330 syslog(LOG_INFO, "INFO: Starting %d workers", XrdFfsQueue_count_workers());
331 }
332#endif
333
334 pthread_mutex_init(&url_mlock, NULL);
335
337}
void XrdFfsDent_cache_init()
void XrdFfsMisc_set_Urlcachelife(const char *urlcachelife)
void XrdFfsMisc_logging_url_cache(const char *url)
void XrdFfsMisc_xrd_secsss_init()
pthread_mutex_t url_mlock
Definition XrdFfsMisc.cc:66
int XrdFfsQueue_count_workers()
int XrdFfsQueue_create_workers(int n)
static void SetEnv(const char *kword, int kval)

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().

+ Here is the call 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.

425{
426 char user_num[9], nurl[MAXROOTURLLEN], *tmp;
427
428// Xrootd proxy also use some of the stat()/unlink(), etc funcitons here, without user "sss". It use the default
429// connection login name. Don't change this behavior. (so for proxy, use no "sss", and always have *id = 0
430 if (id != NULL || XrdFfsMiscSecsss)
431 {
432 tmp = ntoa24(user_uid);
433 memcpy(user_num, tmp, 9);
434 free(tmp);
435 if (id == NULL) user_num[strlen(user_num)] = 48;
436 else user_num[strlen(user_num)] = *id + 48;
437
438 nurl[0] = '\0';
439 strncat(nurl, "root://", 8);
440 strncat(nurl, user_num, 9);
441 strncat(nurl, "@", 2);
442 strncat(nurl, &(url[7]), MAXROOTURLLEN-17);
443 strncpy(url, nurl, MAXROOTURLLEN);
444 }
445}
bool XrdFfsMiscSecsss
char * ntoa24(unsigned int d)

References MAXROOTURLLEN, ntoa24(), and XrdFfsMiscSecsss.

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

+ 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.

372{
373 XrdFfsMiscSecsss = true;
375
376/* Enforce "sss" security */
377 setenv("XrdSecPROTOCOL", "sss", 1);
378}
XrdSecsssID * XrdFfsMiscSssid

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.

381{
382 struct passwd pw, *pwp;
383 struct group gr, *grp;
384 char user_num[9], *pwbuf, *grbuf, *tmp;
385 static size_t pwbuflen = 0;
386 static size_t grbuflen = 0;
387
388 if (pwbuflen == 0) pwbuflen = sysconf(_SC_GETPW_R_SIZE_MAX);
389 if (grbuflen == 0) grbuflen = sysconf(_SC_GETGR_R_SIZE_MAX);
390
391 XrdSecEntity XrdFfsMiscUent("");
392
393 tmp = ntoa24((unsigned int)user_uid);
394 memcpy(user_num, tmp, 9);
395 free(tmp);
396
397 if (id != NULL) {
398 pthread_mutex_lock(&url_mlock);
399 *id = iXrdConnPerUsr +1; // id = 1 to nXrdConnPerUsr+1 (8)
401 pthread_mutex_unlock(&url_mlock);
402 user_num[strlen(user_num)] = *id + 48; // this require that *id stay as single digit.
403 }
404 else
405 user_num[strlen(user_num)] = 48; // id = NULL
406
408 {
409 pwbuf = (char*) malloc(pwbuflen);
410 getpwuid_r(user_uid, &pw, pwbuf, pwbuflen, &pwp);
411 grbuf = (char*) malloc(grbuflen);
412 getgrgid_r(user_gid, &gr, grbuf, grbuflen, &grp);
413
414 XrdFfsMiscUent.name = pw.pw_name;
415 XrdFfsMiscUent.grps = gr.gr_name;
416 XrdFfsMiscUent.uid = user_uid;
417 XrdFfsMiscUent.gid = user_gid;
418 XrdFfsMiscSssid->Register(user_num, &XrdFfsMiscUent, 0);
419 free(pwbuf);
420 free(grbuf);
421 }
422}
#define nXrdConnPerUsr
Definition XrdFfsMisc.cc:64
short iXrdConnPerUsr
Definition XrdFfsMisc.cc:65
bool Register(const char *lgnid, const XrdSecEntity *Ident, bool doReplace=false, bool defer=false)

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

+ Here is the call graph for this function: