diff options
author | Tejun Heo <tj@kernel.org> | 2015-05-22 17:13:41 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2015-06-02 10:33:35 -0400 |
commit | ec8a6f2643923ee5b74d24fa8d134240379f436b (patch) | |
tree | 4188866bc98fb571c3c872d0ad972c5ccc974ee4 /include/linux/backing-dev.h | |
parent | dfb8ae567835425d27db8acc6c9fc5db88d38e2b (diff) |
writeback: make congestion functions per bdi_writeback
Currently, all congestion functions take bdi (backing_dev_info) and
always operate on the root wb (bdi->wb) and the congestion state from
the block layer is propagated only for the root blkcg. This patch
introduces {set|clear}_wb_congested() and wb_congested() which take a
bdi_writeback_congested and bdi_writeback respectively. The bdi
counteparts are now wrappers invoking the wb based functions on
@bdi->wb.
While converting clear_bdi_congested() to clear_wb_congested(), the
local variable declaration order between @wqh and @bit is swapped for
cosmetic reason.
This patch just adds the new wb based functions. The following
patches will apply them.
v2: Updated for bdi_writeback_congested.
Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'include/linux/backing-dev.h')
-rw-r--r-- | include/linux/backing-dev.h | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index 8ae59df2e3d1..2c498a2a8268 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h | |||
@@ -167,27 +167,13 @@ static inline struct backing_dev_info *inode_to_bdi(struct inode *inode) | |||
167 | return sb->s_bdi; | 167 | return sb->s_bdi; |
168 | } | 168 | } |
169 | 169 | ||
170 | static inline int bdi_congested(struct backing_dev_info *bdi, int bdi_bits) | 170 | static inline int wb_congested(struct bdi_writeback *wb, int cong_bits) |
171 | { | 171 | { |
172 | if (bdi->congested_fn) | 172 | struct backing_dev_info *bdi = wb->bdi; |
173 | return bdi->congested_fn(bdi->congested_data, bdi_bits); | ||
174 | return (bdi->wb.congested->state & bdi_bits); | ||
175 | } | ||
176 | |||
177 | static inline int bdi_read_congested(struct backing_dev_info *bdi) | ||
178 | { | ||
179 | return bdi_congested(bdi, 1 << WB_sync_congested); | ||
180 | } | ||
181 | |||
182 | static inline int bdi_write_congested(struct backing_dev_info *bdi) | ||
183 | { | ||
184 | return bdi_congested(bdi, 1 << WB_async_congested); | ||
185 | } | ||
186 | 173 | ||
187 | static inline int bdi_rw_congested(struct backing_dev_info *bdi) | 174 | if (bdi->congested_fn) |
188 | { | 175 | return bdi->congested_fn(bdi->congested_data, cong_bits); |
189 | return bdi_congested(bdi, (1 << WB_sync_congested) | | 176 | return wb->congested->state & cong_bits; |
190 | (1 << WB_async_congested)); | ||
191 | } | 177 | } |
192 | 178 | ||
193 | long congestion_wait(int sync, long timeout); | 179 | long congestion_wait(int sync, long timeout); |
@@ -454,4 +440,25 @@ static inline void wb_blkcg_offline(struct blkcg *blkcg) | |||
454 | 440 | ||
455 | #endif /* CONFIG_CGROUP_WRITEBACK */ | 441 | #endif /* CONFIG_CGROUP_WRITEBACK */ |
456 | 442 | ||
443 | static inline int bdi_congested(struct backing_dev_info *bdi, int cong_bits) | ||
444 | { | ||
445 | return wb_congested(&bdi->wb, cong_bits); | ||
446 | } | ||
447 | |||
448 | static inline int bdi_read_congested(struct backing_dev_info *bdi) | ||
449 | { | ||
450 | return bdi_congested(bdi, 1 << WB_sync_congested); | ||
451 | } | ||
452 | |||
453 | static inline int bdi_write_congested(struct backing_dev_info *bdi) | ||
454 | { | ||
455 | return bdi_congested(bdi, 1 << WB_async_congested); | ||
456 | } | ||
457 | |||
458 | static inline int bdi_rw_congested(struct backing_dev_info *bdi) | ||
459 | { | ||
460 | return bdi_congested(bdi, (1 << WB_sync_congested) | | ||
461 | (1 << WB_async_congested)); | ||
462 | } | ||
463 | |||
457 | #endif /* _LINUX_BACKING_DEV_H */ | 464 | #endif /* _LINUX_BACKING_DEV_H */ |