24 #include <sys/types.h> 30 #include <gurt/common.h> 31 #include <gurt/hash.h> 77 .chunk_size = 1048576,
138 .enable_mdtest =
true,
144 #define DCHECK(rc, format, ...) \ 149 fprintf(stderr, "ERROR (%s:%d): %d: %d: " \ 150 format"\n", __FILE__, __LINE__, rank, _rc, \ 157 #define INFO(level, format, ...) \ 159 if (verbose >= level) \ 160 printf("[%d] "format"\n", rank, ##__VA_ARGS__); \ 163 #define GERR(format, ...) \ 165 fprintf(stderr, format"\n", ##__VA_ARGS__); \ 166 MPI_CHECK(MPI_Abort(MPI_COMM_WORLD, -1), "MPI_Abort() error"); \ 176 key_cmp(
struct d_hash_table *htable, d_list_t *rlink,
177 const void *key,
unsigned int ksize)
181 return (strcmp(hdl->
name, (
const char *)key) == 0);
185 rec_free(
struct d_hash_table *htable, d_list_t *rlink)
189 assert(d_hash_rec_unlinked(&hdl->
entry));
190 dfs_release(hdl->
oh);
206 global.iov_buf =
NULL;
207 global.iov_buf_len = 0;
214 rc = daos_pool_local2global(
poh, &global);
216 rc = daos_cont_local2global(
coh, &global);
218 rc = dfs_local2global(
dfs, &global);
219 DCHECK(rc,
"Failed to get global handle size");
222 MPI_CHECK(MPI_Bcast(&global.iov_buf_len, 1, MPI_UINT64_T, 0,
224 "Failed to bcast global handle buffer size");
226 global.iov_len = global.iov_buf_len;
227 global.iov_buf = malloc(global.iov_buf_len);
228 if (global.iov_buf ==
NULL)
229 ERR(
"Failed to allocate global handle buffer");
233 rc = daos_pool_local2global(
poh, &global);
235 rc = daos_cont_local2global(
coh, &global);
237 rc = dfs_local2global(
dfs, &global);
238 DCHECK(rc,
"Failed to create global handle");
241 MPI_CHECK(MPI_Bcast(global.iov_buf, global.iov_buf_len, MPI_BYTE, 0,
243 "Failed to bcast global pool handle");
247 rc = daos_pool_global2local(global, &
poh);
249 rc = daos_cont_global2local(
poh, global, &
coh);
251 rc = dfs_global2local(
poh,
coh, 0, global, &
dfs);
252 DCHECK(rc,
"Failed to get local handle");
255 free(global.iov_buf);
264 char *cont_name =
NULL;
267 if (path ==
NULL || _obj_name ==
NULL || _cont_name ==
NULL)
270 if (strcmp(path,
"/") == 0) {
271 *_cont_name = strdup(
"/");
272 if (*_cont_name ==
NULL)
290 fname = basename(f1);
291 cont_name = dirname(f2);
293 if (cont_name[0] ==
'.' || cont_name[0] !=
'/') {
296 if (getcwd(cwd, 1024) ==
NULL) {
301 if (strcmp(cont_name,
".") == 0) {
302 cont_name = strdup(cwd);
303 if (cont_name ==
NULL) {
308 char *new_dir = calloc(strlen(cwd) + strlen(cont_name)
310 if (new_dir ==
NULL) {
315 strcpy(new_dir, cwd);
316 if (cont_name[0] ==
'.') {
317 strcat(new_dir, &cont_name[1]);
319 strcat(new_dir,
"/");
320 strcat(new_dir, cont_name);
324 *_cont_name = cont_name;
326 *_cont_name = strdup(cont_name);
327 if (*_cont_name ==
NULL) {
333 *_obj_name = strdup(fname);
334 if (*_obj_name ==
NULL) {
356 rlink = d_hash_rec_find(
dir_hash, name, strlen(name));
364 GERR(
"failed to alloc dir handle");
369 rc = dfs_lookup(
dfs, name, O_RDWR, &hdl->
oh, mode,
NULL);
372 if (mode && S_ISREG(*mode))
377 DCHECK(rc,
"Failed to insert dir handle in hashtable");
399 DCHECK(rc,
"Failed to initialize daos");
404 GERR(
"Invalid DAOS object class %s\n", o.
oclass);
414 DCHECK(rc,
"Failed to initialize dir hashtable");
417 uuid_t pool_uuid, co_uuid;
418 d_rank_list_t *svcl =
NULL;
419 daos_pool_info_t pool_info;
420 daos_cont_info_t co_info;
422 rc = uuid_parse(o.
pool, pool_uuid);
423 DCHECK(rc,
"Failed to parse 'Pool uuid': %s", o.
pool);
425 rc = uuid_parse(o.
cont, co_uuid);
426 DCHECK(rc,
"Failed to parse 'Cont uuid': %s", o.
cont);
428 svcl = daos_rank_list_parse(o.
svcl,
":");
430 ERR(
"Failed to allocate svcl");
436 rc = daos_pool_connect(pool_uuid, o.
group, svcl, DAOS_PC_RW,
438 d_rank_list_free(svcl);
439 DCHECK(rc,
"Failed to connect to pool");
441 rc = daos_cont_open(
poh, co_uuid, DAOS_COO_RW, &
coh, &co_info,
444 if (rc == -DER_NONEXIST) {
449 DCHECK(rc,
"Failed to create container");
451 DCHECK(rc,
"Failed to create container");
455 DCHECK(rc,
"Failed to mount DFS namespace");
464 DCHECK(rc,
"Failed to set DFS Prefix");
474 MPI_Barrier(MPI_COMM_WORLD);
475 d_hash_table_destroy(
dir_hash,
true );
477 rc = dfs_umount(
dfs);
478 DCHECK(rc,
"Failed to umount DFS namespace");
479 MPI_Barrier(MPI_COMM_WORLD);
481 rc = daos_cont_close(
coh,
NULL);
482 DCHECK(rc,
"Failed to close container %s (%d)", o.
cont, rc);
483 MPI_Barrier(MPI_COMM_WORLD);
491 uuid_parse(o.
cont, uuid);
493 rc = daos_cont_destroy(
poh, uuid, 1,
NULL);
499 MPI_Bcast(&rc, 1, MPI_INT, 0, MPI_COMM_WORLD);
502 DCHECK(rc,
"Failed to destroy container %s (%d)", o.
cont, rc);
503 MPI_Abort(MPI_COMM_WORLD, -1);
510 rc = daos_pool_disconnect(
poh,
NULL);
511 DCHECK(rc,
"Failed to disconnect from pool");
513 MPI_CHECK(MPI_Barrier(MPI_COMM_WORLD),
"barrier error");
519 DCHECK(rc,
"Failed to finalize DAOS");
543 dfs_obj_t *obj =
NULL, *parent =
NULL;
551 DCHECK(rc,
"Failed to parse path %s", testFileName);
557 GERR(
"Failed to lookup parent dir");
559 mode = S_IFREG | param->
mode;
561 fd_oflag |= O_CREAT | O_RDWR | O_EXCL;
563 rc = dfs_open(
dfs, parent, name, mode, fd_oflag,
565 DCHECK(rc,
"dfs_open() of %s Failed", name);
568 MPI_Barrier(MPI_COMM_WORLD);
571 rc = dfs_open(
dfs, parent, name, mode, fd_oflag,
573 DCHECK(rc,
"dfs_open() of %s Failed", name);
582 return ((
void *)obj);
592 dfs_obj_t *obj =
NULL, *parent =
NULL;
598 mode = S_IFREG | param->
mode;
601 DCHECK(rc,
"Failed to parse path %s", testFileName);
608 GERR(
"Failed to lookup parent dir");
612 DCHECK(rc,
"dfs_open() of %s Failed", name);
619 return ((
void *)obj);
630 long long remaining = (
long long)length;
631 char *ptr = (
char *)buffer;
636 obj = (dfs_obj_t *)file;
638 while (remaining > 0) {
645 d_iov_set(&iov, (
void *)ptr, remaining);
649 if (access ==
WRITE) {
652 fprintf(stderr,
"dfs_write() failed (%d)", rc);
659 fprintf(stderr,
"dfs_read() failed(%d)", rc);
662 if (ret < remaining) {
666 ERR(
"too many retries -- aborting");
670 assert(ret <= remaining);
707 dfs_release((dfs_obj_t *)fd);
717 dfs_obj_t *parent =
NULL;
721 DCHECK(rc,
"Failed to parse path %s", testFileName);
728 GERR(
"Failed to lookup parent dir");
730 rc = dfs_remove(
dfs, parent, name,
false,
NULL);
731 DCHECK(rc,
"dfs_remove() of %s Failed", name);
741 static char ver[1024] = {};
743 sprintf(ver,
"%s",
"DAOS");
754 daos_size_t fsize, tmpMin, tmpMax, tmpSum;
757 rc = dfs_lookup(
dfs, testFileName, O_RDONLY, &obj,
NULL,
NULL);
759 fprintf(stderr,
"dfs_lookup() of %s Failed (%d)", testFileName, rc);
763 rc = dfs_get_size(
dfs, obj, &fsize);
770 MPI_CHECK(MPI_Allreduce(&fsize, &tmpSum, 1,
771 MPI_LONG_LONG_INT, MPI_SUM, comm),
772 "cannot total data moved");
775 MPI_CHECK(MPI_Allreduce(&fsize, &tmpMin, 1,
776 MPI_LONG_LONG_INT, MPI_MIN, comm),
777 "cannot total data moved");
778 MPI_CHECK(MPI_Allreduce(&fsize, &tmpMax, 1,
779 MPI_LONG_LONG_INT, MPI_MAX, comm),
780 "cannot total data moved");
781 if (tmpMin != tmpMax) {
783 WARN(
"inconsistent file size by different tasks");
802 dfs_obj_t *parent =
NULL;
807 DCHECK(rc,
"Failed to parse path %s", path);
815 GERR(
"Failed to lookup parent dir");
818 DCHECK(rc,
"dfs_mkdir() of %s Failed", name);
830 dfs_obj_t *parent =
NULL;
835 DCHECK(rc,
"Failed to parse path %s", path);
842 GERR(
"Failed to lookup parent dir");
844 rc = dfs_remove(
dfs, parent, name,
false,
NULL);
845 DCHECK(rc,
"dfs_remove() of %s Failed", name);
859 dfs_obj_t *obj =
NULL;
876 dfs_obj_t *parent =
NULL;
881 DCHECK(rc,
"Failed to parse path %s", path);
888 GERR(
"Failed to lookup parent dir");
890 rc = dfs_stat(
dfs, parent, name, buf);
891 DCHECK(rc,
"dfs_stat() of Failed (%d)", rc);
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 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)