Skip to content

Commit

Permalink
DAOS-623 vos: Add visible iterator option to vos command line (#14653)
Browse files Browse the repository at this point in the history
For VOS command test, add a visible iterator option so
one can manually verify that VOS iterates correctly for
that case.

Signed-off-by: Jeff Olivier <jeffolivier@google.com>
  • Loading branch information
jolivier23 authored Jul 29, 2024
1 parent 96a95b8 commit 53d96f4
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/vos/tests/vos_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ free_pool(struct known_pool *pool)
ACTION(AGGREGATE, aggregate, true, 1) \
ACTION(DISCARD, discard, true, 0) \
ACTION(ITERATE, iterate, true, 0) \
ACTION(VISIBLE_ITERATE, visible_iterate, true, 0) \
ACTION(SIZE_QUERY, print_size, true, 0) \
ACTION(RANDOMIZE, run_many_tests, true, 0)

Expand Down Expand Up @@ -478,7 +479,7 @@ iter_cb(daos_handle_t ih, vos_iter_entry_t *entry, vos_iter_type_t type, vos_ite
}

static int
iterate(struct cmd_info *cinfo)
iterate_common(struct cmd_info *cinfo, bool visible)
{
struct vos_iter_anchors anchors = {0};
vos_iter_param_t param = {0};
Expand All @@ -489,7 +490,9 @@ iterate(struct cmd_info *cinfo)
set_oid(&param.ip_oid);
param.ip_epr.epr_lo = 0;
param.ip_epr.epr_hi = d_hlc_get();
param.ip_flags = VOS_IT_RECX_VISIBLE | VOS_IT_RECX_COVERED;
param.ip_flags = VOS_IT_RECX_VISIBLE;
if (!visible)
param.ip_flags |= VOS_IT_RECX_COVERED;

rc = vos_iterate(&param, VOS_ITER_DKEY, true, &anchors, iter_cb, NULL, &count, NULL);
if (rc != 0) {
Expand All @@ -501,6 +504,18 @@ iterate(struct cmd_info *cinfo)
return rc;
}

static int
iterate(struct cmd_info *cinfo)
{
return iterate_common(cinfo, false);
}

static int
visible_iterate(struct cmd_info *cinfo)
{
return iterate_common(cinfo, true);
}

int
write_key(struct cmd_info *cinfo)
{
Expand Down Expand Up @@ -945,6 +960,7 @@ run_vos_command(const char *arg0, const char *cmd)
{"write", required_argument, 0, 'w'},
{"punch_range", required_argument, 0, 'P'},
{"iterate", required_argument, 0, 'i'},
{"visible_iterate", required_argument, 0, 'I'},
{"remove", required_argument, 0, 'R'},
{"punch", required_argument, 0, 'p'},
{"aggregate", no_argument, 0, 'a'},
Expand Down Expand Up @@ -977,7 +993,7 @@ run_vos_command(const char *arg0, const char *cmd)

optind = 1;

while ((c = getopt_long(args.a_nr, args.a_argv, "c:o:dw:p:ahrsP:R:ix:A:D", long_options,
while ((c = getopt_long(args.a_nr, args.a_argv, "c:o:dw:p:ahrsP:R:iIx:A:D", long_options,
&option_index)) != -1) {
cinfo = &args.a_cmds[args.a_cmd_nr];
switch (c) {
Expand All @@ -991,6 +1007,10 @@ run_vos_command(const char *arg0, const char *cmd)
cinfo->type = ITERATE;
args.a_cmd_nr++;
break;
case 'I':
cinfo->type = VISIBLE_ITERATE;
args.a_cmd_nr++;
break;
case 'c':
cinfo->type = CREATE_POOL;
strncpy(cinfo->key, optarg, MAX_KEY_LEN);
Expand Down

0 comments on commit 53d96f4

Please sign in to comment.