- est_refdblocks = (refdbytes >> est_maxblockshift) +
- (OSD_DNODE_EST_COUNT >> OSD_DNODE_EST_BLKSHIFT);
- est_usedobjs = usedobjs + OSD_DNODE_EST_COUNT;
-
- /* Average space/dnode more than maximum dnode size, use max dnode
- * size to estimate free dnodes from adjusted free blocks count.
- * OSTs typically use more than one block dnode so this case applies. */
- if (est_usedobjs <= est_refdblocks * 2) {
- est_objs = nrblocks;
-
- /* Average space/dnode smaller than min dnode size (probably due to
- * metadnode compression), use min dnode size to estimate the number of
- * objects.
- * An MDT typically uses below 512 bytes/dnode so this case applies. */
- } else if (est_usedobjs >= (est_refdblocks << OSD_DNODE_MIN_BLKSHIFT)) {
- est_objs = nrblocks << OSD_DNODE_MIN_BLKSHIFT;
-
- /* Between the extremes, we try to use the average size of
- * existing dnodes to compute the number of dnodes that fit
- * into nrblocks:
+ est_usedblocks = ((OSD_DNODE_EST_COUNT << OSD_DNODE_EST_BLKSHIFT) +
+ usedbytes) >> est_maxblockshift;
+ est_usedobjs = OSD_DNODE_EST_COUNT + usedobjs;
+
+ if (est_usedobjs <= est_usedblocks) {
+ /*
+ * Average space/dnode more than maximum block size, use max
+ * block size to estimate free dnodes from adjusted free blocks
+ * count. OSTs typically use multiple blocks per dnode so this
+ * case applies.
+ */
+ est_totobjs = nrblocks;
+
+ } else if (est_usedobjs >= (est_usedblocks << OSD_DNODE_MIN_BLKSHIFT)) {
+ /*
+ * Average space/dnode smaller than min dnode size (probably
+ * due to metadnode compression), use min dnode size to
+ * estimate object count. MDTs may use only one block per node
+ * so this case applies.
+ */
+ est_totobjs = nrblocks << OSD_DNODE_MIN_BLKSHIFT;
+
+ } else {
+ /*
+ * Between the extremes, use average space per existing dnode
+ * to compute the number of dnodes that will fit into nrblocks: