summaryrefslogtreecommitdiff
path: root/include/linux/fs.h
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2021-01-12 11:02:53 -0800
committerJan Kara <jack@suse.cz>2021-01-13 17:27:13 +0100
commited296c6c05b0ac52d7c6bf13a90f02b8b8222169 (patch)
treed5d0a282d2a2f421fad8a050c58a5b67ad99898f /include/linux/fs.h
parent3aac630b5ce18b0a7e34cb35cdd99fcc508edc92 (diff)
downloadlwn-ed296c6c05b0ac52d7c6bf13a90f02b8b8222169.tar.gz
lwn-ed296c6c05b0ac52d7c6bf13a90f02b8b8222169.zip
ext4: simplify i_state checks in __ext4_update_other_inode_time()
Since I_DIRTY_TIME and I_DIRTY_INODE are mutually exclusive in i_state, there's no need to check for I_DIRTY_TIME && !I_DIRTY_INODE. Just check for I_DIRTY_TIME. Also introduce a helper function in include/linux/fs.h to do this check. Link: https://lore.kernel.org/r/20210112190253.64307-12-ebiggers@kernel.org Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r--include/linux/fs.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 45a0303b2aeb..de0c789104c2 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2194,6 +2194,21 @@ static inline void mark_inode_dirty_sync(struct inode *inode)
__mark_inode_dirty(inode, I_DIRTY_SYNC);
}
+/*
+ * Returns true if the given inode itself only has dirty timestamps (its pages
+ * may still be dirty) and isn't currently being allocated or freed.
+ * Filesystems should call this if when writing an inode when lazytime is
+ * enabled, they want to opportunistically write the timestamps of other inodes
+ * located very nearby on-disk, e.g. in the same inode block. This returns true
+ * if the given inode is in need of such an opportunistic update. Requires
+ * i_lock, or at least later re-checking under i_lock.
+ */
+static inline bool inode_is_dirtytime_only(struct inode *inode)
+{
+ return (inode->i_state & (I_DIRTY_TIME | I_NEW |
+ I_FREEING | I_WILL_FREE)) == I_DIRTY_TIME;
+}
+
extern void inc_nlink(struct inode *inode);
extern void drop_nlink(struct inode *inode);
extern void clear_nlink(struct inode *inode);