Skip to content

Commit

Permalink
enable LITE feature in Posix preload library
Browse files Browse the repository at this point in the history
  • Loading branch information
wyang007 committed May 11, 2017
1 parent f2eb8ef commit 697eb5d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
1 change: 1 addition & 0 deletions docs/PreReleaseNotes.txt
Expand Up @@ -10,6 +10,7 @@ Prerelease Notes
* **{Server]** Add org and role types to AuthDB authorization.
* **[Server]** Handle systemd socket inheritance.
* **[Proxy/Posix]** Allow Name2Name to populate cache using the LFN.
* **[Posix]** enable LITE feature in Posix preload library.

+ **Major bug fixes**

Expand Down
26 changes: 14 additions & 12 deletions src/XrdPosix/XrdPosixPreload.cc
Expand Up @@ -31,6 +31,7 @@
#include <sys/types.h>
#include <stdarg.h>
#include <unistd.h>
#include <stdlib.h>

#include "XrdPosix/XrdPosixLinkage.hh"
#include "XrdPosix/XrdPosixOsDep.hh"
Expand Down Expand Up @@ -87,7 +88,7 @@ int chdir(const char *path)
{
static int Init = Xunix.Init(&Init);

return XrdPosix_Chdir(path);
return (getenv("XRD_POSIX_PRELOAD_LITE")? Xunix.Chdir(path) : XrdPosix_Chdir(path));
}
}

Expand Down Expand Up @@ -115,7 +116,7 @@ int closedir(DIR *dirp)
{
static int Init = Xunix.Init(&Init);

return XrdPosix_Closedir(dirp);
return (getenv("XRD_POSIX_PRELOAD_LITE")? Xunix.Closedir(dirp) : XrdPosix_Closedir(dirp));
}
}

Expand Down Expand Up @@ -452,7 +453,7 @@ int mkdir(const char *path, mode_t mode)
{
static int Init = Xunix.Init(&Init);

return XrdPosix_Mkdir(path, mode);
return (getenv("XRD_POSIX_PRELOAD_LITE")? Xunix.Mkdir(path, mode) : XrdPosix_Mkdir(path, mode));
}
}

Expand Down Expand Up @@ -485,7 +486,7 @@ DIR* opendir(const char *path)
{
static int Init = Xunix.Init(&Init);

return XrdPosix_Opendir(path);
return (getenv("XRD_POSIX_PRELOAD_LITE")? Xunix.Opendir(path) : XrdPosix_Opendir(path));
}
}

Expand Down Expand Up @@ -571,7 +572,7 @@ struct dirent64* readdir64(DIR *dirp)
{
static int Init = Xunix.Init(&Init);

return XrdPosix_Readdir64(dirp);
return (getenv("XRD_POSIX_PRELOAD_LITE")? Xunix.Readdir64(dirp) : XrdPosix_Readdir64(dirp));
}
}

Expand All @@ -585,7 +586,8 @@ int readdir64_r(DIR *dirp, struct dirent64 *entry, struct dirent64 **result)
{
static int Init = Xunix.Init(&Init);

return XrdPosix_Readdir64_r(dirp, entry, result);
return (getenv("XRD_POSIX_PRELOAD_LITE")? Xunix.Readdir64_r(dirp, entry, result) :
XrdPosix_Readdir64_r(dirp, entry, result));
}
}

Expand All @@ -599,7 +601,7 @@ int rename(const char *oldpath, const char *newpath)
{
static int Init = Xunix.Init(&Init);

return XrdPosix_Rename(oldpath, newpath);
return (getenv("XRD_POSIX_PRELOAD_LITE")? Xunix.Rename(oldpath, newpath) : XrdPosix_Rename(oldpath, newpath));
}
}

Expand All @@ -614,7 +616,7 @@ void rewinddir(DIR *dirp)
{
static int Init = Xunix.Init(&Init);

XrdPosix_Rewinddir(dirp);
(getenv("XRD_POSIX_PRELOAD_LITE")? Xunix.Rewinddir(dirp) : XrdPosix_Rewinddir(dirp));
}
}
#endif
Expand All @@ -629,7 +631,7 @@ int rmdir(const char *path)
{
static int Init = Xunix.Init(&Init);

return XrdPosix_Rmdir(path);
return (getenv("XRD_POSIX_PRELOAD_LITE")? Xunix.Rmdir(path) : XrdPosix_Rmdir(path));
}
}

Expand All @@ -643,7 +645,7 @@ void seekdir(DIR *dirp, long loc)
{
static int Init = Xunix.Init(&Init);

XrdPosix_Seekdir(dirp, loc);
(getenv("XRD_POSIX_PRELOAD_LITE")? Xunix.Seekdir(dirp, loc) : XrdPosix_Seekdir(dirp, loc));
}
}

Expand Down Expand Up @@ -705,7 +707,7 @@ long telldir(DIR *dirp)
{
static int Init = Xunix.Init(&Init);

return XrdPosix_Telldir(dirp);
return (getenv("XRD_POSIX_PRELOAD_LITE")? Xunix.Telldir(dirp) : XrdPosix_Telldir(dirp));
}
}

Expand Down Expand Up @@ -733,7 +735,7 @@ int unlink(const char *path)
{
static int Init = Xunix.Init(&Init);

return XrdPosix_Unlink(path);
return (getenv("XRD_POSIX_PRELOAD_LITE")? Xunix.Unlink(path) : XrdPosix_Unlink(path));
}
}

Expand Down
17 changes: 14 additions & 3 deletions src/XrdPosix/XrdPosixPreload32.cc
Expand Up @@ -49,6 +49,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>

#if defined(__APPLE__) || defined(__FreeBSD__)
#include <sys/param.h>
Expand Down Expand Up @@ -323,6 +324,7 @@ int lstat( const char *path, struct stat *buf)
#else
struct stat64 buf64;
int rc;

if ((rc = XrdPosix_Lstat(path, (struct stat *)&buf64))) return rc;
return XrdPosix_CopyStat(buf, buf64);
#endif
Expand Down Expand Up @@ -379,7 +381,12 @@ struct dirent* readdir(DIR *dirp)
static int Init = Xunix.Init(&Init);
struct dirent64 *dp64;

if (!(dp64 = XrdPosix_Readdir64(dirp))) return 0;
if ( getenv("XRD_POSIX_PRELOAD_LITE") )
{
if (!(dp64 = Xunix.Readdir64(dirp))) return 0;
}
else
if (!(dp64 = XrdPosix_Readdir64(dirp))) return 0;

#if !defined(__APPLE__) && !defined(_LP64) && !defined(__LP64__)
if (XrdPosix_CopyDirent((struct dirent *)dp64, dp64)) return 0;
Expand Down Expand Up @@ -408,8 +415,12 @@ int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
struct dirent64 *mydirent;
int rc;

if ((rc = XrdPosix_Readdir64_r(dirp, dp64, &mydirent)))
return rc;
if ( getenv("XRD_POSIX_PRELOAD_LITE") )
{
if ((rc = Xunix.Readdir64_r(dirp, dp64, &mydirent))) return rc;
}
else
if ((rc = XrdPosix_Readdir64_r(dirp, dp64, &mydirent))) return rc;

if (!mydirent) {*result = 0; return 0;}

Expand Down

1 comment on commit 697eb5d

@wyang007
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit add LITE feature to the posix preload library. With LITE, data operations such as read() will be ignored. Metadata operations such as readdir() will be taken to the destination xrootd cluster (pointed by XROOTD_VMP)

Please sign in to comment.