25 #include <cephfs/libcephfs.h> 32 #define CEPH_O_RDONLY 00000000 33 #define CEPH_O_WRONLY 00000001 34 #define CEPH_O_RDWR 00000002 35 #define CEPH_O_CREAT 00000100 36 #define CEPH_O_EXCL 00000200 37 #define CEPH_O_TRUNC 00001000 38 #define CEPH_O_LAZY 00020000 39 #define CEPH_O_DIRECTORY 00200000 40 #define CEPH_O_NOFOLLOW 00400000 55 .remote_prefix =
NULL,
68 static struct ceph_mount_info *
cmount;
116 #define CEPHFS_ERR(__err_str, __ret) do { \ 128 static const char*
pfix(
const char* path) {
129 const char* npath = path;
132 if(*prefix++ != *npath++) {
149 WARN(
"CEPHFS_Init() called before options have been populated!");
165 CEPHFS_ERR(
"unable to create CEPHFS mount handle", ret);
171 CEPHFS_ERR(
"unable to read ceph config file", ret);
175 ret = ceph_mount(
cmount, remote_prefix);
185 ret = ceph_ll_lookup_root(
cmount, &root);
187 CEPHFS_ERR(
"uanble to retrieve root cephfs inode", ret);
198 int ret = ceph_unmount(
cmount);
202 ret = ceph_release(
cmount);
216 const char *file =
pfix(path);
218 fd = (
int *)malloc(
sizeof(
int));
221 int ceph_flags = (int) 0;
235 CEPHFS_ERR(
"File append not implemented in CephFS", EINVAL);
247 CEPHFS_ERR(
"O_DIRECT not implemented in CephFS", EINVAL);
249 *fd = ceph_open(
cmount, file, ceph_flags, mode);
254 int ret = ceph_lazyio(
cmount, *fd, 1);
256 WARN(
"Error enabling lazy mode");
265 uint64_t size = (uint64_t) length;
266 char *buf = (
char *) buffer;
267 int fd = *(
int *) file;
272 ret = ceph_write(
cmount, fd, buf, size, offset);
274 CEPHFS_ERR(
"unable to write file to CephFS", ret);
275 }
else if (ret < size) {
284 ret = ceph_read(
cmount, fd, buf, size, offset);
286 CEPHFS_ERR(
"unable to read file from CephFS", ret);
287 }
else if (ret < size) {
297 int fd = *(
int *) file;
298 int ret = ceph_fsync(
cmount, fd, 0);
306 int fd = *(
int *) file;
307 int ret = ceph_close(
cmount, fd);
326 struct stat stat_buf;
327 IOR_offset_t aggFileSizeFromStat, tmpMin, tmpMax, tmpSum;
329 int ret = ceph_stat(
cmount,
pfix(path), &stat_buf);
333 aggFileSizeFromStat = stat_buf.st_size;
336 MPI_CHECK(MPI_Allreduce(&aggFileSizeFromStat, &tmpSum, 1,
337 MPI_LONG_LONG_INT, MPI_SUM,
testComm),
338 "cannot total data moved");
339 aggFileSizeFromStat = tmpSum;
341 MPI_CHECK(MPI_Allreduce(&aggFileSizeFromStat, &tmpMin, 1,
342 MPI_LONG_LONG_INT, MPI_MIN,
testComm),
343 "cannot total data moved");
344 MPI_CHECK(MPI_Allreduce(&aggFileSizeFromStat, &tmpMax, 1,
345 MPI_LONG_LONG_INT, MPI_MAX,
testComm),
346 "cannot total data moved");
347 if (tmpMin != tmpMax) {
349 WARN(
"inconsistent file size by different tasks");
352 aggFileSizeFromStat = tmpMin;
356 return (aggFileSizeFromStat);
361 #if defined(HAVE_STATVFS) 362 struct statvfs statfs_buf;
363 int ret = ceph_statfs(
cmount,
pfix(path), &statfs_buf);
369 stat_buf->
f_bsize = statfs_buf.f_bsize;
370 stat_buf->
f_blocks = statfs_buf.f_blocks;
371 stat_buf->
f_bfree = statfs_buf.f_bfree;
372 stat_buf->
f_files = statfs_buf.f_files;
373 stat_buf->
f_ffree = statfs_buf.f_ffree;
377 WARN(
"ceph_statfs requires statvfs!");
405 int ret = ceph_sync_fs(
cmount);
static int CEPHFS_Stat(const char *path, struct stat *buf, aiori_mod_opt_t *options)
static struct ceph_mount_info * cmount
static void CEPHFS_Fsync(aiori_fd_t *, aiori_mod_opt_t *)
static aiori_fd_t * CEPHFS_Open(char *path, int flags, aiori_mod_opt_t *options)
static IOR_offset_t CEPHFS_GetFileSize(aiori_mod_opt_t *, char *)
static int CEPHFS_Access(const char *path, int mode, aiori_mod_opt_t *options)
static int CEPHFS_StatFS(const char *path, ior_aiori_statfs_t *stat, aiori_mod_opt_t *options)
#define CEPHFS_ERR(__err_str, __ret)
static int CEPHFS_MkDir(const char *path, mode_t mode, aiori_mod_opt_t *options)
#define MPI_CHECK(MPI_STATUS, MSG)
static aiori_xfer_hint_t * hints
static void CEPHFS_Init()
static void CEPHFS_Close(aiori_fd_t *, aiori_mod_opt_t *)
static aiori_fd_t * CEPHFS_Create(char *path, int flags, aiori_mod_opt_t *options)
char * aiori_get_version()
static void CEPHFS_Final()
static IOR_offset_t CEPHFS_Xfer(int access, aiori_fd_t *file, IOR_size_t *buffer, IOR_offset_t length, IOR_offset_t offset, aiori_mod_opt_t *options)
static option_help options[]
void CEPHFS_xfer_hints(aiori_xfer_hint_t *params)
static void CEPHFS_Delete(char *path, aiori_mod_opt_t *)
static int CEPHFS_RmDir(const char *path, aiori_mod_opt_t *options)
static void CEPHFS_Sync(aiori_mod_opt_t *)
static option_help * CEPHFS_options()
static const char * pfix(const char *path)
long long int IOR_offset_t
static struct cephfs_options o