XRootD
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

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

1175 {
1176 CephFileRef* fr = getFileRef(fd);
1177 if (fr) {
1178 // get the parameters from the Xroot aio object
1179 size_t count = aiop->sfsAio.aio_nbytes;
1180 size_t offset = aiop->sfsAio.aio_offset;
1181 // TODO implement proper logging level for this plugin - this should be only debug
1182 //logwrapper((char*)"ceph_aio_read: for fd %d, count=%d", fd, count);
1183 if ((fr->flags & O_WRONLY) != 0) {
1184 return -EBADF;
1185 }
1186 // get the striper object
1187 libradosstriper::RadosStriper *striper = getRadosStriper(*fr);
1188 if (0 == striper) {
1189 return -EINVAL;
1190 }
1191 // prepare a bufferlist to receive data
1192 ceph::bufferlist *bl = new ceph::bufferlist();
1193 // get the poolIdx to use
1194 int cephPoolIdx = getCephPoolIdxAndIncrease();
1195 // Get the cluster to use
1196 librados::Rados* cluster = checkAndCreateCluster(cephPoolIdx);
1197 if (0 == cluster) {
1198 return -EINVAL;
1199 }
1200 // prepare a ceph AioCompletion object and do async call
1201 AioArgs *args = new AioArgs(aiop, cb, count, fd, bl);
1202 librados::AioCompletion *completion =
1203 cluster->aio_create_completion(args, ceph_aio_read_complete, NULL);
1204 // do the read
1205 int rc = striper->aio_read(fr->name, completion, bl, count, offset);
1206 completion->release();
1207 XrdSysMutexHelper lock(fr->statsMutex);
1208 fr->asyncRdStartCount++;
1209 return rc;
1210 } else {
1211 return -EBADF;
1212 }
1213}
static libradosstriper::RadosStriper * getRadosStriper(const CephFile &file)
CephFileRef * getFileRef(int fd)
look for a FileRef from its file descriptor
unsigned int getCephPoolIdxAndIncrease()
librados::Rados * checkAndCreateCluster(unsigned int cephPoolIdx, std::string userId=g_defaultParams.userId)
static void ceph_aio_read_complete(rados_completion_t c, void *arg)
off_t aio_offset
Definition XrdSfsAio.hh:49
size_t aio_nbytes
Definition XrdSfsAio.hh:48
struct aiocb sfsAio
Definition XrdSfsAio.hh:62
small struct for aio API callbacks
unsigned asyncRdStartCount
XrdSysMutex statsMutex
std::string name

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.

903 {
904 CephFileRef* fr = getFileRef(fd);
905 if (fr) {
906 // get the parameters from the Xroot aio object
907 size_t count = aiop->sfsAio.aio_nbytes;
908 const char *buf = (const char*)aiop->sfsAio.aio_buf;
909 size_t offset = aiop->sfsAio.aio_offset;
910 // TODO implement proper logging level for this plugin - this should be only debug
911 //logwrapper((char*)"ceph_aio_write: for fd %d, count=%d", fd, count);
912 if ((fr->flags & (O_WRONLY|O_RDWR)) == 0) {
913 return -EBADF;
914 }
915 // get the striper object
916 libradosstriper::RadosStriper *striper = getRadosStriper(*fr);
917 if (0 == striper) {
918 return -EINVAL;
919 }
920 // prepare a bufferlist around the given buffer
921 ceph::bufferlist bl;
922 bl.append(buf, count);
923 // get the poolIdx to use
924 int cephPoolIdx = getCephPoolIdxAndIncrease();
925 // Get the cluster to use
926 librados::Rados* cluster = checkAndCreateCluster(cephPoolIdx);
927 if (0 == cluster) {
928 return -EINVAL;
929 }
930 // prepare a ceph AioCompletion object and do async call
931 AioArgs *args = new AioArgs(aiop, cb, count, fd);
932 librados::AioCompletion *completion =
933 cluster->aio_create_completion(args, ceph_aio_write_complete, NULL);
934 // do the write
935 int rc = striper->aio_write(fr->name, completion, bl, count, offset);
936 completion->release();
938 fr->asyncWrStartCount++;
939 ::gettimeofday(&fr->lastAsyncSubmission, nullptr);
940 fr->bytesAsyncWritePending+=count;
941 return rc;
942 } else {
943 return -EBADF;
944 }
945}
static void ceph_aio_write_complete(rados_completion_t c, void *arg)
void * aio_buf
Definition XrdSfsAio.hh:47
uint64_t bytesAsyncWritePending
unsigned asyncWrStartCount
::timeval lastAsyncSubmission

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.

