Provide a helper function checking whether inode itself or some of its folios are dirty. We'll use it in filesystems instead of direct i_state checks. Note that this check returns true also if only timestamps are dirty when lazytime is enabled. This is what users really want. Signed-off-by: Jan Kara --- include/linux/fs.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 025f5d890689..f602deacf953 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2228,6 +2228,13 @@ static inline bool inode_is_dirty(struct inode *inode, bool datasync) return inode_state_read_once(inode) & mask; } +/* Check whether anything in the inode itself or its folios need writing */ +static inline bool inode_or_folios_dirty(struct inode *inode) +{ + return inode_state_read_once(inode) & I_DIRTY_ALL || + mapping_tagged(inode->i_mapping, PAGECACHE_TAG_DIRTY); +} + static inline void set_inode_metadata_writeback(struct inode *inode) { spin_lock(&inode->i_lock); -- 2.53.0