diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-03-16 03:56:57 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-03-16 04:52:02 -0400 |
commit | fb1cd01a33ecb8a49d590c034ba146dff80c5597 (patch) | |
tree | d963edf8512c6979fd7c8a34b6550a81e9828128 /fs/ubifs/budget.c | |
parent | c9927c3ee2d3d14893efd793a2a9ea772ddb4289 (diff) |
UBIFS: introduce a helpful variable
This patch introduces a helpful @c->idx_leb_size variable.
The patch also fixes some spelling issues and makes comments
use "LEB" instead of "eraseblock", which is more correct.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'fs/ubifs/budget.c')
-rw-r--r-- | fs/ubifs/budget.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/fs/ubifs/budget.c b/fs/ubifs/budget.c index f393620890ee..8cd425b628ee 100644 --- a/fs/ubifs/budget.c +++ b/fs/ubifs/budget.c | |||
@@ -194,29 +194,26 @@ static int make_free_space(struct ubifs_info *c) | |||
194 | } | 194 | } |
195 | 195 | ||
196 | /** | 196 | /** |
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. |
198 | * @c: UBIFS file-system description object | 198 | * @c: UBIFS file-system description object |
199 | * | 199 | * |
200 | * This function calculates and returns the number of eraseblocks which should | 200 | * This function calculates and returns the number of LEBs which should be kept |
201 | * be kept for index usage. | 201 | * for index usage. |
202 | */ | 202 | */ |
203 | int ubifs_calc_min_idx_lebs(struct ubifs_info *c) | 203 | int ubifs_calc_min_idx_lebs(struct ubifs_info *c) |
204 | { | 204 | { |
205 | int idx_lebs, eff_leb_size = c->leb_size - c->max_idx_node_sz; | 205 | int idx_lebs; |
206 | long long idx_size; | 206 | long long idx_size; |
207 | 207 | ||
208 | idx_size = c->old_idx_sz + c->budg_idx_growth + c->budg_uncommitted_idx; | 208 | idx_size = c->old_idx_sz + c->budg_idx_growth + c->budg_uncommitted_idx; |
209 | |||
210 | /* And make sure we have thrice the index size of space reserved */ | 209 | /* And make sure we have thrice the index size of space reserved */ |
211 | idx_size = idx_size + (idx_size << 1); | 210 | idx_size += idx_size << 1; |
212 | |||
213 | /* | 211 | /* |
214 | * We do not maintain 'old_idx_size' as 'old_idx_lebs'/'old_idx_bytes' | 212 | * We do not maintain 'old_idx_size' as 'old_idx_lebs'/'old_idx_bytes' |
215 | * pair, nor similarly the two variables for the new index size, so we | 213 | * pair, nor similarly the two variables for the new index size, so we |
216 | * have to do this costly 64-bit division on fast-path. | 214 | * have to do this costly 64-bit division on fast-path. |
217 | */ | 215 | */ |
218 | idx_size += eff_leb_size - 1; | 216 | idx_lebs = div_u64(idx_size + c->idx_leb_size - 1, c->idx_leb_size); |
219 | idx_lebs = div_u64(idx_size, eff_leb_size); | ||
220 | /* | 217 | /* |
221 | * The index head is not available for the in-the-gaps method, so add an | 218 | * The index head is not available for the in-the-gaps method, so add an |
222 | * extra LEB to compensate. | 219 | * extra LEB to compensate. |
@@ -310,15 +307,15 @@ static int can_use_rp(struct ubifs_info *c) | |||
310 | * do_budget_space - reserve flash space for index and data growth. | 307 | * do_budget_space - reserve flash space for index and data growth. |
311 | * @c: UBIFS file-system description object | 308 | * @c: UBIFS file-system description object |
312 | * | 309 | * |
313 | * This function makes sure UBIFS has enough free eraseblocks for index growth | 310 | * This function makes sure UBIFS has enough free LEBs for index growth and |
314 | * and data. | 311 | * data. |
315 | * | 312 | * |
316 | * When budgeting index space, UBIFS reserves thrice as many LEBs as the index | 313 | * When budgeting index space, UBIFS reserves thrice as many LEBs as the index |
317 | * would take if it was consolidated and written to the flash. This guarantees | 314 | * would take if it was consolidated and written to the flash. This guarantees |
318 | * that the "in-the-gaps" commit method always succeeds and UBIFS will always | 315 | * that the "in-the-gaps" commit method always succeeds and UBIFS will always |
319 | * be able to commit dirty index. So this function basically adds amount of | 316 | * be able to commit dirty index. So this function basically adds amount of |
320 | * budgeted index space to the size of the current index, multiplies this by 3, | 317 | * 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. |
322 | * | 319 | * |
323 | * Notes about @c->min_idx_lebs and @c->lst.idx_lebs variables: | 320 | * Notes about @c->min_idx_lebs and @c->lst.idx_lebs variables: |
324 | * o @c->lst.idx_lebs is the number of LEBs the index currently uses. It might | 321 | * 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) | |||
695 | * This function calculates amount of free space to report to user-space. | 692 | * This function calculates amount of free space to report to user-space. |
696 | * | 693 | * |
697 | * Because UBIFS may introduce substantial overhead (the index, node headers, | 694 | * Because UBIFS may introduce substantial overhead (the index, node headers, |
698 | * alignment, wastage at the end of eraseblocks, etc), it cannot report real | 695 | * alignment, wastage at the end of LEBs, etc), it cannot report real amount of |
699 | * amount of free flash space it has (well, because not all dirty space is | 696 | * free flash space it has (well, because not all dirty space is reclaimable, |
700 | * reclaimable, UBIFS does not actually know the real amount). If UBIFS did so, | 697 | * UBIFS does not actually know the real amount). If UBIFS did so, it would |
701 | * it would bread user expectations about what free space is. Users seem to | 698 | * bread user expectations about what free space is. Users seem to accustomed |
702 | * accustomed to assume that if the file-system reports N bytes of free space, | 699 | * to assume that if the file-system reports N bytes of free space, they would |
703 | * they would be able to fit a file of N bytes to the FS. This almost works for | 700 | * be able to fit a file of N bytes to the FS. This almost works for |
704 | * traditional file-systems, because they have way less overhead than UBIFS. | 701 | * traditional file-systems, because they have way less overhead than UBIFS. |
705 | * So, to keep users happy, UBIFS tries to take the overhead into account. | 702 | * So, to keep users happy, UBIFS tries to take the overhead into account. |
706 | */ | 703 | */ |