947 {
948 CephFileRef* fr = getFileRef(fd);
949 if (fr) {
950 // TODO implement proper logging level for this plugin - this should be only debug
951 //logwrapper((char*)"ceph_read: for fd %d, count=%d", fd, count);
952 if ((fr->flags & O_WRONLY) != 0) {
953 return -EBADF;
954 }
955 if (fr->nbStripes != 1) {
956 //Non-striper based read method works only with a single stripe
957 return -ENOTSUP;
958 }
959
960 ssize_t read_bytes;
961 int rc;
962
963 librados::IoCtx *ioctx = getIoCtx(*fr);
964 if (0 == ioctx) {
965 return -EINVAL;
966 }
967
968 try {
969 //Constructor can throw bad alloc
970 bulkAioRead readOp(ioctx, logwrapper, fr);
971
972 for (int i = 0; i < n; i++) {
973 rc = readOp.read(readV[i].data, readV[i].size, readV[i].offset);
974 if (rc < 0) {
975 logwrapper( (char*)"Can not declare read request\n");
976 return rc;
977 }
978 }
979
980 std::time_t wait_time = std::time(0);
981 rc = readOp.submit_and_wait_for_complete();
982 wait_time = std::time(0) - wait_time;
983 if (wait_time > g_cephAioWaitThresh) {
985 (char*)"Waiting for AIO results in readv for %s took %ld seconds, too long!\n",
986 fr->name.c_str(),
987 wait_time
988 );
989 }
990 if (rc < 0) {
991 logwrapper( (char*)"Can not submit read requests\n");
992 return rc;
993 }
994 read_bytes = readOp.get_results();
996 //We consider readv as a single operation
997 fr->rdcount += 1;
998 return read_bytes;
999 } catch(std::bad_alloc&) {
1000 return -ENOMEM;
1001 }
1002 } else {
1003 return -EBADF;
1004 }
1005}
static void logwrapper(char *format, va_list argp)
Definition XrdCephOss.cc:62
unsigned int g_cephAioWaitThresh
static librados::IoCtx * getIoCtx(const CephFile &file)
static void logwrapper(char *format,...)
unsigned rdcount
unsigned int nbStripes

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.

760 {
761 CephFileRef* fr = getFileRef(fd);
762 if (fr) {
763 ::timeval now;
764 ::gettimeofday(&now, nullptr);
766 double lastAsyncAge = 0.0;
767 // Only compute an age if the starting point was set.
768 if (fr->lastAsyncSubmission.tv_sec && fr->lastAsyncSubmission.tv_usec) {
769 lastAsyncAge = 1.0 * (now.tv_sec - fr->lastAsyncSubmission.tv_sec)
770 + 0.000001 * (now.tv_usec - fr->lastAsyncSubmission.tv_usec);
771 }
772 logwrapper((char*)"ceph_close: closed fd %d for file %s, read ops count %d, write ops count %d, "
773 "async write ops %d/%d, async pending write bytes %ld, "
774 "async read ops %d/%d, bytes written/max offset %ld/%ld, "
775 "longest async write %f, longest callback invocation %f, last async op age %f",
776 fd, fr->name.c_str(), fr->rdcount, fr->wrcount,
779 fr->longestAsyncWriteTime, fr->longestCallbackInvocation, (lastAsyncAge));
780 deleteFileRef(fd, *fr);
781 return 0;
782 } else {
783 return -EBADF;
784 }
785}
void deleteFileRef(int fd, const CephFileRef &fr)
deletes a FileRef from the global table of file descriptors
uint64_t maxOffsetWritten
double longestCallbackInvocation
uint64_t bytesWritten
double longestAsyncWriteTime
unsigned wrcount
unsigned asyncWrCompletionCount
unsigned asyncRdCompletionCount

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.

1626 {
1627 delete ((DirIterator*)dirp);
1628 return 0;
1629}
small struct for directory listing

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.

