Commit ed296c6c authored by Eric Biggers's avatar Eric Biggers Committed by Jan Kara

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.orgReviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent 3aac630b
...@@ -4961,15 +4961,11 @@ static void __ext4_update_other_inode_time(struct super_block *sb, ...@@ -4961,15 +4961,11 @@ static void __ext4_update_other_inode_time(struct super_block *sb,
if (!inode) if (!inode)
return; return;
if ((inode->i_state & (I_FREEING | I_WILL_FREE | I_NEW | if (!inode_is_dirtytime_only(inode))
I_DIRTY_INODE)) ||
((inode->i_state & I_DIRTY_TIME) == 0))
return; return;
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
if (((inode->i_state & (I_FREEING | I_WILL_FREE | I_NEW | if (inode_is_dirtytime_only(inode)) {
I_DIRTY_INODE)) == 0) &&
(inode->i_state & I_DIRTY_TIME)) {
struct ext4_inode_info *ei = EXT4_I(inode); struct ext4_inode_info *ei = EXT4_I(inode);
inode->i_state &= ~I_DIRTY_TIME; inode->i_state &= ~I_DIRTY_TIME;
......
...@@ -2194,6 +2194,21 @@ static inline void mark_inode_dirty_sync(struct inode *inode) ...@@ -2194,6 +2194,21 @@ static inline void mark_inode_dirty_sync(struct inode *inode)
__mark_inode_dirty(inode, I_DIRTY_SYNC); __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 inc_nlink(struct inode *inode);
extern void drop_nlink(struct inode *inode); extern void drop_nlink(struct inode *inode);
extern void clear_nlink(struct inode *inode); extern void clear_nlink(struct inode *inode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment