Skip to content

Commit

Permalink
daos: remove prefix from docs and update call to duns_resolve_path (#487
Browse files Browse the repository at this point in the history
)

This just removes the daos-prefix option from the documentation
because it is no longer necessary after a recent DAOS PR
that allows passing a subset of a UNS path to duns_resolve_path.
The option is removed from the documentation but not removed
from the code in order to preserve backwards compatibility with
the DAOS tests for the datamover.

The call to duns_resolve_path was updated in the case that the
last directory or file in the UNS path does not yet exist, since
it doesn't recurse the rest of the paths in the directory tree
in that case.

Signed-off-by: Danielle Sikich <danielle.sikich@intel.com>
  • Loading branch information
Danielle Sikich committed Nov 25, 2021
1 parent d5f41b3 commit 49b04c1
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 30 deletions.
6 changes: 0 additions & 6 deletions doc/rst/dcmp.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ OPTIONS
"GB" can immediately follow the number without spaces (e.g. 64MB).
The default chunksize is 4MB.

.. option:: --daos-prefix PREFIX

Specify the DAOS prefix to be used. This is only necessary
if copying a subset of a POSIX container in DAOS using a
Unified Namespace path.

.. option:: --daos-api API

Specify the DAOS API to be used. By default, the API is automatically
Expand Down
6 changes: 0 additions & 6 deletions doc/rst/dcp.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ OPTIONS
"GB" can immediately follow the number without spaces (e.g. 64MB).
The default chunksize is 4MB.

.. option:: --daos-prefix PREFIX

Specify the DAOS prefix to be used. This is only necessary
if copying a subset of a POSIX container in DAOS using a
Unified Namespace path.

.. option:: --daos-api API

Specify the DAOS API to be used. By default, the API is automatically
Expand Down
6 changes: 0 additions & 6 deletions doc/rst/dsync.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ OPTIONS
"GB" can immediately follow the number without spaces (e.g. 64MB).
The default chunksize is 4MB.

.. option:: --daos-prefix PREFIX

Specify the DAOS prefix to be used. This is only necessary
if copying a subset of a POSIX container in DAOS using a
Unified Namespace path.

.. option:: --daos-api API

Specify the DAOS API to be used. By default, the API is automatically
Expand Down
73 changes: 64 additions & 9 deletions src/common/mfu_daos.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <daos_uns.h>
#include <gurt/common.h>
#include <gurt/hash.h>
#include <libgen.h>

#ifdef HDF5_SUPPORT
#include <hdf5.h>
Expand Down Expand Up @@ -323,8 +324,13 @@ int daos_parse_path(
{
struct duns_attr_t dattr = {0};
int rc;
char* tmp_path1 = NULL;
char* path_dirname = NULL;
char* tmp_path2 = NULL;
char* path_basename = NULL;
char* tmp = NULL;

/* Check if this path represents a daos pool and/or container. */
/* check first if duns_resolve_path succeeds on regular path */
rc = duns_resolve_path(path, &dattr);
if (rc == 0) {
/* daos:// or UNS path */
Expand All @@ -335,17 +341,66 @@ int daos_parse_path(
} else {
strncpy(path, dattr.da_rel_path, path_len);
}
} else if (strncmp(path, "daos:", 5) == 0) {
/* Actual error, since we expect a daos path */
rc = -1;
} else {
/* We didn't parse a daos path,
* but we weren't necessarily looking for one */
rc = 1;
}
/* If basename does not exist yet then duns_resolve_path will fail even
* if dirname is a UNS path */

mfu_free(&dattr.da_rel_path);
/* get dirname */
tmp_path1 = strdup(path);
if (tmp_path1 == NULL) {
rc = -ENOMEM;
goto out;
}
path_dirname = dirname(tmp_path1);

/* reset before calling duns_resolve_path with new string */
memset(&dattr, 0, sizeof(struct duns_attr_t));

/* Check if this path represents a daos pool and/or container. */
rc = duns_resolve_path(path_dirname, &dattr);
/* if it succeeds get the basename and append it to the rel_path */
if (rc == 0) {
/* if duns_resolve_path succeeds then concat basename to
* da_rel_path */
tmp_path2 = strdup(path);
if (tmp_path2 == NULL) {
rc = -ENOMEM;
goto out;
}
path_basename = basename(tmp_path2);

/* dirname might be root uns path, if that is the case,
* then da_rel_path might be NULL */
if (dattr.da_rel_path == NULL) {
tmp = MFU_CALLOC(path_len, sizeof(char));
} else {
tmp = realloc(dattr.da_rel_path, path_len);
}
if (tmp == NULL) {
rc = -ENOMEM;
goto out;
}
dattr.da_rel_path = tmp;
strcat(dattr.da_rel_path, "/");
strcat(dattr.da_rel_path, path_basename);

snprintf(*pool_str, DAOS_PROP_LABEL_MAX_LEN + 1, "%s", dattr.da_pool);
snprintf(*cont_str, DAOS_PROP_LABEL_MAX_LEN + 1, "%s", dattr.da_cont);
strncpy(path, dattr.da_rel_path, path_len);
} else if (strncmp(path, "daos:", 5) == 0) {
/* Actual error, since we expect a daos path */
rc = -1;
} else {
/* We didn't parse a daos path,
* but we weren't necessarily looking for one */
rc = 1;
}
}
out:
mfu_free(&tmp_path1);
mfu_free(&tmp_path2);
mfu_free(&dattr.da_rel_path);
duns_destroy_attr(&dattr);
return rc;
}

Expand Down
1 change: 0 additions & 1 deletion src/dcmp/dcmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ static void print_usage(void)
printf(" --bufsize <SIZE> - IO buffer size in bytes (default " MFU_BUFFER_SIZE_STR ")\n");
printf(" --chunksize <SIZE> - minimum work size per task in bytes (default " MFU_CHUNK_SIZE_STR ")\n");
#ifdef DAOS_SUPPORT
printf(" --daos-prefix - DAOS prefix for unified namespace path\n");
printf(" --daos-api - DAOS API in {DFS, DAOS} (default uses DFS for POSIX containers)\n");
#endif
printf(" -s, --direct - open files with O_DIRECT\n");
Expand Down
1 change: 0 additions & 1 deletion src/dcp/dcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ void print_usage(void)
printf(" -b, --bufsize <SIZE> - IO buffer size in bytes (default " MFU_BUFFER_SIZE_STR ")\n");
printf(" -k, --chunksize <SIZE> - work size per task in bytes (default " MFU_CHUNK_SIZE_STR ")\n");
#ifdef DAOS_SUPPORT
printf(" --daos-prefix - DAOS prefix for unified namespace path\n");
printf(" --daos-api - DAOS API in {DFS, DAOS} (default uses DFS for POSIX containers)\n");
#ifdef HDF5_SUPPORT
printf(" --daos-preserve - preserve DAOS container properties and user attributes, a filename "
Expand Down
1 change: 0 additions & 1 deletion src/dsync/dsync.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ static void print_usage(void)
printf(" --bufsize <SIZE> - IO buffer size in bytes (default " MFU_BUFFER_SIZE_STR ")\n");
printf(" --chunksize <SIZE> - minimum work size per task in bytes (default " MFU_CHUNK_SIZE_STR ")\n");
#ifdef DAOS_SUPPORT
printf(" --daos-prefix - DAOS prefix for unified namespace path \n");
printf(" --daos-api - DAOS API in {DFS, DAOS} (default uses DFS for POSIX containers)\n");
#endif
printf(" -c, --contents - read and compare file contents rather than compare size and mtime\n");
Expand Down

0 comments on commit 49b04c1

Please sign in to comment.