@@ -194,29 +194,26 @@ static int make_free_space(struct ubifs_info *c)
194194}
195195
196196/**
197- * ubifs_calc_min_idx_lebs - calculate amount of eraseblocks for the index.
197+ * ubifs_calc_min_idx_lebs - calculate amount of LEBs for the index.
198198 * @c: UBIFS file-system description object
199199 *
200- * This function calculates and returns the number of eraseblocks which should
201- * be kept for index usage.
200+ * This function calculates and returns the number of LEBs which should be kept
201+ * for index usage.
202202 */
203203int ubifs_calc_min_idx_lebs (struct ubifs_info * c )
204204{
205- int idx_lebs , eff_leb_size = c -> leb_size - c -> max_idx_node_sz ;
205+ int idx_lebs ;
206206 long long idx_size ;
207207
208208 idx_size = c -> old_idx_sz + c -> budg_idx_growth + c -> budg_uncommitted_idx ;
209-
210209 /* And make sure we have thrice the index size of space reserved */
211- idx_size = idx_size + (idx_size << 1 );
212-
210+ idx_size += idx_size << 1 ;
213211 /*
214212 * We do not maintain 'old_idx_size' as 'old_idx_lebs'/'old_idx_bytes'
215213 * pair, nor similarly the two variables for the new index size, so we
216214 * have to do this costly 64-bit division on fast-path.
217215 */
218- idx_size += eff_leb_size - 1 ;
219- idx_lebs = div_u64 (idx_size , eff_leb_size );
216+ idx_lebs = div_u64 (idx_size + c -> idx_leb_size - 1 , c -> idx_leb_size );
220217 /*
221218 * The index head is not available for the in-the-gaps method, so add an
222219 * extra LEB to compensate.
@@ -310,15 +307,15 @@ static int can_use_rp(struct ubifs_info *c)
310307 * do_budget_space - reserve flash space for index and data growth.
311308 * @c: UBIFS file-system description object
312309 *
313- * This function makes sure UBIFS has enough free eraseblocks for index growth
314- * and data.
310+ * This function makes sure UBIFS has enough free LEBs for index growth and
311+ * data.
315312 *
316313 * When budgeting index space, UBIFS reserves thrice as many LEBs as the index
317314 * would take if it was consolidated and written to the flash. This guarantees
318315 * that the "in-the-gaps" commit method always succeeds and UBIFS will always
319316 * be able to commit dirty index. So this function basically adds amount of
320317 * budgeted index space to the size of the current index, multiplies this by 3,
321- * and makes sure this does not exceed the amount of free eraseblocks .
318+ * and makes sure this does not exceed the amount of free LEBs .
322319 *
323320 * Notes about @c->min_idx_lebs and @c->lst.idx_lebs variables:
324321 * o @c->lst.idx_lebs is the number of LEBs the index currently uses. It might
@@ -695,12 +692,12 @@ long long ubifs_reported_space(const struct ubifs_info *c, long long free)
695692 * This function calculates amount of free space to report to user-space.
696693 *
697694 * Because UBIFS may introduce substantial overhead (the index, node headers,
698- * alignment, wastage at the end of eraseblocks , etc), it cannot report real
699- * amount of free flash space it has (well, because not all dirty space is
700- * reclaimable, UBIFS does not actually know the real amount). If UBIFS did so,
701- * it would bread user expectations about what free space is. Users seem to
702- * accustomed to assume that if the file-system reports N bytes of free space,
703- * they would be able to fit a file of N bytes to the FS. This almost works for
695+ * alignment, wastage at the end of LEBs , etc), it cannot report real amount of
696+ * free flash space it has (well, because not all dirty space is reclaimable,
697+ * UBIFS does not actually know the real amount). If UBIFS did so, it would
698+ * bread user expectations about what free space is. Users seem to accustomed
699+ * to assume that if the file-system reports N bytes of free space, they would
700+ * be able to fit a file of N bytes to the FS. This almost works for
704701 * traditional file-systems, because they have way less overhead than UBIFS.
705702 * So, to keep users happy, UBIFS tries to take the overhead into account.
706703 */
0 commit comments