624 {
626 for (unsigned int i= 0; i < g_maxCephPoolIdx; i++) {
627 for (StriperDict::iterator it2 = g_radosStripers[i].begin();
628 it2 != g_radosStripers[i].end();
629 it2++) {
630 delete it2->second;
631 }
632 for (IOCtxDict::iterator it2 = g_ioCtx[i].begin();
633 it2 != g_ioCtx[i].end();
634 it2++) {
635 delete it2->second;
636 }
637 delete g_cluster[i];
638 }
639 g_radosStripers.clear();
640 g_ioCtx.clear();
641 g_cluster.clear();
642}
unsigned int g_maxCephPoolIdx
std::vector< librados::Rados * > g_cluster
XrdSysMutex g_striper_mutex
mutex protecting the striper and ioctx maps
std::vector< IOCtxDict > g_ioCtx
std::vector< StriperDict > g_radosStripers

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.

1286 {
1287 CephFileRef* fr = getFileRef(fd);
1288 if (fr) {
1289 logwrapper((char*)"ceph_fcntl: fd %d cmd=%d", fd, cmd);
1290 // minimal implementation
1291 switch (cmd) {
1292 case F_GETFL:
1293 return fr->mode;
1294 default:
1295 return -EINVAL;
1296 }
1297 } else {
1298 return -EBADF;
1299 }
1300}

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.

1324 {
1325 CephFileRef* fr = getFileRef(fd);
1326 if (fr) {
1327 logwrapper((char*)"ceph_fgetxattr: fd %d name=%s", fd, name);
1328 return ceph_posix_internal_getxattr(*fr, name, value, size);
1329 } else {
1330 return -EBADF;
1331 }
1332}
static ssize_t ceph_posix_internal_getxattr(const CephFile &file, const char *name, void *value, size_t size)

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.

1435 {
1436 CephFileRef* fr = getFileRef(fd);
1437 if (fr) {
1438 logwrapper((char*)"ceph_flistxattrs: fd %d", fd);
1439 return ceph_posix_internal_listxattrs(*fr, aPL, getSz);
1440 } else {
1441 return -EBADF;
1442 }
1443}
static int ceph_posix_internal_listxattrs(const CephFile &file, XrdSysXAttr::AList **aPL, int getSz)

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.

1445 {
1446 while (aPL) {
1447 free(aPL->Name);
1448 XrdSysXAttr::AList *cur = aPL;
1449 aPL = aPL->Next;
1450 free(cur);
1451 }
1452}
char Name[1]
Start of the name (size of struct is dynamic)
AList * Next
-> next element.

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.

1386 {
1387 CephFileRef* fr = getFileRef(fd);
1388 if (fr) {
1389 logwrapper((char*)"ceph_fremovexattr: fd %d name=%s", fd, name);
1390 return ceph_posix_internal_removexattr(*fr, name);
1391 } else {
1392 return -EBADF;
1393 }
1394}
static int ceph_posix_internal_removexattr(const CephFile &file, const char *name)

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.

1358 {
1359 CephFileRef* fr = getFileRef(fd);
1360 if (fr) {
1361 logwrapper((char*)"ceph_fsetxattr: fd %d name=%s value=%s", fd, name, value);
1362 return ceph_posix_internal_setxattr(*fr, name, value, size, flags);
1363 } else {
1364 return -EBADF;
1365 }
1366}
static ssize_t ceph_posix_internal_setxattr(const CephFile &file, const char *name, const void *value, size_t size, int flags)

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.

1215 {
1216 CephFileRef* fr = getFileRef(fd);
1217 if (fr) {
1218 logwrapper((char*)__FUNCTION__,": fd %d", fd);
1219 // minimal stat : only size and times are filled
1220 // atime, mtime and ctime are set all to the same value
1221 // mode is set arbitrarily to 0666 | S_IFREG
1222 libradosstriper::RadosStriper *striper = getRadosStriper(*fr);
1223 if (0 == striper) {
1224 logwrapper((char*)"ceph_stat: getRadosStriper failed");
1225 return -EINVAL;
1226 }
1227 memset(buf, 0, sizeof(*buf));
1228 int rc = striper->stat(fr->name, (uint64_t*)&(buf->st_size), &(buf->st_atime));
1229 if (rc != 0) {
1230 return -rc;
1231 }
1232 buf->st_dev = 1;
1233 buf->st_ino = 1;
1234 buf->st_mtime = buf->st_atime;
1235 buf->st_ctime = buf->st_atime;
1236 buf->st_mode = 0666 | S_IFREG;
1237 return 0;
1238 } else {
1239 return -EBADF;
1240 }
1241}

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.

