24 #include <sys/types.h> 31 #include <gurt/common.h> 32 #include <gurt/hash.h> 62 #if !defined(DAOS_API_VERSION_MAJOR) || DAOS_API_VERSION_MAJOR < 1 78 if (init_values !=
NULL) {
90 #if !defined(DAOS_API_VERSION_MAJOR) || DAOS_API_VERSION_MAJOR < 1 105 memcpy(help, h,
sizeof(h));
154 .enable_mdtest =
true,
160 #define DCHECK(rc, format, ...) \ 165 fprintf(stderr, "ERROR (%s:%d): %d: %d: " \ 166 format"\n", __FILE__, __LINE__, rank, _rc, \ 173 #define INFO(level, format, ...) \ 175 if (verbose >= level) \ 176 printf("[%d] "format"\n", rank, ##__VA_ARGS__); \ 179 #define GERR(format, ...) \ 181 fprintf(stderr, format"\n", ##__VA_ARGS__); \ 182 MPI_CHECK(MPI_Abort(MPI_COMM_WORLD, -1), "MPI_Abort() error"); \ 196 ERR(
"Invalid pool or container options\n");
198 #if !defined(DAOS_API_VERSION_MAJOR) || DAOS_API_VERSION_MAJOR < 1 200 ERR(
"Invalid SVCL\n");
212 key_cmp(
struct d_hash_table *htable, d_list_t *rlink,
213 const void *key,
unsigned int ksize)
217 return (strcmp(hdl->
name, (
const char *)key) == 0);
221 rec_free(
struct d_hash_table *htable, d_list_t *rlink)
225 assert(d_hash_rec_unlinked(&hdl->
entry));
226 dfs_release(hdl->
oh);
242 global.iov_buf =
NULL;
243 global.iov_buf_len = 0;
250 rc = daos_pool_local2global(
poh, &global);
252 rc = daos_cont_local2global(
coh, &global);
254 rc = dfs_local2global(
dfs, &global);
255 DCHECK(rc,
"Failed to get global handle size");
259 "Failed to bcast global handle buffer size");
261 global.iov_len = global.iov_buf_len;
262 global.iov_buf = malloc(global.iov_buf_len);
263 if (global.iov_buf ==
NULL)
264 ERR(
"Failed to allocate global handle buffer");
268 rc = daos_pool_local2global(
poh, &global);
270 rc = daos_cont_local2global(
coh, &global);
272 rc = dfs_local2global(
dfs, &global);
273 DCHECK(rc,
"Failed to create global handle");
277 "Failed to bcast global pool handle");
281 rc = daos_pool_global2local(global, &
poh);
283 rc = daos_cont_global2local(
poh, global, &
coh);
285 rc = dfs_global2local(
poh,
coh, 0, global, &
dfs);
286 DCHECK(rc,
"Failed to get local handle");
289 free(global.iov_buf);
298 char *cont_name =
NULL;
301 if (path ==
NULL || _obj_name ==
NULL || _cont_name ==
NULL)
304 if (strcmp(path,
"/") == 0) {
305 *_cont_name = strdup(
"/");
306 if (*_cont_name ==
NULL)
324 fname = basename(f1);
325 cont_name = dirname(f2);
327 if (cont_name[0] ==
'.' || cont_name[0] !=
'/') {
330 if (getcwd(cwd, 1024) ==
NULL) {
335 if (strcmp(cont_name,
".") == 0) {
336 cont_name = strdup(cwd);
337 if (cont_name ==
NULL) {
342 char *new_dir = calloc(strlen(cwd) + strlen(cont_name)
344 if (new_dir ==
NULL) {
349 strcpy(new_dir, cwd);
350 if (cont_name[0] ==
'.') {
351 strcat(new_dir, &cont_name[1]);
353 strcat(new_dir,
"/");
354 strcat(new_dir, cont_name);
358 *_cont_name = cont_name;
360 *_cont_name = strdup(cont_name);
361 if (*_cont_name ==
NULL) {
367 *_obj_name = strdup(fname);
368 if (*_obj_name ==
NULL) {
389 global.iov_buf =
NULL;
390 global.iov_buf_len = 0;
394 rc = dfs_obj_local2global(
dfs, *file, &global);
395 DCHECK(rc,
"Failed to get global handle size");
399 "Failed to bcast global handle buffer size");
401 global.iov_len = global.iov_buf_len;
402 global.iov_buf = malloc(global.iov_buf_len);
403 if (global.iov_buf ==
NULL)
404 ERR(
"Failed to allocate global handle buffer");
407 rc = dfs_obj_local2global(
dfs, *file, &global);
408 DCHECK(rc,
"Failed to create global handle");
412 "Failed to bcast global pool handle");
415 rc = dfs_obj_global2local(
dfs, 0, global, file);
416 DCHECK(rc,
"Failed to get local handle");
419 free(global.iov_buf);
429 rlink = d_hash_rec_find(
dir_hash, name, strlen(name));
437 GERR(
"failed to alloc dir handle");
442 rc = dfs_lookup(
dfs, name, O_RDWR, &hdl->
oh, mode,
NULL);
445 if (mode && S_ISREG(*mode))
450 DCHECK(rc,
"Failed to insert dir handle in hashtable");
469 #if !defined(DAOS_API_VERSION_MAJOR) || DAOS_API_VERSION_MAJOR < 1 475 DCHECK(rc,
"Failed to initialize daos");
480 GERR(
"Invalid DAOS object class %s\n", o->
oclass);
490 DCHECK(rc,
"Failed to initialize dir hashtable");
493 uuid_t pool_uuid, co_uuid;
494 daos_pool_info_t pool_info;
495 daos_cont_info_t co_info;
497 rc = uuid_parse(o->
pool, pool_uuid);
498 DCHECK(rc,
"Failed to parse 'Pool uuid': %s", o->
pool);
500 rc = uuid_parse(o->
cont, co_uuid);
501 DCHECK(rc,
"Failed to parse 'Cont uuid': %s", o->
cont);
506 #if !defined(DAOS_API_VERSION_MAJOR) || DAOS_API_VERSION_MAJOR < 1 507 d_rank_list_t *svcl =
NULL;
509 svcl = daos_rank_list_parse(o->
svcl,
":");
511 ERR(
"Failed to allocate svcl");
515 rc = daos_pool_connect(pool_uuid, o->
group, svcl, DAOS_PC_RW,
517 d_rank_list_free(svcl);
519 rc = daos_pool_connect(pool_uuid, o->
group, DAOS_PC_RW,
522 DCHECK(rc,
"Failed to connect to pool");
524 rc = daos_cont_open(
poh, co_uuid, DAOS_COO_RW, &
coh, &co_info,
527 if (rc == -DER_NONEXIST) {
532 DCHECK(rc,
"Failed to create container");
534 DCHECK(rc,
"Failed to create container");
538 DCHECK(rc,
"Failed to mount DFS namespace");
547 DCHECK(rc,
"Failed to set DFS Prefix");
559 d_hash_table_destroy(
dir_hash,
true );
561 rc = dfs_umount(
dfs);
562 DCHECK(rc,
"Failed to umount DFS namespace");
565 rc = daos_cont_close(
coh,
NULL);
566 DCHECK(rc,
"Failed to close container %s (%d)", o->
cont, rc);
575 uuid_parse(o->
cont, uuid);
577 rc = daos_cont_destroy(
poh, uuid, 1,
NULL);
583 MPI_Bcast(&rc, 1, MPI_INT, 0,
testComm);
586 DCHECK(rc,
"Failed to destroy container %s (%d)", o->
cont, rc);
587 MPI_Abort(MPI_COMM_WORLD, -1);
594 rc = daos_pool_disconnect(
poh,
NULL);
595 DCHECK(rc,
"Failed to disconnect from pool");
603 DCHECK(rc,
"Failed to finalize DAOS");
607 #if !defined(DAOS_API_VERSION_MAJOR) || DAOS_API_VERSION_MAJOR < 1 630 dfs_obj_t *obj =
NULL, *parent =
NULL;
636 DCHECK(rc,
"Failed to parse path %s", testFileName);
640 mode = S_IFREG | mode;
642 fd_oflag |= O_CREAT | O_RDWR | O_EXCL;
646 GERR(
"Failed to lookup parent dir");
648 rc = dfs_open(
dfs, parent, name, mode, fd_oflag,
650 DCHECK(rc,
"dfs_open() of %s Failed", name);
673 dfs_obj_t *obj =
NULL, *parent =
NULL;
679 mode = S_IFREG | flags;
682 DCHECK(rc,
"Failed to parse path %s", testFileName);
689 GERR(
"Failed to lookup parent dir");
693 DCHECK(rc,
"dfs_open() of %s Failed", name);
716 long long remaining = (
long long)length;
717 char *ptr = (
char *)buffer;
722 obj = (dfs_obj_t *)file;
724 while (remaining > 0) {
731 d_iov_set(&iov, (
void *)ptr, remaining);
735 if (access ==
WRITE) {
736 rc = dfs_write(
dfs, obj, &sgl, off,
NULL);
738 fprintf(stderr,
"dfs_write() failed (%d)\n", rc);
743 rc = dfs_read(
dfs, obj, &sgl, off, &ret,
NULL);
745 fprintf(stderr,
"dfs_read() failed(%d)\n", rc);
748 if (ret < remaining) {
752 ERR(
"too many retries -- aborting");
756 assert(ret <= remaining);
793 dfs_release((dfs_obj_t *)fd);
803 dfs_obj_t *parent =
NULL;
807 DCHECK(rc,
"Failed to parse path %s", testFileName);
814 GERR(
"Failed to lookup parent dir");
816 rc = dfs_remove(
dfs, parent, name,
false,
NULL);
817 DCHECK(rc,
"dfs_remove() of %s Failed", name);
827 static char ver[1024] = {};
829 sprintf(ver,
"%s",
"DAOS");
845 comm = MPI_COMM_SELF;
851 rc = dfs_lookup(
dfs, testFileName, O_RDONLY, &obj,
NULL,
NULL);
853 fprintf(stderr,
"dfs_lookup() of %s Failed (%d)", testFileName, rc);
857 rc = dfs_get_size(
dfs, obj, &fsize);
864 rc = MPI_Bcast(&fsize, 1, MPI_UINT64_T, 0, comm);
881 dfs_obj_t *parent =
NULL;
886 DCHECK(rc,
"Failed to parse path %s", path);
894 GERR(
"Failed to lookup parent dir");
897 DCHECK(rc,
"dfs_mkdir() of %s Failed", name);
909 dfs_obj_t *parent =
NULL;
914 DCHECK(rc,
"Failed to parse path %s", path);
921 GERR(
"Failed to lookup parent dir");
923 rc = dfs_remove(
dfs, parent, name,
false,
NULL);
924 DCHECK(rc,
"dfs_remove() of %s Failed", name);
938 dfs_obj_t *obj =
NULL;
955 dfs_obj_t *parent =
NULL;
960 DCHECK(rc,
"Failed to parse path %s", path);
967 GERR(
"Failed to lookup parent dir");
969 rc = dfs_stat(
dfs, parent, name, buf);
static void HandleDistribute(enum handleType type)
static void rec_free(struct d_hash_table *htable, d_list_t *rlink)
static struct aiori_dir_hdl * hdl_obj(d_list_t *rlink)
#define DCHECK(rc, format,...)
struct benchmark_options o
static int parse_filename(const char *path, char **_obj_name, char **_cont_name)
static d_hash_table_ops_t hdl_hash_ops
static IOR_offset_t DFS_Xfer(int, aiori_fd_t *, IOR_size_t *, IOR_offset_t, IOR_offset_t, aiori_mod_opt_t *)
static aiori_fd_t * DFS_Create(char *, int, aiori_mod_opt_t *)
#define MPI_CHECK(MPI_STATUS, MSG)
static void share_file_handle(dfs_obj_t **file, MPI_Comm comm)
static int DFS_Access(const char *, int, aiori_mod_opt_t *)
static void DFS_Finalize(aiori_mod_opt_t *)
#define INFO(level, format,...)
static aiori_xfer_hint_t * hints
static struct d_hash_table * dir_hash
static option_help options[]
static void DFS_Sync(aiori_mod_opt_t *)
static daos_oclass_id_t dir_oclass
static IOR_offset_t DFS_GetFileSize(aiori_mod_opt_t *, char *)
static int DFS_Mkdir(const char *, mode_t, aiori_mod_opt_t *)
static void DFS_init_xfer_options(aiori_xfer_hint_t *)
static option_help * DFS_options(aiori_mod_opt_t **init_backend_options, aiori_mod_opt_t *init_values)
static void DFS_Delete(char *, aiori_mod_opt_t *)
static daos_oclass_id_t objectClass
static char * DFS_GetVersion()
static void DFS_Close(aiori_fd_t *, aiori_mod_opt_t *)
static int DFS_Statfs(const char *, ior_aiori_statfs_t *, aiori_mod_opt_t *)
static dfs_obj_t * lookup_insert_dir(const char *name, mode_t *mode)
static int DFS_Stat(const char *, struct stat *, aiori_mod_opt_t *)
static void DFS_Fsync(aiori_fd_t *, aiori_mod_opt_t *)
static void DFS_Init(aiori_mod_opt_t *)
static aiori_fd_t * DFS_Open(char *, int, aiori_mod_opt_t *)
long long int IOR_offset_t
static int DFS_Rmdir(const char *, aiori_mod_opt_t *)
static bool key_cmp(struct d_hash_table *htable, d_list_t *rlink, const void *key, unsigned int ksize)
static int DFS_check_params(aiori_mod_opt_t *)