lkml.org 
[lkml]   [2023]   [Feb]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2 v2] f2fs: fix wrong calculation of block age
> > 
> > How about updating as below to avoid lossing accuracy if new is less than 100?
> >
> > return div_u64(new * (100 - LAST_AGE_WEIGHT), 100) +
> > div_u64(old * LAST_AGE_WEIGHT, 100);
> >
> > Thanks,
> >
>
> We want to avoid overflow by doing the division first. To keep the accuracy, how
> about updating as below:
>
> res = div_u64_rem(new, 100, &rem_new) * (100 - LAST_AGE_WEIGHT)
> + div_u64_rem(old, 100, &rem_old) * LAST_AGE_WEIGHT;
> res += rem_new * (100 - LAST_AGE_WEIGHT) / 100 + rem_old * LAST_AGE_WEIGHT / 100;
> return res;
>
> Thanks,
>

Friendly ping

> > > }
> > > /* This returns a new age and allocated blocks in ei */

\
 
 \ /
  Last update: 2023-03-27 00:05    [W:0.108 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site