XRootD
Loading...
Searching...
No Matches
XrdCephPosix.hh
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// Copyright (c) 2014-2015 by European Organization for Nuclear Research (CERN)
3// Author: Sebastien Ponce <sebastien.ponce@cern.ch>
4//------------------------------------------------------------------------------
5// This file is part of the XRootD software suite.
6//
7// XRootD is free software: you can redistribute it and/or modify
8// it under the terms of the GNU Lesser General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// XRootD is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU Lesser General Public License
18// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
19//
20// In applying this licence, CERN does not waive the privileges and immunities
21// granted to it by virtue of its status as an Intergovernmental Organization
22// or submit itself to any jurisdiction.
23//------------------------------------------------------------------------------
24
25/*
26 * This interface provides wrapper methods for using ceph through a POSIX API.
27 */
28
29#ifndef _XRD_CEPH_POSIX_H
30#define _XRD_CEPH_POSIX_H
31
32#include <sys/types.h>
33#include <stdarg.h>
34#include <string>
35#include <dirent.h>
36#include <cstdint>
37#include <XrdOuc/XrdOucEnv.hh>
38#include <XrdSys/XrdSysXAttr.hh>
39
41#include "XrdOuc/XrdOucIOVec.hh"
42
43// simple logging for XrdCeph buffering code
44#define XRDCEPHLOGLEVEL 1
45#define MAXDIGITSIZE 32
46#ifdef XRDCEPHLOGLEVEL
47 // ensure that
48 // extern XrdOucTrace XrdCephTrace;
49 // is in the cc file where you want to log // << std::endl
50 //#define LOGCEPH(x) {std::stringstream _s; _s << x; XrdCephTrace.Beg(); std::clog << _s.str() ; XrdCephTrace.End(); _s.clear();}
51 #define LOGCEPH(x) {std::stringstream _s; _s << x; std::clog << _s.str() << std::endl; _s.clear(); }
52#else
53 #define LOGCEPH(x)
54#endif
55
56
57class XrdSfsAio;
58typedef void(AioCB)(XrdSfsAio*, size_t);
59
60void ceph_posix_set_defaults(const char* value);
62void ceph_posix_set_logfunc(void (*logfunc) (char *, va_list argp));
63int ceph_posix_open(XrdOucEnv* env, const char *pathname, int flags, mode_t mode);
64int ceph_posix_close(int fd);
65off_t ceph_posix_lseek(int fd, off_t offset, int whence);
66off64_t ceph_posix_lseek64(int fd, off64_t offset, int whence);
67ssize_t ceph_posix_write(int fd, const void *buf, size_t count);
68ssize_t ceph_posix_pwrite(int fd, const void *buf, size_t count, off64_t offset);
69ssize_t ceph_aio_write(int fd, XrdSfsAio *aiop, AioCB *cb);
70ssize_t ceph_nonstriper_readv(int fd, XrdOucIOVec *readV, int n);
71ssize_t ceph_striper_readv(int fd, XrdOucIOVec *readV, int n);
72ssize_t ceph_posix_read(int fd, void *buf, size_t count);
73ssize_t ceph_posix_nonstriper_pread(int fd, void *buf, size_t count, off64_t offset);
74ssize_t ceph_posix_pread(int fd, void *buf, size_t count, off64_t offset);
75ssize_t ceph_posix_maybestriper_pread(int fd, void *buf, size_t count, off64_t offset, bool allowStriper=true);
76
77ssize_t ceph_aio_read(int fd, XrdSfsAio *aiop, AioCB *cb);
78int ceph_posix_fstat(int fd, struct stat *buf);
79int ceph_posix_stat(XrdOucEnv* env, const char *pathname, struct stat *buf);
80int ceph_posix_fsync(int fd);
81int ceph_posix_fcntl(int fd, int cmd, ... /* arg */ );
82ssize_t ceph_posix_getxattr(XrdOucEnv* env, const char* path, const char* name,
83 void* value, size_t size);
84ssize_t ceph_posix_fgetxattr(int fd, const char* name, void* value, size_t size);
85ssize_t ceph_posix_setxattr(XrdOucEnv* env, const char* path, const char* name,
86 const void* value, size_t size, int flags);
87int ceph_posix_fsetxattr(int fd, const char* name, const void* value, size_t size, int flags);
88int ceph_posix_removexattr(XrdOucEnv* env, const char* path, const char* name);
89int ceph_posix_fremovexattr(int fd, const char* name);
90int ceph_posix_listxattrs(XrdOucEnv* env, const char* path, XrdSysXAttr::AList **aPL, int getSz);
91int ceph_posix_flistxattrs(int fd, XrdSysXAttr::AList **aPL, int getSz);
93int ceph_posix_statfs(long long *totalSpace, long long *freeSpace);
94int ceph_posix_stat_pool(char const *poolName, long long *usedSpace);
95int ceph_posix_truncate(XrdOucEnv* env, const char *pathname, unsigned long long size);
96int ceph_posix_ftruncate(int fd, unsigned long long size);
97int ceph_posix_unlink(XrdOucEnv* env, const char *pathname);
98DIR* ceph_posix_opendir(XrdOucEnv* env, const char *pathname);
99int ceph_posix_readdir(DIR* dirp, char *buff, int blen);
100int ceph_posix_closedir(DIR *dirp);
101
103struct CephFile {
104 std::string name;
105 std::string pool;
106 std::string userId;
107 unsigned int nbStripes;
108 unsigned long long stripeUnit;
109 unsigned long long objectSize;
110};
111
113 int flags;
114 mode_t mode;
115 uint64_t offset;
116 // This mutex protects against parallel updates of the stats.
120 uint64_t bytesWritten;
121 unsigned rdcount;
122 unsigned wrcount;
130};
131
132#endif // __XRD_CEPH_POSIX__
void AioCB(XrdSfsAio *, size_t)
ssize_t ceph_posix_write(int fd, const void *buf, size_t count)
void ceph_posix_set_logfunc(void(*logfunc)(char *, va_list argp))
int ceph_posix_truncate(XrdOucEnv *env, const char *pathname, unsigned long long size)
ssize_t ceph_aio_write(int fd, XrdSfsAio *aiop, AioCB *cb)
int ceph_posix_unlink(XrdOucEnv *env, const char *pathname)
ssize_t ceph_aio_read(int fd, XrdSfsAio *aiop, AioCB *cb)
int ceph_posix_readdir(DIR *dirp, char *buff, int blen)
int ceph_posix_fcntl(int fd, int cmd,...)
ssize_t ceph_posix_getxattr(XrdOucEnv *env, const char *path, const char *name, void *value, size_t size)
ssize_t ceph_nonstriper_readv(int fd, XrdOucIOVec *readV, int n)
ssize_t ceph_posix_read(int fd, void *buf, size_t count)
ssize_t ceph_posix_pread(int fd, void *buf, size_t count, off64_t offset)
int ceph_posix_listxattrs(XrdOucEnv *env, const char *path, XrdSysXAttr::AList **aPL, int getSz)
int ceph_posix_fstat(int fd, struct stat *buf)
void ceph_posix_disconnect_all()
int ceph_posix_fsync(int fd)
int ceph_posix_closedir(DIR *dirp)
DIR * ceph_posix_opendir(XrdOucEnv *env, const char *pathname)
int ceph_posix_statfs(long long *totalSpace, long long *freeSpace)
int ceph_posix_fremovexattr(int fd, const char *name)
int ceph_posix_close(int fd)
int ceph_posix_stat_pool(char const *poolName, long long *usedSpace)
Return the amount of space used in a pool.
off_t ceph_posix_lseek(int fd, off_t offset, int whence)
void ceph_posix_set_defaults(const char *value)
int ceph_posix_fsetxattr(int fd, const char *name, const void *value, size_t size, int flags)
int ceph_posix_ftruncate(int fd, unsigned long long size)
int ceph_posix_open(XrdOucEnv *env, const char *pathname, int flags, mode_t mode)
ssize_t ceph_posix_nonstriper_pread(int fd, void *buf, size_t count, off64_t offset)
int ceph_posix_removexattr(XrdOucEnv *env, const char *path, const char *name)
off64_t ceph_posix_lseek64(int fd, off64_t offset, int whence)
ssize_t ceph_striper_readv(int fd, XrdOucIOVec *readV, int n)
int ceph_posix_stat(XrdOucEnv *env, const char *pathname, struct stat *buf)
ssize_t ceph_posix_pwrite(int fd, const void *buf, size_t count, off64_t offset)
ssize_t ceph_posix_setxattr(XrdOucEnv *env, const char *path, const char *name, const void *value, size_t size, int flags)
int ceph_posix_flistxattrs(int fd, XrdSysXAttr::AList **aPL, int getSz)
ssize_t ceph_posix_maybestriper_pread(int fd, void *buf, size_t count, off64_t offset, bool allowStriper=true)
ssize_t ceph_posix_fgetxattr(int fd, const char *name, void *value, size_t size)
void ceph_posix_freexattrlist(XrdSysXAttr::AList *aPL)
#define stat(a, b)
Definition XrdPosix.hh:101
uint64_t bytesAsyncWritePending
unsigned asyncRdStartCount
unsigned asyncWrStartCount
uint64_t maxOffsetWritten
::timeval lastAsyncSubmission
double longestCallbackInvocation
uint64_t bytesWritten
uint64_t offset
double longestAsyncWriteTime
unsigned wrcount
unsigned rdcount
XrdSysMutex statsMutex
unsigned asyncWrCompletionCount
unsigned asyncRdCompletionCount
small structs to store file metadata
std::string userId
unsigned int nbStripes
std::string pool
unsigned long long stripeUnit
std::string name
unsigned long long objectSize