Skip to content

Commit

Permalink
DAOS-3114 vos: Consolidate timestamp cache APIs (#3200)
Browse files Browse the repository at this point in the history
Simplify the timestamp cache some by consolidating APIs. There is now one
API for checking for conflicts and one API for updating the read timestamps.
This is preparation for adding more read timestamp updates for iteration
and query APIs and for adding epoch uncertainty checks. More simplification
is probably needed but this is a step in that direction.

Update the mvcc test to enable same transaction tests. A few changes were
required for this to work

*Change the code so that it only calls vts_dtx_begin/end/commit/abort once
per transaction and uses sequence number.
*Disable 5 cases that require the punch model change patch that is
blocked by a rebuild bug.
*Fixes a bug that was clearing the uuids in the timestamp cache
*Disable cases where the first operation is a failing conditional update
or punch in the same transaction. These cases require more work in
*VOS to support
*Encapsulate vos_publish/cancel inside of vos_tx_end
*Defer free for same transaction overwrites
*Add full dtx_id to timestamps for comparisons

Signed-off-by: Jeff Olivier <[email protected]>
  • Loading branch information
jolivier23 authored and SABollinger committed Nov 11, 2020
1 parent 88fbcb8 commit 0fd7fb7
Show file tree
Hide file tree
Showing 28 changed files with 907 additions and 658 deletions.
2 changes: 1 addition & 1 deletion ci/patch_src_in_place
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

# shellcheck disable=SC2046,SC2035
codespell -w --ignore-words-list nd,uint,ths,ba,creat,te,cas,mapp,pres,crashers,dout,tre,reord,mimick,cloneable,keypair,bject,tread,cancelled --builtin clear,rare,informal,names,en-GB_to_en-US --skip *.png,*.PNG,*.pyc,src/rdb/raft/*,src/control/vendor/*,RSA.golden $(git ls-tree --full-tree --name-only HEAD)
codespell -w --ignore-words-list dedup,nd,uint,ths,ba,creat,te,cas,mapp,pres,crashers,dout,tre,reord,mimick,cloneable,keypair,bject,tread,cancelled --builtin clear,rare,informal,names,en-GB_to_en-US --skip *.png,*.PNG,*.pyc,src/rdb/raft/*,src/control/vendor/*,RSA.golden $(git ls-tree --full-tree --name-only HEAD)

# The return code of codespell is the number of works it could not correct
# because of multiple options. We could report on these but they're rare
Expand Down
2 changes: 1 addition & 1 deletion ci/unit/test_main_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This is a script to be run by the unit/test_main.sh to run a test
# on a CI node.

set -ex
set -x

sudo bash -c 'echo 1 > /proc/sys/kernel/sysrq'
if grep /mnt/daos\ /proc/mounts; then
Expand Down
10 changes: 10 additions & 0 deletions src/common/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,15 @@ pmem_tx_commit(struct umem_instance *umm)
return rc ? umem_tx_errno(rc) : 0;
}

static void
pmem_defer_free(struct umem_instance *umm, umem_off_t off,
struct pobj_action *act)
{
PMEMoid id = umem_off2id(umm, off);

pmemobj_defer_free(umm->umm_pool, id, act);
}

static umem_off_t
pmem_reserve(struct umem_instance *umm, struct pobj_action *act, size_t size,
unsigned int type_num)
Expand Down Expand Up @@ -359,6 +368,7 @@ static umem_ops_t pmem_ops = {
.mo_tx_begin = pmem_tx_begin,
.mo_tx_commit = pmem_tx_commit,
.mo_reserve = pmem_reserve,
.mo_defer_free = pmem_defer_free,
.mo_cancel = pmem_cancel,
.mo_tx_publish = pmem_tx_publish,
.mo_tx_add_callback = pmem_tx_add_callback,
Expand Down
2 changes: 1 addition & 1 deletion src/container/cli_internal.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2016 Intel Corporation.
* (C) Copyright 2016-2020 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
15 changes: 2 additions & 13 deletions src/dtx/dtx_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,23 +313,13 @@ dtx_handle_init(struct dtx_id *dti, daos_handle_t coh, struct dtx_epoch *epoch,
dth->dth_modification_cnt = sub_modification_cnt;

dth->dth_op_seq = 0;
dth->dth_rsrvd_cnt = 0;
dth->dth_oid_cnt = 0;
dth->dth_oid_cap = 0;
dth->dth_oid_array = NULL;

dth->dth_dkey_hash = 0;

if (sub_modification_cnt <= 1) {
dth->dth_rsrvds = &dth->dth_rsrvd_inline;
return 0;
}

D_ALLOC_ARRAY(dth->dth_rsrvds, sub_modification_cnt);
if (dth->dth_rsrvds == NULL)
return -DER_NOMEM;

return 0;
return vos_dtx_rsrvd_init(dth);
}

static int
Expand Down Expand Up @@ -764,8 +754,7 @@ dtx_leader_end(struct dtx_leader_handle *dlh, struct ds_cont_child *cont,
D_FREE(dlh->dlh_subs);
D_FREE(dth->dth_oid_array);

if (dth->dth_rsrvds != &dth->dth_rsrvd_inline)
D_FREE(dth->dth_rsrvds);
vos_dtx_rsrvd_fini(dth);

return result;
}
Expand Down
3 changes: 2 additions & 1 deletion src/dtx/dtx_internal.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2019 Intel Corporation.
* (C) Copyright 2019-2020 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -117,4 +117,5 @@ int dtx_abort(uuid_t po_uuid, uuid_t co_uuid, daos_epoch_t epoch,
struct dtx_entry **dtes, int count);
int dtx_check(uuid_t po_uuid, uuid_t co_uuid, struct dtx_entry *dte);


#endif /* __DTX_INTERNAL_H__ */
26 changes: 26 additions & 0 deletions src/include/daos/mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,18 @@ typedef struct {
struct pobj_action *act, size_t size,
unsigned int type_num);

/**
* Defer free til commit. For use with reserved extents that are not
* yet published. For VMEM, it just calls free.
*
* \param umm [IN] umem class instance.
* \param off [IN] offset of allocation
* \param act [IN|OUT] action used for later cancel/publish.
*/
void (*mo_defer_free)(struct umem_instance *umm,
umem_off_t off,
struct pobj_action *act);

/**
* Cancel the reservation.
*
Expand Down Expand Up @@ -494,6 +506,20 @@ umem_reserve(struct umem_instance *umm, struct pobj_action *act, size_t size)
return UMOFF_NULL;
}

static inline void
umem_defer_free(struct umem_instance *umm, umem_off_t off,
struct pobj_action *act)
{
if (umm->umm_ops->mo_defer_free)
return umm->umm_ops->mo_defer_free(umm, off, act);

/** Go ahead and free immediately. The purpose of this function
* is to allow reserve/publish pair to execute on commit
*/
umem_free(umm, off);
}