1275 {
1276 CephFileRef* fr = getFileRef(fd);
1277 if (fr) {
1278 // no locking of fr as it is not used.
1279 logwrapper((char*)"ceph_sync: fd %d", fd);
1280 return 0;
1281 } else {
1282 return -EBADF;
1283 }
1284}

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.

1525 {
1526 CephFileRef* fr = getFileRef(fd);
1527 if (fr) {
1528 logwrapper((char*)"ceph_posix_ftruncate: fd %d, size %d", fd, size);
1529 return ceph_posix_internal_truncate(*fr, size);
1530 } else {
1531 return -EBADF;
1532 }
1533}
static int ceph_posix_internal_truncate(const CephFile &file, unsigned long long size)

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.

1318 {
1319 logwrapper((char*)"ceph_getxattr: path %s name=%s", path, name);
1320 return ceph_posix_internal_getxattr(getCephFile(path, env), name, value, size);
1321}
static CephFile getCephFile(const char *path, XrdOucEnv *env)

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.

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

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.

801 {
802 CephFileRef* fr = getFileRef(fd);
803 if (fr) {
804 logwrapper((char*)"ceph_lseek: for fd %d, offset=%lld, whence=%d", fd, offset, whence);
805 return (off_t)lseek_compute_offset(*fr, offset, whence);
806 } else {
807 return -EBADF;
808 }
809}
static off64_t lseek_compute_offset(CephFileRef &fr, off64_t offset, int whence)

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.

811 {
812 CephFileRef* fr = getFileRef(fd);
813 if (fr) {
814 logwrapper((char*)"ceph_lseek64: for fd %d, offset=%lld, whence=%d", fd, offset, whence);
815 return lseek_compute_offset(*fr, offset, whence);
816 } else {
817 return -EBADF;
818 }
819}

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.

1134 {
1135 ssize_t rc {0};
1136 if (!allowStriper) {
1137 rc = ceph_posix_pread(fd,buf,count,offset);
1138 return rc;
1139 }
1140 rc = ceph_posix_nonstriper_pread(fd, buf, count,offset);
1141 if (-ENOENT == rc || -ENOTSUP == rc) {
1142 //This might be a sparse file or nbstripes > 1, so let's try striper read
1143 rc = ceph_posix_pread(fd, buf, count,offset);
1144 if (rc >= 0) {
1145 char err_str[100]; //99 symbols should be enough for the short message
1146 snprintf(err_str, 100, "WARNING! The file (fd %d) seem to be sparse, this is not expected", fd);
1147 logwrapper(err_str);
1148 }
1149 }
1150 return rc;
1151}
ssize_t ceph_posix_pread(int fd, void *buf, size_t count, off64_t offset)
ssize_t ceph_posix_nonstriper_pread(int fd, void *buf, size_t count, off64_t offset)

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.

1048 {
1049 //The same as pread, but do not relies on rados striper library. Uses direct atomic
1050 //reads from ceph object (see BulkAioRead class for details).
1051 CephFileRef* fr = getFileRef(fd);
1052 if (fr) {
1053 // TODO implement proper logging level for this plugin - this should be only debug
1054 //logwrapper((char*)"ceph_read: for fd %d, count=%d", fd, count);
1055 if ((fr->flags & O_WRONLY) != 0) {
1056 return -EBADF;
1057 }
1058 if (fr->nbStripes != 1) {
1059 //Non-striper based read method works only with a single stripe
1060 return -ENOTSUP;
1061 }
1062
1063 int rc;
1064 ssize_t bytes_read;
1065
1066 librados::IoCtx *ioctx = getIoCtx(*fr);
1067 if (0 == ioctx) {
1068 return -EINVAL;
1069 }
1070
1071 try {
1072 //Constructor can throw bad alloc
1073 bulkAioRead readOp(ioctx, logwrapper, fr);
1074 rc = readOp.read(buf, count, offset);
1075 if (rc < 0) {
1076 logwrapper( (char*)"Can not declare read request\n");
1077 return rc;
1078 }
1079 std::time_t wait_time = std::time(0);
1080 rc = readOp.submit_and_wait_for_complete();
1081 wait_time = std::time(0) - wait_time;
1082 if (wait_time > g_cephAioWaitThresh) {
1083 logwrapper(
1084 (char*)"Waiting for AIO results in pread for %s took %ld seconds, too long!\n",
1085 fr->name.c_str(),
1086 wait_time
1087 );
1088 }
1089 if (rc < 0) {
1090 logwrapper( (char*)"Can not submit read request\n");
1091 return rc;
1092 }
1093 bytes_read = readOp.get_results();
1094
1095 if (bytes_read > 0) {
1096 XrdSysMutexHelper lock(fr->statsMutex);
1097 fr->rdcount++;
1098 } else {
1099 logwrapper( (char*)"Error while read: %d\n", bytes_read);
1100 }
1101 return bytes_read;
1102 } catch (std::bad_alloc&) {
1103 return -ENOMEM;
1104 }
1105 } else {
1106 return -EBADF;
1107 }
1108}

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.

