Loading...
Searching...
No Matches
XrdCephPosix.hh
Go to the documentation of this file.
//------------------------------------------------------------------------------
// Copyright (c) 2014-2015 by European Organization for Nuclear Research (CERN)
// Author: Sebastien Ponce <sebastien.ponce@cern.ch>
//------------------------------------------------------------------------------
// This file is part of the XRootD software suite.
//
// XRootD is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// XRootD is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
//
// In applying this licence, CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
//------------------------------------------------------------------------------
/*
* This interface provides wrapper methods for using ceph through a POSIX API.
*/
#ifndef _XRD_CEPH_POSIX_H
#define _XRD_CEPH_POSIX_H
#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"
// simple logging for XrdCeph buffering code
#define XRDCEPHLOGLEVEL 1
#define MAXDIGITSIZE 32
#ifdef XRDCEPHLOGLEVEL
// ensure that
// extern XrdOucTrace XrdCephTrace;
// is in the cc file where you want to log // << std::endl
//#define LOGCEPH(x) {std::stringstream _s; _s << x; XrdCephTrace.Beg(); std::clog << _s.str() ; XrdCephTrace.End(); _s.clear();}
#define LOGCEPH(x) {std::stringstream _s; _s << x; std::clog << _s.str() << std::endl; _s.clear(); }
#else
#define LOGCEPH(x)
#endif
class XrdSfsAio;
typedef void(AioCB)(XrdSfsAio*, size_t);
void ceph_posix_set_defaults(const char* value);
void ceph_posix_disconnect_all();
void ceph_posix_set_logfunc(void (*logfunc) (char *, va_list argp));
int ceph_posix_open(XrdOucEnv* env, const char *pathname, int flags, mode_t mode);
int ceph_posix_close(int fd);
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_write(int fd, const void *buf, size_t count);
ssize_t ceph_posix_pwrite(int fd, const void *buf, size_t count, off64_t offset);
ssize_t ceph_aio_write(int fd, XrdSfsAio *aiop, AioCB *cb);
ssize_t ceph_nonstriper_readv(int fd, XrdOucIOVec *readV, int n);
ssize_t ceph_striper_readv(int fd, XrdOucIOVec *readV, int n);
ssize_t ceph_posix_read(int fd, void *buf, size_t count);
ssize_t ceph_posix_nonstriper_pread(int fd, void *buf, size_t count, off64_t offset);
ssize_t ceph_posix_pread(int fd, void *buf, size_t count, off64_t offset);
ssize_t ceph_posix_maybestriper_pread(int fd, void *buf, size_t count, off64_t offset, bool allowStriper=true);
ssize_t ceph_aio_read(int fd, XrdSfsAio *aiop, AioCB *cb);
int ceph_posix_fstat(int fd, struct stat *buf);
int ceph_posix_stat(XrdOucEnv* env, const char *pathname, struct stat *buf);
int ceph_posix_fsync(int fd);
int ceph_posix_fcntl(int fd, int cmd, ... /* arg */ );
ssize_t ceph_posix_getxattr(XrdOucEnv* env, const char* path, const char* name,
void* value, size_t size);
ssize_t ceph_posix_fgetxattr(int fd, const char* name, void* value, size_t size);
ssize_t ceph_posix_setxattr(XrdOucEnv* env, const char* path, const char* name,
const void* value, size_t size, int flags);
int ceph_posix_fsetxattr(int fd, const char* name, const void* value, size_t size, int flags);
int ceph_posix_removexattr(XrdOucEnv* env, const char* path, const char* name);
int ceph_posix_fremovexattr(int fd, const char* name);
int ceph_posix_listxattrs(XrdOucEnv* env, const char* path, XrdSysXAttr::AList **aPL, int getSz);
int ceph_posix_flistxattrs(int fd, XrdSysXAttr::AList **aPL, int getSz);
void ceph_posix_freexattrlist(XrdSysXAttr::AList *aPL);
int ceph_posix_statfs(long long *totalSpace, long long *freeSpace);
int ceph_posix_stat_pool(char const *poolName, long long *usedSpace);
int ceph_posix_truncate(XrdOucEnv* env, const char *pathname, unsigned long long size);
int ceph_posix_ftruncate(int fd, unsigned long long size);
int ceph_posix_unlink(XrdOucEnv* env, const char *pathname);
DIR* ceph_posix_opendir(XrdOucEnv* env, const char *pathname);
int ceph_posix_readdir(DIR* dirp, char *buff, int blen);
int ceph_posix_closedir(DIR *dirp);
struct CephFile {
std::string name;
std::string pool;
std::string userId;
unsigned int nbStripes;
unsigned long long stripeUnit;
unsigned long long objectSize;
};
struct CephFileRef : CephFile {
int flags;
mode_t mode;
uint64_t offset;
// This mutex protects against parallel updates of the stats.
XrdSysMutex statsMutex;
uint64_t maxOffsetWritten;
uint64_t bytesAsyncWritePending;
uint64_t bytesWritten;
unsigned rdcount;
unsigned wrcount;
unsigned asyncRdStartCount;
unsigned asyncRdCompletionCount;
unsigned asyncWrStartCount;
unsigned asyncWrCompletionCount;
::timeval lastAsyncSubmission;
double longestAsyncWriteTime;
double longestCallbackInvocation;
};
#endif // __XRD_CEPH_POSIX__
AioCB
void AioCB(XrdSfsAio *, size_t)
Definition XrdCephPosix.hh:58
ceph_posix_write
ssize_t ceph_posix_write(int fd, const void *buf, size_t count)
Definition XrdCephPosix.cc:821
ceph_posix_set_logfunc
void ceph_posix_set_logfunc(void(*logfunc)(char *, va_list argp))
Definition XrdCephPosix.cc:644
ceph_posix_truncate
int ceph_posix_truncate(XrdOucEnv *env, const char *pathname, unsigned long long size)
Definition XrdCephPosix.cc:1535
ceph_aio_write
ssize_t ceph_aio_write(int fd, XrdSfsAio *aiop, AioCB *cb)
Definition XrdCephPosix.cc:903
ceph_posix_unlink
int ceph_posix_unlink(XrdOucEnv *env, const char *pathname)
Definition XrdCephPosix.cc:1542
ceph_aio_read
ssize_t ceph_aio_read(int fd, XrdSfsAio *aiop, AioCB *cb)
Definition XrdCephPosix.cc:1175
ceph_posix_readdir
int ceph_posix_readdir(DIR *dirp, char *buff, int blen)
Definition XrdCephPosix.cc:1607
ceph_posix_fcntl
int ceph_posix_fcntl(int fd, int cmd,...)
Definition XrdCephPosix.cc:1286
ceph_posix_getxattr
ssize_t ceph_posix_getxattr(XrdOucEnv *env, const char *path, const char *name, void *value, size_t size)
Definition XrdCephPosix.cc:1316
ceph_nonstriper_readv
ssize_t ceph_nonstriper_readv(int fd, XrdOucIOVec *readV, int n)
Definition XrdCephPosix.cc:947
ceph_posix_read
ssize_t ceph_posix_read(int fd, void *buf, size_t count)
Definition XrdCephPosix.cc:1023
ceph_posix_pread
ssize_t ceph_posix_pread(int fd, void *buf, size_t count, off64_t offset)
Definition XrdCephPosix.cc:1110
ceph_posix_listxattrs
int ceph_posix_listxattrs(XrdOucEnv *env, const char *path, XrdSysXAttr::AList **aPL, int getSz)
Definition XrdCephPosix.cc:1430
ceph_posix_fstat
int ceph_posix_fstat(int fd, struct stat *buf)
Definition XrdCephPosix.cc:1215
ceph_posix_disconnect_all
void ceph_posix_disconnect_all()
Definition XrdCephPosix.cc:624
ceph_posix_fsync
int ceph_posix_fsync(int fd)
Definition XrdCephPosix.cc:1275
ceph_posix_closedir
int ceph_posix_closedir(DIR *dirp)
Definition XrdCephPosix.cc:1626
ceph_posix_opendir
DIR * ceph_posix_opendir(XrdOucEnv *env, const char *pathname)
Definition XrdCephPosix.cc:1588
ceph_posix_statfs
int ceph_posix_statfs(long long *totalSpace, long long *freeSpace)
Definition XrdCephPosix.cc:1454
ceph_posix_fremovexattr
int ceph_posix_fremovexattr(int fd, const char *name)
Definition XrdCephPosix.cc:1386
ceph_posix_close
int ceph_posix_close(int fd)
Definition XrdCephPosix.cc:760
ceph_posix_stat_pool
int ceph_posix_stat_pool(char const *poolName, long long *usedSpace)
Return the amount of space used in a pool.
Definition XrdCephPosix.cc:1491
ceph_posix_lseek
off_t ceph_posix_lseek(int fd, off_t offset, int whence)
Definition XrdCephPosix.cc:801
ceph_posix_set_defaults
void ceph_posix_set_defaults(const char *value)
Definition XrdCephPosix.cc:397
ceph_posix_fsetxattr
int ceph_posix_fsetxattr(int fd, const char *name, const void *value, size_t size, int flags)
Definition XrdCephPosix.cc:1356
ceph_posix_ftruncate
int ceph_posix_ftruncate(int fd, unsigned long long size)
Definition XrdCephPosix.cc:1525
ceph_posix_open
int ceph_posix_open(XrdOucEnv *env, const char *pathname, int flags, mode_t mode)
Definition XrdCephPosix.cc:664
ceph_posix_nonstriper_pread
ssize_t ceph_posix_nonstriper_pread(int fd, void *buf, size_t count, off64_t offset)
Definition XrdCephPosix.cc:1048
ceph_posix_removexattr
int ceph_posix_removexattr(XrdOucEnv *env, const char *path, const char *name)
Definition XrdCephPosix.cc:1380
ceph_posix_lseek64
off64_t ceph_posix_lseek64(int fd, off64_t offset, int whence)
Definition XrdCephPosix.cc:811
ceph_striper_readv
ssize_t ceph_striper_readv(int fd, XrdOucIOVec *readV, int n)
Definition XrdCephPosix.cc:1007
ceph_posix_stat
int ceph_posix_stat(XrdOucEnv *env, const char *pathname, struct stat *buf)
Definition XrdCephPosix.cc:1243
ceph_posix_pwrite
ssize_t ceph_posix_pwrite(int fd, const void *buf, size_t count, off64_t offset)
Definition XrdCephPosix.cc:847
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 XrdCephPosix.cc:1349
ceph_posix_flistxattrs
int ceph_posix_flistxattrs(int fd, XrdSysXAttr::AList **aPL, int getSz)
Definition XrdCephPosix.cc:1435
ceph_posix_maybestriper_pread
ssize_t ceph_posix_maybestriper_pread(int fd, void *buf, size_t count, off64_t offset, bool allowStriper=true)
Definition XrdCephPosix.cc:1134
ceph_posix_fgetxattr
ssize_t ceph_posix_fgetxattr(int fd, const char *name, void *value, size_t size)
Definition XrdCephPosix.cc:1323
ceph_posix_freexattrlist
void ceph_posix_freexattrlist(XrdSysXAttr::AList *aPL)
Definition XrdCephPosix.cc:1445
XrdOucEnv.hh
XrdOucIOVec.hh
stat
#define stat(a, b)
Definition XrdPosix.hh:101
XrdSysPthread.hh
XrdSysXAttr.hh
XrdOucEnv
Definition XrdOucEnv.hh:42
XrdSfsAio
Definition XrdSfsAio.hh:59
XrdSysMutex
Definition XrdSysPthread.hh:165
XrdSysXAttr::AList
Definition XrdSysXAttr.hh:53
CephFileRef
Definition XrdCephPosix.hh:112
CephFileRef::bytesAsyncWritePending
uint64_t bytesAsyncWritePending
Definition XrdCephPosix.hh:119
CephFileRef::asyncRdStartCount
unsigned asyncRdStartCount
Definition XrdCephPosix.hh:123
CephFileRef::asyncWrStartCount
unsigned asyncWrStartCount
Definition XrdCephPosix.hh:125
CephFileRef::maxOffsetWritten
uint64_t maxOffsetWritten
Definition XrdCephPosix.hh:118
CephFileRef::lastAsyncSubmission
::timeval lastAsyncSubmission
Definition XrdCephPosix.hh:127
CephFileRef::longestCallbackInvocation
double longestCallbackInvocation
Definition XrdCephPosix.hh:129
CephFileRef::mode
mode_t mode
Definition XrdCephPosix.hh:114
CephFileRef::bytesWritten
uint64_t bytesWritten
Definition XrdCephPosix.hh:120
CephFileRef::offset
uint64_t offset
Definition XrdCephPosix.hh:115
CephFileRef::longestAsyncWriteTime
double longestAsyncWriteTime
Definition XrdCephPosix.hh:128
CephFileRef::wrcount
unsigned wrcount
Definition XrdCephPosix.hh:122
CephFileRef::rdcount
unsigned rdcount
Definition XrdCephPosix.hh:121
CephFileRef::statsMutex
XrdSysMutex statsMutex
Definition XrdCephPosix.hh:117
CephFileRef::asyncWrCompletionCount
unsigned asyncWrCompletionCount
Definition XrdCephPosix.hh:126
CephFileRef::flags
int flags
Definition XrdCephPosix.hh:113
CephFileRef::asyncRdCompletionCount
unsigned asyncRdCompletionCount
Definition XrdCephPosix.hh:124
CephFile
small structs to store file metadata
Definition XrdCephPosix.hh:103
CephFile::userId
std::string userId
Definition XrdCephPosix.hh:106
CephFile::nbStripes
unsigned int nbStripes
Definition XrdCephPosix.hh:107
CephFile::pool
std::string pool
Definition XrdCephPosix.hh:105
CephFile::stripeUnit
unsigned long long stripeUnit
Definition XrdCephPosix.hh:108
CephFile::name
std::string name
Definition XrdCephPosix.hh:104
CephFile::objectSize
unsigned long long objectSize
Definition XrdCephPosix.hh:109
XrdOucIOVec
Definition XrdOucIOVec.hh:41