static inline void
umem_cancel(struct umem_instance *umm, struct pobj_action *actv, int actv_cnt)
{
Expand Down
2 changes: 1 addition & 1 deletion src/include/daos_obj_class.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2015-2019 Intel Corporation.
* (C) Copyright 2015-2020 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
4 changes: 3 additions & 1 deletion src/include/daos_srv/dtx_srv.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ struct dtx_handle {
/** The flags, see dtx_entry_flags. */
uint32_t dth_flags;
/** The count of reserved items in the dth_rsrvds array. */
uint32_t dth_rsrvd_cnt;
uint16_t dth_rsrvd_cnt;
uint16_t dth_deferred_cnt;
/** The total sub modifications count. */
uint16_t dth_modification_cnt;
/** Modification sequence in the distributed transaction. */
Expand All @@ -105,6 +106,7 @@ struct dtx_handle {

struct dtx_rsrvd_uint dth_rsrvd_inline;
struct dtx_rsrvd_uint *dth_rsrvds;
void **dth_deferred;
};

/* Each sub transaction handle to manage each sub thandle */
Expand Down
17 changes: 17 additions & 0 deletions src/include/daos_srv/vos.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@
#include <daos_srv/dtx_srv.h>
#include <daos_srv/vos_types.h>

/** Initialize the vos reserve/cancel related fields in dtx handle
*
* \param dth [IN] The dtx handle
*
* \return 0 on success
* -DER_NOMEM on failure
*/
int
vos_dtx_rsrvd_init(struct dtx_handle *dth);

/** Finalize the vos reserve/cancel related fields in dtx handle
*
* \param dth [IN] The dtx handle
*/
void
vos_dtx_rsrvd_fini(struct dtx_handle *dth);

/**
* Check the specified DTX's status, and related epoch, pool map version
* information if required.
Expand Down
2 changes: 1 addition & 1 deletion src/tests/suite/daos_test.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2016-2019 Intel Corporation.
* (C) Copyright 2016-2020 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
5 changes: 3 additions & 2 deletions src/vos/tests/vts_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ vts_dtx_begin_ex(const daos_unit_oid_t *oid, daos_handle_t coh,
dth = *dthp;

dth->dth_modification_cnt = nmods;
D_ALLOC_ARRAY(dth->dth_rsrvds, nmods);
assert_ptr_not_equal(dth->dth_rsrvds, NULL);

/** first call in vts_dtx_begin will have set this to inline */
assert_int_equal(vos_dtx_rsrvd_init(dth), 0);
}

void
Expand Down
7 changes: 3 additions & 4 deletions src/vos/tests/vts_dtx.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,21 @@ vts_dtx_begin(const daos_unit_oid_t *oid, daos_handle_t coh, daos_epoch_t epoch,
dth->dth_modification_cnt = 1;

dth->dth_op_seq = 1;
dth->dth_rsrvd_cnt = 0;
dth->dth_oid_cnt = 0;
dth->dth_oid_cap = 0;
dth->dth_oid_array = NULL;

dth->dth_dkey_hash = dkey_hash;
dth->dth_rsrvds = &dth->dth_rsrvd_inline;

vos_dtx_rsrvd_init(dth);

*dthp = dth;
}

void
vts_dtx_end(struct dtx_handle *dth)
{
if (dth->dth_modification_cnt > 1)
D_FREE(dth->dth_rsrvds);
vos_dtx_rsrvd_fini(dth);
D_FREE(dth->dth_dte.dte_mbs);
D_FREE_PTR(dth);
}
Expand Down
Loading

0 comments on commit 0fd7fb7

Please sign in to comment.