Loading...
Searching...
No Matches
XrdCephPosix.hh File Reference
`#include <sys/types.h>`
`#include <stdarg.h>`
`#include <string>`
`#include <dirent.h>`
`#include <cstdint>`
`#include <XrdOuc/XrdOucEnv.hh>`
`#include <XrdSys/XrdSysXAttr.hh>`
`#include "XrdSys/XrdSysPthread.hh"`
`#include "XrdOuc/XrdOucIOVec.hh"`
Include dependency graph for XrdCephPosix.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Classes

struct | CephFile
| small structs to store file metadata More...
struct | CephFileRef

## Macros

#define | LOGCEPH(x)
#define | MAXDIGITSIZE 32
#define | XRDCEPHLOGLEVEL 1

## Typedefs

typedef void | AioCB(XrdSfsAio *, size_t)

## Functions

ssize_t | ceph_aio_read (int fd, XrdSfsAio *aiop, AioCB *cb)
ssize_t | ceph_aio_write (int fd, XrdSfsAio *aiop, AioCB *cb)
ssize_t | ceph_nonstriper_readv (int fd, XrdOucIOVec *readV, int n)
int | ceph_posix_close (int fd)
int | ceph_posix_closedir (DIR *dirp)
void | ceph_posix_disconnect_all ()
int | ceph_posix_fcntl (int fd, int cmd,...)
ssize_t | ceph_posix_fgetxattr (int fd, const char *name, void *value, size_t size)
int | ceph_posix_flistxattrs (int fd, XrdSysXAttr::AList **aPL, int getSz)
void | ceph_posix_freexattrlist (XrdSysXAttr::AList *aPL)
int | ceph_posix_fremovexattr (int fd, const char *name)
int | ceph_posix_fsetxattr (int fd, const char *name, const void *value, size_t size, int flags)
int | ceph_posix_fstat (int fd, struct stat *buf)
int | ceph_posix_fsync (int fd)
int | ceph_posix_ftruncate (int fd, unsigned long long size)
ssize_t | ceph_posix_getxattr (XrdOucEnv *env, const char *path, const char *name, void *value, size_t size)
int | ceph_posix_listxattrs (XrdOucEnv *env, const char *path, XrdSysXAttr::AList **aPL, int getSz)
off_t | ceph_posix_lseek (int fd, off_t offset, int whence)
off64_t | ceph_posix_lseek64 (int fd, off64_t offset, int whence)
ssize_t | ceph_posix_maybestriper_pread (int fd, void *buf, size_t count, off64_t offset, bool allowStriper=true)
ssize_t | ceph_posix_nonstriper_pread (int fd, void *buf, size_t count, off64_t offset)
int | ceph_posix_open (XrdOucEnv *env, const char *pathname, int flags, mode_t mode)
DIR * | ceph_posix_opendir (XrdOucEnv *env, const char *pathname)
ssize_t | ceph_posix_pread (int fd, void *buf, size_t count, off64_t offset)
ssize_t | ceph_posix_pwrite (int fd, const void *buf, size_t count, off64_t offset)
ssize_t | ceph_posix_read (int fd, void *buf, size_t count)
int | ceph_posix_readdir (DIR *dirp, char *buff, int blen)
int | ceph_posix_removexattr (XrdOucEnv *env, const char *path, const char *name)
void | ceph_posix_set_defaults (const char *value)
void | ceph_posix_set_logfunc (void(*logfunc)(char *, va_list argp))
ssize_t | ceph_posix_setxattr (XrdOucEnv *env, const char *path, const char *name, const void *value, size_t size, int flags)
int | ceph_posix_stat (XrdOucEnv *env, const char *pathname, struct stat *buf)
int | ceph_posix_stat_pool (char const *poolName, long long *usedSpace)
| Return the amount of space used in a pool.
int | ceph_posix_statfs (long long *totalSpace, long long *freeSpace)
int | ceph_posix_truncate (XrdOucEnv *env, const char *pathname, unsigned long long size)
int | ceph_posix_unlink (XrdOucEnv *env, const char *pathname)
ssize_t | ceph_posix_write (int fd, const void *buf, size_t count)
ssize_t | ceph_striper_readv (int fd, XrdOucIOVec *readV, int n)

## Macro Definition Documentation

## LOGCEPH

#define LOGCEPH | ( |  | x | ) |

Value:
{std::stringstream _s; _s << x; std::clog << _s.str() << std::endl; _s.clear(); }

Definition at line 51 of file XrdCephPosix.hh.

Referenced by XrdCephOssReadVFile::XrdCephOssReadVFile(), XrdCephOssBufferedFile::Close(), XrdCephOssReadVFile::Close(), XrdCephOssBufferedFile::createBuffer(), XrdCephOssReadVFile::Open(), XrdCephOssBufferedFile::Read(), XrdCephOssBufferedFile::Read(), XrdCephOssReadVFile::ReadV(), XrdCephOssBufferedFile::Write(), and XrdCephOssBufferedFile::Write().

## MAXDIGITSIZE

#define MAXDIGITSIZE 32

Definition at line 45 of file XrdCephPosix.hh.

Referenced by ceph_posix_open().

## XRDCEPHLOGLEVEL

#define XRDCEPHLOGLEVEL 1

Definition at line 44 of file XrdCephPosix.hh.

## Typedef Documentation

## AioCB

typedef void AioCB(XrdSfsAio *, size_t)

Definition at line 58 of file XrdCephPosix.hh.

## Function Documentation

## ceph_aio_read()

ssize_t ceph_aio_read | ( | int | fd,
|  | XrdSfsAio * | aiop,
|  | AioCB * | cb )

Definition at line 1175 of file XrdCephPosix.cc.

{
CephFileRef* fr = getFileRef(fd);
if (fr) {
// get the parameters from the Xroot aio object
size_t count = aiop->sfsAio.aio_nbytes;
size_t offset = aiop->sfsAio.aio_offset;
// TODO implement proper logging level for this plugin - this should be only debug
//logwrapper((char*)"ceph_aio_read: for fd %d, count=%d", fd, count);
if ((fr->flags & O_ACCMODE) == O_WRONLY) {
return -EBADF;
}
// get the striper object
libradosstriper::RadosStriper *striper = getRadosStriper(*fr);
if (0 == striper) {
return -EINVAL;
}
// prepare a bufferlist to receive data
ceph::bufferlist *bl = new ceph::bufferlist();
// get the poolIdx to use
int cephPoolIdx = getCephPoolIdxAndIncrease();
// Get the cluster to use
librados::Rados* cluster = checkAndCreateCluster(cephPoolIdx);
if (0 == cluster) {
return -EINVAL;
}
// prepare a ceph AioCompletion object and do async call
AioArgs *args = new AioArgs(aiop, cb, count, fd, bl);
librados::AioCompletion *completion =
cluster->aio_create_completion(args, ceph_aio_read_complete, NULL);
// do the read
int rc = striper->aio_read(fr->name, completion, bl, count, offset);
completion->release();
XrdSysMutexHelper lock(fr->statsMutex);
fr->asyncRdStartCount++;
return rc;
} else {
return -EBADF;
}
}
getRadosStriper
static libradosstriper::RadosStriper * getRadosStriper(const CephFile &file)
Definition XrdCephPosix.cc:597
getFileRef
CephFileRef * getFileRef(int fd)
look for a FileRef from its file descriptor
Definition XrdCephPosix.cc:149
getCephPoolIdxAndIncrease
unsigned int getCephPoolIdxAndIncrease()
Definition XrdCephPosix.cc:117
checkAndCreateCluster
librados::Rados * checkAndCreateCluster(unsigned int cephPoolIdx, std::string userId=g_defaultParams.userId)
Definition XrdCephPosix.cc:476
ceph_aio_read_complete
static void ceph_aio_read_complete(rados_completion_t c, void *arg)
Definition XrdCephPosix.cc:1154
aiocb::aio_offset
off_t aio_offset
Definition XrdSfsAio.hh:49
aiocb::aio_nbytes
size_t aio_nbytes
Definition XrdSfsAio.hh:48
XrdSfsAio::sfsAio
struct aiocb sfsAio
Definition XrdSfsAio.hh:62
XrdSysMutexHelper
Definition XrdSysPthread.hh:263
AioArgs
small struct for aio API callbacks
Definition XrdCephPosix.cc:66
CephFileRef
Definition XrdCephPosix.hh:112
CephFileRef::asyncRdStartCount
unsigned asyncRdStartCount
Definition XrdCephPosix.hh:123
CephFileRef::statsMutex
XrdSysMutex statsMutex
Definition XrdCephPosix.hh:117
CephFileRef::flags
int flags
Definition XrdCephPosix.hh:113
CephFile::name
std::string name
Definition XrdCephPosix.hh:104