664 {
665
666 CephFileRef fr = getCephFileRef(pathname, env, flags, mode, 0);
667
668 struct stat buf;
669 libradosstriper::RadosStriper *striper = getRadosStriper(fr); //Get a handle to the RADOS striper API
670 if (NULL == striper) {
671 logwrapper((char*)"Cannot create striper");
672 return -EINVAL;
673 }
674 dumpClusterInfo(); // JW enhanced logging
675
676 int rc = striper->stat(fr.name, (uint64_t*)&(buf.st_size), &(buf.st_atime)); //Get details about a file
677
678
679 bool fileExists = (rc != -ENOENT); //Make clear what condition we are testing
680
681 logwrapper((char*)"Access Mode: %s flags&O_ACCMODE %d ", pathname, flags);
682
683 if ((flags&O_ACCMODE) == O_RDONLY) { // Access mode is READ
684
685 if (fileExists) {
686 librados::bufferlist d_stripeUnit;
687 librados::bufferlist d_objectSize;
688 std::string obj_name;
689 librados::IoCtx *context = getIoCtx(fr);
690
691 // read first stripe of the object for xattr stripe unit and object size
692 // this will fail if the object was not written in stripes e.g. s3
693 // TBD: fallback to direct object (no stripe id appends to filename,
694 // replace striper metadata with corresponding metadata)
695 //
696 try {
697 obj_name = fr.name + std::string(".0000000000000000");
698 } catch (std::bad_alloc&) {
699 logwrapper((char*)"Can not create object string for file %s)", fr.name.c_str());
700 return -ENOMEM;
701 }
702 int ret = 0;
703 ret = context->getxattr(obj_name, "striper.layout.stripe_unit", d_stripeUnit);
704 ret = std::min(ret,context->getxattr(obj_name, "striper.layout.object_size", d_objectSize));
705 //log_func((char*)"size xattr for %s , %llu ,%llu", file_ref->name.c_str(), file_ref->objectSize, file_ref->stripeUnit );
706 if (ret<=0){
707 logwrapper((char*)"Could not find size or stripe_unit xattr for %s", fr.name.c_str());
708 }
709 else{
710 //librados's c_str() method does not return a NULL-terminated string, hence why we need to cleanup here
711 char cleanStripeUnit[MAXDIGITSIZE];
712 char cleanObjectSize[MAXDIGITSIZE];
713 unsigned int stripeUnitLength = std::min((unsigned int)MAXDIGITSIZE-1, d_stripeUnit.length());
714 unsigned int objectSizeLength = std::min((unsigned int)MAXDIGITSIZE-1, d_objectSize.length());
715 (void)strncpy( cleanStripeUnit, d_stripeUnit.c_str(), stripeUnitLength );
716 (void)strncpy( cleanObjectSize, d_objectSize.c_str(), objectSizeLength );
717 cleanStripeUnit[stripeUnitLength] = '\0';
718 cleanObjectSize[objectSizeLength] = '\0';
719 //only change defaults if different
720 if(fr.stripeUnit != std::stoull(cleanStripeUnit)){
721 logwrapper((char*)"WARNING: stripe unit of %s does not match defaults. object size is %s", pathname, cleanStripeUnit);
722 fr.stripeUnit = std::stoull(cleanStripeUnit);
723 }
724 if(fr.objectSize != std::stoull(cleanObjectSize)){
725 logwrapper((char*)"WARNING: object size of %s does not match defaults. object size is %s",pathname, cleanObjectSize);
726 fr.objectSize = std::stoull(cleanObjectSize);
727 }
728 }
729 int fd = insertFileRef(fr);
730 logwrapper((char*)"File descriptor %d associated to file %s opened in read mode", fd, pathname);
731 return fd;
732 } else {
733 return -ENOENT;
734 }
735
736 } else { // Access mode is WRITE
737 if (fileExists) {
738 if (flags & O_TRUNC) {
739 int rc = ceph_posix_unlink(env, pathname);
740 if (rc < 0 && rc != -ENOENT) {
741 return rc;
742 }
743 } else {
744 if (flags & O_EXCL) {
745 return -EACCES; // permission denied
746 } else {
747 return -EEXIST; // otherwise return just file exists
748 }
749 }
750 }
751 // At this point, we know either the target file didn't exist, or the ceph_posix_unlink above removed it
752 int fd = insertFileRef(fr);
753 logwrapper((char*)"File descriptor %d associated to file %s opened in write mode", fd, pathname);
754 return fd;
755
756 }
757
758}
int ceph_posix_unlink(XrdOucEnv *env, const char *pathname)
int insertFileRef(CephFileRef &fr)
static CephFileRef getCephFileRef(const char *path, XrdOucEnv *env, int flags, mode_t mode, unsigned long long offset)
void dumpClusterInfo()
#define MAXDIGITSIZE
#define stat(a, b)
Definition XrdPosix.hh:101
unsigned long long stripeUnit
unsigned long long objectSize

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.

