Skip to content

Commit

Permalink
Merge pull request #4947 from pbalcer/obj-chunk-header-fix-1.7
Browse files Browse the repository at this point in the history
obj: fix pmreorder and two existing failure atomicity bugs
  • Loading branch information
lplewa authored Aug 26, 2020
2 parents 9f5cef3 + a5e5bfb commit bebbe8a
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/libpmemobj/heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -928,11 +928,11 @@ heap_split_block(struct palloc_heap *heap, struct bucket *b,
uint32_t new_chunk_id = m->chunk_id + units;
uint32_t new_size_idx = m->size_idx - units;

*m = memblock_huge_init(heap, m->chunk_id, m->zone_id, units);

struct memory_block n = memblock_huge_init(heap,
new_chunk_id, m->zone_id, new_size_idx);

*m = memblock_huge_init(heap, m->chunk_id, m->zone_id, units);

if (bucket_insert_block(b, &n) != 0)
LOG(2,
"failed to allocate memory block runtime tracking info");
Expand Down
10 changes: 10 additions & 0 deletions src/libpmemobj/memops.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ operation_transient_clean(void *base, const void *addr, size_t len,
return 0;
}

/*
* operation_transient_drain -- noop
*/
static void
operation_transient_drain(void *base)
{
}

/*
* operation_transient_memcpy -- transient memcpy wrapper
*/
Expand Down Expand Up @@ -210,10 +218,12 @@ operation_new(struct ulog *ulog, size_t ulog_base_nbytes,
ctx->t_ops.base = NULL;
ctx->t_ops.flush = operation_transient_clean;
ctx->t_ops.memcpy = operation_transient_memcpy;
ctx->t_ops.drain = operation_transient_drain;

ctx->s_ops.base = p_ops->base;
ctx->s_ops.flush = operation_transient_clean;
ctx->s_ops.memcpy = operation_transient_memcpy;
ctx->s_ops.drain = operation_transient_drain;

VECQ_INIT(&ctx->merge_entries);

Expand Down
3 changes: 2 additions & 1 deletion src/libpmemobj/tx.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2019, Intel Corporation
* Copyright 2015-2020, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -411,6 +411,7 @@ tx_abort_set(PMEMobjpool *pop, struct lane *lane)

ulog_foreach_entry((struct ulog *)&lane->layout->undo,
tx_undo_entry_apply, NULL, &pop->p_ops);
pmemops_drain(&pop->p_ops);
operation_finish(lane->undo, ULOG_INC_FIRST_GEN_NUM);
}

Expand Down
2 changes: 2 additions & 0 deletions src/libpmemobj/ulog.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <string.h>

#include "libpmemobj.h"
#include "pmemops.h"
#include "ulog.h"
#include "out.h"
#include "util.h"
Expand Down Expand Up @@ -815,6 +816,7 @@ ulog_process(struct ulog *ulog, ulog_check_offset_fn check,
#endif

ulog_foreach_entry(ulog, ulog_process_entry, NULL, p_ops);
pmemops_drain(p_ops);
}

/*
Expand Down
8 changes: 4 additions & 4 deletions src/test/obj_persist_count/out1.log.match
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ obj_persist_count$(nW)TEST1: START: obj_persist_count
task cl(all) drain(all) pmem_persist pmem_msync pmem_flush pmem_drain pmem_memcpy_cls pmem_memcpy_drain pmem_memset_cls pmem_memset_drain potential_cache_misses
$(OPT)pool_create 49282 14 11 0 0 0 0 0 11 3 49275
$(OPX)pool_create 49602 24 11 5 0 5 0 0 11 3 49595
root_alloc 9 4 0 0 3 1 4 2 2 1 5
root_alloc 9 5 0 0 3 2 4 2 2 1 5
atomic_alloc 2 2 1 0 0 1 1 0 0 0 1
atomic_free 1 2 1 0 0 1 0 0 0 0 1
tx_begin_end 0 2 0 0 0 2 0 0 0 0 0
Expand All @@ -13,10 +13,10 @@ tx_free 1 1 1 0 0 0
tx_free_next 1 1 1 0 0 0 0 0 0 0 1
tx_add 3 3 1 0 0 1 1 0 1 1 1
tx_add_next 3 3 1 0 0 1 1 0 1 1 1
tx_add_large 178 13 6 0 4 3 165 2 3 2 10
tx_add_large 178 14 6 0 4 4 165 2 3 2 10
tx_add_lnext 164 5 1 0 0 2 161 0 2 2 1
pmalloc 6 3 0 0 2 1 4 2 0 0 2
pfree 5 3 0 0 2 1 3 2 0 0 2
pmalloc 6 4 0 0 2 2 4 2 0 0 2
pfree 5 4 0 0 2 2 3 2 0 0 2
pmalloc_stack 2 2 1 0 0 1 1 0 0 0 1
pfree_stack 1 2 1 0 0 1 0 0 0 0 1
obj_persist_count$(nW)TEST1: DONE
10 changes: 8 additions & 2 deletions src/test/obj_reorder_basic/obj_reorder_basic.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018, Intel Corporation
* Copyright 2018-2020, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -99,10 +99,16 @@ main(int argc, char *argv[])
if (argc != 3 || strchr("wc", argv[1][0]) == 0 || argv[1][1] != '\0')
UT_FATAL("usage: %s w|c file", argv[0]);

char opt = argv[1][0];
if (opt == 'c') {
int y = 1;
pmemobj_ctl_set(NULL, "copy_on_write.at_open", &y);
}

PMEMobjpool *pop = pmemobj_open(argv[2], LAYOUT_NAME);
UT_ASSERT(pop != NULL);

char opt = argv[1][0];

VALGRIND_EMIT_LOG("PMREORDER_MARKER_WRITE.BEGIN");
switch (opt) {
case 'w':
Expand Down
4 changes: 2 additions & 2 deletions src/test/unittest/unittest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3482,7 +3482,7 @@ function pmreorder_run_tool()
#
function pmreorder_expect_success()
{
ret=$(pmreorder_run_tool "$@")
ret=$(pmreorder_run_tool "$@" | tail -n1)

if [ "$ret" -ne "0" ]; then
msg=$(interactive_red STDERR "failed with exit code $ret")
Expand All @@ -3504,7 +3504,7 @@ function pmreorder_expect_success()
#
function pmreorder_expect_failure()
{
ret=$(pmreorder_run_tool "$@")
ret=$(pmreorder_run_tool "$@" | tail -n1)

if [ "$ret" -eq "0" ]; then
msg=$(interactive_red STDERR "succeeded")
Expand Down

0 comments on commit bebbe8a

Please sign in to comment.