References aiocb::aio_nbytes, aiocb::aio_offset, CephFileRef::asyncRdStartCount, ceph_aio_read_complete(), checkAndCreateCluster(), CephFileRef::flags, getCephPoolIdxAndIncrease(), getFileRef(), getRadosStriper(), CephFile::name, XrdSfsAio::sfsAio, and CephFileRef::statsMutex.

Referenced by XrdCephOssFile::Read(), and XrdCephBuffer::CephIOAdapterAIORaw::read().

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

## ceph_aio_write()

ssize_t ceph_aio_write | ( | int | fd,
|  | XrdSfsAio * | aiop,
|  | AioCB * | cb )

Definition at line 903 of file XrdCephPosix.cc.

{
CephFileRef* fr = getFileRef(fd);
if (fr) {
// get the parameters from the Xroot aio object
size_t count = aiop->sfsAio.aio_nbytes;
const char *buf = (const char*)aiop->sfsAio.aio_buf;
size_t offset = aiop->sfsAio.aio_offset;
// TODO implement proper logging level for this plugin - this should be only debug
//logwrapper((char*)"ceph_aio_write: for fd %d, count=%d", fd, count);
if ((fr->flags & O_ACCMODE) == O_RDONLY) {
return -EBADF;
}
// get the striper object
libradosstriper::RadosStriper *striper = getRadosStriper(*fr);
if (0 == striper) {
return -EINVAL;
}
// prepare a bufferlist around the given buffer
ceph::bufferlist bl;
bl.append(buf, count);
// get the poolIdx to use
int cephPoolIdx = getCephPoolIdxAndIncrease();
// Get the cluster to use
librados::Rados* cluster = checkAndCreateCluster(cephPoolIdx);
if (0 == cluster) {
return -EINVAL;
}
// prepare a ceph AioCompletion object and do async call
AioArgs *args = new AioArgs(aiop, cb, count, fd);
librados::AioCompletion *completion =
cluster->aio_create_completion(args, ceph_aio_write_complete, NULL);
// do the write
int rc = striper->aio_write(fr->name, completion, bl, count, offset);
completion->release();
XrdSysMutexHelper lock(fr->statsMutex);
fr->asyncWrStartCount++;
::gettimeofday(&fr->lastAsyncSubmission, nullptr);
fr->bytesAsyncWritePending+=count;
return rc;
} else {
return -EBADF;
}
}
ceph_aio_write_complete
static void ceph_aio_write_complete(rados_completion_t c, void *arg)
Definition XrdCephPosix.cc:873
aiocb::aio_buf
void * aio_buf
Definition XrdSfsAio.hh:47
CephFileRef::bytesAsyncWritePending
uint64_t bytesAsyncWritePending
Definition XrdCephPosix.hh:119
CephFileRef::asyncWrStartCount
unsigned asyncWrStartCount
Definition XrdCephPosix.hh:125
CephFileRef::lastAsyncSubmission
::timeval lastAsyncSubmission
Definition XrdCephPosix.hh:127

References aiocb::aio_buf, aiocb::aio_nbytes, aiocb::aio_offset, CephFileRef::asyncWrStartCount, CephFileRef::bytesAsyncWritePending, ceph_aio_write_complete(), checkAndCreateCluster(), CephFileRef::flags, getCephPoolIdxAndIncrease(), getFileRef(), getRadosStriper(), CephFileRef::lastAsyncSubmission, CephFile::name, XrdSfsAio::sfsAio, and CephFileRef::statsMutex.

Referenced by XrdCephOssFile::Write(), and XrdCephBuffer::CephIOAdapterAIORaw::write().

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

## ceph_nonstriper_readv()

ssize_t ceph_nonstriper_readv | ( | int | fd,
|  | XrdOucIOVec * | readV,
|  | int | n )

Definition at line 947 of file XrdCephPosix.cc.

{
CephFileRef* fr = getFileRef(fd);
if (fr) {
// TODO implement proper logging level for this plugin - this should be only debug
//logwrapper((char*)"ceph_read: for fd %d, count=%d", fd, count);
if ((fr->flags & O_ACCMODE) == O_WRONLY) {
return -EBADF;
}
if (fr->nbStripes != 1) {
//Non-striper based read method works only with a single stripe
return -ENOTSUP;
}
ssize_t read_bytes;
int rc;
librados::IoCtx *ioctx = getIoCtx(*fr);
if (0 == ioctx) {
return -EINVAL;
}
try {
//Constructor can throw bad alloc
bulkAioRead readOp(ioctx, logwrapper, fr);
for (int i = 0; i < n; i++) {
rc = readOp.read(readV[i].data, readV[i].size, readV[i].offset);
if (rc < 0) {
logwrapper( (char*)"Can not declare read request\n");
return rc;
}
}
std::time_t wait_time = std::time(0);
rc = readOp.submit_and_wait_for_complete();
wait_time = std::time(0) - wait_time;
if (wait_time > g_cephAioWaitThresh) {
logwrapper(
(char*)"Waiting for AIO results in readv for %s took %ld seconds, too long!\n",
fr->name.c_str(),
wait_time
);
}
if (rc < 0) {
logwrapper( (char*)"Can not submit read requests\n");
return rc;
}
read_bytes = readOp.get_results();
XrdSysMutexHelper lock(fr->statsMutex);
//We consider readv as a single operation
fr->rdcount += 1;
return read_bytes;
} catch(std::bad_alloc&) {
return -ENOMEM;
}
} else {
return -EBADF;
}
}
logwrapper
static void logwrapper(char *format, va_list argp)
Definition XrdCephOss.cc:62
g_cephAioWaitThresh
unsigned int g_cephAioWaitThresh
Definition XrdCephPosix.cc:91
getIoCtx
static librados::IoCtx * getIoCtx(const CephFile &file)
Definition XrdCephPosix.cc:611
logwrapper
static void logwrapper(char *format,...)
Definition XrdCephPosix.cc:203
bulkAioRead
Definition XrdCephBulkAioRead.hh:10
CephFileRef::rdcount
unsigned rdcount
Definition XrdCephPosix.hh:121
CephFile::nbStripes
unsigned int nbStripes
Definition XrdCephPosix.hh:107

