diff --git a/src/common/set.c b/src/common/set.c index c1df5b86fa9e33edd0c7f44e46e14994509d8518..1cbd12115deca3a1087303dc9811a489c8a4613f 100644 --- a/src/common/set.c +++ b/src/common/set.c @@ -1,5 +1,5 @@ /* - * Copyright 2015-2018, Intel Corporation + * Copyright 2015-2019, Intel Corporation * Copyright (c) 2016, Microsoft Corporation. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1469,12 +1469,14 @@ util_poolset_directories_load(struct pool_set *set) */ struct pool_replica *rep; struct pool_replica *mrep = set->replica[max_parts_rep]; + for (unsigned r = 0; r < set->nreplicas; r++) { if (set->replica[r]->nparts == mrep->nparts) continue; if (VEC_SIZE(&set->replica[r]->directory) == 0) { - ERR("no directories in replica"); + errno = ENOENT; + ERR("!no directories in replica"); return -1; } @@ -3937,6 +3939,12 @@ util_pool_open(struct pool_set **setp, const char *path, size_t minpartsize, return -1; } + if ((*setp)->replica[0]->nparts == 0) { + errno = ENOENT; + ERR("!no parts in replicas"); + return -1; + } + if (cow && (*setp)->replica[0]->part[0].is_dev_dax) { ERR("device dax cannot be mapped privately"); errno = ENOTSUP; diff --git a/src/test/util_poolset/TEST4 b/src/test/util_poolset/TEST4 index 1ad4c7de79a0b1abda521ddeac72d68fe8af2e55..01f626feae3406dcb9e5a08a852bdc68b3911f66 100755 --- a/src/test/util_poolset/TEST4 +++ b/src/test/util_poolset/TEST4 @@ -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 @@ -45,6 +45,8 @@ setup RESVSIZE=$((4 * 1024 * 1024 * 1024)) # 4GiB MIN_POOL=$((128 * 1024 * 1024)) # 128MiB +require_free_space $(( $MIN_POOL * 12 )) + export TEST_LOG_LEVEL=4 export TEST_LOG_FILE=./test$UNITTEST_NUM.log diff --git a/src/test/util_poolset/TEST4w.PS1 b/src/test/util_poolset/TEST4w.PS1 index 56925173e411b76c95164b406f15b530acfcd998..0f4be2b6f28d574ece65b0d12f9af09367748100 100644 --- a/src/test/util_poolset/TEST4w.PS1 +++ b/src/test/util_poolset/TEST4w.PS1 @@ -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 @@ -50,6 +50,9 @@ $MIN_POOL_STR = ${MIN_POOL}.toString() + "B" # 128MiB $RESVSIZE=4 * 1024 * 1024 * 1024 # 4GiB $RESVSIZE_STR = ${RESVSIZE}.toString() + "B" # 4GiB +$REQUIRE_POOL = ${MIN_POOL} * 12 +require_free_space "${REQUIRE_POOL}b" + create_poolset $DIR\testset1 ` ${RESVSIZE_STR}:$DIR\testdir11:d ` O SINGLEHDR diff --git a/src/test/util_poolset/TEST5 b/src/test/util_poolset/TEST5 index 9930819b8c7100739c91f2e3f9b5841bbadbcc12..74b6a429e10a17de420e78a46cd75548271b18be 100755 --- a/src/test/util_poolset/TEST5 +++ b/src/test/util_poolset/TEST5 @@ -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 @@ -45,6 +45,8 @@ setup RESVSIZE=$(((128 + 4) * 1024 * 1024)) MIN_POOL=$((128 * 1024 * 1024)) +require_free_space $(( $MIN_POOL * 15 )) + export TEST_LOG_LEVEL=4 export TEST_LOG_FILE=./test$UNITTEST_NUM.log @@ -72,7 +74,6 @@ expect_normal_exit ./util_poolset$EXESUFFIX c $MIN_POOL\ $DIR/testset2\ $DIR/testset3\ $DIR/testset4\ - $DIR/testset4\ $DIR/testset9 # now check if pool sets may be opened diff --git a/src/test/util_poolset/TEST5w.PS1 b/src/test/util_poolset/TEST5w.PS1 index 71c4838a3a54e2c323918d76b86363a8ea04dc80..5925cfc3666b64d1990787522b87ed9931e5ba3d 100644 --- a/src/test/util_poolset/TEST5w.PS1 +++ b/src/test/util_poolset/TEST5w.PS1 @@ -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 @@ -50,6 +50,9 @@ $MIN_POOL_STR = ${MIN_POOL}.toString() + "B" # 128MiB $RESVSIZE=(128 + 4) * 1024 * 1024 # initial part + extension $RESVSIZE_STR = ${RESVSIZE}.toString() + "B" # initial part + extension +$REQUIRE_POOL = ${MIN_POOL} * 15 +require_free_space "${REQUIRE_POOL}b" + create_poolset $DIR\testset1 ` ${RESVSIZE_STR}:$DIR\testdir11:d ` O SINGLEHDR diff --git a/src/test/util_poolset/TEST6 b/src/test/util_poolset/TEST6 index 8feb1c4e23463b5e026b242aa0606bf54aea512b..60a296ab4b68450cab98b18b4e2ceb53dc85bcc8 100755 --- a/src/test/util_poolset/TEST6 +++ b/src/test/util_poolset/TEST6 @@ -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 @@ -45,6 +45,8 @@ setup RESVSIZE=$((260 * 1024 * 1024)) # 264MiB (base part + 2 extends) MIN_POOL=$((128 * 1024 * 1024)) # 128MiB +require_free_space $(( $MIN_POOL * 8 )) + export TEST_LOG_LEVEL=4 export TEST_LOG_FILE=./test$UNITTEST_NUM.log diff --git a/src/test/util_poolset/TEST6w.PS1 b/src/test/util_poolset/TEST6w.PS1 index 07f43ce7e8d9718488a3208669a0b8dd37a6bed8..9e78544b61f6f43a249251d36816846574971683 100644 --- a/src/test/util_poolset/TEST6w.PS1 +++ b/src/test/util_poolset/TEST6w.PS1 @@ -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 @@ -50,6 +50,9 @@ $MIN_POOL_STR = ${MIN_POOL}.toString() + "B" # 128MiB $RESVSIZE=260 * 1024 * 1024 # 260 MiB $RESVSIZE_STR = ${RESVSIZE}.toString() + "B" # 260 MiB +$REQUIRE_POOL = ${MIN_POOL} * 8 +require_free_space "${REQUIRE_POOL}b" + # prepare pool sets create_poolset $DIR\testset2 ` ${RESVSIZE_STR}:$DIR\testdir21:d ${RESVSIZE_STR}:$DIR\testfile22 diff --git a/src/test/util_poolset/TEST7 b/src/test/util_poolset/TEST7 index 06710e6114736259d042c39bb3a2f6f5172b7b0b..46d12b3c07b36935ce928438e4d26c89418c17c3 100755 --- a/src/test/util_poolset/TEST7 +++ b/src/test/util_poolset/TEST7 @@ -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 @@ -47,6 +47,8 @@ setup RESVSIZE=$((4 * 1024 * 1024 * 1024)) # 4GiB MIN_POOL=$((128 * 1024 * 1024)) # 128MiB +require_free_space $(( $MIN_POOL * 6 )) + export TEST_LOG_LEVEL=4 export TEST_LOG_FILE=./test$UNITTEST_NUM.log diff --git a/src/test/util_poolset/TEST8 b/src/test/util_poolset/TEST8 new file mode 100755 index 0000000000000000000000000000000000000000..7be610e4767ea34c042e09d55f04f20b9119575b --- /dev/null +++ b/src/test/util_poolset/TEST8 @@ -0,0 +1,82 @@ +#!/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. +# + +# +# src/test/util_poolset/TEST8 -- unit test for util_pool_open() +# + +# standard unit test setup +. ../unittest/unittest.sh + +require_test_type medium +require_fs_type any + +setup + +RESVSIZE=$(((128 + 4) * 1024 * 1024)) +MIN_POOL=$((128 * 1024 * 1024)) + +export TEST_LOG_LEVEL=8 +export TEST_LOG_FILE=./test$UNITTEST_NUM.log + +# prepare pool sets +create_poolset $DIR/testset1\ + $RESVSIZE:$DIR/testdir11:d\ + O SINGLEHDR # pass +create_poolset $DIR/testset2\ + $RESVSIZE:$DIR/testdir21:d $RESVSIZE:$DIR/testdir22:d\ + O SINGLEHDR # pass +create_poolset $DIR/testset3\ + $RESVSIZE:$DIR/testdir31:d R $RESVSIZE:$DIR/testdir32:d\ + O SINGLEHDR # pass +create_poolset $DIR/testset4\ + $RESVSIZE:$DIR/testdir41:d $RESVSIZE:$DIR/testdir42:d\ + R $RESVSIZE:$DIR/testdir43:d $RESVSIZE:$DIR/testdir44:d\ + O SINGLEHDR # pass +create_poolset $DIR/testset9\ + $RESVSIZE:$DIR/testdir91:d R $RESVSIZE:$DIR/testdir91/testdir92:d\ + O SINGLEHDR # pass + +# should fail to open +expect_normal_exit ./util_poolset$EXESUFFIX o $MIN_POOL\ + $DIR/testset1\ + $DIR/testset2\ + $DIR/testset3\ + $DIR/testset4\ + $DIR/testset9 + +$GREP "<1>" $TEST_LOG_FILE | sed -e "s/^.*\][ ]*//g" > ./grep$UNITTEST_NUM.log + +check + +pass diff --git a/src/test/util_poolset/out8.log.match b/src/test/util_poolset/out8.log.match new file mode 100644 index 0000000000000000000000000000000000000000..041541f70b5c29f116aa9ba9dcb444d16fc621e0 --- /dev/null +++ b/src/test/util_poolset/out8.log.match @@ -0,0 +1,8 @@ +util_poolset$(nW)TEST8: START: util_poolset + ./util_poolset$(nW) o 134217728 $(nW)testset1 $(nW)testset2 $(nW)testset3 $(nW)testset4 $(nW)testset9 +$(nW)testset1: util_pool_open: No such file or directory +$(nW)testset2: util_pool_open: No such file or directory +$(nW)testset3: util_pool_open: No such file or directory +$(nW)testset4: util_pool_open: No such file or directory +$(nW)testset9: util_pool_open: No such file or directory +util_poolset$(nW)TEST8: DONE