Skip to content

Commit 3465843

Browse files
kanard38knard38
authored andcommitted
DAOS-17321 ddb: Checksum management with ddb
First commit. Signed-off-by: Cedric Koch-Hofer <[email protected]>
1 parent f42142f commit 3465843

File tree

16 files changed

+857
-59
lines changed

16 files changed

+857
-59
lines changed

site_scons/prereq_tools/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ def __init__(self, env, opts):
518518
opts.Add(EnumVariable('WARNING_LEVEL', "Set default warning level", 'error',
519519
['warning', 'warn', 'error'], ignorecase=2))
520520
opts.Add(('SANITIZERS', 'Instrument C code with google sanitizers', None))
521+
opts.Add(BoolVariable('CMOCKA_FILTER_SUPPORTED', 'Allows to filter cmocka tests', False))
521522

522523
opts.Update(self.__env)
523524

site_scons/site_tools/compiler_setup.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def _base_setup(env):
5454

5555
# Turn on -Wall first, then DESIRED_FLAGS may disable some of the options
5656
# that this brings in.
57-
env.Append(CCFLAGS=['-g', '-Wextra', '-Wshadow', '-Wall', '-fpic'])
57+
env.Append(CCFLAGS=['-g3', '-Wextra', '-Wshadow', '-Wall', '-fpic'])
5858

5959
env.AppendIfSupported(CCFLAGS=DESIRED_FLAGS)
6060

@@ -106,7 +106,10 @@ def _base_setup(env):
106106
env.AppendUnique(CPPDEFINES={'FAULT_INJECTION': '1'})
107107
env.AppendUnique(CPPDEFINES={'BUILD_PIPELINE': '1'})
108108

109-
env.AppendUnique(CPPDEFINES={'CMOCKA_FILTER_SUPPORTED': '0'})
109+
if env['CMOCKA_FILTER_SUPPORTED']:
110+
env.AppendUnique(CPPDEFINES={'CMOCKA_FILTER_SUPPORTED': '1'})
111+
else:
112+
env.AppendUnique(CPPDEFINES={'CMOCKA_FILTER_SUPPORTED': '0'})
110113

111114
env.AppendUnique(CPPDEFINES='_GNU_SOURCE')
112115

src/control/cmd/ddb/commands_wrapper.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,3 +349,15 @@ func ddbDtxAggr(ctx *DdbContext, path string, cmt_time uint64, cmt_date string)
349349
/* Run the c code command */
350350
return daosError(C.ddb_run_dtx_aggr(&ctx.ctx, &options))
351351
}
352+
353+
func ddbCsumDump(ctx *DdbContext, path string, dst string, epoch uint64) error {
354+
/* Set up the options */
355+
options := C.struct_csum_dump_options{}
356+
options.path = C.CString(path)
357+
defer freeString(options.path)
358+
options.dst = C.CString(dst)
359+
defer freeString(options.dst)
360+
options.epoch = C.uint64_t(epoch)
361+
/* Run the c code command */
362+
return daosError(C.ddb_run_csum_dump(&ctx.ctx, &options))
363+
}