References CephFileRef::flags, g_cephAioWaitThresh, bulkAioRead::get_results(), getFileRef(), getIoCtx(), logwrapper(), logwrapper(), CephFile::name, CephFile::nbStripes, CephFileRef::rdcount, bulkAioRead::read(), CephFileRef::statsMutex, and bulkAioRead::submit_and_wait_for_complete().

Referenced by XrdCephOssFile::ReadV().

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

## ceph_posix_close()

int ceph_posix_close | ( | int | fd | ) |

Definition at line 760 of file XrdCephPosix.cc.

{
CephFileRef* fr = getFileRef(fd);
if (fr) {
::timeval now;
::gettimeofday(&now, nullptr);
XrdSysMutexHelper lock(fr->statsMutex);
double lastAsyncAge = 0.0;
// Only compute an age if the starting point was set.
if (fr->lastAsyncSubmission.tv_sec && fr->lastAsyncSubmission.tv_usec) {
lastAsyncAge = 1.0 * (now.tv_sec - fr->lastAsyncSubmission.tv_sec)
+ 0.000001 * (now.tv_usec - fr->lastAsyncSubmission.tv_usec);
}
logwrapper((char*)"ceph_close: closed fd %d for file %s, read ops count %d, write ops count %d, "
"async write ops %d/%d, async pending write bytes %ld, "
"async read ops %d/%d, bytes written/max offset %ld/%ld, "
"longest async write %f, longest callback invocation %f, last async op age %f",
fd, fr->name.c_str(), fr->rdcount, fr->wrcount,
fr->asyncWrCompletionCount, fr->asyncWrStartCount, fr->bytesAsyncWritePending,
fr->asyncRdCompletionCount, fr->asyncRdStartCount, fr->bytesWritten, fr->maxOffsetWritten,
fr->longestAsyncWriteTime, fr->longestCallbackInvocation, (lastAsyncAge));
deleteFileRef(fd, *fr);
return 0;
} else {
return -EBADF;
}
}
deleteFileRef
void deleteFileRef(int fd, const CephFileRef &fr)
deletes a FileRef from the global table of file descriptors
Definition XrdCephPosix.cc:164
CephFileRef::maxOffsetWritten
uint64_t maxOffsetWritten
Definition XrdCephPosix.hh:118
CephFileRef::longestCallbackInvocation
double longestCallbackInvocation
Definition XrdCephPosix.hh:129
CephFileRef::bytesWritten
uint64_t bytesWritten
Definition XrdCephPosix.hh:120
CephFileRef::longestAsyncWriteTime
double longestAsyncWriteTime
Definition XrdCephPosix.hh:128
CephFileRef::wrcount
unsigned wrcount
Definition XrdCephPosix.hh:122
CephFileRef::asyncWrCompletionCount
unsigned asyncWrCompletionCount
Definition XrdCephPosix.hh:126
CephFileRef::asyncRdCompletionCount
unsigned asyncRdCompletionCount
Definition XrdCephPosix.hh:124

References CephFileRef::asyncRdCompletionCount, CephFileRef::asyncRdStartCount, CephFileRef::asyncWrCompletionCount, CephFileRef::asyncWrStartCount, CephFileRef::bytesAsyncWritePending, CephFileRef::bytesWritten, deleteFileRef(), getFileRef(), CephFileRef::lastAsyncSubmission, logwrapper(), CephFileRef::longestAsyncWriteTime, CephFileRef::longestCallbackInvocation, CephFileRef::maxOffsetWritten, CephFile::name, CephFileRef::rdcount, CephFileRef::statsMutex, and CephFileRef::wrcount.

Referenced by XrdCephOssFile::Close().

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

## ceph_posix_closedir()

int ceph_posix_closedir | ( | DIR * | dirp | ) |

Definition at line 1626 of file XrdCephPosix.cc.

{
delete ((DirIterator*)dirp);
return 0;
}
DirIterator
small struct for directory listing
Definition XrdCephPosix.cc:60

Referenced by XrdCephOssDir::Close().

Here is the caller graph for this function:

## ceph_posix_disconnect_all()

void ceph_posix_disconnect_all | ( |  | ) |

Definition at line 624 of file XrdCephPosix.cc.

{
XrdSysMutexHelper lock(g_striper_mutex);
for (unsigned int i= 0; i < g_maxCephPoolIdx; i++) {
for (StriperDict::iterator it2 = g_radosStripers[i].begin();
it2 != g_radosStripers[i].end();
it2++) {
delete it2->second;
}
for (IOCtxDict::iterator it2 = g_ioCtx[i].begin();
it2 != g_ioCtx[i].end();
it2++) {
delete it2->second;
}
delete g_cluster[i];
}
g_radosStripers.clear();
g_ioCtx.clear();
g_cluster.clear();
}
g_maxCephPoolIdx
unsigned int g_maxCephPoolIdx
Definition XrdCephPosix.cc:95
g_cluster
std::vector< librados::Rados * > g_cluster
Definition XrdCephPosix.cc:84
g_striper_mutex
XrdSysMutex g_striper_mutex
mutex protecting the striper and ioctx maps
Definition XrdCephPosix.cc:86
g_ioCtx
std::vector< IOCtxDict > g_ioCtx
Definition XrdCephPosix.cc:83
g_radosStripers
std::vector< StriperDict > g_radosStripers
Definition XrdCephPosix.cc:81

References g_cluster, g_ioCtx, g_maxCephPoolIdx, g_radosStripers, and g_striper_mutex.

Referenced by XrdCephOss::~XrdCephOss().

Here is the caller graph for this function:

## ceph_posix_fcntl()

int ceph_posix_fcntl | ( | int | fd,
|  | int | cmd,
|  |  | ... )

Definition at line 1286 of file XrdCephPosix.cc.

{
CephFileRef* fr = getFileRef(fd);
if (fr) {
logwrapper((char*)"ceph_fcntl: fd %d cmd=%d", fd, cmd);
// minimal implementation
switch (cmd) {
case F_GETFL:
return fr->mode;
default:
return -EINVAL;
}
} else {
return -EBADF;
}
}
CephFileRef::mode
mode_t mode
Definition XrdCephPosix.hh:114

References getFileRef(), logwrapper(), and CephFileRef::mode.

Here is the call graph for this function:

## ceph_posix_fgetxattr()

ssize_t ceph_posix_fgetxattr | ( | int | fd,
|  | const char * | name,
|  | void * | value,
|  | size_t | size )

Definition at line 1323 of file XrdCephPosix.cc.

{
CephFileRef* fr = getFileRef(fd);
if (fr) {
logwrapper((char*)"ceph_fgetxattr: fd %d name=%s", fd, name);
return ceph_posix_internal_getxattr(*fr, name, value, size);
} else {
return -EBADF;
}
}
ceph_posix_internal_getxattr
static ssize_t ceph_posix_internal_getxattr(const CephFile &file, const char *name, void *value, size_t size)
Definition XrdCephPosix.cc:1302

References ceph_posix_internal_getxattr(), getFileRef(), and logwrapper().

