[PATCH] bcache: Use the lastest writeback_delay value when writeback thread is woken up

Julian Sun <[email protected]>
Newsgroups org.kernel.vger.linux-bcache
Message-ID <[email protected]>
When users reset writeback_delay value and woke up writeback
thread via sysfs interface, expect the writeback thread
to do actual writeback work, but in reality, the writeback
thread probably continue to sleep.

For example the following script set writeback_delay to 0 and
wake up writeback thread, but writeback thread just continue to
sleep:
echo 0 > /sys/block/bcache0/bcache/writeback_delay
echo 1 > /sys/block/bcache0/bcache/writeback_running

Using the lastest value when writeback thread is woken up can
urge it to do actual writeback work.

Signed-off-by: Julian Sun <[email protected]>
---
 drivers/md/bcache/writeback.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c
index c1d28e365910..0d2d06aaacfe 100644
--- a/drivers/md/bcache/writeback.c
+++ b/drivers/md/bcache/writeback.c
@@ -825,8 +825,10 @@ static int bch_writeback_thread(void *arg)
 			while (delay &&
 			       !kthread_should_stop() &&
 			       !test_bit(CACHE_SET_IO_DISABLE, &c->flags) &&
-			       !test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags))
+			       !test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags)) {
 				delay = schedule_timeout_interruptible(delay);
+				delay = min(delay, dc->writeback_delay * HZ);
+			}
 
 			bch_ratelimit_reset(&dc->writeback_rate);
 		}
-- 
2.39.5
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.