Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a8500fc8 authored by Michael Lyle's avatar Michael Lyle Committed by Jens Axboe
Browse files

bcache: rearrange writeback main thread ratelimit



The time spent searching for things to write back "counts" for the
actual rate achieved, so don't flush the accumulated rate with each
chunk.

This will maintain better fidelity to user-commanded rates, but it
may slightly increase the burstiness of writeback.  The writeback
lock needs improvement to help mitigate this.

Signed-off-by: default avatarMichael Lyle <mlyle@lyle.org>
Reviewed-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent e41166c5
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -440,6 +440,8 @@ static int bch_writeback_thread(void *arg)
	struct cached_dev *dc = arg;
	bool searched_full_index;

	bch_ratelimit_reset(&dc->writeback_rate);

	while (!kthread_should_stop()) {
		down_write(&dc->writeback_lock);
		if (!atomic_read(&dc->has_dirty) ||
@@ -467,7 +469,6 @@ static int bch_writeback_thread(void *arg)

		up_write(&dc->writeback_lock);

		bch_ratelimit_reset(&dc->writeback_rate);
		read_dirty(dc);

		if (searched_full_index) {
@@ -477,6 +478,8 @@ static int bch_writeback_thread(void *arg)
			       !kthread_should_stop() &&
			       !test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags))
				delay = schedule_timeout_interruptible(delay);

			bch_ratelimit_reset(&dc->writeback_rate);
		}
	}