Referenced by XrdCephXAttr::Get().

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

## ceph_posix_flistxattrs()

int ceph_posix_flistxattrs | ( | int | fd,
|  | XrdSysXAttr::AList ** | aPL,
|  | int | getSz )

Definition at line 1435 of file XrdCephPosix.cc.

{
CephFileRef* fr = getFileRef(fd);
if (fr) {
logwrapper((char*)"ceph_flistxattrs: fd %d", fd);
return ceph_posix_internal_listxattrs(*fr, aPL, getSz);
} else {
return -EBADF;
}
}
ceph_posix_internal_listxattrs
static int ceph_posix_internal_listxattrs(const CephFile &file, XrdSysXAttr::AList **aPL, int getSz)
Definition XrdCephPosix.cc:1396

References ceph_posix_internal_listxattrs(), getFileRef(), and logwrapper().

Referenced by XrdCephXAttr::List().

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

## ceph_posix_freexattrlist()

void ceph_posix_freexattrlist | ( | XrdSysXAttr::AList * | aPL | ) |

Definition at line 1445 of file XrdCephPosix.cc.

{
while (aPL) {
free(aPL->Name);
XrdSysXAttr::AList *cur = aPL;
aPL = aPL->Next;
free(cur);
}
}
XrdSysXAttr::AList::Name
char Name[1]
Start of the name (size of struct is dynamic).
Definition XrdSysXAttr.hh:56
XrdSysXAttr::AList::Next
AList * Next
-> next element.
Definition XrdSysXAttr.hh:53
XrdSysXAttr::AList
Definition XrdSysXAttr.hh:53

References XrdSysXAttr::AList::Name, and XrdSysXAttr::AList::Next.

Referenced by XrdCephXAttr::Free().

Here is the caller graph for this function:

## ceph_posix_fremovexattr()

int ceph_posix_fremovexattr | ( | int | fd,
|  | const char * | name )

Definition at line 1386 of file XrdCephPosix.cc.

{
CephFileRef* fr = getFileRef(fd);
if (fr) {
logwrapper((char*)"ceph_fremovexattr: fd %d name=%s", fd, name);
return ceph_posix_internal_removexattr(*fr, name);
} else {
return -EBADF;
}
}
ceph_posix_internal_removexattr
static int ceph_posix_internal_removexattr(const CephFile &file, const char *name)
Definition XrdCephPosix.cc:1368

References ceph_posix_internal_removexattr(), getFileRef(), and logwrapper().

Here is the call graph for this function:

## ceph_posix_fsetxattr()

int ceph_posix_fsetxattr | ( | int | fd,
|  | const char * | name,
|  | const void * | value,
|  | size_t | size,
|  | int | flags )

Definition at line 1356 of file XrdCephPosix.cc.

{
CephFileRef* fr = getFileRef(fd);
if (fr) {
logwrapper((char*)"ceph_fsetxattr: fd %d name=%s value=%s", fd, name, value);
return ceph_posix_internal_setxattr(*fr, name, value, size, flags);
} else {
return -EBADF;
}
}
ceph_posix_internal_setxattr
static ssize_t ceph_posix_internal_setxattr(const CephFile &file, const char *name, const void *value, size_t size, int flags)
Definition XrdCephPosix.cc:1334

References ceph_posix_internal_setxattr(), getFileRef(), and logwrapper().

Referenced by XrdCephXAttr::Set().

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

## ceph_posix_fstat()

int ceph_posix_fstat | ( | int | fd,
|  | struct stat * | buf )

Definition at line 1215 of file XrdCephPosix.cc.

{
CephFileRef* fr = getFileRef(fd);
if (fr) {
logwrapper((char*)__FUNCTION__,": fd %d", fd);
// minimal stat : only size and times are filled
// atime, mtime and ctime are set all to the same value
// mode is set arbitrarily to 0666 | S_IFREG
libradosstriper::RadosStriper *striper = getRadosStriper(*fr);
if (0 == striper) {
logwrapper((char*)"ceph_stat: getRadosStriper failed");
return -EINVAL;
}
memset(buf, 0, sizeof(*buf));
int rc = striper->stat(fr->name, (uint64_t*)&(buf->st_size), &(buf->st_atime));
if (rc != 0) {
return -rc;
}
buf->st_dev = 1;
buf->st_ino = 1;
buf->st_mtime = buf->st_atime;
buf->st_ctime = buf->st_atime;
buf->st_mode = 0666 | S_IFREG;
return 0;
} else {
return -EBADF;
}
}

References getFileRef(), getRadosStriper(), logwrapper(), CephFile::name, and stat.

Referenced by XrdCephOssFile::Fstat().

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

## ceph_posix_fsync()

int ceph_posix_fsync | ( | int | fd | ) |

Definition at line 1275 of file XrdCephPosix.cc.

{
CephFileRef* fr = getFileRef(fd);
if (fr) {
// no locking of fr as it is not used.
logwrapper((char*)"ceph_sync: fd %d", fd);
return 0;
} else {
return -EBADF;
}
}

References getFileRef(), and logwrapper().

Referenced by XrdCephOssFile::Fsync().

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

## ceph_posix_ftruncate()

int ceph_posix_ftruncate | ( | int | fd,
|  | unsigned long long | size )

Definition at line 1525 of file XrdCephPosix.cc.

{
CephFileRef* fr = getFileRef(fd);
if (fr) {
logwrapper((char*)"ceph_posix_ftruncate: fd %d, size %d", fd, size);
return ceph_posix_internal_truncate(*fr, size);
} else {
return -EBADF;
}
}
ceph_posix_internal_truncate
static int ceph_posix_internal_truncate(const CephFile &file, unsigned long long size)
Definition XrdCephPosix.cc:1517

References ceph_posix_internal_truncate(), getFileRef(), and logwrapper().

Referenced by XrdCephOssFile::Ftruncate().

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

## ceph_posix_getxattr()

ssize_t ceph_posix_getxattr | ( | XrdOucEnv * | env,
|  | const char * | path,
|  | const char * | name,
|  | void * | value,
|  | size_t | size )

Definition at line 1316 of file XrdCephPosix.cc.

{
logwrapper((char*)"ceph_getxattr: path %s name=%s", path, name);
return ceph_posix_internal_getxattr(getCephFile(path, env), name, value, size);
}
getCephFile
static CephFile getCephFile(const char *path, XrdOucEnv *env)
Definition XrdCephPosix.cc:447

References ceph_posix_internal_getxattr(), getCephFile(), and logwrapper().

Referenced by XrdCephXAttr::Get(), and getNumericAttr().

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

## ceph_posix_listxattrs()

int ceph_posix_listxattrs | ( | XrdOucEnv * | env,
|  | const char * | path,
|  | XrdSysXAttr::AList ** | aPL,
|  | int | getSz )

Definition at line 1430 of file XrdCephPosix.cc.

{
logwrapper((char*)"ceph_listxattrs: path %s", path);
return ceph_posix_internal_listxattrs(getCephFile(path, env), aPL, getSz);
}

References ceph_posix_internal_listxattrs(), getCephFile(), and logwrapper().

Referenced by XrdCephXAttr::List().

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

## ceph_posix_lseek()

off_t ceph_posix_lseek | ( | int | fd,
|  | off_t | offset,
|  | int | whence )

Definition at line 801 of file XrdCephPosix.cc.

