From d5b96952149c4e021e9fa18a82a817c5067dda97 Mon Sep 17 00:00:00 2001 From: Noctis Ackerman Date: Thu, 6 Dec 2018 23:04:05 +0800 Subject: [PATCH] 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 --- dfr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dfr.c b/dfr.c index 2853fe4..abb4710 100644 --- a/dfr.c +++ b/dfr.c @@ -1248,7 +1248,7 @@ defrag_check_defrag_required( frag_ratio = ((amap->n_au - amap->n_clean_au) * 100) / amap->n_full_au; else 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: