Skip to content

Commit

Permalink
daos: add epoch supporting code
Browse files Browse the repository at this point in the history
Added epc to daos_args_t and some supporting
functionality that paves the way for being able to pass
an epc through the command line in the future.

Signed-off-by: Dalton Bohning <daltonx.bohning@intel.com>
  • Loading branch information
Dalton Bohning authored and daltonbohning committed Jan 20, 2021
1 parent 650e81e commit f9c2b0f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
23 changes: 18 additions & 5 deletions src/common/mfu_daos.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,8 @@ daos_args_t* daos_args_new(void)
/* By default, try to automatically determine the API */
da->api = DAOS_API_AUTO;

da->epc = 0;

return da;
}

Expand Down Expand Up @@ -666,6 +668,18 @@ int daos_parse_api_str(
return rc;
}

int daos_parse_epc_str(
const char* epc_str,
daos_epoch_t* epc)
{
*epc = strtoull(epc_str, NULL, 10);
if (*epc == 0 || (*epc == ULLONG_MAX && errno != 0)) {
return 1;
}

return 0;
}

int daos_setup(
int rank,
char** argpaths,
Expand Down Expand Up @@ -1165,7 +1179,7 @@ static int daos_obj_copy(
return rc;
}

static int daos_obj_list_oids(daos_args_t* da, daos_epoch_t* epoch, mfu_flist bflist) {
static int daos_obj_list_oids(daos_args_t* da, mfu_flist bflist) {
/* List objects in src container to be copied to
* destination container */
static const int OID_ARR_SIZE = 50;
Expand All @@ -1177,7 +1191,7 @@ static int daos_obj_list_oids(daos_args_t* da, daos_epoch_t* epoch, mfu_flist bf
int rc = 0;

/* create snapshot to pass to object iterator table */
rc = daos_cont_create_snap_opt(da->src_coh, epoch, NULL,
rc = daos_cont_create_snap_opt(da->src_coh, &da->epc, NULL,
DAOS_SNAP_OPT_CR | DAOS_SNAP_OPT_OIT,
NULL);
if (rc != 0) {
Expand All @@ -1187,7 +1201,7 @@ static int daos_obj_list_oids(daos_args_t* da, daos_epoch_t* epoch, mfu_flist bf
}

/* open object iterator table */
rc = daos_oit_open(da->src_coh, *epoch, &toh, NULL);
rc = daos_oit_open(da->src_coh, da->epc, &toh, NULL);
if (rc != 0) {
MFU_LOG(MFU_LOG_ERR, "DAOS failed to open oit: ", MFU_ERRF,
MFU_ERRP(-MFU_ERR_DAOS));
Expand Down Expand Up @@ -1229,7 +1243,6 @@ static int daos_obj_list_oids(daos_args_t* da, daos_epoch_t* epoch, mfu_flist bf

int mfu_flist_walk_daos(
daos_args_t* da,
daos_epoch_t* epoch,
mfu_flist flist)
{
/* assume we'll succeed */
Expand All @@ -1241,7 +1254,7 @@ int mfu_flist_walk_daos(

/* have rank 0 do the work of listing the objects */
if (rank == 0) {
rc = daos_obj_list_oids(da, epoch, flist);
rc = daos_obj_list_oids(da, flist);
if (rc != 0) {
MFU_LOG(MFU_LOG_ERR, "DAOS failed to list oids: ",
MFU_ERRF, MFU_ERRP(-MFU_ERR_DAOS));
Expand Down
7 changes: 6 additions & 1 deletion src/common/mfu_daos.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ typedef struct {
char* src_path; /* allocated src path */
char* dst_path; /* allocated dst path */
daos_api_t api; /* API to use */
daos_epoch_t epc; /* src container epoch */
} daos_args_t;

/* Return a newly allocated daos_args_t structure.
Expand All @@ -48,6 +49,11 @@ int daos_parse_api_str(
const char* api_str,
daos_api_t* api);

/* Parse a string representation of the epoch */
int daos_parse_epc_str(
const char* epc_str,
daos_epoch_t* epc);

/* Setup DAOS arguments.
* Connect to pools.
* Open containers.
Expand All @@ -74,7 +80,6 @@ int daos_cleanup(
/* walk objects in daos and insert to given flist */
int mfu_flist_walk_daos(
daos_args_t* da,
daos_epoch_t* epoch,
mfu_flist flist
);

Expand Down
8 changes: 4 additions & 4 deletions src/dcp/dcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,7 @@ int main(int argc, char** argv)
else {
/* take a snapshot and walk container to get list of objects,
* returns epoch number of snapshot */
daos_epoch_t epoch;
int tmp_rc = mfu_flist_walk_daos(daos_args, &epoch, flist);
int tmp_rc = mfu_flist_walk_daos(daos_args, flist);
if (tmp_rc != 0) {
rc = 1;
}
Expand All @@ -491,10 +490,11 @@ int main(int argc, char** argv)
}

/* destroy snapshot after copy */
/* TODO consider moving this into mfu_flist_copy_daos */
if (rank == 0) {
daos_epoch_range_t epr;
epr.epr_lo = epoch;
epr.epr_hi = epoch;
epr.epr_lo = daos_args->epc;
epr.epr_hi = daos_args->epc;
rc = daos_cont_destroy_snap(daos_args->src_coh, epr, NULL);
if (rc != 0) {
MFU_LOG(MFU_LOG_ERR, "DAOS destroy snapshot failed: ", MFU_ERRF,
Expand Down

0 comments on commit f9c2b0f

Please sign in to comment.