1588 {
1589 logwrapper((char*)"ceph_posix_opendir : %s", pathname);
1590 // only accept root dir, as there is no concept of dirs in object stores
1591 CephFile file = getCephFile(pathname, env);
1592 if (file.name.size() != 1 || file.name[0] != '/') {
1593 errno = -ENOENT;
1594 return 0;
1595 }
1596 librados::IoCtx *ioctx = getIoCtx(file);
1597 if (0 == ioctx) {
1598 errno = EINVAL;
1599 return 0;
1600 }
1601 DirIterator* res = new DirIterator();
1602 res->m_iterator = ioctx->nobjects_begin();
1603 res->m_ioctx = ioctx;
1604 return (DIR*)res;
1605}
librados::IoCtx * m_ioctx
librados::NObjectIterator m_iterator
small structs to store file metadata

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.

1110 {
1111 CephFileRef* fr = getFileRef(fd);
1112 if (fr) {
1113 // TODO implement proper logging level for this plugin - this should be only debug
1114 //logwrapper((char*)"ceph_read: for fd %d, count=%d", fd, count);
1115 if ((fr->flags & O_WRONLY) != 0) {
1116 return -EBADF;
1117 }
1118 libradosstriper::RadosStriper *striper = getRadosStriper(*fr);
1119 if (0 == striper) {
1120 return -EINVAL;
1121 }
1122 ceph::bufferlist bl;
1123 int rc = striper->read(fr->name, &bl, count, offset);
1124 if (rc < 0) return rc;
1125 bl.begin().copy(rc, (char*)buf);
1126 XrdSysMutexHelper lock(fr->statsMutex);
1127 fr->rdcount++;
1128 return rc;
1129 } else {
1130 return -EBADF;
1131 }
1132}

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.

847 {
848 CephFileRef* fr = getFileRef(fd);
849 if (fr) {
850 // TODO implement proper logging level for this plugin - this should be only debug
851 //logwrapper((char*)"ceph_write: for fd %d, count=%d", fd, count);
852 if ((fr->flags & (O_WRONLY|O_RDWR)) == 0) {
853 return -EBADF;
854 }
855 libradosstriper::RadosStriper *striper = getRadosStriper(*fr);
856 if (0 == striper) {
857 return -EINVAL;
858 }
859 ceph::bufferlist bl;
860 bl.append((const char*)buf, count);
861 int rc = striper->write(fr->name, bl, count, offset);
862 if (rc) return rc;
864 fr->wrcount++;
865 fr->bytesWritten+=count;
866 if (offset + count) fr->maxOffsetWritten = std::max(uint64_t(offset + count - 1), fr->maxOffsetWritten);
867 return count;
868 } else {
869 return -EBADF;
870 }
871}

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.