{
CephFileRef* fr = getFileRef(fd);
if (fr) {
logwrapper((char*)"ceph_lseek: for fd %d, offset=%lld, whence=%d", fd, offset, whence);
return (off_t)lseek_compute_offset(*fr, offset, whence);
} else {
return -EBADF;
}
}
lseek_compute_offset
static off64_t lseek_compute_offset(CephFileRef &fr, off64_t offset, int whence)
Definition XrdCephPosix.cc:787

References getFileRef(), logwrapper(), and lseek_compute_offset().

Here is the call graph for this function:

## ceph_posix_lseek64()

off64_t ceph_posix_lseek64 | ( | int | fd,
|  | off64_t | offset,
|  | int | whence )

Definition at line 811 of file XrdCephPosix.cc.

{
CephFileRef* fr = getFileRef(fd);
if (fr) {
logwrapper((char*)"ceph_lseek64: for fd %d, offset=%lld, whence=%d", fd, offset, whence);
return lseek_compute_offset(*fr, offset, whence);
} else {
return -EBADF;
}
}

References getFileRef(), logwrapper(), and lseek_compute_offset().

Here is the call graph for this function:

## ceph_posix_maybestriper_pread()

ssize_t ceph_posix_maybestriper_pread | ( | int | fd,
|  | void * | buf,
|  | size_t | count,
|  | off64_t | offset,
|  | bool | allowStriper = true )

Definition at line 1134 of file XrdCephPosix.cc.

{
ssize_t rc {0};
if (!allowStriper) {
rc = ceph_posix_pread(fd,buf,count,offset);
return rc;
}
rc = ceph_posix_nonstriper_pread(fd, buf, count,offset);
if (-ENOENT == rc || -ENOTSUP == rc) {
//This might be a sparse file or nbstripes > 1, so let's try striper read
rc = ceph_posix_pread(fd, buf, count,offset);
if (rc >= 0) {
char err_str[100]; //99 symbols should be enough for the short message
snprintf(err_str, 100, "WARNING! The file (fd %d) seem to be sparse, this is not expected", fd);
logwrapper(err_str);
}
}
return rc;
}
ceph_posix_pread
ssize_t ceph_posix_pread(int fd, void *buf, size_t count, off64_t offset)
Definition XrdCephPosix.cc:1110
ceph_posix_nonstriper_pread
ssize_t ceph_posix_nonstriper_pread(int fd, void *buf, size_t count, off64_t offset)
Definition XrdCephPosix.cc:1048

References ceph_posix_nonstriper_pread(), ceph_posix_pread(), and logwrapper().

Referenced by XrdCephBuffer::CephIOAdapterRaw::read(), and XrdCephBuffer::XrdCephBufferAlgSimple::read().

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

## ceph_posix_nonstriper_pread()

ssize_t ceph_posix_nonstriper_pread | ( | int | fd,
|  | void * | buf,
|  | size_t | count,
|  | off64_t | offset )

Definition at line 1048 of file XrdCephPosix.cc.

{
//The same as pread, but do not relies on rados striper library. Uses direct atomic
//reads from ceph object (see BulkAioRead class for details).
CephFileRef* fr = getFileRef(fd);
if (fr) {
// TODO implement proper logging level for this plugin - this should be only debug
//logwrapper((char*)"ceph_read: for fd %d, count=%d", fd, count);
if ((fr->flags & O_ACCMODE) == O_WRONLY) {
return -EBADF;
}
if (fr->nbStripes != 1) {
//Non-striper based read method works only with a single stripe
return -ENOTSUP;
}
int rc;
ssize_t bytes_read;
librados::IoCtx *ioctx = getIoCtx(*fr);
if (0 == ioctx) {
return -EINVAL;
}
try {
//Constructor can throw bad alloc
bulkAioRead readOp(ioctx, logwrapper, fr);
rc = readOp.read(buf, count, offset);
if (rc < 0) {
logwrapper( (char*)"Can not declare read request\n");
return rc;
}
std::time_t wait_time = std::time(0);
rc = readOp.submit_and_wait_for_complete();
wait_time = std::time(0) - wait_time;
if (wait_time > g_cephAioWaitThresh) {
logwrapper(
(char*)"Waiting for AIO results in pread for %s took %ld seconds, too long!\n",
fr->name.c_str(),
wait_time
);
}
if (rc < 0) {
logwrapper( (char*)"Can not submit read request\n");
return rc;
}
bytes_read = readOp.get_results();
if (bytes_read > 0) {
XrdSysMutexHelper lock(fr->statsMutex);
fr->rdcount++;
} else {
logwrapper( (char*)"Error while read: %d\n", bytes_read);
}
return bytes_read;
} catch (std::bad_alloc&) {
return -ENOMEM;
}
} else {
return -EBADF;
}
}

References CephFileRef::flags, g_cephAioWaitThresh, bulkAioRead::get_results(), getFileRef(), getIoCtx(), logwrapper(), logwrapper(), CephFile::name, CephFile::nbStripes, CephFileRef::rdcount, bulkAioRead::read(), CephFileRef::statsMutex, and bulkAioRead::submit_and_wait_for_complete().

Referenced by ceph_posix_maybestriper_pread(), and XrdCephOssFile::Read().

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

## ceph_posix_open()

int ceph_posix_open | ( | XrdOucEnv * | env,
|  | const char * | pathname,
|  | int | flags,
|  | mode_t | mode )

- brief ceph_posix_open function opens a file for read or write
- details This function either:
- Opens a file for reading. If the file doesn't exist, this is an error.
- Opens a file for writing. If the file already exists, check whether overwrite has been requested. If overwrite
- hasn't been requested for an existing file, this is an error.
- param env XrdOucEnv* Unused
- param pathname const char* Specify the file to open.
- param flags int Indicates whether reading or writing, and whether to overwrite an existing file.
- param mode mode_t Unused
- return int This is a file descriptor (non-negative) if the operation is successful,
- or an error code (negative value) if the operation fails

Definition at line 664 of file XrdCephPosix.cc.

