Blob Blame History Raw
From b817c245b8d163528f7ff69262591942cdf98794 Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Wed, 14 Jun 2017 14:30:34 +0800
Subject: [PATCH] bcache: force trigger gc
Patch-mainline: Not yet, this is a patch in development
References: bsc#1038078

Writing trigger_gc takes effect only when sectors_to_gc of a cache set is
minus value. This patch sets cacheset sectors_to_gc to -1 when sysfs file
trigger_gc is written.

Signed-off-by: Junhui Tang <junhui.tang@zte.com>
Tested-by: Coly Li <colyli@suse.de>
---
 drivers/md/bcache/sysfs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
index f90f13616980..5b38a52b8c1f 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
@@ -615,8 +615,10 @@ STORE(__bch_cache_set)
 		bch_cache_accounting_clear(&c->accounting);
 	}
 
-	if (attr == &sysfs_trigger_gc)
+	if (attr == &sysfs_trigger_gc) {
+		atomic_set(&c->sectors_to_gc, -1);
 		wake_up_gc(c);
+	}
 
 	if (attr == &sysfs_prune_cache) {
 		struct shrink_control sc;
-- 
2.12.0