lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <t3klyln4eejq7olm3bseuje2lao6jh3a26kpzkdqrnak5l2sdh@ehrk2o6mmxfw>
Date: Tue, 6 Jan 2026 12:51:00 +0100
From: Jan Kara <jack@...e.cz>
To: Christoph Hellwig <hch@....de>
Cc: Christian Brauner <brauner@...nel.org>, 
	Al Viro <viro@...iv.linux.org.uk>, David Sterba <dsterba@...e.com>, Jan Kara <jack@...e.cz>, 
	Mike Marshall <hubcap@...ibond.com>, Martin Brandenburg <martin@...ibond.com>, 
	Carlos Maiolino <cem@...nel.org>, Stefan Roesch <shr@...com>, Jeff Layton <jlayton@...nel.org>, 
	OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>, Trond Myklebust <trondmy@...nel.org>, 
	Anna Schumaker <anna@...nel.org>, linux-kernel@...r.kernel.org, linux-btrfs@...r.kernel.org, 
	linux-fsdevel@...r.kernel.org, gfs2@...ts.linux.dev, io-uring@...r.kernel.org, 
	devel@...ts.orangefs.org, linux-unionfs@...r.kernel.org, linux-mtd@...ts.infradead.org, 
	linux-xfs@...r.kernel.org, linux-nfs@...r.kernel.org
Subject: Re: [PATCH 09/11] fs: refactor file_update_time_flags

On Tue 06-01-26 08:50:03, Christoph Hellwig wrote:
> Split all the inode timestamp flags into a helper.  This not only
> makes the code a bit more readable, but also optimizes away the
> further checks as soon as know we need an update.
> 
> Signed-off-by: Christoph Hellwig <hch@....de>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@...e.cz>

								Honza

> ---
>  fs/inode.c | 31 +++++++++++++++----------------
>  1 file changed, 15 insertions(+), 16 deletions(-)
> 
> diff --git a/fs/inode.c b/fs/inode.c
> index 01e4f6b9b46e..d2bfe302e647 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -2378,31 +2378,30 @@ struct timespec64 current_time(struct inode *inode)
>  }
>  EXPORT_SYMBOL(current_time);
>  
> +static inline bool need_cmtime_update(struct inode *inode)
> +{
> +	struct timespec64 now = current_time(inode), ts;
> +
> +	ts = inode_get_mtime(inode);
> +	if (!timespec64_equal(&ts, &now))
> +		return true;
> +	ts = inode_get_ctime(inode);
> +	if (!timespec64_equal(&ts, &now))
> +		return true;
> +	return IS_I_VERSION(inode) && inode_iversion_need_inc(inode);
> +}
> +
>  static int file_update_time_flags(struct file *file, unsigned int flags)
>  {
>  	struct inode *inode = file_inode(file);
> -	struct timespec64 now, ts;
> -	bool need_update = false;
> -	int ret = 0;
> +	int ret;
>  
>  	/* First try to exhaust all avenues to not sync */
>  	if (IS_NOCMTIME(inode))
>  		return 0;
>  	if (unlikely(file->f_mode & FMODE_NOCMTIME))
>  		return 0;
> -
> -	now = current_time(inode);
> -
> -	ts = inode_get_mtime(inode);
> -	if (!timespec64_equal(&ts, &now))
> -		need_update = true;
> -	ts = inode_get_ctime(inode);
> -	if (!timespec64_equal(&ts, &now))
> -		need_update = true;
> -	if (IS_I_VERSION(inode) && inode_iversion_need_inc(inode))
> -		need_update = true;
> -
> -	if (!need_update)
> +	if (!need_cmtime_update(inode))
>  		return 0;
>  
>  	flags &= IOCB_NOWAIT;
> -- 
> 2.47.3
> 
-- 
Jan Kara <jack@...e.com>
SUSE Labs, CR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