aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bcache/writeback.c
diff options
context:
space:
mode:
authorTang Junhui <tang.junhui@zte.com.cn>2017-09-06 13:28:53 -0400
committerJens Axboe <axboe@kernel.dk>2017-09-07 15:32:29 -0400
commit175206cf9ab63161dec74d9cd7f9992e062491f5 (patch)
treee296d08687407bec1b6d28b84c41f1dcfb9e58dd /drivers/md/bcache/writeback.c
parentbf09375337077b692d21d062c30697c86f2872d3 (diff)
bcache: initialize dirty stripes in flash_dev_run()
bcache uses a Proportion-Differentiation Controller algorithm to control writeback rate to cached devices. In the PD controller algorithm, dirty stripes of thin flash device should not be counted in, because flash only volumes never write back dirty data. Currently dirty stripe counter for thin flash device is not initialized when the thin flash device starts. Which means the following calculation in PD controller will reference an undefined dirty stripes number, and all cached devices attached to the same cache set where the thin flash device lies on may have an inaccurate writeback rate. This patch calles bch_sectors_dirty_init() in flash_dev_run(), to correctly initialize dirty stripe counter when the thin flash device starts to run. This patch also does following parameter data type change, -void bch_sectors_dirty_init(struct cached_dev *dc); +void bch_sectors_dirty_init(struct bcache_device *); to call this function conveniently in flash_dev_run(). (Commit log is composed by Coly Li) Signed-off-by: Tang Junhui <tang.junhui@zte.com.cn> Reviewed-by: Coly Li <colyli@suse.de> Cc: stable@vger.kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/md/bcache/writeback.c')
-rw-r--r--drivers/md/bcache/writeback.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c
index 34131439e28c..e663ca082183 100644
--- a/drivers/md/bcache/writeback.c
+++ b/drivers/md/bcache/writeback.c
@@ -482,17 +482,17 @@ static int sectors_dirty_init_fn(struct btree_op *_op, struct btree *b,
482 return MAP_CONTINUE; 482 return MAP_CONTINUE;
483} 483}
484 484
485void bch_sectors_dirty_init(struct cached_dev *dc) 485void bch_sectors_dirty_init(struct bcache_device *d)
486{ 486{
487 struct sectors_dirty_init op; 487 struct sectors_dirty_init op;
488 488
489 bch_btree_op_init(&op.op, -1); 489 bch_btree_op_init(&op.op, -1);
490 op.inode = dc->disk.id; 490 op.inode = d->id;
491 491
492 bch_btree_map_keys(&op.op, dc->disk.c, &KEY(op.inode, 0, 0), 492 bch_btree_map_keys(&op.op, d->c, &KEY(op.inode, 0, 0),
493 sectors_dirty_init_fn, 0); 493 sectors_dirty_init_fn, 0);
494 494
495 dc->disk.sectors_dirty_last = bcache_dev_sectors_dirty(&dc->disk); 495 d->sectors_dirty_last = bcache_dev_sectors_dirty(d);
496} 496}
497 497
498void bch_cached_dev_writeback_init(struct cached_dev *dc) 498void bch_cached_dev_writeback_init(struct cached_dev *dc)