diff --git a/.travis.yml b/.travis.yml index ad229315455d335cbae178457b5dabfc58f28c59..8555f333cd12a159a085e9f839d7bd7b1464ef4b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,7 @@ env: - OS=ubuntu_ndctl_v60 TEST_BUILD=debug - OS=ubuntu_ndctl_v60 PUSH_IMAGE=1 TEST_BUILD=nondebug - OS=fedora OS_VER=28 PMDK_CC=clang PMDK_CXX=clang++ TEST_BUILD=debug - - OS=fedora OS_VER=28 PMDK_CC=clang PMDK_CXX=clang++ TEST_BUILD=nondebug + - OS=fedora OS_VER=28 PMDK_CC=clang PMDK_CXX=clang++ TEST_BUILD=nondebug AUTO_DOC_UPDATE=1 - MAKE_PKG=1 EXPERIMENTAL=y REMOTE_TESTS=0 VALGRIND=0 NDCTL_ENABLE=n PUSH_IMAGE=1 - MAKE_PKG=1 EXPERIMENTAL=y REMOTE_TESTS=0 VALGRIND=0 PUSH_IMAGE=1 OS=fedora OS_VER=28 - MAKE_PKG=1 EXPERIMENTAL=y REMOTE_TESTS=0 VALGRIND=0 NDCTL_ENABLE=n PMDK_CC=clang PMDK_CXX=clang++ diff --git a/doc/generated/pmemobj_tx_begin.3 b/doc/generated/pmemobj_tx_begin.3 index 509b03e27460a752e88d22e376bdef82e3682b66..29b3d831766cc76da426e8fb2025c5f31a8af705 100644 --- a/doc/generated/pmemobj_tx_begin.3 +++ b/doc/generated/pmemobj_tx_begin.3 @@ -213,8 +213,8 @@ of type \f[I]lock_type\f[] and adds it to the current transaction. \f[I]PMEMmutex\f[] or \f[I]PMEMrwlock\f[], respectively. If \f[I]lock_type\f[] is \f[B]TX_LOCK_RWLOCK\f[] the lock is acquired for writing. -If the lock is not successfully acquired, the stage is changed to -\f[B]TX_STAGE_ONABORT\f[]. +If the lock is not successfully acquired, the function returns an error +number. This function must be called during \f[B]TX_STAGE_WORK\f[]. .PP \f[B]pmemobj_tx_abort\f[]() aborts the current transaction and causes a diff --git a/doc/generated/pmreorder.1 b/doc/generated/pmreorder.1 index a748c38a34a183a3c19241da1cae86e5c67af968..aff8b984f945ed8322831a29759094279334d4a6 100644 --- a/doc/generated/pmreorder.1 +++ b/doc/generated/pmreorder.1 @@ -233,7 +233,7 @@ engines. For this purpose, Valgrind's pmemcheck tool exposes a generic marker macro: .IP \[bu] 2 -\f[B]VALGRIND_EMIT_LOG(value)\f[] +\f[B]VALGRIND_PMC_EMIT_LOG(value)\f[] .PP It emits log to \f[I]store_log\f[] during pmemcheck processing. \f[I]value\f[] is a user\-defined marker name. @@ -248,11 +248,11 @@ main.c \&. \&. \&. -VALGRIND_EMIT_LOG("PMREORDER_MEMSET_PERSIST.BEGIN"); +VALGRIND_PMC_EMIT_LOG("PMREORDER_MEMSET_PERSIST.BEGIN"); pmem_memset_persist(...); -VALGRIND_EMIT_LOG("PMREORDER_MEMSET_PERSIST.END"); +VALGRIND_PMC_EMIT_LOG("PMREORDER_MEMSET_PERSIST.END"); \&. \&. \&. diff --git a/src/common/vecq.h b/src/common/vecq.h index 274bd15f920c8086c145693742f30952c6ecc0b3..034f4389f0e5eb38f9ef31b19225b3a2e9753e2c 100644 --- a/src/common/vecq.h +++ b/src/common/vecq.h @@ -90,29 +90,29 @@ struct name {\ ((vec)->back - (vec)->front) static inline int -vecq_grow(void *vec, size_t s) +realloc_set(void **buf, size_t s) { - VECQ(vvec, void) *vecp = (struct vvec *)vec; - size_t ncapacity = vecp->capacity == 0 ? - VECQ_INIT_SIZE : vecp->capacity * 2; - void *tbuf = Realloc(vecp->buffer, s * ncapacity); + void *tbuf = Realloc(*buf, s); if (tbuf == NULL) { ERR("!Realloc"); return -1; } - memcpy((char *)tbuf + (s * vecp->capacity), (char *)tbuf, - (s * VECQ_FRONT_POS(vecp))); - - vecp->front = VECQ_FRONT_POS(vecp); - vecp->back = vecp->front + vecp->capacity; - vecp->capacity = ncapacity; - vecp->buffer = tbuf; - + *buf = tbuf; return 0; } +#define VECQ_NCAPACITY(vec)\ +((vec)->capacity == 0 ? VECQ_INIT_SIZE : (vec)->capacity * 2) #define VECQ_GROW(vec)\ -vecq_grow((void *)vec, sizeof(*(vec)->buffer)) +(realloc_set((void **)&(vec)->buffer,\ + VECQ_NCAPACITY(vec) * sizeof(*(vec)->buffer)) ? -1 :\ + (memcpy((vec)->buffer + (vec)->capacity, (vec)->buffer,\ + VECQ_FRONT_POS(vec) * sizeof(*(vec)->buffer)),\ + (vec)->front = VECQ_FRONT_POS(vec),\ + (vec)->back = (vec)->front + (vec)->capacity,\ + (vec)->capacity = VECQ_NCAPACITY(vec),\ + 0\ +)) #define VECQ_INSERT(vec, element)\ (VECQ_BACK(vec) = element, (vec)->back += 1, 0) diff --git a/utils/check-doc.sh b/utils/check-doc.sh index d65004469a01baf5ab0cb1327f9ad66c7e2710c5..61d1937696e7be4fb8b71eb76349e9d415e7a3e9 100755 --- a/utils/check-doc.sh +++ b/utils/check-doc.sh @@ -39,7 +39,7 @@ # directory=doc/generated -allowed_user="Generic builder <nvml-bot@intel.com>" +allowed_user="pmem-bot <pmem-bot@intel.com>" if [[ -z "$TRAVIS" ]]; then echo "ERROR: $0 can only be executed on Travis CI." diff --git a/utils/docker/build-travis.sh b/utils/docker/build-travis.sh index 2b3c29e723e635d52ae2c6b22b39dc93a2770309..08d805992435e4f7ca708cc561b5b460489bec2b 100755 --- a/utils/docker/build-travis.sh +++ b/utils/docker/build-travis.sh @@ -39,6 +39,8 @@ set -e +source `dirname $0`/valid-branches.sh + if [[ "$TRAVIS_EVENT_TYPE" != "cron" && "$TRAVIS_BRANCH" != "coverity_scan" \ && "$COVERITY" -eq 1 ]]; then echo "INFO: Skip Coverity scan job if build is triggered neither by " \ @@ -85,6 +87,11 @@ if [ -n "$DNS_SERVER" ]; then DNS_SETTING=" --dns=$DNS_SERVER "; fi if [[ $SKIP_CHECK -eq 1 ]]; then BUILD_PACKAGE_CHECK=n; else BUILD_PACKAGE_CHECK=y; fi if [ -z "$NDCTL_ENABLE" ]; then ndctl_enable=; else ndctl_enable="--env NDCTL_ENABLE=$NDCTL_ENABLE"; fi +# Only run doc update on $GITHUB_REPO master or stable branch +if [[ ! "${VALID_BRANCHES[@]}" =~ "${TRAVIS_BRANCH}" || "$TRAVIS_PULL_REQUEST" != "false" || "$TRAVIS_REPO_SLUG" != "${GITHUB_REPO}" ]]; then + AUTO_DOC_UPDATE=0 +fi + WORKDIR=/pmdk SCRIPTSDIR=$WORKDIR/utils/docker @@ -97,6 +104,7 @@ docker run --rm --privileged=true --name=$containerName -ti \ $ci_env \ --env http_proxy=$http_proxy \ --env https_proxy=$https_proxy \ + --env AUTO_DOC_UPDATE=$AUTO_DOC_UPDATE \ --env CC=$PMDK_CC \ --env CXX=$PMDK_CXX \ --env VALGRIND=$VALGRIND \ @@ -114,6 +122,7 @@ docker run --rm --privileged=true --name=$containerName -ti \ --env TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG \ --env TRAVIS_BRANCH=$TRAVIS_BRANCH \ --env TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE \ + --env GITHUB_TOKEN=$GITHUB_TOKEN \ --env COVERITY_SCAN_TOKEN=$COVERITY_SCAN_TOKEN \ --env COVERITY_SCAN_NOTIFICATION_EMAIL=$COVERITY_SCAN_NOTIFICATION_EMAIL \ --env FAULT_INJECTION=$FAULT_INJECTION \ diff --git a/utils/docker/run-build.sh b/utils/docker/run-build.sh index c86b8711a172307c5f58ae0eb0ee56b5a76817e4..cb1c874313c0db0c42fc353eb2b2f7c543a24d78 100755 --- a/utils/docker/run-build.sh +++ b/utils/docker/run-build.sh @@ -50,3 +50,8 @@ make -j2 pcheck TEST_BUILD=$TEST_BUILD make -j2 pycheck make DESTDIR=/tmp source +# Create PR with generated docs +if [[ "$AUTO_DOC_UPDATE" == "1" ]]; then + echo "Running auto doc update" + ./utils/docker/run-doc-update.sh +fi diff --git a/utils/docker/run-doc-update.sh b/utils/docker/run-doc-update.sh new file mode 100755 index 0000000000000000000000000000000000000000..caa1c53d3ef58c285b948166a2d1327f67e7e37c --- /dev/null +++ b/utils/docker/run-doc-update.sh @@ -0,0 +1,108 @@ +#!/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. + +set -e + +source `dirname $0`/valid-branches.sh + +BOT_NAME="pmem-bot" +USER_NAME="pmem" +REPO_NAME="pmdk" + +ORIGIN="https://${GITHUB_TOKEN}@github.com/${BOT_NAME}/${REPO_NAME}" +UPSTREAM="https://github.com/${USER_NAME}/${REPO_NAME}" +# master or stable-* branch +TARGET_BRANCH=${TRAVIS_BRANCH} +VERSION=${TARGET_BRANCHES[$TARGET_BRANCH]} + +if [ -z $VERSION ]; then + echo "Target location for branch $TARGET_BRANCH is not defined." + exit 1 +fi + +# Clone bot repo +git clone ${ORIGIN} +cd ${REPO_NAME} +git remote add upstream ${UPSTREAM} + +git config --local user.name ${BOT_NAME} +git config --local user.email "pmem-bot@intel.com" + +git remote update +git checkout -B ${TARGET_BRANCH} upstream/${TARGET_BRANCH} + +make doc + +# Build & PR groff +git add -A +git commit -m "doc: automatic $TARGET_BRANCH docs update" && true +git push -f ${ORIGIN} ${TARGET_BRANCH} + +# Makes pull request. +# When there is already an open PR or there are no changes an error is thrown, which we ignore. +hub pull-request -f -b ${USER_NAME}:${TARGET_BRANCH} -h ${BOT_NAME}:${TARGET_BRANCH} -m "doc: automatic $TARGET_BRANCH docs update" && true + +git clean -dfx + +# Copy man & PR web md +cd ./doc +make web +cd .. + +mv ./doc/web_linux ../ +mv ./doc/web_windows ../ + +# Checkout gh-pages and copy docs +GH_PAGES_NAME="gh-pages-for-${TARGET_BRANCH}" +git checkout -B $GH_PAGES_NAME upstream/gh-pages +git clean -dfx + +rsync -a ../web_linux/ ./manpages/linux/${VERSION}/ +rsync -a ../web_windows/ ./manpages/windows/${VERSION}/ \ + --exclude='libvmmalloc' --exclude='librpmem' \ + --exclude='rpmemd' --exclude='pmreorder' \ + --exclude='daxio' + +rm -r ../web_linux +rm -r ../web_windows + +# Add and push changes. +# git commit command may fail if there is nothing to commit. +# In that case we want to force push anyway (there might be open pull request with +# changes which were reverted). +git add -A +git commit -m "doc: automatic gh-pages docs update" && true +git push -f ${ORIGIN} $GH_PAGES_NAME + +hub pull-request -f -b ${USER_NAME}:gh-pages -h ${BOT_NAME}:${GH_PAGES_NAME} -m "doc: automatic gh-pages docs update" && true + +exit 0 diff --git a/utils/docker/valid-branches.sh b/utils/docker/valid-branches.sh new file mode 100755 index 0000000000000000000000000000000000000000..6c8f21bc7d2f0b659a410d46b5bf330c1e9a7f0f --- /dev/null +++ b/utils/docker/valid-branches.sh @@ -0,0 +1,38 @@ +#!/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. + +VALID_BRANCHES=("master" "stable-1.5" "stable-1.6") + +declare -A TARGET_BRANCHES=( \ + ["master"]="master" \ + ["stable-1.5"]="v1.5" \ + ["stable-1.6"]="v1.6")