aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColy Li <colyli@suse.de>2018-08-09 03:48:43 -0400
committerJens Axboe <axboe@kernel.dk>2018-08-09 10:21:03 -0400
commitb4cb6efc1af7da2fa1e9ff0eaf90e2be02cfdf5f (patch)
treedc2ff414c77f92ce984d3412746246b069a80828
parent78ac2107176baa0daf65b0fb8e561d2ed14c83ca (diff)
bcache: display rate debug parameters to 0 when writeback is not running
When writeback is not running, writeback rate should be 0, other value is misleading. And the following dyanmic writeback rate debug parameters should be 0 too, rate, proportional, integral, change otherwise they are misleading when writeback is not running. Signed-off-by: Coly Li <colyli@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--drivers/md/bcache/sysfs.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
index 225b15aa0340..3e9d3459a224 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
@@ -149,6 +149,7 @@ SHOW(__bch_cached_dev)
149 struct cached_dev *dc = container_of(kobj, struct cached_dev, 149 struct cached_dev *dc = container_of(kobj, struct cached_dev,
150 disk.kobj); 150 disk.kobj);
151 const char *states[] = { "no cache", "clean", "dirty", "inconsistent" }; 151 const char *states[] = { "no cache", "clean", "dirty", "inconsistent" };
152 int wb = dc->writeback_running;
152 153
153#define var(stat) (dc->stat) 154#define var(stat) (dc->stat)
154 155
@@ -170,7 +171,7 @@ SHOW(__bch_cached_dev)
170 var_printf(writeback_running, "%i"); 171 var_printf(writeback_running, "%i");
171 var_print(writeback_delay); 172 var_print(writeback_delay);
172 var_print(writeback_percent); 173 var_print(writeback_percent);
173 sysfs_hprint(writeback_rate, dc->writeback_rate.rate << 9); 174 sysfs_hprint(writeback_rate, wb ? dc->writeback_rate.rate << 9 : 0);
174 sysfs_hprint(io_errors, atomic_read(&dc->io_errors)); 175 sysfs_hprint(io_errors, atomic_read(&dc->io_errors));
175 sysfs_printf(io_error_limit, "%i", dc->error_limit); 176 sysfs_printf(io_error_limit, "%i", dc->error_limit);
176 sysfs_printf(io_disable, "%i", dc->io_disable); 177 sysfs_printf(io_disable, "%i", dc->io_disable);
@@ -188,15 +189,20 @@ SHOW(__bch_cached_dev)
188 char change[20]; 189 char change[20];
189 s64 next_io; 190 s64 next_io;
190 191
191 bch_hprint(rate, dc->writeback_rate.rate << 9); 192 /*
192 bch_hprint(dirty, bcache_dev_sectors_dirty(&dc->disk) << 9); 193 * Except for dirty and target, other values should
193 bch_hprint(target, dc->writeback_rate_target << 9); 194 * be 0 if writeback is not running.
194 bch_hprint(proportional,dc->writeback_rate_proportional << 9); 195 */
195 bch_hprint(integral, dc->writeback_rate_integral_scaled << 9); 196 bch_hprint(rate, wb ? dc->writeback_rate.rate << 9 : 0);
196 bch_hprint(change, dc->writeback_rate_change << 9); 197 bch_hprint(dirty, bcache_dev_sectors_dirty(&dc->disk) << 9);
197 198 bch_hprint(target, dc->writeback_rate_target << 9);
198 next_io = div64_s64(dc->writeback_rate.next - local_clock(), 199 bch_hprint(proportional,
199 NSEC_PER_MSEC); 200 wb ? dc->writeback_rate_proportional << 9 : 0);
201 bch_hprint(integral,
202 wb ? dc->writeback_rate_integral_scaled << 9 : 0);
203 bch_hprint(change, wb ? dc->writeback_rate_change << 9 : 0);
204 next_io = wb ? div64_s64(dc->writeback_rate.next-local_clock(),
205 NSEC_PER_MSEC) : 0;
200 206
201 return sprintf(buf, 207 return sprintf(buf,
202 "rate:\t\t%s/sec\n" 208 "rate:\t\t%s/sec\n"