1023 {
1024 CephFileRef* fr = getFileRef(fd);
1025 if (fr) {
1026 // TODO implement proper logging level for this plugin - this should be only debug
1027 //logwrapper((char*)"ceph_read: for fd %d, count=%d", fd, count);
1028 if ((fr->flags & O_WRONLY) != 0) {
1029 return -EBADF;
1030 }
1031 libradosstriper::RadosStriper *striper = getRadosStriper(*fr);
1032 if (0 == striper) {
1033 return -EINVAL;
1034 }
1035 ceph::bufferlist bl;
1036 int rc = striper->read(fr->name, &bl, count, fr->offset);
1037 if (rc < 0) return rc;
1038 bl.begin().copy(rc, (char*)buf);
1039 XrdSysMutexHelper lock(fr->statsMutex);
1040 fr->offset += rc;
1041 fr->rdcount++;
1042 return rc;
1043 } else {
1044 return -EBADF;
1045 }
1046}
uint64_t offset

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.

1607 {
1608 librados::NObjectIterator &iterator = ((DirIterator*)dirp)->m_iterator;
1609 librados::IoCtx *ioctx = ((DirIterator*)dirp)->m_ioctx;
1610 while (iterator->get_oid().compare(iterator->get_oid().size()-17, 17, ".0000000000000000") &&
1611 iterator != ioctx->nobjects_end()) {
1612 iterator++;
1613 }
1614 if (iterator == ioctx->nobjects_end()) {
1615 buff[0] = 0;
1616 } else {
1617 int l = iterator->get_oid().size()-17;
1618 if (l < blen) blen = l;
1619 strncpy(buff, iterator->get_oid().c_str(), blen-1);
1620 buff[blen-1] = 0;
1621 iterator++;
1622 }
1623 return 0;
1624}

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.

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

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.

397 {
398 if (value) {
399 CephFile newdefault;
400 fillCephFileParams(value, NULL, newdefault);
401 g_defaultParams = newdefault;
402 }
403}
CephFile g_defaultParams
global variable containing defaults for CephFiles
void fillCephFileParams(const std::string &params, XrdOucEnv *env, CephFile &file)

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.

644 {
645 g_logfunc = logfunc;
646};
static void(* g_logfunc)(char *, va_list argp)=0
global variable for the log function

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.

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

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.

1243 {
1244 logwrapper((char*)__FUNCTION__, pathname);
1245 // minimal stat : only size and times are filled
1246 // atime, mtime and ctime are set all to the same value
1247 // mode is set arbitrarily to 0666 | S_IFREG
1248 CephFile file = getCephFile(pathname, env);
1249 libradosstriper::RadosStriper *striper = getRadosStriper(file);
1250 if (0 == striper) {
1251 return -EINVAL;
1252 }
1253 memset(buf, 0, sizeof(*buf));
1254 int rc = striper->stat(file.name, (uint64_t*)&(buf->st_size), &(buf->st_atime));
1255 if (rc != 0) {
1256 // for non existing file. Check that we did not open it for write recently
1257 // in that case, we return 0 size and current time
1258 if (-ENOENT == rc && isOpenForWrite(file.name)) {
1259 buf->st_size = 0;
1260 buf->st_atime = time(NULL);
1261 } else {
1262 return -rc;
1263 }
1264 }
1265 // XRootD assumes an 'offline' file if st_dev and st_ino
1266// are zero. Set to non-zero (meaningful) values to avoid this
1267 buf->st_dev = 1;
1268 buf->st_ino = 1;
1269 buf->st_mtime = buf->st_atime;
1270 buf->st_ctime = buf->st_atime;
1271 buf->st_mode = 0666 | S_IFREG;
1272 return 0;
1273}
bool isOpenForWrite(std::string &name)
check whether a file is open for write

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.

1491 {
1492
1493 logwrapper((char*)__FUNCTION__, poolName);
1494 // get the poolIdx to use
1495 int cephPoolIdx = getCephPoolIdxAndIncrease();
1496 librados::Rados* cluster = checkAndCreateCluster(cephPoolIdx);
1497 if (0 == cluster) {
1498 return -EINVAL;
1499 }
1500
1501 std::list<std::string> poolNames({poolName});
1502 std::map<std::string, librados::pool_stat_t> stat;
1503
1504 if (cluster->get_pool_stats(poolNames, stat) < 0) {
1505
1506 logwrapper((char*)"Unable to get_pool_stats for pool ", poolName);
1507 return -EINVAL;
1508
1509 } else {
1510
1511 *usedSpace = stat[poolName].num_kb * 1024;
1512 return XrdOssOK;
1513
1514 }
1515}
#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.