src/control/cmd/ddb/ddb_commands.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,4 +442,28 @@ the path must include the extent, otherwise, it must not.`,
442442
},
443443
Completer: nil,
444444
})
445+
// Command csum_dump
446+
app.AddCommand(&grumble.Command{
447+
Name: "csum_dump",
448+
Aliases: nil,
449+
Help: "Dump visible checksum(s)",
450+
LongHelp: `Dump visible checksum(s) to the screen or in a file. The vos
451+
path should be a complete path, including the akey and if the value is an array
452+
value it should include the extent. If a path to a file was provided then the
453+
value(s) will be written to the file, else it will be printed to the screen.
454+
With array values it is possible to define the maximal epoch of the visible record
455+
extent to select`,
456+
HelpGroup: "vos",
457+
Args: func(a *grumble.Args) {
458+
a.String("path", "VOS tree path to dump.")
459+
a.String("dst", "Optional, destination vos tree path to a value.", grumble.Default(""))
460+
},
461+
Flags: func(f *grumble.Flags) {
462+
f.Uint64("e", "epoch", math.MaxUint64, "Maximal epoch of the visible array value to select (default EPOCH_MAX).")
463+
},
464+
Run: func(c *grumble.Context) error {
465+
return ddbCsumDump(ctx, c.Args.String("path"), c.Args.String("dst"), c.Flags.Uint64("epoch"))
466+
},
467+
Completer: nil,
468+
})
445469
}

src/include/daos_srv/vos.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,16 @@ vos_obj_fetch_ex(daos_handle_t coh, daos_unit_oid_t oid, daos_epoch_t epoch,
723723
uint64_t flags, daos_key_t *dkey, unsigned int iod_nr,
724724
daos_iod_t *iods, d_sg_list_t *sgls, struct dtx_handle *dth);
725725

726+
// FIXME DAOS-17321 -- Old checksum fetch API, to be removed later
727+
#if 0
728+
/**
729+
* TODO DAOS-17321
730+
*/
731+
int
732+
vos_csum_fetch(daos_handle_t coh, daos_key_t *dkey, daos_unit_oid_t oid, daos_iod_t *iod,
733+
struct daos_recx_ep_list *rel, struct dcs_ci_list *cil);
734+
#endif
735+
726736
/**
727737
* Update records for the specified object.
728738
* If input buffer is not provided in \a sgl, then this function returns
@@ -905,6 +915,7 @@ vos_obj_mark_corruption(daos_handle_t coh, daos_epoch_t epoch, uint32_t pm_ver,
905915
* I/O and release resources.
906916
*
907917
* TODO: add more detail descriptions for punched or missing records.
918+
* TODO DAOS-17321 -- Add description for csum handling.
908919
*
909920
* \param[in] coh Container open handle
910921
* \param[in] oid Object ID

src/include/daos_srv/vos_types.h

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -258,49 +258,51 @@ typedef enum {
258258

259259
enum {
260260
/** Conditional Op: Punch key if it exists, fail otherwise */
261-
VOS_OF_COND_PUNCH = DAOS_COND_PUNCH,
261+
VOS_OF_COND_PUNCH = DAOS_COND_PUNCH,
262262
/** Conditional Op: Insert dkey if it doesn't exist, fail otherwise */
263-
VOS_OF_COND_DKEY_INSERT = DAOS_COND_DKEY_INSERT,
263+
VOS_OF_COND_DKEY_INSERT = DAOS_COND_DKEY_INSERT,
264264
/** Conditional Op: Update dkey if it exists, fail otherwise */
265-
VOS_OF_COND_DKEY_UPDATE = DAOS_COND_DKEY_UPDATE,
265+
VOS_OF_COND_DKEY_UPDATE = DAOS_COND_DKEY_UPDATE,
266266
/** Conditional Op: Fetch dkey if it exists, fail otherwise */
267-
VOS_OF_COND_DKEY_FETCH = DAOS_COND_DKEY_FETCH,
267+
VOS_OF_COND_DKEY_FETCH = DAOS_COND_DKEY_FETCH,
268268
/** Conditional Op: Insert akey if it doesn't exist, fail otherwise */
269-
VOS_OF_COND_AKEY_INSERT = DAOS_COND_AKEY_INSERT,
269+
VOS_OF_COND_AKEY_INSERT = DAOS_COND_AKEY_INSERT,
270270
/** Conditional Op: Update akey if it exists, fail otherwise */
271-
VOS_OF_COND_AKEY_UPDATE = DAOS_COND_AKEY_UPDATE,
271+
VOS_OF_COND_AKEY_UPDATE = DAOS_COND_AKEY_UPDATE,
272272
/** Conditional Op: Fetch akey if it exists, fail otherwise */
273-
VOS_OF_COND_AKEY_FETCH = DAOS_COND_AKEY_FETCH,
273+
VOS_OF_COND_AKEY_FETCH = DAOS_COND_AKEY_FETCH,
274274
/** Indicates akey conditions are specified in iod_flags */
275-
VOS_OF_COND_PER_AKEY = DAOS_COND_PER_AKEY,
275+
VOS_OF_COND_PER_AKEY = DAOS_COND_PER_AKEY,
276276
/* critical update - skip checks on SCM system/held space */
277-
VOS_OF_CRIT = (1 << 8),
277+
VOS_OF_CRIT = (1 << 8),
278278
/** Instead of update or punch of extents, remove all extents
279279
* under the specified range. Intended for internal use only.
280280
*/
281-
VOS_OF_REMOVE = (1 << 9),
281+
VOS_OF_REMOVE = (1 << 9),
282282
/* only query iod_size */
283-
VOS_OF_FETCH_SIZE_ONLY = (1 << 10),
283+
VOS_OF_FETCH_SIZE_ONLY = (1 << 10),
284284
/* query recx list */
285-
VOS_OF_FETCH_RECX_LIST = (1 << 11),
285+
VOS_OF_FETCH_RECX_LIST = (1 << 11),
286286
/* only set read TS */
287-
VOS_OF_FETCH_SET_TS_ONLY = (1 << 12),
287+
VOS_OF_FETCH_SET_TS_ONLY = (1 << 12),
288288
/* check the target (obj/dkey/akey) existence */
289-
VOS_OF_FETCH_CHECK_EXISTENCE = (1 << 13),
289+
VOS_OF_FETCH_CHECK_EXISTENCE = (1 << 13),
290290
/** Set when propagating a punch that results in empty subtree */
291-
VOS_OF_PUNCH_PROPAGATE = (1 << 14),
291+
VOS_OF_PUNCH_PROPAGATE = (1 << 14),
292292
/** replay punch (underwrite) */
293-
VOS_OF_REPLAY_PC = (1 << 15),
293+
VOS_OF_REPLAY_PC = (1 << 15),
294294
/** Dedup update mode */
295-
VOS_OF_DEDUP = (1 << 16),
295+
VOS_OF_DEDUP = (1 << 16),
296296
/** Dedup update with memcmp verify mode */
297-
VOS_OF_DEDUP_VERIFY = (1 << 17),
297+
VOS_OF_DEDUP_VERIFY = (1 << 17),
298298
/** Ignore fetch only used by shadow fetch to ignore the evt fetch */
299-
VOS_OF_SKIP_FETCH = (1 << 18),
299+
VOS_OF_SKIP_FETCH = (1 << 18),
300300
/** Operation on EC object (currently only applies to update) */
301-
VOS_OF_EC = (1 << 19),
301+
VOS_OF_EC = (1 << 19),
302302
/** Update from rebuild */
303-
VOS_OF_REBUILD = (1 << 20),
303+
VOS_OF_REBUILD = (1 << 20),
304+
/* only query iod_size */
305+
VOS_OF_FETCH_CSUM = (1 << 21),
304306
};
305307

306308
enum {

src/utils/ddb/SConscript

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ def scons():
5555
ddblib = denv.d_library('ddb', src, LIBS=libs)
5656
denv.Install('$PREFIX/lib64/daos_srv/', ddblib)
5757

58+
# FIXME DAOS-17321 -- Conditional build for ddb legacies
59+
ddbexe = denv.d_program('ddb_leg', src + ['ddb_entry.c'], LIBS=libs)
60+
denv.Install('$PREFIX/bin', ddbexe)
61+
5862
# tests
5963
SConscript('tests/SConscript', exports=['denv'])
6064

src/utils/ddb/ddb.c

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#define COMMAND_NAME_DTX_STAT "dtx_stat"
5050
#define COMMAND_NAME_PROV_MEM "prov_mem"
5151
#define COMMAND_NAME_DTX_AGGR "dtx_aggr"
52+
#define COMMAND_NAME_CSUM_DUMP "csum_dump"
5253

5354
/* Parse command line options for the 'ls' command */
5455
static int
@@ -996,6 +997,56 @@ dtx_aggr_option_parse(struct ddb_ctx *ctx, struct dtx_aggr_options *cmd_args, ui
996997
return 0;
997998
}
998999

1000+
/* Parse command line options for the 'dtx_aggr' command */
1001+
static int
1002+
csum_dump_option_parse(struct ddb_ctx *ctx, struct csum_dump_options *cmd_args, uint32_t argc,
1003+
char **argv)
1004+
{
1005+
int opt;
1006+
char *options_short = "e:";
1007+
int index = 0;
1008+
char *endptr;
1009+
struct option options_long[] = {{"epoch", required_argument, NULL, 'e'}, {NULL}};
1010+
1011+
memset(cmd_args, 0, sizeof(*cmd_args));
1012+
1013+
/* Restart getopt */
1014+
optind = 1;
1015+
opterr = 0;
1016+
cmd_args->epoch = DAOS_EPOCH_MAX;
1017+
while ((opt = getopt_long(argc, argv, options_short, options_long, &index)) != -1) {
1018+
switch (opt) {
1019+
case 'e':
1020+
errno = 0;
1021+
cmd_args->epoch = strtoull(optarg, &endptr, 10);
1022+
if (errno != 0 || endptr == optarg || *endptr != '\0') {
1023+
ddb_error(ctx, "'--epoch' option arg format is invalid\n");
1024+
return -DER_INVAL;
1025+
}
1026+
break;
1027+
case '?':
1028+
ddb_printf(ctx, "Unknown option: '%c'\n", optopt);
1029+
break;
1030+
default:
1031+
return -DER_INVAL;
1032+
}
1033+
}
1034+
1035+
index = optind;
1036+
cmd_args->path = NULL;
1037+
if (argc - index > 0 && *argv[index] != '\0') {
1038+
cmd_args->path = argv[index];
1039+
index++;
1040+
}
1041+
1042+
if (argc - index > 0) {
1043+
ddb_errorf(ctx, "Unexpected argument: %s\n", argv[index]);
1044+
return -DER_INVAL;
1045+
}
1046+
1047+
return 0;
1048+
}
1049+
9991050
int
10001051
ddb_parse_cmd_args(struct ddb_ctx *ctx, uint32_t argc, char **argv, struct ddb_cmd_info *info)
10011052
{
@@ -1132,6 +1183,11 @@ ddb_parse_cmd_args(struct ddb_ctx *ctx, uint32_t argc, char **argv, struct ddb_c
11321183
return dtx_aggr_option_parse(ctx, &info->dci_cmd_option.dci_dtx_aggr, argc, argv);
11331184
}
11341185

1186+
if (same(cmd, COMMAND_NAME_CSUM_DUMP)) {
1187+
info->dci_cmd = DDB_CMD_CSUM_DUMP;
1188+
return csum_dump_option_parse(ctx, &info->dci_cmd_option.dci_csum_dump, argc, argv);
1189+
}
1190+
11351191
ddb_errorf(ctx,
11361192
"'%s' is not a valid command. Available commands are:"
11371193
"'help', "
@@ -1160,7 +1216,8 @@ ddb_parse_cmd_args(struct ddb_ctx *ctx, uint32_t argc, char **argv, struct ddb_c
11601216
"'dev_replace', "
11611217
"'dtx_stat', "
11621218
"'prov_mem', "
1163-
"'dtx_aggr'\n",
1219+
"'dtx_aggr', "
1220+
"'csum_dump'\n",
11641221
cmd);
11651222

11661223
return -DER_INVAL;
@@ -1348,6 +1405,10 @@ ddb_run_cmd(struct ddb_ctx *ctx, const char *cmd_str)
13481405
rc = ddb_run_dtx_aggr(ctx, &info.dci_cmd_option.dci_dtx_aggr);
13491406
break;
13501407

1408+
case DDB_CMD_CSUM_DUMP:
1409+
rc = ddb_run_csum_dump(ctx, &info.dci_cmd_option.dci_csum_dump);
1410+
break;
1411+
13511412
case DDB_CMD_UNKNOWN:
13521413
ddb_error(ctx, "Unknown command\n");
13531414
rc = -DER_INVAL;
@@ -1579,7 +1640,7 @@ ddb_commands_help(struct ddb_ctx *ctx)
15791640
ddb_print(ctx, "\n");
15801641

15811642
/* Command: dtx_aggr */
1582-
ddb_print(ctx, "dtx_aggr [path]\n");
1643+
ddb_print(ctx, "dtx_aggr [Options] [path]\n");
15831644
ddb_print(ctx, "\tAggregate DTX entries until a given timestamp or duration.\n");
15841645
ddb_print(ctx, " [path]\n");
15851646
ddb_print(ctx, "\tOptional, VOS tree path of a container to aggregate.\n");
@@ -1589,6 +1650,16 @@ ddb_commands_help(struct ddb_ctx *ctx)
15891650
ddb_print(ctx, " -d, --cmt_date\n");
15901651
ddb_print(ctx, "\tMax aggregation commit date (format '1970-01-01 00:00:00')\n");
15911652
ddb_print(ctx, "\n");
1653+
1654+
/* Command: csum_dump */
1655+
ddb_print(ctx, "csum_dump [Options] <path>\n");
1656+
ddb_print(ctx, "\tDump visible checksum(s) information until a given epoch.\n");
1657+
ddb_print(ctx, " [path]\n");
1658+
ddb_print(ctx, "\tComplete VOS tree path to a Single Value or to an Array Extent.\n");
1659+
ddb_print(ctx, "Options:\n");
1660+
ddb_print(ctx, " -e, --epoch\n");
1661+
ddb_print(ctx, "\tMax epoch to dump checksum(s) information (default MAX_EPOCH).\n");
1662+
ddb_print(ctx, "\n");
15921663
}
15931664

15941665
void
@@ -1661,4 +1732,5 @@ ddb_program_help(struct ddb_ctx *ctx)
16611732
ddb_print(ctx, " dtx_stat Stat on DTX entries\n");
16621733
ddb_print(ctx, " prov_mem Prepare memory environment for md-on-ssd mode.\n");
16631734
ddb_print(ctx, " dtx_aggr Aggregate DTX entries\n");
1735+
ddb_print(ctx, " csum_dump Dump checksum information\n");
16641736
}

src/utils/ddb/ddb.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ enum ddb_cmd {
126126
DDB_CMD_DTX_STAT = 26,
127127
DDB_CMD_PROV_MEM = 27,
128128
DDB_CMD_DTX_AGGR = 28,
129+
DDB_CMD_CSUM_DUMP = 29,
129130
};
130131

131132
/* option and argument structures for commands that need them */
@@ -236,6 +237,12 @@ struct dtx_aggr_options {
236237
char *cmt_date;
237238
};
238239

240+
struct csum_dump_options {
241+
char *path;
242+
char *dst;
243+
daos_epoch_t epoch;
244+
};
245+
239246
struct ddb_cmd_info {
240247
enum ddb_cmd dci_cmd;
241248
union {
@@ -259,6 +266,7 @@ struct ddb_cmd_info {
259266
struct dtx_stat_options dci_dtx_stat;
260267
struct prov_mem_options dci_prov_mem;
261268
struct dtx_aggr_options dci_dtx_aggr;
269+
struct csum_dump_options dci_csum_dump;
262270
} dci_cmd_option;
263271
};
264272

@@ -330,6 +338,8 @@ int
330338
ddb_run_prov_mem(struct ddb_ctx *ctx, struct prov_mem_options *opt);
331339
int
332340
ddb_run_dtx_aggr(struct ddb_ctx *ctx, struct dtx_aggr_options *opt);
341+
int
342+
ddb_run_csum_dump(struct ddb_ctx *ctx, struct csum_dump_options *opt);
333343

334344
void
335345
ddb_program_help(struct ddb_ctx *ctx);

0 commit comments

Comments
 (0)