24 #include <sys/types.h> 30 #include <gurt/common.h> 31 #include <gurt/hash.h> 62 #if !defined(DAOS_API_VERSION_MAJOR) || DAOS_API_VERSION_MAJOR < 1 76 #if !defined(DAOS_API_VERSION_MAJOR) || DAOS_API_VERSION_MAJOR < 1 81 .chunk_size = 1048576,
90 #if !defined(DAOS_API_VERSION_MAJOR) || DAOS_API_VERSION_MAJOR < 1 144 .enable_mdtest =
true,
150 #define DCHECK(rc, format, ...) \ 155 fprintf(stderr, "ERROR (%s:%d): %d: %d: " \ 156 format"\n", __FILE__, __LINE__, rank, _rc, \ 163 #define INFO(level, format, ...) \ 165 if (verbose >= level) \ 166 printf("[%d] "format"\n", rank, ##__VA_ARGS__); \ 169 #define GERR(format, ...) \ 171 fprintf(stderr, format"\n", ##__VA_ARGS__); \ 172 MPI_CHECK(MPI_Abort(MPI_COMM_WORLD, -1), "MPI_Abort() error"); \ 182 key_cmp(
struct d_hash_table *htable, d_list_t *rlink,
183 const void *key,
unsigned int ksize)
187 return (strcmp(hdl->
name, (
const char *)key) == 0);
191 rec_free(
struct d_hash_table *htable, d_list_t *rlink)
195 assert(d_hash_rec_unlinked(&hdl->
entry));
196 dfs_release(hdl->
oh);
212 global.iov_buf =
NULL;
213 global.iov_buf_len = 0;
220 rc = daos_pool_local2global(
poh, &global);
222 rc = daos_cont_local2global(
coh, &global);
224 rc = dfs_local2global(
dfs, &global);
225 DCHECK(rc,
"Failed to get global handle size");
228 MPI_CHECK(MPI_Bcast(&global.iov_buf_len, 1, MPI_UINT64_T, 0, MPI_COMM_WORLD),
229 "Failed to bcast global handle buffer size");
231 global.iov_len = global.iov_buf_len;
232 global.iov_buf = malloc(global.iov_buf_len);
233 if (global.iov_buf ==
NULL)
234 ERR(
"Failed to allocate global handle buffer");
238 rc = daos_pool_local2global(
poh, &global);
240 rc = daos_cont_local2global(
coh, &global);
242 rc = dfs_local2global(
dfs, &global);
243 DCHECK(rc,
"Failed to create global handle");
246 MPI_CHECK(MPI_Bcast(global.iov_buf, global.iov_buf_len, MPI_BYTE, 0, MPI_COMM_WORLD),
247 "Failed to bcast global pool handle");
251 rc = daos_pool_global2local(global, &
poh);
253 rc = daos_cont_global2local(
poh, global, &
coh);
255 rc = dfs_global2local(
poh,
coh, 0, global, &
dfs);
256 DCHECK(rc,
"Failed to get local handle");
259 free(global.iov_buf);
268 char *cont_name =
NULL;
271 if (path ==
NULL || _obj_name ==
NULL || _cont_name ==
NULL)
274 if (strcmp(path,
"/") == 0) {
275 *_cont_name = strdup(
"/");
276 if (*_cont_name ==
NULL)
294 fname = basename(f1);
295 cont_name = dirname(f2);
297 if (cont_name[0] ==
'.' || cont_name[0] !=
'/') {
300 if (getcwd(cwd, 1024) ==
NULL) {
305 if (strcmp(cont_name,
".") == 0) {
306 cont_name = strdup(cwd);
307 if (cont_name ==
NULL) {
312 char *new_dir = calloc(strlen(cwd) + strlen(cont_name)
314 if (new_dir ==
NULL) {
319 strcpy(new_dir, cwd);
320 if (cont_name[0] ==
'.') {
321 strcat(new_dir, &cont_name[1]);
323 strcat(new_dir,
"/");
324 strcat(new_dir, cont_name);
328 *_cont_name = cont_name;
330 *_cont_name = strdup(cont_name);
331 if (*_cont_name ==
NULL) {
337 *_obj_name = strdup(fname);
338 if (*_obj_name ==
NULL) {
359 global.iov_buf =
NULL;
360 global.iov_buf_len = 0;
364 rc = dfs_obj_local2global(
dfs, *file, &global);
365 DCHECK(rc,
"Failed to get global handle size");
369 "Failed to bcast global handle buffer size");
371 global.iov_len = global.iov_buf_len;
372 global.iov_buf = malloc(global.iov_buf_len);
373 if (global.iov_buf ==
NULL)
374 ERR(
"Failed to allocate global handle buffer");
377 rc = dfs_obj_local2global(
dfs, *file, &global);
378 DCHECK(rc,
"Failed to create global handle");
382 "Failed to bcast global pool handle");
385 rc = dfs_obj_global2local(
dfs, 0, global, file);
386 DCHECK(rc,
"Failed to get local handle");
389 free(global.iov_buf);
399 rlink = d_hash_rec_find(
dir_hash, name, strlen(name));
407 GERR(
"failed to alloc dir handle");
412 rc = dfs_lookup(
dfs, name, O_RDWR, &hdl->
oh, mode,
NULL);
415 if (mode && S_ISREG(*mode))
420 DCHECK(rc,
"Failed to insert dir handle in hashtable");
441 #if !defined(DAOS_API_VERSION_MAJOR) || DAOS_API_VERSION_MAJOR < 1 447 DCHECK(rc,
"Failed to initialize daos");
452 GERR(
"Invalid DAOS object class %s\n", o.
oclass);
462 DCHECK(rc,
"Failed to initialize dir hashtable");
465 uuid_t pool_uuid, co_uuid;
466 daos_pool_info_t pool_info;
467 daos_cont_info_t co_info;
469 rc = uuid_parse(o.
pool, pool_uuid);
470 DCHECK(rc,
"Failed to parse 'Pool uuid': %s", o.
pool);
472 rc = uuid_parse(o.
cont, co_uuid);
473 DCHECK(rc,
"Failed to parse 'Cont uuid': %s", o.
cont);
478 #if !defined(DAOS_API_VERSION_MAJOR) || DAOS_API_VERSION_MAJOR < 1 479 d_rank_list_t *svcl =
NULL;
481 svcl = daos_rank_list_parse(o.
svcl,
":");
483 ERR(
"Failed to allocate svcl");
487 rc = daos_pool_connect(pool_uuid, o.
group, svcl, DAOS_PC_RW,
489 d_rank_list_free(svcl);
491 rc = daos_pool_connect(pool_uuid, o.
group, DAOS_PC_RW,
494 DCHECK(rc,
"Failed to connect to pool");
496 rc = daos_cont_open(
poh, co_uuid, DAOS_COO_RW, &
coh, &co_info,
499 if (rc == -DER_NONEXIST) {
504 DCHECK(rc,
"Failed to create container");
506 DCHECK(rc,
"Failed to create container");
510 DCHECK(rc,
"Failed to mount DFS namespace");
519 DCHECK(rc,
"Failed to set DFS Prefix");
529 MPI_Barrier(MPI_COMM_WORLD);
530 d_hash_table_destroy(
dir_hash,
true );
532 rc = dfs_umount(
dfs);
533 DCHECK(rc,
"Failed to umount DFS namespace");
534 MPI_Barrier(MPI_COMM_WORLD);
536 rc = daos_cont_close(
coh,
NULL);
537 DCHECK(rc,
"Failed to close container %s (%d)", o.
cont, rc);
538 MPI_Barrier(MPI_COMM_WORLD);
546 uuid_parse(o.
cont, uuid);
548 rc = daos_cont_destroy(
poh, uuid, 1,
NULL);
554 MPI_Bcast(&rc, 1, MPI_INT, 0, MPI_COMM_WORLD);
557 DCHECK(rc,
"Failed to destroy container %s (%d)", o.
cont, rc);
558 MPI_Abort(MPI_COMM_WORLD, -1);
565 rc = daos_pool_disconnect(
poh,
NULL);
566 DCHECK(rc,
"Failed to disconnect from pool");
568 MPI_CHECK(MPI_Barrier(MPI_COMM_WORLD),
"barrier error");
574 DCHECK(rc,
"Failed to finalize DAOS");
578 #if !defined(DAOS_API_VERSION_MAJOR) || DAOS_API_VERSION_MAJOR < 1 600 dfs_obj_t *obj =
NULL, *parent =
NULL;
608 DCHECK(rc,
"Failed to parse path %s", testFileName);
612 mode = S_IFREG | mode;
614 fd_oflag |= O_CREAT | O_RDWR | O_EXCL;
618 GERR(
"Failed to lookup parent dir");
620 rc = dfs_open(
dfs, parent, name, mode, fd_oflag,
622 DCHECK(rc,
"dfs_open() of %s Failed", name);
633 return ((
void *)obj);
643 dfs_obj_t *obj =
NULL, *parent =
NULL;
649 mode = S_IFREG | param->
mode;
652 DCHECK(rc,
"Failed to parse path %s", testFileName);
660 GERR(
"Failed to lookup parent dir");
664 DCHECK(rc,
"dfs_open() of %s Failed", name);
676 return ((
void *)obj);
687 long long remaining = (
long long)length;
688 char *ptr = (
char *)buffer;
693 obj = (dfs_obj_t *)file;
695 while (remaining > 0) {
702 d_iov_set(&iov, (
void *)ptr, remaining);
706 if (access ==
WRITE) {
709 fprintf(stderr,
"dfs_write() failed (%d)\n", rc);
716 fprintf(stderr,
"dfs_read() failed(%d)\n", rc);
719 if (ret < remaining) {
723 ERR(
"too many retries -- aborting");
727 assert(ret <= remaining);
764 dfs_release((dfs_obj_t *)fd);
774 dfs_obj_t *parent =
NULL;
778 DCHECK(rc,
"Failed to parse path %s", testFileName);
785 GERR(
"Failed to lookup parent dir");
787 rc = dfs_remove(
dfs, parent, name,
false,
NULL);
788 DCHECK(rc,
"dfs_remove() of %s Failed", name);
798 static char ver[1024] = {};
800 sprintf(ver,
"%s",
"DAOS");
811 daos_size_t fsize, tmpMin, tmpMax, tmpSum;
815 rc = dfs_lookup(
dfs, testFileName, O_RDONLY, &obj,
NULL,
NULL);
817 fprintf(stderr,
"dfs_lookup() of %s Failed (%d)", testFileName, rc);
821 rc = dfs_get_size(
dfs, obj, &fsize);
828 MPI_CHECK(MPI_Allreduce(&fsize, &tmpSum, 1,
829 MPI_LONG_LONG_INT, MPI_SUM, comm),
830 "cannot total data moved");
833 MPI_CHECK(MPI_Allreduce(&fsize, &tmpMin, 1,
834 MPI_LONG_LONG_INT, MPI_MIN, comm),
835 "cannot total data moved");
836 MPI_CHECK(MPI_Allreduce(&fsize, &tmpMax, 1,
837 MPI_LONG_LONG_INT, MPI_MAX, comm),
838 "cannot total data moved");
839 if (tmpMin != tmpMax) {
841 WARN(
"inconsistent file size by different tasks");
860 dfs_obj_t *parent =
NULL;
865 DCHECK(rc,
"Failed to parse path %s", path);
873 GERR(
"Failed to lookup parent dir");
876 DCHECK(rc,
"dfs_mkdir() of %s Failed", name);
888 dfs_obj_t *parent =
NULL;
893 DCHECK(rc,
"Failed to parse path %s", path);
900 GERR(
"Failed to lookup parent dir");
902 rc = dfs_remove(
dfs, parent, name,
false,
NULL);
903 DCHECK(rc,
"dfs_remove() of %s Failed", name);
917 dfs_obj_t *obj =
NULL;
934 dfs_obj_t *parent =
NULL;
939 DCHECK(rc,
"Failed to parse path %s", path);
946 GERR(
"Failed to lookup parent dir");
948 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 option_help * DFS_options()
static int DFS_Stat(const char *, struct stat *, IOR_param_t *)
static void DFS_Delete(char *, IOR_param_t *)
static struct aiori_dir_hdl * hdl_obj(d_list_t *rlink)
#define DCHECK(rc, format,...)
static void DFS_Finalize()
static int parse_filename(const char *path, char **_obj_name, char **_cont_name)
static void * DFS_Create(char *, IOR_param_t *)
static d_hash_table_ops_t hdl_hash_ops
static void DFS_Sync(IOR_param_t *)
static void share_file_handle(dfs_obj_t **file, MPI_Comm comm)
static struct dfs_options o
static int DFS_Statfs(const char *, ior_aiori_statfs_t *, IOR_param_t *)
#define INFO(level, format,...)
static struct d_hash_table * dir_hash
#define MPI_CHECK(MPI_STATUS, MSG)
static daos_oclass_id_t dir_oclass
static void * DFS_Open(char *, IOR_param_t *)
static IOR_offset_t DFS_GetFileSize(IOR_param_t *, MPI_Comm, char *)
static daos_oclass_id_t objectClass
static void DFS_Close(void *, IOR_param_t *)
static int DFS_Access(const char *, int, IOR_param_t *)
static void DFS_Fsync(void *, IOR_param_t *)
static char * DFS_GetVersion()
static dfs_obj_t * lookup_insert_dir(const char *name, mode_t *mode)
static option_help options[]
static int DFS_Mkdir(const char *, mode_t, IOR_param_t *)
static IOR_offset_t DFS_Xfer(int, void *, IOR_size_t *, IOR_offset_t, IOR_param_t *)
static int DFS_Rmdir(const char *, IOR_param_t *)
long long int IOR_offset_t
static bool key_cmp(struct d_hash_table *htable, d_list_t *rlink, const void *key, unsigned int ksize)