Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3a2f099
DAOS-17322 ddb: DTX aggregation with ddb
kanard38 Sep 22, 2025
22ab8bf
DAOS-17322 ddb: DTX aggregation with ddb
kanard38 Apr 30, 2025
a329d20
Merge remote-tracking branch 'origin/master' into ckochhof/dev/master…
kanard38 Oct 1, 2025
c2b4bb7
DAOS-17322 ddb: DTX aggregation with ddb
kanard38 Oct 1, 2025
5e45d30
DAOS-17322 ddb: DTX aggregation with ddb
kanard38 Oct 2, 2025
4017abf
DAOS-17322 ddb: DTX aggregation with ddb
kanard38 Oct 2, 2025
81ed634
DAOS-17322 ddb: DTX aggregation with ddb
kanard38 Oct 2, 2025
bf83502
DAOS-17322 ddb: DTX aggregation with ddb
kanard38 Oct 3, 2025
663bff0
Merge remote-tracking branch 'origin/master' into ckochhof/dev/master…
kanard38 Oct 5, 2025
5a242a9
DAOS-17322 ddb: DTX aggregation with ddb
kanard38 Oct 5, 2025
bfd2588
Merge remote-tracking branch 'origin/master' into ckochhof/dev/master…
kanard38 Oct 7, 2025
f35e531
DAOS-17322 ddb: DTX aggregation with ddb
kanard38 Oct 7, 2025
20cb306
Merge remote-tracking branch 'origin/master' into ckochhof/dev/master…
kanard38 Oct 13, 2025
f474fcb
DAOS-17322 ddb: DTX aggregation with ddb
kanard38 Oct 13, 2025
7a36240
DAOS-17322 ddb: DTX aggregation with ddb
kanard38 Oct 13, 2025
98b381d
Merge remote-tracking branch 'origin/master' into ckochhof/dev/master…
kanard38 Oct 15, 2025
f798b07
DAOS-17322 ddb: DTX aggregation with ddb
kanard38 Oct 15, 2025
9ed9532
DAOS-17322 ddb: DTX aggregation with ddb
kanard38 Oct 15, 2025
a7bbda1
DAOS-17322 ddb: DTX aggregation with ddb
kanard38 Oct 16, 2025
2a604ef
DAOS-17322 ddb: DTX aggregation with ddb
kanard38 Oct 16, 2025
74a85bb
DAOS-17322 ddb: DTX aggregation with ddb
kanard38 Oct 16, 2025
9dfa864
Merge remote-tracking branch 'origin/master' into ckochhof/dev/master…
kanard38 Oct 17, 2025
c6ee641
DAOS-17322 ddb: DTX aggregation with ddb
kanard38 Oct 17, 2025
92d784d
Merge remote-tracking branch 'origin/master' into ckochhof/dev/master…
kanard38 Oct 17, 2025
12c8084
DAOS-17322 ddb: DTX aggregation with ddb
kanard38 Oct 17, 2025
643bef1
DAOS-17322 ddb: DTX aggregation with ddb
kanard38 Oct 17, 2025
ec9038c
DAOS-17322 ddb: DTX aggregation with ddb
kanard38 Oct 17, 2025
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
36 changes: 34 additions & 2 deletions src/control/cmd/ddb/commands_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
package main

import (
"math"
"runtime"
"unsafe"

"github.com/daos-stack/daos/src/control/lib/daos"
"github.com/daos-stack/daos/src/control/logging"
)

/*
Expand All @@ -36,7 +38,7 @@ func freeString(s *C.char) {
}

// InitDdb initializes the ddb context and returns a closure to finalize it.
func InitDdb() (*DdbContext, func(), error) {
func InitDdb(log *logging.LeveledLogger) (*DdbContext, func(), error) {
// Must lock to OS thread because vos init/fini uses ABT init and finalize which must be called on the same thread
runtime.LockOSThread()

Expand All @@ -47,6 +49,7 @@ func InitDdb() (*DdbContext, func(), error) {

ctx := &DdbContext{}
C.ddb_ctx_init(&ctx.ctx) // Initialize with ctx default values
ctx.log = log

return ctx, func() {
C.ddb_fini()
Expand All @@ -57,6 +60,7 @@ func InitDdb() (*DdbContext, func(), error) {
// DdbContext structure for wrapping the C code context structure
type DdbContext struct {
ctx C.struct_ddb_ctx
log *logging.LeveledLogger
}

func ddbPoolIsOpen(ctx *DdbContext) bool {
Expand Down Expand Up @@ -296,10 +300,11 @@ func ddbDevReplace(ctx *DdbContext, db_path string, old_devid string, new_devid
return daosError(C.ddb_run_dev_replace(&ctx.ctx, &options))
}

func ddbDtxStat(ctx *DdbContext, path string) error {
func ddbDtxStat(ctx *DdbContext, path string, details bool) error {
/* Set up the options */
options := C.struct_dtx_stat_options{}
options.path = C.CString(path)
options.details = C.bool(details)
defer freeString(options.path)
/* Run the c code command */
return daosError(C.ddb_run_dtx_stat(&ctx.ctx, &options))
Expand All @@ -317,3 +322,30 @@ func ddbProvMem(ctx *DdbContext, db_path string, tmpfs_mount string, tmpfs_mount
/* Run the c code command */
return daosError(C.ddb_run_prov_mem(&ctx.ctx, &options))
}

