fat: only specify I_DIRTY_TIME when needed in fat_update_time()

As was done for generic_update_time(), only pass I_DIRTY_TIME to
__mark_inode_dirty() when the inode's timestamps were actually updated
and lazytime is enabled.  This avoids a weird edge case where
I_DIRTY_TIME could be set in i_state when lazytime isn't enabled.

Link: https://lore.kernel.org/r/20210112190253.64307-5-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>
This commit is contained in:
Eric Biggers 2021-01-12 11:02:46 -08:00 committed by Jan Kara
parent e20b14db05
commit ff4136e64d

View file

@ -329,22 +329,23 @@ EXPORT_SYMBOL_GPL(fat_truncate_time);
int fat_update_time(struct inode *inode, struct timespec64 *now, int flags) int fat_update_time(struct inode *inode, struct timespec64 *now, int flags)
{ {
int iflags = I_DIRTY_TIME; int dirty_flags = 0;
bool dirty = false;
if (inode->i_ino == MSDOS_ROOT_INO) if (inode->i_ino == MSDOS_ROOT_INO)
return 0; return 0;
fat_truncate_time(inode, now, flags); if (flags & (S_ATIME | S_CTIME | S_MTIME)) {
if (flags & S_VERSION) fat_truncate_time(inode, now, flags);
dirty = inode_maybe_inc_iversion(inode, false); if (inode->i_sb->s_flags & SB_LAZYTIME)
if ((flags & (S_ATIME | S_CTIME | S_MTIME)) && dirty_flags |= I_DIRTY_TIME;
!(inode->i_sb->s_flags & SB_LAZYTIME)) else
dirty = true; dirty_flags |= I_DIRTY_SYNC;
}
if (dirty) if ((flags & S_VERSION) && inode_maybe_inc_iversion(inode, false))
iflags |= I_DIRTY_SYNC; dirty_flags |= I_DIRTY_SYNC;
__mark_inode_dirty(inode, iflags);
__mark_inode_dirty(inode, dirty_flags);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(fat_update_time); EXPORT_SYMBOL_GPL(fat_update_time);