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 */
5455static 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+
9991050int
10001051ddb_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
15941665void
@@ -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}
0 commit comments