Skip to content

Commit

Permalink
DAOS-16951 dtx: add invalid records discard capability
Browse files Browse the repository at this point in the history
Priority: 2
Required-githooks: true

Signed-off-by: Jan Michalski <[email protected]>
  • Loading branch information
janekmi committed Jan 21, 2025
1 parent 0be2d10 commit dc392b6
Show file tree
Hide file tree
Showing 34 changed files with 1,735 additions and 210 deletions.
16 changes: 14 additions & 2 deletions src/control/cmd/ddb/commands_wrapper.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//
// (C) Copyright 2022-2024 Intel Corporation.
// (C) Copyright 2025 Hewlett Packard Enterprise Development LP.
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
Expand Down Expand Up @@ -204,7 +205,7 @@ func ddbVeaUpdate(ctx *DdbContext, offset string, blk_cnt string) error {

func ddbDtxActCommit(ctx *DdbContext, path string, dtx_id string) error {
/* Set up the options */
options := C.struct_dtx_act_commit_options{}
options := C.struct_dtx_act_options{}
options.path = C.CString(path)
defer freeString(options.path)
options.dtx_id = C.CString(dtx_id)
Expand All @@ -215,7 +216,7 @@ func ddbDtxActCommit(ctx *DdbContext, path string, dtx_id string) error {

func ddbDtxActAbort(ctx *DdbContext, path string, dtx_id string) error {
/* Set up the options */
options := C.struct_dtx_act_abort_options{}
options := C.struct_dtx_act_options{}
options.path = C.CString(path)
defer freeString(options.path)
options.dtx_id = C.CString(dtx_id)
Expand Down Expand Up @@ -256,3 +257,14 @@ func ddbRmPool(ctx *DdbContext, path string) error {
/* Run the c code command */
return daosError(C.ddb_run_rm_pool(&ctx.ctx, &options))
}

func ddbDtxActDiscardInvalid(ctx *DdbContext, path string, dtx_id string) error {
/* Set up the options */
options := C.struct_dtx_act_options{}
options.path = C.CString(path)
defer freeString(options.path)
options.dtx_id = C.CString(dtx_id)
defer freeString(options.dtx_id)
/* Run the c code command */
return daosError(C.ddb_run_dtx_act_discard_invalid(&ctx.ctx, &options))
}
17 changes: 17 additions & 0 deletions src/control/cmd/ddb/ddb_commands.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//
// (C) Copyright 2022-2024 Intel Corporation.
// (C) Copyright 2025 Hewlett Packard Enterprise Development LP.
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
Expand Down Expand Up @@ -332,4 +333,20 @@ the path must include the extent, otherwise, it must not.`,
},
Completer: rmPoolCompleter,
})
// Command: dtx_act_discard_invalid
app.AddCommand(&grumble.Command{
Name: "dtx_act_discard_invalid",
Aliases: nil,
Help: "Discard the active DTX entry's records if invalid.",
LongHelp: "Committing or aborting the DTX entry with discarded records may result in inconsistencies. Allow DTX to resync instead.",
HelpGroup: "vos",
Args: func(a *grumble.Args) {
a.String("path", "VOS tree path to a container.")
a.String("dtx_id", "DTX id of the entry to validate.")
},
Run: func(c *grumble.Context) error {
return ddbDtxActDiscardInvalid(ctx, c.Args.String("path"), c.Args.String("dtx_id"))
},
Completer: nil,
})
}
31 changes: 29 additions & 2 deletions src/dtx/tests/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ def scons():
"""Execute build"""
Import('denv', 'vts_objs')

# build dtx_tests

libraries = ['abt', 'bio', 'dtx', 'vos', 'gurt', 'daos_common_pmem', 'cmocka', 'pthread',
'uuid', 'cart', 'daos_tests']

Expand All @@ -19,10 +21,35 @@ def scons():

test_src = ['dtx_tests.c', 'sched_mock.c', 'ult_mock.c', 'srv_mock.c', 'pl_map_mock.c',
'../../common/tls.c', 'dts_utils.c', 'dts_local.c', 'dts_local_rdb.c',
'dts_structs.c', vts_objs]
vts_objs]
dtx_tests = tenv.d_program('dtx_tests', test_src, LIBS=libraries)

tenv.Install('$PREFIX/bin/', [dtx_tests])
# build dtx_ut

libraries = ['abt', 'bio', 'cmocka', 'daos_common_pmem', 'gurt', 'uuid', 'vea']

tenv = denv.Clone()
tenv.Append(CPPPATH=[Dir('../../vos').srcnode()])
tenv.require('pmdk')
tenv.AppendUnique(RPATH_FULL=['$PREFIX/lib64/daos_srv'])
tenv.Append(OBJPREFIX="c_")

# Required for vos_dtx_discard_invalid() tests.
# These functions are validated by their respective unit tests.
tenv.AppendUnique(LINKFLAGS=['-Wl,--wrap=ilog_is_valid'])
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'])

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

test_src = ['dtx_ut.c', 'dts_discard_invalid.c', 'dts_structs.c',
'srv_mock.c', 'sched_mock.c']
dtx_ut = tenv.d_program('dtx_ut', test_src + vos_src, LIBS=libraries)

# install both

tenv.Install('$PREFIX/bin/', [dtx_tests, dtx_ut])


if __name__ == "SCons.Script":
Expand Down
Loading

0 comments on commit dc392b6

Please sign in to comment.