24 #include <cephfs/libcephfs.h> 31 #define CEPH_O_RDONLY 00000000 32 #define CEPH_O_WRONLY 00000001 33 #define CEPH_O_RDWR 00000002 34 #define CEPH_O_CREAT 00000100 35 #define CEPH_O_EXCL 00000200 36 #define CEPH_O_TRUNC 00001000 37 #define CEPH_O_LAZY 00020000 38 #define CEPH_O_DIRECTORY 00200000 39 #define CEPH_O_NOFOLLOW 00400000 61 static struct ceph_mount_info *
cmount;
105 #define CEPHFS_ERR(__err_str, __ret) do { \ 111 static const char*
pfix(
const char* path) {
112 const char* npath = path;
115 if(*prefix++ != *npath++) {
130 WARN(
"CEPHFS_Init() called before options have been populated!");
143 CEPHFS_ERR(
"unable to create CEPHFS mount handle", ret);
149 CEPHFS_ERR(
"unable to read ceph config file", ret);
153 ret = ceph_mount(
cmount,
"/");
163 ret = ceph_ll_lookup_root(
cmount, &root);
165 CEPHFS_ERR(
"uanble to retrieve root cephfs inode", ret);
176 int ret = ceph_unmount(
cmount);
180 ret = ceph_release(
cmount);
194 const char *file =
pfix(testFileName);
196 fd = (
int *)malloc(
sizeof(
int));
213 fprintf(stdout,
"File append not implemented in CephFS\n");
225 fprintf(stdout,
"O_DIRECT not implemented in CephFS\n");
227 *fd = ceph_open(
cmount, file, flags, mode);
237 uint64_t
size = (uint64_t) length;
238 char *buf = (
char *) buffer;
239 int fd = *(
int *) file;
246 CEPHFS_ERR(
"unable to write file to CephFS", ret);
247 }
else if (ret < size) {
258 CEPHFS_ERR(
"unable to read file from CephFS", ret);
259 }
else if (ret < size) {
269 int fd = *(
int *) file;
270 int ret = ceph_fsync(
cmount, fd, 0);
278 int fd = *(
int *) file;
279 int ret = ceph_close(
cmount, fd);
289 int ret = ceph_unlink(
cmount,
pfix(testFileName));
299 struct stat stat_buf;
300 IOR_offset_t aggFileSizeFromStat, tmpMin, tmpMax, tmpSum;
302 int ret = ceph_stat(
cmount,
pfix(testFileName), &stat_buf);
306 aggFileSizeFromStat = stat_buf.st_size;
309 MPI_CHECK(MPI_Allreduce(&aggFileSizeFromStat, &tmpSum, 1,
310 MPI_LONG_LONG_INT, MPI_SUM, testComm),
311 "cannot total data moved");
312 aggFileSizeFromStat = tmpSum;
314 MPI_CHECK(MPI_Allreduce(&aggFileSizeFromStat, &tmpMin, 1,
315 MPI_LONG_LONG_INT, MPI_MIN, testComm),
316 "cannot total data moved");
317 MPI_CHECK(MPI_Allreduce(&aggFileSizeFromStat, &tmpMax, 1,
318 MPI_LONG_LONG_INT, MPI_MAX, testComm),
319 "cannot total data moved");
320 if (tmpMin != tmpMax) {
322 WARN(
"inconsistent file size by different tasks");
325 aggFileSizeFromStat = tmpMin;
329 return (aggFileSizeFromStat);
336 #if defined(HAVE_STATVFS) 337 struct statvfs statfs_buf;
338 int ret = ceph_statfs(
cmount,
pfix(path), &statfs_buf);
344 stat_buf->
f_bsize = statfs_buf.f_bsize;
345 stat_buf->
f_blocks = statfs_buf.f_blocks;
346 stat_buf->
f_bfree = statfs_buf.f_bfree;
347 stat_buf->
f_files = statfs_buf.f_files;
348 stat_buf->
f_ffree = statfs_buf.f_ffree;
352 WARN(
"ceph_statfs requires statvfs!");
370 return ceph_stat(
cmount,
pfix(testFileName), &buf);
375 return ceph_stat(
cmount,
pfix(testFileName), buf);
380 int ret = ceph_sync_fs(
cmount);
static struct ceph_mount_info * cmount
static int CEPHFS_StatFS(const char *, ior_aiori_statfs_t *, IOR_param_t *)
static void CEPHFS_Sync(IOR_param_t *)
static int CEPHFS_Stat(const char *, struct stat *, IOR_param_t *)
static IOR_offset_t CEPHFS_Xfer(int, void *, IOR_size_t *, IOR_offset_t, IOR_param_t *)
#define CEPHFS_ERR(__err_str, __ret)
static void CEPHFS_Init()
static void CEPHFS_Fsync(void *, IOR_param_t *)
static int CEPHFS_RmDir(const char *, IOR_param_t *)
static int CEPHFS_Access(const char *, int, IOR_param_t *)
char * aiori_get_version()
static void CEPHFS_Final()
static option_help options[]
#define MPI_CHECK(MPI_STATUS, MSG)
static void * CEPHFS_Create(char *, IOR_param_t *)
static void CEPHFS_Delete(char *, IOR_param_t *)
static IOR_offset_t CEPHFS_GetFileSize(IOR_param_t *, MPI_Comm, char *)
static void CEPHFS_Close(void *, IOR_param_t *)
static option_help * CEPHFS_options()
static const char * pfix(const char *path)
static int CEPHFS_MkDir(const char *, mode_t, IOR_param_t *)
long long int IOR_offset_t
static struct cephfs_options o
static void * CEPHFS_Open(char *, IOR_param_t *)