diff options
| author | Tejun Heo <tj@kernel.org> | 2015-05-22 17:13:27 -0400 |
|---|---|---|
| committer | Jens Axboe <axboe@fb.com> | 2015-06-02 10:33:34 -0400 |
| commit | 93f78d882865cb90020d0f80a9523c99cf46924c (patch) | |
| tree | 6cd9c3531085c7d51fbd6ec2086142255bc2c219 /include/linux | |
| parent | 4452226ea276e74fc3e252c88d9bb7e8f8e44bf0 (diff) | |
writeback: move backing_dev_info->bdi_stat[] into bdi_writeback
Currently, a bdi (backing_dev_info) embeds single wb (bdi_writeback)
and the role of the separation is unclear. For cgroup support for
writeback IOs, a bdi will be updated to host multiple wb's where each
wb serves writeback IOs of a different cgroup on the bdi. To achieve
that, a wb should carry all states necessary for servicing writeback
IOs for a cgroup independently.
This patch moves bdi->bdi_stat[] into wb.
* enum bdi_stat_item is renamed to wb_stat_item and the prefix of all
enums is changed from BDI_ to WB_.
* BDI_STAT_BATCH() -> WB_STAT_BATCH()
* [__]{add|inc|dec|sum}_wb_stat(bdi, ...) -> [__]{add|inc}_wb_stat(wb, ...)
* bdi_stat[_error]() -> wb_stat[_error]()
* bdi_writeout_inc() -> wb_writeout_inc()
* stat init is moved to bdi_wb_init() and bdi_wb_exit() is added and
frees stat.
* As there's still only one bdi_writeback per backing_dev_info, all
uses of bdi->stat[] are mechanically replaced with bdi->wb.stat[]
introducing no behavior changes.
Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/backing-dev.h | 68 |
1 files changed, 32 insertions, 36 deletions
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index eb14f988a63e..fe7a907a4e16 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h | |||
| @@ -36,15 +36,15 @@ enum wb_state { | |||
| 36 | 36 | ||
| 37 | typedef int (congested_fn)(void *, int); | 37 | typedef int (congested_fn)(void *, int); |
| 38 | 38 | ||
| 39 | enum bdi_stat_item { | 39 | enum wb_stat_item { |
| 40 | BDI_RECLAIMABLE, | 40 | WB_RECLAIMABLE, |
| 41 | BDI_WRITEBACK, | 41 | WB_WRITEBACK, |
| 42 | BDI_DIRTIED, | 42 | WB_DIRTIED, |
| 43 | BDI_WRITTEN, | 43 | WB_WRITTEN, |
| 44 | NR_BDI_STAT_ITEMS | 44 | NR_WB_STAT_ITEMS |
| 45 | }; | 45 | }; |
| 46 | 46 | ||
| 47 | #define BDI_STAT_BATCH (8*(1+ilog2(nr_cpu_ids))) | 47 | #define WB_STAT_BATCH (8*(1+ilog2(nr_cpu_ids))) |
| 48 | 48 | ||
| 49 | struct bdi_writeback { | 49 | struct bdi_writeback { |
| 50 | struct backing_dev_info *bdi; /* our parent bdi */ | 50 | struct backing_dev_info *bdi; /* our parent bdi */ |
| @@ -58,6 +58,8 @@ struct bdi_writeback { | |||
| 58 | struct list_head b_more_io; /* parked for more writeback */ | 58 | struct list_head b_more_io; /* parked for more writeback */ |
| 59 | struct list_head b_dirty_time; /* time stamps are dirty */ | 59 | struct list_head b_dirty_time; /* time stamps are dirty */ |
| 60 | spinlock_t list_lock; /* protects the b_* lists */ | 60 | spinlock_t list_lock; /* protects the b_* lists */ |
| 61 | |||
| 62 | struct percpu_counter stat[NR_WB_STAT_ITEMS]; | ||
| 61 | }; | 63 | }; |
| 62 | 64 | ||
| 63 | struct backing_dev_info { | 65 | struct backing_dev_info { |
| @@ -69,8 +71,6 @@ struct backing_dev_info { | |||
| 69 | 71 | ||
| 70 | char *name; | 72 | char *name; |
| 71 | 73 | ||
| 72 | struct percpu_counter bdi_stat[NR_BDI_STAT_ITEMS]; | ||
| 73 | |||
| 74 | unsigned long bw_time_stamp; /* last time write bw is updated */ | 74 | unsigned long bw_time_stamp; /* last time write bw is updated */ |
| 75 | unsigned long dirtied_stamp; | 75 | unsigned long dirtied_stamp; |
| 76 | unsigned long written_stamp; /* pages written at bw_time_stamp */ | 76 | unsigned long written_stamp; /* pages written at bw_time_stamp */ |
| @@ -137,78 +137,74 @@ static inline int wb_has_dirty_io(struct bdi_writeback *wb) | |||
| 137 | !list_empty(&wb->b_more_io); | 137 | !list_empty(&wb->b_more_io); |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | static inline void __add_bdi_stat(struct backing_dev_info *bdi, | 140 | static inline void __add_wb_stat(struct bdi_writeback *wb, |
| 141 | enum bdi_stat_item item, s64 amount) | 141 | enum wb_stat_item item, s64 amount) |
| 142 | { | 142 | { |
| 143 | __percpu_counter_add(&bdi->bdi_stat[item], amount, BDI_STAT_BATCH); | 143 | __percpu_counter_add(&wb->stat[item], amount, WB_STAT_BATCH); |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | static inline void __inc_bdi_stat(struct backing_dev_info *bdi, | 146 | static inline void __inc_wb_stat(struct bdi_writeback *wb, |
| 147 | enum bdi_stat_item item) | 147 | enum wb_stat_item item) |
| 148 | { | 148 | { |
| 149 | __add_bdi_stat(bdi, item, 1); | 149 | __add_wb_stat(wb, item, 1); |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | static inline void inc_bdi_stat(struct backing_dev_info *bdi, | 152 | static inline void inc_wb_stat(struct bdi_writeback *wb, enum wb_stat_item item) |
| 153 | enum bdi_stat_item item) | ||
| 154 | { | 153 | { |
| 155 | unsigned long flags; | 154 | unsigned long flags; |
| 156 | 155 | ||
| 157 | local_irq_save(flags); | 156 | local_irq_save(flags); |
| 158 | __inc_bdi_stat(bdi, item); | 157 | __inc_wb_stat(wb, item); |
| 159 | local_irq_restore(flags); | 158 | local_irq_restore(flags); |
| 160 | } | 159 | } |
| 161 | 160 | ||
| 162 | static inline void __dec_bdi_stat(struct backing_dev_info *bdi, | 161 | static inline void __dec_wb_stat(struct bdi_writeback *wb, |
| 163 | enum bdi_stat_item item) | 162 | enum wb_stat_item item) |
| 164 | { | 163 | { |
| 165 | __add_bdi_stat(bdi, item, -1); | 164 | __add_wb_stat(wb, item, -1); |
| 166 | } | 165 | } |
| 167 | 166 | ||
| 168 | static inline void dec_bdi_stat(struct backing_dev_info *bdi, | 167 | static inline void dec_wb_stat(struct bdi_writeback *wb, enum wb_stat_item item) |
| 169 | enum bdi_stat_item item) | ||
| 170 | { | 168 | { |
| 171 | unsigned long flags; | 169 | unsigned long flags; |
| 172 | 170 | ||
| 173 | local_irq_save(flags); | 171 | local_irq_save(flags); |
| 174 | __dec_bdi_stat(bdi, item); | 172 | __dec_wb_stat(wb, item); |
| 175 | local_irq_restore(flags); | 173 | local_irq_restore(flags); |
| 176 | } | 174 | } |
| 177 | 175 | ||
| 178 | static inline s64 bdi_stat(struct backing_dev_info *bdi, | 176 | static inline s64 wb_stat(struct bdi_writeback *wb, enum wb_stat_item item) |
| 179 | enum bdi_stat_item item) | ||
| 180 | { | 177 | { |
| 181 | return percpu_counter_read_positive(&bdi->bdi_stat[item]); | 178 | return percpu_counter_read_positive(&wb->stat[item]); |
| 182 | } | 179 | } |
| 183 | 180 | ||
| 184 | static inline s64 __bdi_stat_sum(struct backing_dev_info *bdi, | 181 | static inline s64 __wb_stat_sum(struct bdi_writeback *wb, |
| 185 | enum bdi_stat_item item) | 182 | enum wb_stat_item item) |
| 186 | { | 183 | { |
| 187 | return percpu_counter_sum_positive(&bdi->bdi_stat[item]); | 184 | return percpu_counter_sum_positive(&wb->stat[item]); |
| 188 | } | 185 | } |
| 189 | 186 | ||
| 190 | static inline s64 bdi_stat_sum(struct backing_dev_info *bdi, | 187 | static inline s64 wb_stat_sum(struct bdi_writeback *wb, enum wb_stat_item item) |
| 191 | enum bdi_stat_item item) | ||
| 192 | { | 188 | { |
| 193 | s64 sum; | 189 | s64 sum; |
| 194 | unsigned long flags; | 190 | unsigned long flags; |
| 195 | 191 | ||
| 196 | local_irq_save(flags); | 192 | local_irq_save(flags); |
| 197 | sum = __bdi_stat_sum(bdi, item); | 193 | sum = __wb_stat_sum(wb, item); |
| 198 | local_irq_restore(flags); | 194 | local_irq_restore(flags); |
| 199 | 195 | ||
| 200 | return sum; | 196 | return sum; |
| 201 | } | 197 | } |
| 202 | 198 | ||
| 203 | extern void bdi_writeout_inc(struct backing_dev_info *bdi); | 199 | extern void wb_writeout_inc(struct bdi_writeback *wb); |
| 204 | 200 | ||
| 205 | /* | 201 | /* |
| 206 | * maximal error of a stat counter. | 202 | * maximal error of a stat counter. |
| 207 | */ | 203 | */ |
| 208 | static inline unsigned long bdi_stat_error(struct backing_dev_info *bdi) | 204 | static inline unsigned long wb_stat_error(struct bdi_writeback *wb) |
| 209 | { | 205 | { |
| 210 | #ifdef CONFIG_SMP | 206 | #ifdef CONFIG_SMP |
| 211 | return nr_cpu_ids * BDI_STAT_BATCH; | 207 | return nr_cpu_ids * WB_STAT_BATCH; |
| 212 | #else | 208 | #else |
| 213 | return 1; | 209 | return 1; |
| 214 | #endif | 210 | #endif |
