• C
    f2fs: introduce discard_granularity sysfs entry · 969d1b18
    Chao Yu 提交于
    Commit d618ebaf ("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.
    
    Jaegeuk Kim:
     We must issue all the accumulated discard commands when fstrim is called.
     So, I've added pend_list_tag[] to indicate whether we should issue the
     commands or not. If tag sets P_ACTIVE or P_TRIM, we have to issue them.
     P_TRIM is set once at a time, given fstrim trigger.
     In addition, issue_discard_thread is calling too much due to the number of
     discard commands remaining in the pending list. I added a timer to control
     it likewise gc_thread.
    Signed-off-by: NChao Yu <yuchao0@huawei.com>
    Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
    969d1b18
f2fs.h 92.6 KB