1454 {
1455 logwrapper((char*)"ceph_posix_statfs");
1456 // get the poolIdx to use
1457 int cephPoolIdx = getCephPoolIdxAndIncrease();
1458 // Get the cluster to use
1459 librados::Rados* cluster = checkAndCreateCluster(cephPoolIdx);
1460 if (0 == cluster) {
1461 return -EINVAL;
1462 }
1463 // call ceph stat
1464 librados::cluster_stat_t result;
1465 int rc = cluster->cluster_stat(result);
1466 if (0 == rc) {
1467 *totalSpace = result.kb * 1024;
1468 *freeSpace = result.kb_avail * 1024;
1469 }
1470 return rc;
1471}

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.

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

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.

1542 {
1543 logwrapper((char*)"ceph_posix_unlink : %s", pathname);
1544 // start the timer
1545 auto timer_start = std::chrono::steady_clock::now();
1546
1547 // minimal stat : only size and times are filled
1548 CephFile file = getCephFile(pathname, env);
1549 libradosstriper::RadosStriper *striper = getRadosStriper(file);
1550 if (0 == striper) {
1551 return -EINVAL;
1552 }
1553 int rc = striper->remove(file.name);
1554 auto end = std::chrono::steady_clock::now();
1555 auto deltime_ms = std::chrono::duration_cast<std::chrono::milliseconds>(end - timer_start).count();
1556
1557 if (rc == 0) {
1558 logwrapper((char*)"ceph_posix_unlink : %s unlink successful: %d ms", pathname, deltime_ms);
1559 return 0;
1560 }
1561 if (rc != -EBUSY) {
1562 logwrapper((char*)"ceph_posix_unlink : %s unlink failed: %d ms; return code %d", pathname, deltime_ms, rc);
1563 return rc;
1564 }
1565 // if EBUSY returned, assume the file is locked; so try to remove the lock
1566 logwrapper((char*)"ceph_posix_unlink : unlink failed with -EBUSY %s, now trying to remove lock.", pathname);
1567
1568 // lock name is only exposed in the libradosstriper source file, so hardcode it here.
1569 rc = ceph_posix_internal_removexattr(file, "lock.striper.lock");
1570 if (rc !=0 ) {
1571 logwrapper((char*)"ceph_posix_unlink : unlink rmxattr failed %s, %d", pathname, rc);
1572 return rc;
1573 }
1574
1575 // now try to remove again
1576 rc = striper->remove(file.name);
1577 end = std::chrono::steady_clock::now();
1578 deltime_ms = std::chrono::duration_cast<std::chrono::milliseconds>(end - timer_start).count();
1579
1580 if (rc != 0) {
1581 logwrapper((char*)"ceph_posix_unlink : unlink failed after lock removal %s, %d ms", pathname, deltime_ms);
1582 } else {
1583 logwrapper((char*)"ceph_posix_unlink : unlink succeeded after lock removal %s, %d ms", pathname, deltime_ms);
1584 }
1585 return rc;
1586}

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.

821 {
822 CephFileRef* fr = getFileRef(fd);
823 if (fr) {
824 logwrapper((char*)"ceph_write: for fd %d, count=%d", fd, count);
825 if ((fr->flags & (O_WRONLY|O_RDWR)) == 0) {
826 return -EBADF;
827 }
828 libradosstriper::RadosStriper *striper = getRadosStriper(*fr);
829 if (0 == striper) {
830 return -EINVAL;
831 }
832 ceph::bufferlist bl;
833 bl.append((const char*)buf, count);
834 int rc = striper->write(fr->name, bl, count, fr->offset);
835 if (rc) return rc;
836 fr->offset += count;
838 fr->wrcount++;
839 fr->bytesWritten+=count;
840 if (fr->offset) fr->maxOffsetWritten = std::max(fr->offset - 1, fr->maxOffsetWritten);
841 return count;
842 } else {
843 return -EBADF;
844 }
845}

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.

1007 {
1011 ssize_t nbytes = 0, curCount = 0;
1012 for (int i=0; i<n; i++) {
1013 curCount = ceph_posix_pread(fd, (void *)readV[i].data, (size_t)readV[i].size, (off_t)readV[i].offset);
1014 if (curCount != readV[i].size) {
1015 if (curCount < 0) return curCount;
1016 return -ESPIPE;
1017 }
1018 nbytes += curCount;
1019 }
1020 return nbytes;
1021}

References ceph_posix_pread().

Referenced by XrdCephOssFile::ReadV().

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