]>
Commit | Line | Data |
---|---|---|
23b3ff3a GKH |
1 | From 175206cf9ab63161dec74d9cd7f9992e062491f5 Mon Sep 17 00:00:00 2001 |
2 | From: Tang Junhui <tang.junhui@zte.com.cn> | |
3 | Date: Thu, 7 Sep 2017 01:28:53 +0800 | |
4 | Subject: bcache: initialize dirty stripes in flash_dev_run() | |
5 | ||
6 | From: Tang Junhui <tang.junhui@zte.com.cn> | |
7 | ||
8 | commit 175206cf9ab63161dec74d9cd7f9992e062491f5 upstream. | |
9 | ||
10 | bcache uses a Proportion-Differentiation Controller algorithm to control | |
11 | writeback rate to cached devices. In the PD controller algorithm, dirty | |
12 | stripes of thin flash device should not be counted in, because flash only | |
13 | volumes never write back dirty data. | |
14 | ||
15 | Currently dirty stripe counter for thin flash device is not initialized | |
16 | when the thin flash device starts. Which means the following calculation | |
17 | in PD controller will reference an undefined dirty stripes number, and | |
18 | all cached devices attached to the same cache set where the thin flash | |
19 | device lies on may have an inaccurate writeback rate. | |
20 | ||
21 | This patch calles bch_sectors_dirty_init() in flash_dev_run(), to | |
22 | correctly initialize dirty stripe counter when the thin flash device | |
23 | starts 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 *); | |
26 | to call this function conveniently in flash_dev_run(). | |
27 | ||
28 | (Commit log is composed by Coly Li) | |
29 | ||
30 | Signed-off-by: Tang Junhui <tang.junhui@zte.com.cn> | |
31 | Reviewed-by: Coly Li <colyli@suse.de> | |
32 | Signed-off-by: Jens Axboe <axboe@kernel.dk> | |
33 | Signed-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 |