Re: [PATCH v4] f2fs: introduce discard_granularity sysfs entry

From: Jaegeuk Kim
Date: Tue Aug 15 2017 - 13:54:52 EST


On 08/15, Chao Yu wrote:
> On 2017/8/15 11:45, Jaegeuk Kim wrote:
> > On 08/07, Chao Yu wrote:
> >> From: Chao Yu <yuchao0@xxxxxxxxxx>
> >>
> >> Commit d618ebaf0aa8 ("f2fs: enable small discard by default") enables
> >> f2fs to issue 4K size discard in real-time discard mode. However, issuing
> >> smaller discard may cost more lifetime but releasing less free space in
> >> flash device. Since f2fs has ability of separating hot/cold data and
> >> garbage collection, we can expect that small-sized invalid region would
> >> expand soon with OPU, deletion or garbage collection on valid datas, so
> >> it's better to delay or skip issuing smaller size discards, it could help
> >> to reduce overmuch consumption of IO bandwidth and lifetime of flash
> >> storage.
> >>
> >> This patch makes f2fs selectng 64K size as its default minimal
> >> granularity, and issue discard with the size which is not smaller than
> >> minimal granularity. Also it exposes discard granularity as sysfs entry
> >> for configuration in different scenario.
> >
> > Hi Chao,
> >
> > I'd like to change the default value to 1 in order to keep the original
> > behavior, since we must avoid performance fluctuation after this single
> > patch. Instead, you probably can change the value through sysfs.
>
> As I know, in fragmented filesystem space, there are may dozens of thousand
> discard, in scenario of cellphone user are using, 30% is above 64K size, but
> occupy 75% space of all undiscard space, so I changed discard_granularity to 64K
> just to release bulk space in device. For other small-sized discards, I expect
> that they may extend and cross the granularity threshold soon, and fstrim of
> android could cover them in the night.

Yup, I thought that, but this patch prevents fstrim from issuing small discards
due to the granularity check. And, low-end device likes to issue small discards
much more. How about this?