From f18d11116c8a44a583178690de7076aabe00a25f Mon Sep 17 00:00:00 2001 From: Grzegorz Brzezinski Date: Thu, 24 Jan 2019 15:19:03 +0100 Subject: [PATCH 1/4] doc: update description of pmem_is_pmem function --- doc/libpmem/pmem_is_pmem.3.md | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/doc/libpmem/pmem_is_pmem.3.md b/doc/libpmem/pmem_is_pmem.3.md index 8ba7c68f0fb..d2976226821 100644 --- a/doc/libpmem/pmem_is_pmem.3.md +++ b/doc/libpmem/pmem_is_pmem.3.md @@ -7,7 +7,7 @@ header: PMDK date: pmem API version 1.1 ... -[comment]: <> (Copyright 2017, Intel Corporation) +[comment]: <> (Copyright 2017-2019, Intel Corporation) [comment]: <> (Redistribution and use in source and binary forms, with or without) [comment]: <> (modification, are permitted provided that the following conditions) @@ -75,15 +75,16 @@ responsibility for flushing stores to persistence will find the functions described in this section to be the most commonly used. The **pmem_is_pmem**() function detects if the entire range -\[*addr*, *addr*+*len*) consists of persistent memory. -The implementation of **pmem_is_pmem**() requires a non-trivial amount -of work to determine if the given range is entirely persistent memory. -For this reason, it is better to call **pmem_is_pmem**() once when a -range of memory is first encountered, save the result, and use the saved -result to determine whether **pmem_persist**(3) or **msync**(2) is -appropriate for flushing changes to persistence. Calling -**pmem_is_pmem**() each time changes are flushed to persistence will -not perform well. +\[*addr*, *addr*+*len*) consists of persistent memory. Calling this function +with a memory range that originates from a source different than +**pmem_map_file()** is undefined. The implementation of **pmem_is_pmem**() +requires a non-trivial amount of work to determine if the given range is +entirely persistent memory. For this reason, it is better to call +**pmem_is_pmem**() once when a range of memory is first encountered, +save the result, and use the saved result to determine whether +**pmem_persist**(3) or **msync**(2) is appropriate for flushing changes to +persistence. Calling **pmem_is_pmem**() each time changes are flushed to +persistence will not perform well. The _UW(pmem_map_file) function creates a new read/write mapping for a file. If **PMEM_FILE_CREATE** is not specified in *flags*, the entire existing From 1c6e223e3e80c367b093151b0b20b1a8e02dc17b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20=C5=9Alusarz?= Date: Sun, 27 Jan 2019 00:32:22 +0100 Subject: [PATCH 2/4] obj: fix pmemobj_tx_lock error handling Locking failure should NOT result in adding lock to transaction! --- src/libpmemobj/tx.c | 3 ++- src/test/obj_tx_lock/obj_tx_lock.c | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/libpmemobj/tx.c b/src/libpmemobj/tx.c index 907c53e7f63..71e0270e8b1 100644 --- a/src/libpmemobj/tx.c +++ b/src/libpmemobj/tx.c @@ -511,7 +511,8 @@ add_to_tx_and_lock(struct tx *tx, enum pobj_tx_param type, void *lock) break; } - SLIST_INSERT_HEAD(&tx->tx_locks, txl, tx_lock); + if (retval == 0) + SLIST_INSERT_HEAD(&tx->tx_locks, txl, tx_lock); return retval; } diff --git a/src/test/obj_tx_lock/obj_tx_lock.c b/src/test/obj_tx_lock/obj_tx_lock.c index 9e42a755cee..3e29e6d1e3d 100644 --- a/src/test/obj_tx_lock/obj_tx_lock.c +++ b/src/test/obj_tx_lock/obj_tx_lock.c @@ -141,6 +141,29 @@ do_tx_add_locks_nested_all(struct transaction_data *data) return NULL; } +/* + * do_tx_add_taken_lock -- (internal) verify that failed tx_lock doesn't add + * the lock to transaction + */ +static void * +do_tx_add_taken_lock(struct transaction_data *data) +{ + /* wrlocks on Windows don't detect self-deadlocks */ +#ifdef _WIN32 + (void) data; +#else + UT_ASSERTeq(pmemobj_rwlock_wrlock(Pop, &data->rwlocks[0]), 0); + + TX_BEGIN(Pop) { + UT_ASSERTne(pmemobj_tx_lock(TX_PARAM_RWLOCK, &data->rwlocks[0]), + 0); + } TX_END + + UT_ASSERTne(pmemobj_rwlock_trywrlock(Pop, &data->rwlocks[0]), 0); + UT_ASSERTeq(pmemobj_rwlock_unlock(Pop, &data->rwlocks[0]), 0); +#endif + return NULL; +} int main(int argc, char *argv[]) @@ -162,6 +185,7 @@ main(int argc, char *argv[]) do_tx_add_locks(test_obj); do_tx_add_locks_nested(test_obj); do_tx_add_locks_nested_all(test_obj); + do_tx_add_taken_lock(test_obj); pmemobj_close(Pop); From 4faa0931575119e467d47f8dd97e8119df0b2b1a Mon Sep 17 00:00:00 2001 From: Weronika Lewandowska Date: Wed, 30 Jan 2019 13:47:43 +0100 Subject: [PATCH 3/4] common: fix clang format version issue Ref: pmem/issues#1004 --- utils/docker/build-local.sh | 3 +-- utils/docker/build-travis.sh | 3 +-- utils/docker/images/Dockerfile.ubuntu-18.04 | 3 ++- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/utils/docker/build-local.sh b/utils/docker/build-local.sh index 1363bc237ae..9a4d1c49f24 100755 --- a/utils/docker/build-local.sh +++ b/utils/docker/build-local.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright 2017-2018, Intel Corporation +# Copyright 2017-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -115,7 +115,6 @@ docker run --privileged=true --name=$containerName -ti \ --env WORKDIR=$WORKDIR \ --env EXPERIMENTAL=$EXPERIMENTAL \ --env SCRIPTSDIR=$SCRIPTSDIR \ - --env CLANG_FORMAT=clang-format-6.0 \ --env KEEP_TEST_CONFIG=$KEEP_TEST_CONFIG \ $ndctl_enable \ -v $HOST_WORKDIR:$WORKDIR \ diff --git a/utils/docker/build-travis.sh b/utils/docker/build-travis.sh index f65f2e46f49..1ea5778a352 100755 --- a/utils/docker/build-travis.sh +++ b/utils/docker/build-travis.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright 2016-2018, Intel Corporation +# Copyright 2016-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -108,7 +108,6 @@ docker run --rm --privileged=true --name=$containerName -ti \ --env EXPERIMENTAL=$EXPERIMENTAL \ --env BUILD_PACKAGE_CHECK=$BUILD_PACKAGE_CHECK \ --env SCRIPTSDIR=$SCRIPTSDIR \ - --env CLANG_FORMAT=clang-format-6.0 \ --env TRAVIS=$TRAVIS \ --env TRAVIS_COMMIT_RANGE=$TRAVIS_COMMIT_RANGE \ --env TRAVIS_COMMIT=$TRAVIS_COMMIT \ diff --git a/utils/docker/images/Dockerfile.ubuntu-18.04 b/utils/docker/images/Dockerfile.ubuntu-18.04 index b65957b010f..37f317329a7 100644 --- a/utils/docker/images/Dockerfile.ubuntu-18.04 +++ b/utils/docker/images/Dockerfile.ubuntu-18.04 @@ -1,5 +1,5 @@ # -# Copyright 2016-2017, Intel Corporation +# Copyright 2016-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -44,6 +44,7 @@ RUN apt-get update \ autoconf \ bc \ clang \ + clang-format \ cmake \ debhelper \ devscripts \ From 95927d7fdcbc7776527aee3d851701b0fe6af1bb Mon Sep 17 00:00:00 2001 From: Piotr Balcer Date: Mon, 4 Feb 2019 12:28:01 +0100 Subject: [PATCH 4/4] obj: suppress pmemcheck warnings for statistics --- src/libpmemobj/stats.c | 3 +- src/test/obj_ctl_stats/TEST1 | 46 ++++++++++++++++++++++++++ src/test/obj_ctl_stats/obj_ctl_stats.c | 12 ++++++- 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100755 src/test/obj_ctl_stats/TEST1 diff --git a/src/libpmemobj/stats.c b/src/libpmemobj/stats.c index 3746b7429d5..7c2c15376af 100644 --- a/src/libpmemobj/stats.c +++ b/src/libpmemobj/stats.c @@ -1,5 +1,5 @@ /* - * Copyright 2017-2018, Intel Corporation + * Copyright 2017-2019, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -97,6 +97,7 @@ stats_new(PMEMobjpool *pop) struct stats *s = Malloc(sizeof(*s)); s->enabled = 0; s->persistent = &pop->stats_persistent; + VALGRIND_ADD_TO_GLOBAL_TX_IGNORE(s->persistent, sizeof(*s->persistent)); s->transient = Zalloc(sizeof(struct stats_transient)); if (s->transient == NULL) goto error_transient_alloc; diff --git a/src/test/obj_ctl_stats/TEST1 b/src/test/obj_ctl_stats/TEST1 new file mode 100755 index 00000000000..214b66b4846 --- /dev/null +++ b/src/test/obj_ctl_stats/TEST1 @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +# +# Copyright 2019, Intel Corporation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# * Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + + +# standard unit test setup +. ../unittest/unittest.sh + +require_test_type short +require_fs_type any +configure_valgrind pmemcheck force-enable + +setup + +expect_normal_exit ./obj_ctl_stats$EXESUFFIX $DIR/testfile1 + +pass diff --git a/src/test/obj_ctl_stats/obj_ctl_stats.c b/src/test/obj_ctl_stats/obj_ctl_stats.c index 25082558796..b25e790337b 100644 --- a/src/test/obj_ctl_stats/obj_ctl_stats.c +++ b/src/test/obj_ctl_stats/obj_ctl_stats.c @@ -1,5 +1,5 @@ /* - * Copyright 2017, Intel Corporation + * Copyright 2017-2019, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -82,6 +82,16 @@ main(int argc, char *argv[]) UT_ASSERTeq(ret, 0); UT_ASSERTeq(allocated, 0); + TX_BEGIN(pop) { + oid = pmemobj_tx_alloc(1, 0); + } TX_ONABORT { + UT_ASSERT(0); + } TX_END + oid_size = pmemobj_alloc_usable_size(oid) + 16; + ret = pmemobj_ctl_get(pop, "stats.heap.curr_allocated", &allocated); + UT_ASSERTeq(ret, 0); + UT_ASSERTeq(allocated, oid_size); + pmemobj_close(pop); DONE(NULL);