Re: [PATCH 09/16] fs: exit early in generic_update_time when there is no work

Jeff Layton <[email protected]>
Newsgroups dev.linux.lists.gfs2,org.infradead.lists.linux-mtd,org.kernel.vger.io-uring,org.kernel.vger.linux-btrfs,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-nfs,org.kernel.vger.linux-unionfs,org.kernel.vger.linux-xfs
Message-ID <[email protected]>
On Thu, 2025-11-20 at 07:47 +0100, Christoph Hellwig wrote:
> Exit early if not attributes are to be updated, to avoid a spurious call
> to __mark_inode_dirty which can turn into a fairly expensive no-op due to
> the extra checks and locking.
> 
> Signed-off-by: Christoph Hellwig <[email protected]>
> ---
>  fs/inode.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/inode.c b/fs/inode.c
> index 15a8b2cf78ef..cda78f76e1dd 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -2110,6 +2110,9 @@ int generic_update_time(struct inode *inode, int flags)
>  	int updated = inode_update_timestamps(inode, flags);
>  	int dirty_flags = 0;
>  
> +	if (!updated)
> +		return 0;
> +
>  	if (updated & (S_ATIME|S_MTIME|S_CTIME))
>  		dirty_flags = inode->i_sb->s_flags & SB_LAZYTIME ? I_DIRTY_TIME : I_DIRTY_SYNC;
>  	if (updated & S_VERSION)

Reviewed-by: Jeff Layton <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.