{
CephFileRef fr = getCephFileRef(pathname, env, flags, mode, 0);
struct stat buf;
libradosstriper::RadosStriper *striper = getRadosStriper(fr); //Get a handle to the RADOS striper API
if (NULL == striper) {
logwrapper((char*)"Cannot create striper");
return -EINVAL;
}
dumpClusterInfo(); // JW enhanced logging
int rc = striper->stat(fr.name, (uint64_t*)&(buf.st_size), &(buf.st_atime)); //Get details about a file
bool fileExists = (rc != -ENOENT); //Make clear what condition we are testing
logwrapper((char*)"Access Mode: %s flags&O_ACCMODE %d ", pathname, flags);
if ((flags & O_ACCMODE) == O_RDONLY) { // Access mode is READ
if (fileExists) {
librados::bufferlist d_stripeUnit;
librados::bufferlist d_objectSize;
std::string obj_name;
librados::IoCtx *context = getIoCtx(fr);
// read first stripe of the object for xattr stripe unit and object size
// this will fail if the object was not written in stripes e.g. s3
// TBD: fallback to direct object (no stripe id appends to filename,
// replace striper metadata with corresponding metadata)
//
try {
obj_name = fr.name + std::string(".0000000000000000");
} catch (std::bad_alloc&) {
logwrapper((char*)"Can not create object string for file %s)", fr.name.c_str());
return -ENOMEM;
}
int ret = 0;
ret = context->getxattr(obj_name, "striper.layout.stripe_unit", d_stripeUnit);
ret = std::min(ret,context->getxattr(obj_name, "striper.layout.object_size", d_objectSize));
//log_func((char*)"size xattr for %s , %llu ,%llu", file_ref->name.c_str(), file_ref->objectSize, file_ref->stripeUnit );
if (ret<=0){
logwrapper((char*)"Could not find size or stripe_unit xattr for %s", fr.name.c_str());
}
else{
//librados's c_str() method does not return a NULL-terminated string, hence why we need to cleanup here
char cleanStripeUnit[MAXDIGITSIZE];
char cleanObjectSize[MAXDIGITSIZE];
unsigned int stripeUnitLength = std::min((unsigned int)MAXDIGITSIZE-1, d_stripeUnit.length());
unsigned int objectSizeLength = std::min((unsigned int)MAXDIGITSIZE-1, d_objectSize.length());
(void)strncpy( cleanStripeUnit, d_stripeUnit.c_str(), stripeUnitLength );
(void)strncpy( cleanObjectSize, d_objectSize.c_str(), objectSizeLength );
cleanStripeUnit[stripeUnitLength] = '\0';
cleanObjectSize[objectSizeLength] = '\0';
//only change defaults if different
if(fr.stripeUnit != std::stoull(cleanStripeUnit)){
logwrapper((char*)"WARNING: stripe unit of %s does not match defaults. object size is %s", pathname, cleanStripeUnit);
fr.stripeUnit = std::stoull(cleanStripeUnit);
}
if(fr.objectSize != std::stoull(cleanObjectSize)){
logwrapper((char*)"WARNING: object size of %s does not match defaults. object size is %s",pathname, cleanObjectSize);
fr.objectSize = std::stoull(cleanObjectSize);
}
}
int fd = insertFileRef(fr);
logwrapper((char*)"File descriptor %d associated to file %s opened in read mode", fd, pathname);
return fd;
} else {
return -ENOENT;
}
} else { // Access mode is WRITE
if (fileExists) {
if (flags & O_TRUNC) {
int rc = ceph_posix_unlink(env, pathname);
if (rc < 0 && rc != -ENOENT) {
return rc;
}
} else {
if (flags & O_EXCL) {
return -EACCES; // permission denied
} else {
return -EEXIST; // otherwise return just file exists
}
}
}
// At this point, we know either the target file didn't exist, or the ceph_posix_unlink above removed it
int fd = insertFileRef(fr);
logwrapper((char*)"File descriptor %d associated to file %s opened in write mode", fd, pathname);
return fd;
}
}
ceph_posix_unlink
int ceph_posix_unlink(XrdOucEnv *env, const char *pathname)
Definition XrdCephPosix.cc:1542
insertFileRef
int insertFileRef(CephFileRef &fr)
Definition XrdCephPosix.cc:179
getCephFileRef
static CephFileRef getCephFileRef(const char *path, XrdOucEnv *env, int flags, mode_t mode, unsigned long long offset)
Definition XrdCephPosix.cc:453
dumpClusterInfo
void dumpClusterInfo()
Definition XrdCephPosix.cc:241
MAXDIGITSIZE
#define MAXDIGITSIZE
Definition XrdCephPosix.hh:45
stat
#define stat(a, b)
Definition XrdPosix.hh:101
CephFile::stripeUnit
unsigned long long stripeUnit
Definition XrdCephPosix.hh:108
CephFile::objectSize
unsigned long long objectSize
Definition XrdCephPosix.hh:109

References ceph_posix_unlink(), dumpClusterInfo(), getCephFileRef(), getIoCtx(), getRadosStriper(), insertFileRef(), logwrapper(), MAXDIGITSIZE, CephFile::name, CephFile::objectSize, stat, and CephFile::stripeUnit.

Referenced by XrdCephOssFile::Open().

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

## ceph_posix_opendir()

DIR * ceph_posix_opendir | ( | XrdOucEnv * | env,
|  | const char * | pathname )

Definition at line 1588 of file XrdCephPosix.cc.

{
logwrapper((char*)"ceph_posix_opendir : %s", pathname);
// only accept root dir, as there is no concept of dirs in object stores
CephFile file = getCephFile(pathname, env);
if (file.name.size() != 1 || file.name[0] != '/') {
errno = -ENOENT;
return 0;
}
librados::IoCtx *ioctx = getIoCtx(file);
if (0 == ioctx) {
errno = EINVAL;
return 0;
}
DirIterator* res = new DirIterator();
res->m_iterator = ioctx->nobjects_begin();
res->m_ioctx = ioctx;
return (DIR*)res;
}
DirIterator::m_ioctx
librados::IoCtx * m_ioctx
Definition XrdCephPosix.cc:62
DirIterator::m_iterator
librados::NObjectIterator m_iterator
Definition XrdCephPosix.cc:61
CephFile
small structs to store file metadata
Definition XrdCephPosix.hh:103

References getCephFile(), getIoCtx(), logwrapper(), DirIterator::m_ioctx, DirIterator::m_iterator, and CephFile::name.

Referenced by XrdCephOssDir::Opendir().

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

## ceph_posix_pread()

ssize_t ceph_posix_pread | ( | int | fd,
|  | void * | buf,
|  | size_t | count,
|  | off64_t | offset )

Definition at line 1110 of file XrdCephPosix.cc.

{
CephFileRef* fr = getFileRef(fd);
if (fr) {
// TODO implement proper logging level for this plugin - this should be only debug
//logwrapper((char*)"ceph_read: for fd %d, count=%d", fd, count);
if ((fr->flags & O_ACCMODE) == O_WRONLY) {
return -EBADF;
}
libradosstriper::RadosStriper *striper = getRadosStriper(*fr);
if (0 == striper) {
return -EINVAL;
}
ceph::bufferlist bl;
int rc = striper->read(fr->name, &bl, count, offset);
if (rc < 0) return rc;
bl.begin().copy(rc, (char*)buf);
XrdSysMutexHelper lock(fr->statsMutex);
fr->rdcount++;
return rc;
} else {
return -EBADF;
}
}

References CephFileRef::flags, getFileRef(), getRadosStriper(), CephFile::name, CephFileRef::rdcount, and CephFileRef::statsMutex.

Referenced by ceph_posix_maybestriper_pread(), ceph_striper_readv(), and XrdCephOssFile::Read().

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

## ceph_posix_pwrite()

ssize_t ceph_posix_pwrite | ( | int | fd,
|  | const void * | buf,
|  | size_t | count,
|  | off64_t | offset )

Definition at line 847 of file XrdCephPosix.cc.

{
CephFileRef* fr = getFileRef(fd);
if (fr) {
// TODO implement proper logging level for this plugin - this should be only debug
//logwrapper((char*)"ceph_write: for fd %d, count=%d", fd, count);
if ((fr->flags & O_ACCMODE) == O_RDONLY) {
return -EBADF;
}
libradosstriper::RadosStriper *striper = getRadosStriper(*fr);
if (0 == striper) {
return -EINVAL;
}
ceph::bufferlist bl;
bl.append((const char*)buf, count);
int rc = striper->write(fr->name, bl, count, offset);
if (rc) return rc;
XrdSysMutexHelper lock(fr->statsMutex);
fr->wrcount++;
fr->bytesWritten+=count;
if (offset + count) fr->maxOffsetWritten = std::max(uint64_t(offset + count - 1), fr->maxOffsetWritten);
return count;
} else {
return -EBADF;
}
}

