Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAOS-10417 ddb: Verify VOS Tree Paths #9213

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions src/ddb/ddb_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ddb_run_quit(struct ddb_ctx *ctx)
int
ddb_run_open(struct ddb_ctx *ctx, struct open_options *opt)
{
return ddb_vos_pool_open(opt->vos_pool_shard, &ctx->dc_poh);
return dv_pool_open(opt->vos_pool_shard, &ctx->dc_poh);
}

int ddb_run_close(struct ddb_ctx *ctx)
Expand All @@ -33,7 +33,7 @@ int ddb_run_close(struct ddb_ctx *ctx)
if (daos_handle_is_inval(ctx->dc_poh))
return 0;

rc = ddb_vos_pool_close(ctx->dc_poh);
rc = dv_pool_close(ctx->dc_poh);
ctx->dc_poh = DAOS_HDL_INVAL;

return rc;
Expand All @@ -59,7 +59,7 @@ init_path(daos_handle_t poh, char *path, struct dv_tree_path_builder *vtp)
if (!SUCCESS(rc))
return rc;

rc = dv_path_update_from_indexes(vtp);
rc = dv_path_verify(vtp);
if (!SUCCESS(rc))
return rc;
return 0;
Expand Down Expand Up @@ -418,7 +418,7 @@ ddb_run_rm(struct ddb_ctx *ctx, struct rm_options *opt)
int
ddb_run_load(struct ddb_ctx *ctx, struct load_options *opt)
{
struct dv_tree_path_builder vtpb;
struct dv_tree_path_builder pb;
d_iov_t iov = {0};
size_t file_size;
uint32_t epoch;
Expand All @@ -435,20 +435,25 @@ ddb_run_load(struct ddb_ctx *ctx, struct load_options *opt)
return -DER_INVAL;
}

rc = init_path(ctx->dc_poh, opt->dst, &vtpb);
rc = init_path(ctx->dc_poh, opt->dst, &pb);
if (rc == -DER_NONEXIST) {
/* It's okay that the path doesn't exist as long as the container does */
if (pb.vtp_cont_verified)
rc = 0;
}

if (!SUCCESS(rc)) {
ddb_error(ctx, "Invalid VOS path\n");
D_GOTO(done, rc);
}


if (!dvp_is_complete(&vtpb.vtp_path)) {
if (!dvp_is_complete(&pb.vtp_path)) {
ddb_error(ctx, "Invalid path");
D_GOTO(done, rc = -DER_INVAL);
}

vtp_print(ctx, &vtpb.vtp_path, true);
vtp_print(ctx, &pb.vtp_path, true);

if (!ctx->dc_io_ft.ddb_get_file_exists(opt->src)) {
ddb_errorf(ctx, "Unable to access '%s'\n", opt->src);
Expand All @@ -471,15 +476,15 @@ ddb_run_load(struct ddb_ctx *ctx, struct load_options *opt)
}
D_ASSERT(rc == iov.iov_buf_len && rc == iov.iov_len);

rc = dv_update(ctx->dc_poh, &vtpb.vtp_path, &iov, epoch);
rc = dv_update(ctx->dc_poh, &pb.vtp_path, &iov, epoch);
if (!SUCCESS(rc)) {
ddb_errorf(ctx, "Unable to update path: "DF_RC"\n", DP_RC(rc));
D_GOTO(done, rc);
}

done:
daos_iov_free(&iov);
ddb_vtp_fini(&vtpb);
ddb_vtp_fini(&pb);

if (SUCCESS(rc))
ddb_printf(ctx, "Successfully loaded file '%s'\n", opt->src);
Expand Down
14 changes: 14 additions & 0 deletions src/ddb/ddb_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ struct dv_tree_path {
daos_key_t vtp_dkey;
daos_key_t vtp_akey;
daos_recx_t vtp_recx;
bool vtp_is_recx;
};

/* Is used while parsing user input for building the vos tree path. The builder can use branch
Expand All @@ -133,15 +134,22 @@ struct dv_tree_path_builder {
uint8_t *vtp_dkey_buf;
uint8_t *vtp_akey_buf;

/* Used during the verification process */
uint32_t vtp_current_idx;
/*
* A user can pass an index of the path part. These indexes will be used to complete
* the path parts.
*/
uint32_t vtp_cont_idx;
bool vtp_cont_verified;
uint32_t vtp_oid_idx;
bool vtp_oid_verified;
uint32_t vtp_dkey_idx;
bool vtp_dkey_verified;
uint32_t vtp_akey_idx;
bool vtp_akey_verified;
uint32_t vtp_recx_idx;
bool vtp_recx_verified;
};

static inline bool
Expand Down Expand Up @@ -169,6 +177,12 @@ dv_has_akey(struct dv_tree_path *vtp)
return vtp->vtp_akey.iov_len > 0;
}

static inline bool
dv_has_recx(struct dv_tree_path *vtp)
{
return vtp->vtp_recx.rx_nr > 0;
}

static inline bool
dvp_is_complete(struct dv_tree_path *vtp)
{
Expand Down
4 changes: 2 additions & 2 deletions src/ddb/ddb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ ddb_main(struct ddb_io_ft *io_ft, int argc, char *argv[])
D_GOTO(done, rc);

if (str_has_value(pa.pa_pool_path)) {
rc = ddb_vos_pool_open(pa.pa_pool_path, &ctx.dc_poh);
rc = dv_pool_open(pa.pa_pool_path, &ctx.dc_poh);
if (!SUCCESS(rc))
D_GOTO(done, rc);
}
Expand All @@ -133,7 +133,7 @@ ddb_main(struct ddb_io_ft *io_ft, int argc, char *argv[])
snprintf(buf, buf_len, "%s %s", argv[0], pa.pa_r_cmd_run);
rc = ddb_str2argv_create(buf, &parse_args);
if (!SUCCESS(rc)) {
ddb_vos_pool_close(ctx.dc_poh);
dv_pool_close(ctx.dc_poh);
D_GOTO(done, rc);
}

Expand Down
Loading