bcache: option to automatically run gc thread after writeback

The option gc_after_writeback is disabled by default, because garbage
collection will discard SSD data which drops cached data.

Echo 1 into /sys/fs/bcache/<UUID>/internal/gc_after_writeback will
enable this option, which wakes up gc thread when writeback accomplished
and all cached data is clean.

This option is helpful for people who cares writing performance more. In
heavy writing workload, all cached data can be clean only happens when
writeback thread cleans all cached data in I/O idle time. In such
situation a following gc running may help to shrink bcache B+ tree and
discard more clean data, which may be helpful for future writing
requests.

If you are not sure whether this is helpful for your own workload,
please leave it as disabled by default.

Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Coly Li
2018-12-13 22:53:53 +08:00
committed by Jens Axboe
父節點 cb07ad6368
當前提交 7a671d8ef8
共有 4 個文件被更改,包括 52 次插入0 次删除

查看文件

@@ -626,6 +626,20 @@ struct cache_set {
/* Where in the btree gc currently is */
struct bkey gc_done;
/*
* For automatical garbage collection after writeback completed, this
* varialbe is used as bit fields,
* - 0000 0001b (BCH_ENABLE_AUTO_GC): enable gc after writeback
* - 0000 0010b (BCH_DO_AUTO_GC): do gc after writeback
* This is an optimization for following write request after writeback
* finished, but read hit rate dropped due to clean data on cache is
* discarded. Unless user explicitly sets it via sysfs, it won't be
* enabled.
*/
#define BCH_ENABLE_AUTO_GC 1
#define BCH_DO_AUTO_GC 2
uint8_t gc_after_writeback;
/*
* The allocation code needs gc_mark in struct bucket to be correct, but
* it's not while a gc is in progress. Protected by bucket_lock.