References CephFileRef::bytesWritten, CephFileRef::flags, getFileRef(), getRadosStriper(), CephFileRef::maxOffsetWritten, CephFile::name, CephFileRef::statsMutex, and CephFileRef::wrcount.

Referenced by XrdCephOssFile::Write(), and XrdCephBuffer::CephIOAdapterRaw::write().

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

## ceph_posix_read()

ssize_t ceph_posix_read | ( | int | fd,
|  | void * | buf,
|  | size_t | count )

Definition at line 1023 of file XrdCephPosix.cc.

{
CephFileRef* fr = getFileRef(fd);
if (fr) {
// TODO implement proper logging level for this plugin - this should be only debug
//logwrapper((char*)"ceph_read: for fd %d, count=%d", fd, count);
if ((fr->flags & O_ACCMODE) == O_WRONLY) {
return -EBADF;
}
libradosstriper::RadosStriper *striper = getRadosStriper(*fr);
if (0 == striper) {
return -EINVAL;
}
ceph::bufferlist bl;
int rc = striper->read(fr->name, &bl, count, fr->offset);
if (rc < 0) return rc;
bl.begin().copy(rc, (char*)buf);
XrdSysMutexHelper lock(fr->statsMutex);
fr->offset += rc;
fr->rdcount++;
return rc;
} else {
return -EBADF;
}
}
CephFileRef::offset
uint64_t offset
Definition XrdCephPosix.hh:115

References CephFileRef::flags, getFileRef(), getRadosStriper(), CephFile::name, CephFileRef::offset, CephFileRef::rdcount, and CephFileRef::statsMutex.

Here is the call graph for this function:

## ceph_posix_readdir()

int ceph_posix_readdir | ( | DIR * | dirp,
|  | char * | buff,
|  | int | blen )

Definition at line 1607 of file XrdCephPosix.cc.

{
librados::NObjectIterator &iterator = ((DirIterator*)dirp)->m_iterator;
librados::IoCtx *ioctx = ((DirIterator*)dirp)->m_ioctx;
while (iterator->get_oid().compare(iterator->get_oid().size()-17, 17, ".0000000000000000") &&
iterator != ioctx->nobjects_end()) {
iterator++;
}
if (iterator == ioctx->nobjects_end()) {
buff[0] = 0;
} else {
int l = iterator->get_oid().size()-17;
if (l < blen) blen = l;
strncpy(buff, iterator->get_oid().c_str(), blen-1);
buff[blen-1] = 0;
iterator++;
}
return 0;
}

References DirIterator::m_iterator.

Referenced by XrdCephOssDir::Readdir().

Here is the caller graph for this function:

## ceph_posix_removexattr()

int ceph_posix_removexattr | ( | XrdOucEnv * | env,
|  | const char * | path,
|  | const char * | name )

Definition at line 1380 of file XrdCephPosix.cc.

{
logwrapper((char*)"ceph_removexattr: path %s name=%s", path, name);
return ceph_posix_internal_removexattr(getCephFile(path, env), name);
}

References ceph_posix_internal_removexattr(), getCephFile(), and logwrapper().

Referenced by XrdCephXAttr::Del().

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

## ceph_posix_set_defaults()

void ceph_posix_set_defaults | ( | const char * | value | ) |

sets the default userId, pool and file layout syntax is [user@]pool[,nbStripes[,stripeUnit[,objectSize]]] may throw std::invalid_argument or std::out_of_range in case of error

Definition at line 397 of file XrdCephPosix.cc.

{
if (value) {
CephFile newdefault;
fillCephFileParams(value, NULL, newdefault);
g_defaultParams = newdefault;
}
}
g_defaultParams
CephFile g_defaultParams
global variable containing defaults for CephFiles
Definition XrdCephPosix.cc:190
fillCephFileParams
void fillCephFileParams(const std::string &params, XrdOucEnv *env, CephFile &file)
Definition XrdCephPosix.cc:385

References fillCephFileParams(), and g_defaultParams.

Referenced by XrdOssGetStorageSystem(), and XrdSysGetXAttrObject().

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

## ceph_posix_set_logfunc()

void ceph_posix_set_logfunc | ( | void(* | logfunc )(char *, va_list argp) | ) |

Definition at line 644 of file XrdCephPosix.cc.

{
g_logfunc = logfunc;
};
g_logfunc
static void(* g_logfunc)(char *, va_list argp)=0
global variable for the log function
Definition XrdCephPosix.cc:201

References g_logfunc.

Referenced by XrdOssGetStorageSystem().

Here is the caller graph for this function:

## ceph_posix_setxattr()

ssize_t ceph_posix_setxattr | ( | XrdOucEnv * | env,
|  | const char * | path,
|  | const char * | name,
|  | const void * | value,
|  | size_t | size,
|  | int | flags )

Definition at line 1349 of file XrdCephPosix.cc.

{
logwrapper((char*)"ceph_setxattr: path %s name=%s value=%s", path, name, value);
return ceph_posix_internal_setxattr(getCephFile(path, env), name, value, size, flags);
}

References ceph_posix_internal_setxattr(), getCephFile(), and logwrapper().

Referenced by XrdCephXAttr::Set().

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

## ceph_posix_stat()

int ceph_posix_stat | ( | XrdOucEnv * | env,
|  | const char * | pathname,
|  | struct stat * | buf )

Definition at line 1243 of file XrdCephPosix.cc.

{
logwrapper((char*)__FUNCTION__, pathname);
// minimal stat : only size and times are filled
// atime, mtime and ctime are set all to the same value
// mode is set arbitrarily to 0666 | S_IFREG
CephFile file = getCephFile(pathname, env);
libradosstriper::RadosStriper *striper = getRadosStriper(file);
if (0 == striper) {
return -EINVAL;
}
memset(buf, 0, sizeof(*buf));
int rc = striper->stat(file.name, (uint64_t*)&(buf->st_size), &(buf->st_atime));
if (rc != 0) {
// for non existing file. Check that we did not open it for write recently
// in that case, we return 0 size and current time
if (-ENOENT == rc && isOpenForWrite(file.name)) {
buf->st_size = 0;
buf->st_atime = time(NULL);
} else {
return -rc;
}
}
// XRootD assumes an 'offline' file if st_dev and st_ino
// are zero. Set to non-zero (meaningful) values to avoid this
buf->st_dev = 1;
buf->st_ino = 1;
buf->st_mtime = buf->st_atime;
buf->st_ctime = buf->st_atime;
buf->st_mode = 0666 | S_IFREG;
return 0;
}
isOpenForWrite
bool isOpenForWrite(std::string &name)
check whether a file is open for write
Definition XrdCephPosix.cc:143

References getCephFile(), getRadosStriper(), isOpenForWrite(), logwrapper(), CephFile::name, and stat.

Referenced by XrdCephOss::Stat().

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

## ceph_posix_stat_pool()

int ceph_posix_stat_pool | ( | char const * | poolName,
|  | long long * | usedSpace )

Return the amount of space used in a pool.

