diff options
Diffstat (limited to 'include/linux/backing-dev.h')
-rw-r--r-- | include/linux/backing-dev.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index 5a5d79ee256f..d5eb4ad1c534 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/sched.h> | 13 | #include <linux/sched.h> |
14 | #include <linux/blkdev.h> | 14 | #include <linux/blkdev.h> |
15 | #include <linux/writeback.h> | 15 | #include <linux/writeback.h> |
16 | #include <linux/memcontrol.h> | ||
16 | #include <linux/blk-cgroup.h> | 17 | #include <linux/blk-cgroup.h> |
17 | #include <linux/backing-dev-defs.h> | 18 | #include <linux/backing-dev-defs.h> |
18 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
@@ -252,13 +253,19 @@ int inode_congested(struct inode *inode, int cong_bits); | |||
252 | * @inode: inode of interest | 253 | * @inode: inode of interest |
253 | * | 254 | * |
254 | * cgroup writeback requires support from both the bdi and filesystem. | 255 | * cgroup writeback requires support from both the bdi and filesystem. |
255 | * Test whether @inode has both. | 256 | * Also, both memcg and iocg have to be on the default hierarchy. Test |
257 | * whether all conditions are met. | ||
258 | * | ||
259 | * Note that the test result may change dynamically on the same inode | ||
260 | * depending on how memcg and iocg are configured. | ||
256 | */ | 261 | */ |
257 | static inline bool inode_cgwb_enabled(struct inode *inode) | 262 | static inline bool inode_cgwb_enabled(struct inode *inode) |
258 | { | 263 | { |
259 | struct backing_dev_info *bdi = inode_to_bdi(inode); | 264 | struct backing_dev_info *bdi = inode_to_bdi(inode); |
260 | 265 | ||
261 | return bdi_cap_account_dirty(bdi) && | 266 | return cgroup_on_dfl(mem_cgroup_root_css->cgroup) && |
267 | cgroup_on_dfl(blkcg_root_css->cgroup) && | ||
268 | bdi_cap_account_dirty(bdi) && | ||
262 | (bdi->capabilities & BDI_CAP_CGROUP_WRITEBACK) && | 269 | (bdi->capabilities & BDI_CAP_CGROUP_WRITEBACK) && |
263 | (inode->i_sb->s_iflags & SB_I_CGROUPWB); | 270 | (inode->i_sb->s_iflags & SB_I_CGROUPWB); |
264 | } | 271 | } |