]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.52/bcache-initialize-dirty-stripes-in-flash_dev_run.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.52 / bcache-initialize-dirty-stripes-in-flash_dev_run.patch
CommitLineData
23b3ff3a
GKH
1From 175206cf9ab63161dec74d9cd7f9992e062491f5 Mon Sep 17 00:00:00 2001
2From: Tang Junhui <tang.junhui@zte.com.cn>
3Date: Thu, 7 Sep 2017 01:28:53 +0800
4Subject: bcache: initialize dirty stripes in flash_dev_run()
5
6From: Tang Junhui <tang.junhui@zte.com.cn>
7
8commit 175206cf9ab63161dec74d9cd7f9992e062491f5 upstream.
9
10bcache uses a Proportion-Differentiation Controller algorithm to control
11writeback rate to cached devices. In the PD controller algorithm, dirty
12stripes of thin flash device should not be counted in, because flash only
13volumes never write back dirty data.
14
15Currently dirty stripe counter for thin flash device is not initialized
16when the thin flash device starts. Which means the following calculation
17in PD controller will reference an undefined dirty stripes number, and
18all cached devices attached to the same cache set where the thin flash
19device lies on may have an inaccurate writeback rate.
20
21This patch calles bch_sectors_dirty_init() in flash_dev_run(), to
22correctly initialize dirty stripe counter when the thin flash device
23starts to run. This patch also does following parameter data type change,
24 -void bch_sectors_dirty_init(struct cached_dev *dc);
25 +void bch_sectors_dirty_init(struct bcache_device *);
26to call this function conveniently in flash_dev_run().
27
28(Commit log is composed by Coly Li)
29
30Signed-off-by: Tang Junhui <tang.junhui@zte.com.cn>
31Reviewed-by: Coly Li <colyli@suse.de>
32Signed-off-by: Jens Axboe <axboe@kernel.dk>
33Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
34
35---
36 drivers/md/bcache/super.c | 3 ++-
37 drivers/md/bcache/writeback.c | 8 ++++----
38 drivers/md/bcache/writeback.h | 2 +-
39 3 files changed, 7 insertions(+), 6 deletions(-)
40
41--- a/drivers/md/bcache/super.c
42+++ b/drivers/md/bcache/super.c
43@@ -1025,7 +1025,7 @@ int bch_cached_dev_attach(struct cached_
44 }
45
46 if (BDEV_STATE(&dc->sb) == BDEV_STATE_DIRTY) {
47- bch_sectors_dirty_init(dc);
48+ bch_sectors_dirty_init(&dc->disk);
49 atomic_set(&dc->has_dirty, 1);
50 atomic_inc(&dc->count);
51 bch_writeback_queue(dc);
52@@ -1229,6 +1229,7 @@ static int flash_dev_run(struct cache_se
53 goto err;
54
55 bcache_device_attach(d, c, u - c->uuids);
56+ bch_sectors_dirty_init(d);
57 bch_flash_dev_request_init(d);
58 add_disk(d->disk);
59
60--- a/drivers/md/bcache/writeback.c
61+++ b/drivers/md/bcache/writeback.c
62@@ -482,17 +482,17 @@ static int sectors_dirty_init_fn(struct
63 return MAP_CONTINUE;
64 }
65
66-void bch_sectors_dirty_init(struct cached_dev *dc)
67+void bch_sectors_dirty_init(struct bcache_device *d)
68 {
69 struct sectors_dirty_init op;
70
71 bch_btree_op_init(&op.op, -1);
72- op.inode = dc->disk.id;
73+ op.inode = d->id;
74
75- bch_btree_map_keys(&op.op, dc->disk.c, &KEY(op.inode, 0, 0),
76+ bch_btree_map_keys(&op.op, d->c, &KEY(op.inode, 0, 0),
77 sectors_dirty_init_fn, 0);
78
79- dc->disk.sectors_dirty_last = bcache_dev_sectors_dirty(&dc->disk);
80+ d->sectors_dirty_last = bcache_dev_sectors_dirty(d);
81 }
82
83 void bch_cached_dev_writeback_init(struct cached_dev *dc)
84--- a/drivers/md/bcache/writeback.h
85+++ b/drivers/md/bcache/writeback.h
86@@ -85,7 +85,7 @@ static inline void bch_writeback_add(str
87
88 void bcache_dev_sectors_dirty_add(struct cache_set *, unsigned, uint64_t, int);
89
90-void bch_sectors_dirty_init(struct cached_dev *dc);
91+void bch_sectors_dirty_init(struct bcache_device *);
92 void bch_cached_dev_writeback_init(struct cached_dev *);
93 int bch_cached_dev_writeback_start(struct cached_dev *);
94