{"id":828,"date":"2019-01-10T01:56:02","date_gmt":"2019-01-10T01:56:02","guid":{"rendered":"http:\/\/www.selinuxplus.com\/?p=828"},"modified":"2019-01-10T01:56:02","modified_gmt":"2019-01-10T01:56:02","slug":"ceph-pg-%e8%ae%a1%e7%ae%97%e6%96%b9%e6%b3%95-python","status":"publish","type":"post","link":"http:\/\/www.selinuxplus.com\/?p=828","title":{"rendered":"ceph pg \u8ba1\u7b97\u65b9\u6cd5 python"},"content":{"rendered":"\n<pre class=\"lang:default decode:true \" >import math\r\n\r\npow_threshold = 0.25\r\n\r\ndef nearest_pow2(size):\r\n    val = math.pow(2,round(math.log(size)\/math.log(2)))\r\n    if val &lt; size * (1-pow_threshold):\r\n        val *=2\r\n    return val\r\n\r\ndef update_pg_count(osd_num,size,pg_osd=100,pre_data=0.1):\r\n\r\n    min_val = nearest_pow2(math.floor(osd_num\/size)+1)\r\n\r\n    if min_val &lt; osd_num:\r\n        min_val *= 2\r\n    calc_val = nearest_pow2(math.floor(pg_osd*osd_num*pre_data)\/(100*size))\r\n\r\n    if min_val &gt; calc_val:\r\n        return min_val\r\n    else:\r\n        return calc_val\r\n\r\n\r\nprint(int(update_pg_count(100,3,100,0.1)))<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>import math pow_threshold&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[84],"tags":[177,180,167],"_links":{"self":[{"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/posts\/828"}],"collection":[{"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=828"}],"version-history":[{"count":2,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/posts\/828\/revisions"}],"predecessor-version":[{"id":860,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/posts\/828\/revisions\/860"}],"wp:attachment":[{"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=828"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=828"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=828"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}