Skip to content

Commit

Permalink
Enhance the xrootd.fslib directive to allow for one library to wrap
Browse files Browse the repository at this point in the history
another library.
  • Loading branch information
abh3 committed Feb 12, 2013
1 parent d9f1230 commit 82af91d
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 29 deletions.
90 changes: 68 additions & 22 deletions src/XrdXrootd/XrdXrootdConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,13 @@ int XrdXrootdProtocol::Configure(char *parms, XrdProtocol_Config *pi)
XrdSysLogger *Logger,
const char *configFn,
XrdOucEnv *EnvInfo);

extern XrdSecService *XrdXrootdloadSecurity(XrdSysError *, char *,
char *, void **);
extern XrdSfsFileSystem *XrdXrootdloadFileSystem(XrdSysError *, char *,
const char *);

extern XrdSfsFileSystem *XrdXrootdloadFileSystem(XrdSysError *,
XrdSfsFileSystem *,
char *, const char *);
extern int optind, opterr;

XrdXrootdXPath *xp;
Expand Down Expand Up @@ -249,9 +252,9 @@ int XrdXrootdProtocol::Configure(char *parms, XrdProtocol_Config *pi)

// Get the filesystem to be used
//
if (FSLib)
{TRACE(DEBUG, "Loading filesystem library " <<FSLib);
osFS = XrdXrootdloadFileSystem(&eDest, FSLib, pi->ConfigFN);
if (FSLib[0])
{TRACE(DEBUG, "Loading base filesystem library " <<FSLib[0]);
osFS = XrdXrootdloadFileSystem(&eDest, 0, FSLib[0], pi->ConfigFN);
} else {
XrdOucEnv myEnv;
myEnv.PutPtr("XrdInet*", (void *)(pi->NetTCP));
Expand All @@ -263,13 +266,15 @@ int XrdXrootdProtocol::Configure(char *parms, XrdProtocol_Config *pi)
return 0;
} else SI->setFS(osFS);

// Check if the file system version matches our version
// Check if we have a wrapper library
//
if (chkfsV)
{fsver = (char *)osFS->getVersion();
if (strcmp(XrdVERSION, fsver))
eDest.Emsg("Config", "Warning! xrootd build version " XrdVERSION
"differs from file system version ", fsver);
if (FSLib[1])
{TRACE(DEBUG, "Loading wrapper filesystem library " <<FSLib[0]);
osFS = XrdXrootdloadFileSystem(&eDest, osFS, FSLib[0], pi->ConfigFN);
if (!osFS)
{eDest.Emsg("Config", "Unable to load file system wrapper.");
return 0;
}
}

// Check if we are going to be processing checksums locally
Expand Down Expand Up @@ -700,36 +705,77 @@ int XrdXrootdProtocol::xexpdo(char *path, int popt)

/* Function: xfsl
Purpose: To parse the directive: fslib [?] <path>
Purpose: To parse the directive: fslib [?] [throttle | <fspath2>]
{default | <fspath1>}
? check if fslib build version matches our version
<path> the path of the filesystem library to be used.
This is ignored now because it's always done.
throttle load libXrdThrottle.so as the head interface.
<fspath2> load the named library as the head interface.
default load libXrdOfs.so ro libXrdPss.so as the tail
interface. This is the default.
<fspath1> load the named library as the tail interface.
Output: 0 upon success or !0 upon failure.
*/

int XrdXrootdProtocol::xfsl(XrdOucStream &Config)
{
char *val, *Slash;
int n = 0;

// Get the path
// Clear storage pointers
//
chkfsV = 0;
if ((val = Config.GetWord()) && *val == '?' && !val[1])
{chkfsV = '?'; val = Config.GetWord();}
if (FSLib[0]) {free(FSLib[0]); FSLib[0] = 0;}
if (FSLib[1]) {free(FSLib[1]); FSLib[1] = 0;}

if (!val || !val[0])
// Get the path
//
if (!(val = Config.GetWord()))
{eDest.Emsg("Config", "fslib not specified"); return 1;}

// Check if this is "thottle"
//
if (!strcmp("throttle", val))
{FSLib[1] = strdup("libXrdThrottle.so");
if (!(val = Config.GetWord()))
{eDest.Emsg("Config","fslib throttle target library not specified");
return 1;
}
if (!strcmp("default", val)) return 0;
FSLib[0] = xfsL(val);
return 0;
}

// Check for default or default library, the common case
//
if (!strcmp("default", val) || !(FSLib[1] = xfsL(val))) return 0;

// If we dont have another token, then demote the previous library
//
if (!(val = Config.GetWord()))
{FSLib[0] = FSLib[1]; FSLib[1] = 0; return 0;}

// Check for default or default library, the common case
//
if (strcmp("default", val)) FSLib[0] = xfsL(val);
return 0;
}

/******************************************************************************/

char *XrdXrootdProtocol::xfsL(char *val)
{
char *Slash;

// If this is the "standard" name tell the user that we are ignoring this lib.
// Otherwise, record the path and return.
//
if (!(Slash = rindex(val, '/'))) Slash = val;
if (!strcmp(Slash, "/libXrdOfs.so"))
else Slash++;
if (!strcmp(Slash, "libXrdOfs.so"))
eDest.Say("Config warning: ignoring fslib; libXrdOfs.so is built-in.");
else {if (FSLib) free(FSLib);
FSLib = strdup(val);
}
else return strdup(val);
return 0;
}

Expand Down
7 changes: 4 additions & 3 deletions src/XrdXrootd/XrdXrootdLoadLib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ XrdVERSIONINFOREF(XrdgetProtocol);
/* x r o o t d _ l o a d F i l e s y s t e m */
/******************************************************************************/

XrdSfsFileSystem *XrdXrootdloadFileSystem(XrdSysError *eDest,
XrdSfsFileSystem *XrdXrootdloadFileSystem(XrdSysError *eDest,
XrdSfsFileSystem *prevFS,
char *fslib, const char *cfn)
{
XrdSysPlugin ofsLib(eDest,fslib,"fslib",&XrdVERSIONINFOVAR(XrdgetProtocol));
Expand All @@ -54,7 +55,7 @@ XrdSfsFileSystem *XrdXrootdloadFileSystem(XrdSysError *eDest,

// Record the library path in the environment
//
XrdOucEnv::Export("XRDOFSLIB", fslib);
if (!prevFS) XrdOucEnv::Export("XRDOFSLIB", fslib);

// Get the file system object creator
//
Expand All @@ -64,7 +65,7 @@ XrdSfsFileSystem *XrdXrootdloadFileSystem(XrdSysError *eDest,

// Get the file system object
//
if (!(FS = (*ep)(0, eDest->logger(), cfn)))
if (!(FS = (*ep)(prevFS, eDest->logger(), cfn)))
{eDest->Emsg("Config", "Unable to create file system object via",fslib);
return 0;
}
Expand Down
3 changes: 1 addition & 2 deletions src/XrdXrootd/XrdXrootdProtocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ XrdXrootdXPath XrdXrootdProtocol::RPList;
XrdXrootdXPath XrdXrootdProtocol::RQList;
XrdXrootdXPath XrdXrootdProtocol::XPList;
XrdSfsFileSystem *XrdXrootdProtocol::osFS;
char *XrdXrootdProtocol::FSLib = 0;
char *XrdXrootdProtocol::FSLib[2] = {0, 0};
XrdXrootdFileLock *XrdXrootdProtocol::Locker;
XrdSecService *XrdXrootdProtocol::CIA = 0;
char *XrdXrootdProtocol::SecLib = 0;
Expand All @@ -77,7 +77,6 @@ int XrdXrootdProtocol::Window;
int XrdXrootdProtocol::WANPort;
int XrdXrootdProtocol::WANWindow;
char XrdXrootdProtocol::isRedir = 0;
char XrdXrootdProtocol::chkfsV = 0;
char XrdXrootdProtocol::JobLCL = 0;
XrdNetSocket *XrdXrootdProtocol::AdminSock= 0;

Expand Down
4 changes: 2 additions & 2 deletions src/XrdXrootd/XrdXrootdProtocol.hh
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ static int xcksum(XrdOucStream &Config);
static int xexp(XrdOucStream &Config);
static int xexpdo(char *path, int popt=0);
static int xfsl(XrdOucStream &Config);
static char *xfsL(char *val);
static int xpidf(XrdOucStream &Config);
static int xprep(XrdOucStream &Config);
static int xlog(XrdOucStream &Config);
Expand Down Expand Up @@ -231,10 +232,9 @@ static int Window;
static int WANPort;
static int WANWindow;
static char *SecLib;
static char *FSLib;
static char *FSLib[2];
static char *Notify;
static char isRedir;
static char chkfsV;
static char JobLCL;
static XrdXrootdJob *JobCKS;
static char *JobCKT;
Expand Down

0 comments on commit 82af91d

Please sign in to comment.