]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: incorrect MAX AVAIL in "ceph df" 17724/head
authorliuchang0812 <liuchang0812@gmail.com>
Wed, 6 Sep 2017 03:50:17 +0000 (11:50 +0800)
committerAbhishek Lekshmanan <abhishek@suse.com>
Thu, 14 Sep 2017 09:29:44 +0000 (11:29 +0200)
Fixes: http://tracker.ceph.com/issues/21243
Signed-off-by: liuchang0812 <liuchang0812@gmail.com>
(cherry picked from commit 365558571c59dd42cf0934e6c31c7b4bf2c65026)

qa/standalone/mon/osd-pool-df.sh [new file with mode: 0755]
qa/standalone/mon/test_pool_quota.sh
src/mon/PGMap.cc
src/test/mon/PGMap.cc

diff --git a/qa/standalone/mon/osd-pool-df.sh b/qa/standalone/mon/osd-pool-df.sh
new file mode 100755 (executable)
index 0000000..3ed169d
--- /dev/null
@@ -0,0 +1,75 @@
+#!/usr/bin/env bash
+#
+# Copyright (C) 2017 Tencent <contact@tencent.com>
+#
+# Author: Chang Liu <liuchang0812@gmail.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Library Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Library Public License for more details.
+#
+source $CEPH_ROOT/qa/standalone/ceph-helpers.sh
+
+function run() {
+    local dir=$1
+    shift
+
+    export CEPH_MON="127.0.0.1:7113" # git grep '\<7113\>' : there must be only one
+    export CEPH_ARGS
+    CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
+    CEPH_ARGS+="--mon-host=$CEPH_MON "
+
+    local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
+    for func in $funcs ; do
+        setup $dir || return 1
+        $func $dir || return 1
+        teardown $dir || return 1
+    done
+}
+
+function TEST_ceph_df() {
+    local dir=$1
+    setup $dir || return 1
+
+    run_mon $dir a || return 1
+    run_osd $dir 0 || return 1
+    run_osd $dir 1 || return 1
+    run_osd $dir 2 || return 1
+    run_osd $dir 3 || return 1
+    run_osd $dir 4 || return 1
+    run_osd $dir 5 || return 1
+    run_mgr $dir x || return 1
+
+    profile+=" plugin=jerasure"
+    profile+=" technique=reed_sol_van"
+    profile+=" k=4"
+    profile+=" m=2"
+    profile+=" crush-failure-domain=osd"
+
+    ceph osd erasure-code-profile set ec42profile ${profile}
+    local rep_poolname=testcephdf_replicate
+    local ec_poolname=testcephdf_erasurecode
+    create_pool $rep_poolname 6 6 replicated
+    create_pool $ec_poolname 6 6 erasure ec42profile
+
+    local global_avail=`ceph df -f json | jq '.stats.total_avail_bytes'`
+    local rep_avail=`ceph df -f json | jq '.pools | map(select(.name == "$rep_poolname"))[0].stats.max_avail'`
+    local ec_avail=`ceph df -f json | jq '.pools | map(select(.name == "$ec_poolname"))[0].stats.max_avail'`
+
+    echo "${global_avail} >= ${rep_avail}*3" | bc || return 1
+    echo "${global_avail} >= ${ec_avail}*1.5" | bc || return 1
+
+    ceph osd pool delete  $rep_poolname $rep_poolname  --yes-i-really-really-mean-it
+    ceph osd pool delete  $ec_poolname $ec_poolname  --yes-i-really-really-mean-it
+    ceph osd erasure-code-profile rm ec42profile
+    teardown $dir || return 1
+}
+
+main osd-pool-df "$@"
index 85941a895f631870062953393b457c10a1be8031..7ea6ae0dddc0fb55fa642ba1f5f792212242ea2f 100755 (executable)
@@ -33,7 +33,7 @@ function TEST_pool_quota() {
     run_osd $dir 1 || return 1
     run_osd $dir 2 || return 1
 
-    local poolname=testquoa
+    local poolname=testquota
     create_pool $poolname 20
     local objects=`ceph df detail | grep -w $poolname|awk '{print $3}'`
     local bytes=`ceph df detail | grep -w $poolname|awk '{print $4}'`
index b1aa8a5e3b22863f0cce5352af98668bae322b89..fde038fc5806a866c5310e1321b0c0d4cc69fd01 100644 (file)
@@ -835,7 +835,7 @@ void PGMapDigest::dump_object_stat_sum(
     f->dump_int("kb_used", SHIFT_ROUND_UP(sum.num_bytes, 10));
     f->dump_int("bytes_used", sum.num_bytes);
     f->dump_format_unquoted("percent_used", "%.2f", (used*100));
-    f->dump_unsigned("max_avail", avail);
+    f->dump_unsigned("max_avail", avail / raw_used_rate);
     f->dump_int("objects", sum.num_objects);
     if (verbose) {
       f->dump_int("quota_objects", pool->quota_max_objects);
@@ -850,7 +850,7 @@ void PGMapDigest::dump_object_stat_sum(
   } else {
     tbl << stringify(si_t(sum.num_bytes));
     tbl << percentify(used*100);
-    tbl << si_t(avail);
+    tbl << si_t(avail / raw_used_rate);
     tbl << sum.num_objects;
     if (verbose) {
       tbl << stringify(si_t(sum.num_objects_dirty))
index 60de6b7ddae91d146682e9e252b59ba8ba40c9a2..d7e8a18fe41c893ac5647100bbf8f87cfbd2a343 100644 (file)
@@ -180,7 +180,7 @@ TEST(pgmap, dump_object_stat_sum_0)
   unsigned col = 0;
   ASSERT_EQ(stringify(si_t(sum.num_bytes)), tbl.get(0, col++));
   ASSERT_EQ(percentify(used_percent), tbl.get(0, col++));
-  ASSERT_EQ(stringify(si_t(avail)), tbl.get(0, col++));
+  ASSERT_EQ(stringify(si_t(avail/pool.size)), tbl.get(0, col++));
   ASSERT_EQ(stringify(sum.num_objects), tbl.get(0, col++));
   ASSERT_EQ(stringify(si_t(sum.num_objects_dirty)), tbl.get(0, col++));
   ASSERT_EQ(stringify(si_t(sum.num_rd)), tbl.get(0, col++));
@@ -210,7 +210,7 @@ TEST(pgmap, dump_object_stat_sum_1)
   unsigned col = 0;
   ASSERT_EQ(stringify(si_t(0)), tbl.get(0, col++));
   ASSERT_EQ(percentify(0), tbl.get(0, col++));
-  ASSERT_EQ(stringify(si_t(avail)), tbl.get(0, col++));
+  ASSERT_EQ(stringify(si_t(avail/pool.size)), tbl.get(0, col++));
   ASSERT_EQ(stringify(0), tbl.get(0, col++));
   ASSERT_EQ(stringify(si_t(0)), tbl.get(0, col++));
   ASSERT_EQ(stringify(si_t(0)), tbl.get(0, col++));
@@ -239,6 +239,6 @@ TEST(pgmap, dump_object_stat_sum_2)
   unsigned col = 0;
   ASSERT_EQ(stringify(si_t(0)), tbl.get(0, col++));
   ASSERT_EQ(percentify(0), tbl.get(0, col++));
-  ASSERT_EQ(stringify(si_t(avail)), tbl.get(0, col++));
+  ASSERT_EQ(stringify(si_t(avail/pool.size)), tbl.get(0, col++));
   ASSERT_EQ(stringify(0), tbl.get(0, col++));
 }