@@ -723,24 +723,25 @@ void ubifs_release_dirty_inode_budget(struct ubifs_info *c,
723
723
*/
724
724
long long ubifs_reported_space (const struct ubifs_info * c , uint64_t free )
725
725
{
726
- int divisor , factor ;
726
+ int divisor , factor , f ;
727
727
728
728
/*
729
729
* Reported space size is @free * X, where X is UBIFS block size
730
730
* divided by UBIFS block size + all overhead one data block
731
731
* introduces. The overhead is the node header + indexing overhead.
732
732
*
733
- * Indexing overhead is calculations are based on the following
734
- * formula: I = N/(f - 1) + 1, where I - number of indexing nodes, N -
735
- * number of data nodes, f - fanout. Because effective UBIFS fanout is
736
- * twice as less than maximum fanout, we assume that each data node
733
+ * Indexing overhead calculations are based on the following formula:
734
+ * I = N/(f - 1) + 1, where I - number of indexing nodes, N - number
735
+ * of data nodes, f - fanout. Because effective UBIFS fanout is twice
736
+ * as less than maximum fanout, we assume that each data node
737
737
* introduces 3 * @c->max_idx_node_sz / (@c->fanout/2 - 1) bytes.
738
738
* Note, the multiplier 3 is because UBIFS reseves thrice as more space
739
739
* for the index.
740
740
*/
741
+ f = c -> fanout > 3 ? c -> fanout >> 1 : 2 ;
741
742
factor = UBIFS_BLOCK_SIZE ;
742
743
divisor = UBIFS_MAX_DATA_NODE_SZ ;
743
- divisor += (c -> max_idx_node_sz * 3 ) / (( c -> fanout >> 1 ) - 1 );
744
+ divisor += (c -> max_idx_node_sz * 3 ) / (f - 1 );
744
745
free *= factor ;
745
746
do_div (free , divisor );
746
747
return free ;
0 commit comments