From: Sage Weil Date: Fri, 3 Feb 2017 15:08:33 +0000 (-0500) Subject: mon/PGMap: factor mon_osd_full_ratio into MAX AVAIL calc X-Git-Tag: v11.2.1~98^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=648c6adf52a7847a5b46d1523da45a29504a68da;p=ceph.git mon/PGMap: factor mon_osd_full_ratio into MAX AVAIL calc If we only fill OSDs to 95%, we should factor that into the MAX AVAIL calculation for the pool. Fixes: http://tracker.ceph.com/issues/18522 Signed-off-by: Sage Weil (cherry picked from commit f223ac92917f4bc18e5b9b3ad61afa155e4d088a) --- diff --git a/doc/rados/operations/monitoring.rst b/doc/rados/operations/monitoring.rst index 526577f05b219..ad1484bcaf063 100644 --- a/doc/rados/operations/monitoring.rst +++ b/doc/rados/operations/monitoring.rst @@ -122,6 +122,8 @@ on the number of replicas, clones and snapshots. - **USED:** The notional amount of data stored in kilobytes, unless the number appends **M** for megabytes or **G** for gigabytes. - **%USED:** The notional percentage of storage used per pool. +- **MAX AVAIL:** An estimate of the notional amount of data that can be written + to this pool. - **Objects:** The notional number of objects stored per pool. .. note:: The numbers in the **POOLS** section are notional. They are not @@ -130,6 +132,11 @@ on the number of replicas, clones and snapshots. **RAW USED** and **%RAW USED** amounts in the **GLOBAL** section of the output. +.. note:: The **MAX AVAIL** value is a complicated function of the + replication or erasure code used, the CRUSH rule that maps storage + to devices, the utilization of those devices, and the configured + mon_osd_full_ratio. + Checking a Cluster's Status =========================== diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index 984776960f7bd..c5e4f39606908 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -1832,15 +1832,17 @@ int64_t PGMap::get_rule_avail(const OSDMap& osdmap, int ruleno) const { map wm; int r = osdmap.crush->get_rule_weight_osd_map(ruleno, &wm); - if (r < 0) + if (r < 0) { return r; - - if(wm.empty()) + } + if (wm.empty()) { return 0; + } int64_t min = -1; for (map::iterator p = wm.begin(); p != wm.end(); ++p) { - ceph::unordered_map::const_iterator osd_info = osd_stat.find(p->first); + ceph::unordered_map::const_iterator osd_info = + osd_stat.find(p->first); if (osd_info != osd_stat.end()) { if (osd_info->second.kb == 0 || p->second == 0) { // osd must be out, hence its stats have been zeroed @@ -1850,10 +1852,14 @@ int64_t PGMap::get_rule_avail(const OSDMap& osdmap, int ruleno) const // calculate proj below. continue; } - int64_t proj = (int64_t)((double)((osd_info->second).kb_avail * 1024ull) / - (double)p->second); - if (min < 0 || proj < min) + double unusable = (double)osd_info->second.kb * + (1.0 - g_conf->mon_osd_full_ratio); + double avail = MAX(0.0, (double)osd_info->second.kb_avail - unusable); + avail *= 1024.0; + int64_t proj = (int64_t)(avail / (double)p->second); + if (min < 0 || proj < min) { min = proj; + } } else { dout(0) << "Cannot get stat of OSD " << p->first << dendl; }