func ddbDtxAggr(ctx *DdbContext, path string, cmt_time uint64, cmt_date string) error {
if cmt_time != math.MaxUint64 && cmt_date != "" {
ctx.log.Error("'--cmt_time' and '--cmt_date' options are mutually exclusive")
return daosError(-C.DER_INVAL)
}
if cmt_time == math.MaxUint64 && cmt_date == "" {
ctx.log.Error("'--cmt_time' or '--cmt_date' option has to be defined")
return daosError(-C.DER_INVAL)
}

/* Set up the options */
options := C.struct_dtx_aggr_options{}
options.path = C.CString(path)
defer freeString(options.path)
if cmt_time != math.MaxUint64 {
options.format = C.DDB_DTX_AGGR_CMT_TIME
options.cmt_time = C.uint64_t(cmt_time)
}
if cmt_date != "" {
options.format = C.DDB_DTX_AGGR_CMT_DATE
options.cmt_date = C.CString(cmt_date)
defer freeString(options.cmt_date)
}
/* Run the c code command */
return daosError(C.ddb_run_dtx_aggr(&ctx.ctx, &options))
}
28 changes: 26 additions & 2 deletions src/control/cmd/ddb/ddb_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
package main

import (
"math"

"github.com/desertbit/grumble"
)

Expand Down Expand Up @@ -391,11 +393,14 @@ the path must include the extent, otherwise, it must not.`,
Help: "Stat on DTX entries",
LongHelp: "Print statistic on the DTX entries",
HelpGroup: "vos",
Flags: func(a *grumble.Flags) {
a.Bool("d", "details", false, "Show detailed time related stats.")
},
Args: func(a *grumble.Args) {
a.String("path", "Optional, VOS tree path to query.", grumble.Default(""))
a.String("path", "Optional, VOS tree path of a container to query.", grumble.Default(""))
},
Run: func(c *grumble.Context) error {
return ddbDtxStat(ctx, c.Args.String("path"))
return ddbDtxStat(ctx, c.Args.String("path"), c.Flags.Bool("details"))
},
Completer: nil,
})
Expand All @@ -418,4 +423,23 @@ the path must include the extent, otherwise, it must not.`,
},
Completer: nil,
})
// Command dtx_aggr
app.AddCommand(&grumble.Command{
Name: "dtx_aggr",
Aliases: nil,
Help: "Aggregate DTX entries",
LongHelp: "Aggregate DTX entries until a given aggregation commit time or date",
HelpGroup: "vos",
Args: func(a *grumble.Args) {
a.String("path", "Optional, VOS tree path of a container to aggregate.", grumble.Default(""))
},
Flags: func(f *grumble.Flags) {
f.Uint64("t", "cmt_time", math.MaxUint64, "Max aggregfation committed time in seconds")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor, typo

Suggested change
f.Uint64("t", "cmt_time", math.MaxUint64, "Max aggregfation committed time in seconds")
f.Uint64("t", "cmt_time", math.MaxUint64, "Max aggregation committed time in seconds")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor, typo

I am going to fix it in a follow-up PR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor, typo

Fixed with PR #17022

f.String("d", "cmt_date", "", "Max aggregation committed date (format '1970-01-01 00:00:00')")
},
Run: func(c *grumble.Context) error {
return ddbDtxAggr(ctx, c.Args.String("path"), c.Flags.Uint64("cmt_time"), c.Flags.String("cmt_date"))
},
Completer: nil,
})
}
4 changes: 2 additions & 2 deletions src/control/cmd/ddb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ type ddbCmdStr string

func (cmdStr ddbCmdStr) Complete(match string) (comps []flags.Completion) {
// hack to get at command names
ctx, cleanup, err := InitDdb()
ctx, cleanup, err := InitDdb(nil)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it OK to pass nil here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, the associated complete function are indeed never using the log attributes.
I agree, that it is not very nice but it is the only way that I found to pass the log object for the standard call of InitDB().

if err != nil {
return
}
Expand Down Expand Up @@ -176,7 +176,7 @@ Example Paths:
log.Debug("debug output enabled")
}

ctx, cleanup, err := InitDdb()
ctx, cleanup, err := InitDdb(log)
if err != nil {
return errors.Wrap(err, "Error initializing the DDB Context")
}
Expand Down
4 changes: 2 additions & 2 deletions src/dtx/dtx_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,8 @@ dtx_aggregate(void *arg)
struct dtx_stat stat = { 0 };
int rc;

rc = vos_dtx_aggregate(cont->sc_hdl);
if (rc != 0)
rc = vos_dtx_aggregate(cont->sc_hdl, NULL);
if (rc < 0)
break;

ABT_thread_yield();
Expand Down
7 changes: 6 additions & 1 deletion src/dtx/tests/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def scons():
tenv.AppendUnique(LINKFLAGS=['-Wl,--wrap=vos_irec_is_valid'])
tenv.AppendUnique(LINKFLAGS=['-Wl,--wrap=evt_desc_is_valid'])
tenv.AppendUnique(LINKFLAGS=['-Wl,--wrap=dbtree_lookup'])
tenv.AppendUnique(LINKFLAGS=['-Wl,--wrap=vos_tls_get'])
tenv.AppendUnique(LINKFLAGS=['-Wl,--wrap=lrua_array_aggregate'])
tenv.AppendUnique(LINKFLAGS=['-Wl,--wrap=dbtree_delete'])
tenv.AppendUnique(LINKFLAGS=['-Wl,--wrap=d_tm_dec_gauge'])

vos_src = Glob('../../vos/*.c')

Expand All @@ -61,7 +65,8 @@ def scons():
'sched_mock.c',
'srv_mock.c',
'srv_module_mock.c',
'dts_count.c'
'dts_cmt_stat.c',
'dts_aggregate.c'
]
dtx_ut = tenv.d_program('dtx_ut', test_src + vos_src, LIBS=libraries)

Expand Down
Loading
Loading