This function - Obtains the statistics that librados holds on a pool Calculates the number of bytes allocated to the pool @params poolName: (in) the name of the pool to query usedSpace: (out) the number of bytes used in the pool

Returns
  success or failure status

Implementation: Jyothish Thomas STFC RAL, jyoth.nosp@m.ish..nosp@m.thoma.nosp@m.s@st.nosp@m.fc.ac.nosp@m..uk, 2022 Ian Johnson STFC RAL, ian.j.nosp@m.ohns.nosp@m.on@st.nosp@m.fc.a.nosp@m.c.uk, 2022, 2023

Definition at line 1491 of file XrdCephPosix.cc.

{
logwrapper((char*)__FUNCTION__, poolName);
// get the poolIdx to use
int cephPoolIdx = getCephPoolIdxAndIncrease();
librados::Rados* cluster = checkAndCreateCluster(cephPoolIdx);
if (0 == cluster) {
return -EINVAL;
}
std::list<std::string> poolNames({poolName});
std::map<std::string, librados::pool_stat_t> stat;
if (cluster->get_pool_stats(poolNames, stat) < 0) {
logwrapper((char*)"Unable to get_pool_stats for pool ", poolName);
return -EINVAL;
} else {
*usedSpace = stat[poolName].num_kb * 1024;
return XrdOssOK;
}
}
XrdOssOK
#define XrdOssOK
Definition XrdOss.hh:50

References checkAndCreateCluster(), getCephPoolIdxAndIncrease(), logwrapper(), stat, and XrdOssOK.

Referenced by XrdCephOss::StatLS().

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

## ceph_posix_statfs()

int ceph_posix_statfs | ( | long long * | totalSpace,
|  | long long * | freeSpace )

Definition at line 1454 of file XrdCephPosix.cc.

{
logwrapper((char*)"ceph_posix_statfs");
// get the poolIdx to use
int cephPoolIdx = getCephPoolIdxAndIncrease();
// Get the cluster to use
librados::Rados* cluster = checkAndCreateCluster(cephPoolIdx);
if (0 == cluster) {
return -EINVAL;
}
// call ceph stat
librados::cluster_stat_t result;
int rc = cluster->cluster_stat(result);
if (0 == rc) {
*totalSpace = result.kb * 1024;
*freeSpace = result.kb_avail * 1024;
}
return rc;
}

References checkAndCreateCluster(), getCephPoolIdxAndIncrease(), and logwrapper().

Referenced by XrdCephOss::StatVS().

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

## ceph_posix_truncate()

int ceph_posix_truncate | ( | XrdOucEnv * | env,
|  | const char * | pathname,
|  | unsigned long long | size )

Definition at line 1535 of file XrdCephPosix.cc.

{
logwrapper((char*)"ceph_posix_truncate : %s", pathname);
// minimal stat : only size and times are filled
CephFile file = getCephFile(pathname, env);
return ceph_posix_internal_truncate(file, size);
}

References ceph_posix_internal_truncate(), getCephFile(), and logwrapper().

Referenced by XrdCephOss::Truncate().

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

## ceph_posix_unlink()

int ceph_posix_unlink | ( | XrdOucEnv * | env,
|  | const char * | pathname )

Definition at line 1542 of file XrdCephPosix.cc.

{
logwrapper((char*)"ceph_posix_unlink : %s", pathname);
// start the timer
auto timer_start = std::chrono::steady_clock::now();
// minimal stat : only size and times are filled
CephFile file = getCephFile(pathname, env);
libradosstriper::RadosStriper *striper = getRadosStriper(file);
if (0 == striper) {
return -EINVAL;
}
int rc = striper->remove(file.name);
auto end = std::chrono::steady_clock::now();
auto deltime_ms = std::chrono::duration_cast<std::chrono::milliseconds>(end - timer_start).count();
if (rc == 0) {
logwrapper((char*)"ceph_posix_unlink : %s unlink successful: %d ms", pathname, deltime_ms);
return 0;
}
if (rc != -EBUSY) {
logwrapper((char*)"ceph_posix_unlink : %s unlink failed: %d ms; return code %d", pathname, deltime_ms, rc);
return rc;
}
// if EBUSY returned, assume the file is locked; so try to remove the lock
logwrapper((char*)"ceph_posix_unlink : unlink failed with -EBUSY %s, now trying to remove lock.", pathname);
// lock name is only exposed in the libradosstriper source file, so hardcode it here.
rc = ceph_posix_internal_removexattr(file, "lock.striper.lock");
if (rc !=0 ) {
logwrapper((char*)"ceph_posix_unlink : unlink rmxattr failed %s, %d", pathname, rc);
return rc;
}
// now try to remove again
rc = striper->remove(file.name);
end = std::chrono::steady_clock::now();
deltime_ms = std::chrono::duration_cast<std::chrono::milliseconds>(end - timer_start).count();
if (rc != 0) {
logwrapper((char*)"ceph_posix_unlink : unlink failed after lock removal %s, %d ms", pathname, deltime_ms);
} else {
logwrapper((char*)"ceph_posix_unlink : unlink succeeded after lock removal %s, %d ms", pathname, deltime_ms);
}
return rc;
}

References ceph_posix_internal_removexattr(), getCephFile(), getRadosStriper(), logwrapper(), and CephFile::name.

Referenced by ceph_posix_open(), and XrdCephOss::Unlink().

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

## ceph_posix_write()

ssize_t ceph_posix_write | ( | int | fd,
|  | const void * | buf,
|  | size_t | count )

Definition at line 821 of file XrdCephPosix.cc.

{
CephFileRef* fr = getFileRef(fd);
if (fr) {
logwrapper((char*)"ceph_write: for fd %d, count=%d", fd, count);
if ((fr->flags & O_ACCMODE) == O_RDONLY) {
return -EBADF;
}
libradosstriper::RadosStriper *striper = getRadosStriper(*fr);
if (0 == striper) {
return -EINVAL;
}
ceph::bufferlist bl;
bl.append((const char*)buf, count);
int rc = striper->write(fr->name, bl, count, fr->offset);
if (rc) return rc;
fr->offset += count;
XrdSysMutexHelper lock(fr->statsMutex);
fr->wrcount++;
fr->bytesWritten+=count;
if (fr->offset) fr->maxOffsetWritten = std::max(fr->offset - 1, fr->maxOffsetWritten);
return count;
} else {
return -EBADF;
}
}

References CephFileRef::bytesWritten, CephFileRef::flags, getFileRef(), getRadosStriper(), logwrapper(), CephFileRef::maxOffsetWritten, CephFile::name, CephFileRef::offset, CephFileRef::statsMutex, and CephFileRef::wrcount.

Here is the call graph for this function:

## ceph_striper_readv()

ssize_t ceph_striper_readv | ( | int | fd,
|  | XrdOucIOVec * | readV,
|  | int | n )

Sequential, striper-based readv implementation.

Definition at line 1007 of file XrdCephPosix.cc.

{
ssize_t nbytes = 0, curCount = 0;
for (int i=0; i<n; i++) {
curCount = ceph_posix_pread(fd, (void *)readV[i].data, (size_t)readV[i].size, (off_t)readV[i].offset);
if (curCount != readV[i].size) {
if (curCount < 0) return curCount;
return -ESPIPE;
}
nbytes += curCount;
}
return nbytes;
}

References ceph_posix_pread().

Referenced by XrdCephOssFile::ReadV().

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