fs: sdfat: Fix frag_ratio formula

When there is no full au in AMAP, if we use the number of non-clean au
divides fsi->used_clusters * CLUS_PER_AU(sb), the frag_ratio is always
smaller than (or equal with) 100%, which is not right.

Actually, frag_ratio should be the the ratio that non-clean aus divides
the number of aus if all used_clusters are contiguous.

Signed-off-by: Noctis Ackerman <noctis.akm@gmail.com>
This commit is contained in:
Noctis Ackerman 2018-12-06 23:04:05 +08:00 committed by Andreas Schneider
parent 46b831137b
commit d5b9695214
1 changed files with 1 additions and 1 deletions

2
dfr.c
View File

@ -1248,7 +1248,7 @@ defrag_check_defrag_required(
frag_ratio = ((amap->n_au - amap->n_clean_au) * 100) / amap->n_full_au; frag_ratio = ((amap->n_au - amap->n_clean_au) * 100) / amap->n_full_au;
else else
frag_ratio = ((amap->n_au - amap->n_clean_au) * 100) / frag_ratio = ((amap->n_au - amap->n_clean_au) * 100) /
(fsi->used_clusters * CLUS_PER_AU(sb)); (fsi->used_clusters / CLUS_PER_AU(sb) + 1);
/* /*
* Wake-up defrag_daemon: * Wake-up defrag_daemon: