diff options
Diffstat (limited to 'fs/ubifs/lprops.c')
-rw-r--r-- | fs/ubifs/lprops.c | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/fs/ubifs/lprops.c b/fs/ubifs/lprops.c index 4cdd284dea56..4d4ca388889b 100644 --- a/fs/ubifs/lprops.c +++ b/fs/ubifs/lprops.c | |||
@@ -281,7 +281,7 @@ void ubifs_add_to_cat(struct ubifs_info *c, struct ubifs_lprops *lprops, | |||
281 | case LPROPS_FREE: | 281 | case LPROPS_FREE: |
282 | if (add_to_lpt_heap(c, lprops, cat)) | 282 | if (add_to_lpt_heap(c, lprops, cat)) |
283 | break; | 283 | break; |
284 | /* No more room on heap so make it uncategorized */ | 284 | /* No more room on heap so make it un-categorized */ |
285 | cat = LPROPS_UNCAT; | 285 | cat = LPROPS_UNCAT; |
286 | /* Fall through */ | 286 | /* Fall through */ |
287 | case LPROPS_UNCAT: | 287 | case LPROPS_UNCAT: |
@@ -375,8 +375,8 @@ void ubifs_replace_cat(struct ubifs_info *c, struct ubifs_lprops *old_lprops, | |||
375 | * @lprops: LEB properties | 375 | * @lprops: LEB properties |
376 | * | 376 | * |
377 | * A LEB may have fallen off of the bottom of a heap, and ended up as | 377 | * A LEB may have fallen off of the bottom of a heap, and ended up as |
378 | * uncategorized even though it has enough space for us now. If that is the case | 378 | * un-categorized even though it has enough space for us now. If that is the |
379 | * this function will put the LEB back onto a heap. | 379 | * case this function will put the LEB back onto a heap. |
380 | */ | 380 | */ |
381 | void ubifs_ensure_cat(struct ubifs_info *c, struct ubifs_lprops *lprops) | 381 | void ubifs_ensure_cat(struct ubifs_info *c, struct ubifs_lprops *lprops) |
382 | { | 382 | { |
@@ -436,10 +436,10 @@ int ubifs_categorize_lprops(const struct ubifs_info *c, | |||
436 | /** | 436 | /** |
437 | * change_category - change LEB properties category. | 437 | * change_category - change LEB properties category. |
438 | * @c: UBIFS file-system description object | 438 | * @c: UBIFS file-system description object |
439 | * @lprops: LEB properties to recategorize | 439 | * @lprops: LEB properties to re-categorize |
440 | * | 440 | * |
441 | * LEB properties are categorized to enable fast find operations. When the LEB | 441 | * LEB properties are categorized to enable fast find operations. When the LEB |
442 | * properties change they must be recategorized. | 442 | * properties change they must be re-categorized. |
443 | */ | 443 | */ |
444 | static void change_category(struct ubifs_info *c, struct ubifs_lprops *lprops) | 444 | static void change_category(struct ubifs_info *c, struct ubifs_lprops *lprops) |
445 | { | 445 | { |
@@ -461,21 +461,18 @@ static void change_category(struct ubifs_info *c, struct ubifs_lprops *lprops) | |||
461 | } | 461 | } |
462 | 462 | ||
463 | /** | 463 | /** |
464 | * calc_dark - calculate LEB dark space size. | 464 | * ubifs_calc_dark - calculate LEB dark space size. |
465 | * @c: the UBIFS file-system description object | 465 | * @c: the UBIFS file-system description object |
466 | * @spc: amount of free and dirty space in the LEB | 466 | * @spc: amount of free and dirty space in the LEB |
467 | * | 467 | * |
468 | * This function calculates amount of dark space in an LEB which has @spc bytes | 468 | * This function calculates and returns amount of dark space in an LEB which |
469 | * of free and dirty space. Returns the calculations result. | 469 | * has @spc bytes of free and dirty space. |
470 | * | 470 | * |
471 | * Dark space is the space which is not always usable - it depends on which | 471 | * UBIFS is trying to account the space which might not be usable, and this |
472 | * nodes are written in which order. E.g., if an LEB has only 512 free bytes, | 472 | * space is called "dark space". For example, if an LEB has only %512 free |
473 | * it is dark space, because it cannot fit a large data node. So UBIFS cannot | 473 | * bytes, it is dark space, because it cannot fit a large data node. |
474 | * count on this LEB and treat these 512 bytes as usable because it is not true | ||
475 | * if, for example, only big chunks of uncompressible data will be written to | ||
476 | * the FS. | ||
477 | */ | 474 | */ |
478 | static int calc_dark(struct ubifs_info *c, int spc) | 475 | int ubifs_calc_dark(const struct ubifs_info *c, int spc) |
479 | { | 476 | { |
480 | ubifs_assert(!(spc & 7)); | 477 | ubifs_assert(!(spc & 7)); |
481 | 478 | ||
@@ -518,7 +515,7 @@ static int is_lprops_dirty(struct ubifs_info *c, struct ubifs_lprops *lprops) | |||
518 | * @free: new free space amount | 515 | * @free: new free space amount |
519 | * @dirty: new dirty space amount | 516 | * @dirty: new dirty space amount |
520 | * @flags: new flags | 517 | * @flags: new flags |
521 | * @idx_gc_cnt: change to the count of idx_gc list | 518 | * @idx_gc_cnt: change to the count of @idx_gc list |
522 | * | 519 | * |
523 | * This function changes LEB properties (@free, @dirty or @flag). However, the | 520 | * This function changes LEB properties (@free, @dirty or @flag). However, the |
524 | * property which has the %LPROPS_NC value is not changed. Returns a pointer to | 521 | * property which has the %LPROPS_NC value is not changed. Returns a pointer to |
@@ -535,7 +532,7 @@ const struct ubifs_lprops *ubifs_change_lp(struct ubifs_info *c, | |||
535 | { | 532 | { |
536 | /* | 533 | /* |
537 | * This is the only function that is allowed to change lprops, so we | 534 | * This is the only function that is allowed to change lprops, so we |
538 | * discard the const qualifier. | 535 | * discard the "const" qualifier. |
539 | */ | 536 | */ |
540 | struct ubifs_lprops *lprops = (struct ubifs_lprops *)lp; | 537 | struct ubifs_lprops *lprops = (struct ubifs_lprops *)lp; |
541 | 538 | ||
@@ -575,7 +572,7 @@ const struct ubifs_lprops *ubifs_change_lp(struct ubifs_info *c, | |||
575 | if (old_spc < c->dead_wm) | 572 | if (old_spc < c->dead_wm) |
576 | c->lst.total_dead -= old_spc; | 573 | c->lst.total_dead -= old_spc; |
577 | else | 574 | else |
578 | c->lst.total_dark -= calc_dark(c, old_spc); | 575 | c->lst.total_dark -= ubifs_calc_dark(c, old_spc); |
579 | 576 | ||
580 | c->lst.total_used -= c->leb_size - old_spc; | 577 | c->lst.total_used -= c->leb_size - old_spc; |
581 | } | 578 | } |
@@ -616,7 +613,7 @@ const struct ubifs_lprops *ubifs_change_lp(struct ubifs_info *c, | |||
616 | if (new_spc < c->dead_wm) | 613 | if (new_spc < c->dead_wm) |
617 | c->lst.total_dead += new_spc; | 614 | c->lst.total_dead += new_spc; |
618 | else | 615 | else |
619 | c->lst.total_dark += calc_dark(c, new_spc); | 616 | c->lst.total_dark += ubifs_calc_dark(c, new_spc); |
620 | 617 | ||
621 | c->lst.total_used += c->leb_size - new_spc; | 618 | c->lst.total_used += c->leb_size - new_spc; |
622 | } | 619 | } |
@@ -1096,7 +1093,7 @@ static int scan_check_cb(struct ubifs_info *c, | |||
1096 | } | 1093 | } |
1097 | } | 1094 | } |
1098 | 1095 | ||
1099 | sleb = ubifs_scan(c, lnum, 0, c->dbg->buf); | 1096 | sleb = ubifs_scan(c, lnum, 0, c->dbg->buf, 0); |
1100 | if (IS_ERR(sleb)) { | 1097 | if (IS_ERR(sleb)) { |
1101 | /* | 1098 | /* |
1102 | * After an unclean unmount, empty and freeable LEBs | 1099 | * After an unclean unmount, empty and freeable LEBs |
@@ -1107,7 +1104,7 @@ static int scan_check_cb(struct ubifs_info *c, | |||
1107 | "- continuing checking"); | 1104 | "- continuing checking"); |
1108 | lst->empty_lebs += 1; | 1105 | lst->empty_lebs += 1; |
1109 | lst->total_free += c->leb_size; | 1106 | lst->total_free += c->leb_size; |
1110 | lst->total_dark += calc_dark(c, c->leb_size); | 1107 | lst->total_dark += ubifs_calc_dark(c, c->leb_size); |
1111 | return LPT_SCAN_CONTINUE; | 1108 | return LPT_SCAN_CONTINUE; |
1112 | } | 1109 | } |
1113 | 1110 | ||
@@ -1117,7 +1114,7 @@ static int scan_check_cb(struct ubifs_info *c, | |||
1117 | "- continuing checking"); | 1114 | "- continuing checking"); |
1118 | lst->total_free += lp->free; | 1115 | lst->total_free += lp->free; |
1119 | lst->total_dirty += lp->dirty; | 1116 | lst->total_dirty += lp->dirty; |
1120 | lst->total_dark += calc_dark(c, c->leb_size); | 1117 | lst->total_dark += ubifs_calc_dark(c, c->leb_size); |
1121 | return LPT_SCAN_CONTINUE; | 1118 | return LPT_SCAN_CONTINUE; |
1122 | } | 1119 | } |
1123 | data->err = PTR_ERR(sleb); | 1120 | data->err = PTR_ERR(sleb); |
@@ -1235,7 +1232,7 @@ static int scan_check_cb(struct ubifs_info *c, | |||
1235 | if (spc < c->dead_wm) | 1232 | if (spc < c->dead_wm) |
1236 | lst->total_dead += spc; | 1233 | lst->total_dead += spc; |
1237 | else | 1234 | else |
1238 | lst->total_dark += calc_dark(c, spc); | 1235 | lst->total_dark += ubifs_calc_dark(c, spc); |
1239 | } | 1236 | } |
1240 | 1237 | ||
1241 | ubifs_scan_destroy(sleb); | 1238 | ubifs_scan_destroy(sleb); |